Benefit Multiplier Config Repository
Component Detail
Description
Reads organisation-specific multiplier values (hourly rate equivalent, travel cost per session, health system cost per hour) from the Supabase organisation configuration table. Values are cached locally after first fetch and refreshed on app start.
benefit-multiplier-config-repository
Summaries
The Benefit Multiplier Config Repository ensures that every benefit calculation reflects the organisation's own validated economic assumptions — hourly rate equivalents, travel cost benchmarks, and health system offset figures — rather than generic industry averages. By sourcing these values from an organisation-specific configuration table, the platform allows each partner organisation to maintain calculation methodologies that align with their funding body requirements, increasing the credibility and defensibility of reported outcomes. The local caching mechanism ensures calculations remain available in low-connectivity field environments, protecting volunteer productivity and preventing data loss in areas where mentoring programmes most commonly operate.
This repository introduces a Supabase read dependency and a local caching layer, both of which require test coverage across online, offline, and stale-cache scenarios. The primary delivery risk is misconfigured multiplier data in the Supabase organisation table causing incorrect calculation outputs that could be shared externally before detection; establish a data validation step in the organisation onboarding process to mitigate this. Coordinate with the backend team to confirm the organisation_config table schema and access policies before implementation begins. Caching behaviour on app start should be confirmed with product — a background refresh strategy avoids blocking the calculator screen on network latency while keeping values reasonably current.
Benefit Multiplier Config Repository implements a cache-then-network pattern: on first access it fetches a BenefitMultiplierConfig value object from the Supabase organisation_config table using the active organisationId, persists it to local storage (SharedPreferences or Hive depending on project convention), and serves subsequent requests from cache until refreshConfig is explicitly called. The getCachedConfig method returns a nullable value allowing callers to handle the cold-start case where no cache exists yet. The typed BenefitMultiplierConfig value object should use freezed or manual immutability to enable safe equality checks in BLoC state comparison. Ensure RLS policies on the Supabase table restrict reads to the authenticated organisation's own row.
Responsibilities
- Fetch multiplier config for the active organisation from Supabase
- Cache config locally to enable fully offline calculation
- Expose a typed BenefitMultiplierConfig value object
Interfaces
getMultiplierConfig(String organisationId) → Future<BenefitMultiplierConfig>
refreshConfig(String organisationId) → Future<void>
getCachedConfig(String organisationId) → BenefitMultiplierConfig?
Relationships
Dependents (2)
Components that depend on this component
Related Data Entities (1)
Data entities managed by this component