Feature Flag Provider
Component Detail
Description
Infrastructure component that loads and exposes the organization-specific feature flag configuration fetched from Supabase after org selection. Allows the app to conditionally enable or disable features (e.g., BankID login, expense registration, Bufdir export) based on which organization is active without requiring separate app builds.
feature-flag-provider
Summaries
The FeatureFlagProvider is a foundational capability that enables the organization to deliver tailored product experiences to different customer segments without releasing separate app versions. By resolving which features are active for a given organization in real time, it directly supports revenue growth through targeted feature rollouts, reduces risk by limiting new functionality exposure to pilot groups, and shortens feedback cycles. This translates into faster market validation, lower rollout costs, and the ability to respond to customer needs without emergency app store releases. Its shared, reusable nature means every future feature launch benefits from the same infrastructure at zero incremental cost, compounding ROI over time.
The FeatureFlagProvider is a shared, medium-complexity mobile service that sits at the intersection of the feature flag repository, cache, and rollout evaluator. Any feature that uses conditional functionality depends on this provider being stable and well-tested, making it a high-priority dependency to resolve early in the project schedule. Integration testing must cover organization context switching, version-based gating, and cache invalidation paths. Because it is shared across all consuming features, a regression here has wide blast radius—regression test coverage and code review gates are essential.
Deployment risk is low since it is client-side only with no backend schema changes required.
FeatureFlagProvider is a Riverpod AsyncNotifier (or equivalent) that orchestrates the feature-flag-repository, feature-flag-cache, and rollout-evaluator into a single reactive interface for UI consumers. On first read it checks the cache via `get(organizationId)`; on miss or TTL expiry it calls `repository.getFlags(organizationId)`, stores results via `cache.set(...)`, then pipes each flag through `rollout-evaluator.evaluate(flag, appVersion, now)` to build the final `Map
Keep the evaluator call pure and synchronous to maintain O(1) `isEnabled` lookups.
Responsibilities
- Fetch feature flag config for the selected organization
- Cache flags for the session duration
- Expose synchronous flag lookup for UI conditional rendering
- Invalidate and reload flags on org context switch
Interfaces
loadFlagsForOrg(String orgId) -> Future<void>
isEnabled(String featureKey) -> bool
getAllFlags() -> Map<String, bool>
invalidate() -> void
Related Data Entities (2)
Data entities managed by this component