Add Riverpod providers for repository and utility classes
epic-membership-recruitment-foundation-task-009 — Create Riverpod providers for ReferralCodeRepository, RecruitmentAttributionRepository, ShareSheetBridge, QrCodeGenerator, and DeepLinkHandler. Wire them to the existing Supabase client provider and organisation context. Ensure providers are scoped appropriately (global singletons for repositories and utilities, organisation-scoped for queries). Export a barrel file for the recruitment infrastructure layer so higher-tier epics can import cleanly.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Follow the existing provider file conventions in the project — if riverpod_generator annotations (@riverpod) are used elsewhere, adopt the same pattern for consistency. Place all five provider definitions in a single file (recruitment_providers.dart) to make the dependency graph easy to review. For the organisation-scoped family providers, use Provider.family
Add a brief inline comment on each provider explaining its scope (singleton vs. org-scoped) to aid future maintainers.
Testing Requirements
Write unit tests using ProviderContainer (from riverpod) to verify provider wiring without a full Flutter widget tree. Test cases: (1) referralCodeRepositoryProvider resolves to a ReferralCodeRepository instance given a mock supabaseClientProvider override, (2) recruitmentAttributionRepositoryProvider resolves correctly, (3) shareSheetBridgeProvider, qrCodeGeneratorProvider, deepLinkHandlerProvider each resolve as singletons (same instance on repeated reads), (4) family-keyed organisation provider returns distinct instances for different organisationId values, (5) barrel file exports all five providers without name conflicts. Use flutter_test with ProviderContainer and mockito/mocktail for dependency overrides. Target 100% provider resolution coverage (all providers are exercised at least once).
iOS Universal Links and Android App Links have distinct configuration requirements (apple-app-site-association, assetlinks.json, entitlements). A misconfiguration causes the OS to open the referral URL in a browser instead of the app, completely breaking the onboarding funnel for new members on one platform.
Mitigation & Contingency
Mitigation: Configure both Universal Links and App Links from the start of this epic using the project's existing Supabase-hosted domain. Write an E2E test on both simulators that taps a referral URL and asserts the onboarding screen is reached. Document the required server-side JSON files alongside the migration.
Contingency: If platform deep-link configuration cannot be resolved before the UI epics need the handler, implement a fallback custom-scheme URI (e.g., likeperson://referral?code=XYZ) that works unconditionally, and schedule Universal/App Link fix as a follow-up task.
Referral click events must be writable without an authenticated session (a new member who has not yet registered is tapping the link). Standard Supabase RLS cannot grant anonymous inserts without opening a security hole. If this is not solved early it blocks the entire attribution pipeline.
Mitigation & Contingency
Mitigation: Design referral_events writes to go exclusively through a Supabase Edge Function that validates the referral code exists and is active before inserting. The Edge Function uses the service-role key server-side; the client only calls the function endpoint. This is documented in the feature spec.
Contingency: If the Edge Function approach is delayed, temporarily allow anon inserts restricted by a CHECK constraint that event_type = 'click' and new_member_id IS NULL, then tighten to Edge Function writes in a follow-up migration before the feature goes to production.
The qr_flutter package version pinned in pubspec may conflict with the current Flutter SDK version or with other packages in the monorepo, causing build failures that block QR code delivery.
Mitigation & Contingency
Mitigation: Verify qr_flutter compatibility against the project's Flutter SDK version as the very first task in this epic. If a conflict exists, resolve it before any other work proceeds.
Contingency: If qr_flutter cannot be made compatible, evaluate mobile_scanner (already likely in pubspec for QR scanning) which also supports generation, or implement QR generation via a lightweight Dart port as a last resort.