Skip to main content

Add a repository

A Repository is the presentation seam over the client_sdk facade — a thin delegate blocs depend on. It holds no domain rules (those live in the SDK Service); it adapts facade calls to what the UI needs and is mocked in tests.

Steps

  1. Create the repository under app/lib/outside/repositories/<name>/, delegating to the injected client facade:

    class PlacesRepository {
    PlacesRepository({required this.clientProvider});
    final SdkClientProvider clientProvider;

    Future<List<Place>> getPlaces() => clientProvider.client.getPlaces();
    }
  2. Register it in RepositoriesAll (app/lib/outside/repositories/all.dart) — both the list and the provider construction — and wire it in the app runner (app/lib/app/runner.dart).

  3. Add a mock in app/test/util/mocks/… (MockPlacesRepository) and include it in MocksContainer so flow tests can stub it.

Rules

  • Thin. No business logic, no validation that belongs in the SDK Service — a repository only adapts and delegates. Domain invariants are the SDK's job.
  • No I/O imports. A repository imports the client_sdk facade only — never drift/supabase.
  • Stateless (beyond presentation-derived caches the bloc needs).

See Architecture for where repositories sit in the one data path.