Infrastructure low complexity Shared Component mobile
0
Dependencies
0
Dependents
2
Entities
0
Integrations

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: Organization Selection & Onboarding

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`. `watchFlag(flagKey)` wraps that map in an `AsyncValue` stream so widgets rebuild reactively. Organization context changes must call `refresh()` which calls `cache.invalidate(organizationId)` before re-fetching.

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

API Contract

View full contract →
REST /api/v1/feature-flags 7 endpoints
GET /api/v1/feature-flags
GET /api/v1/feature-flags/:key
POST /api/v1/feature-flags
PUT /api/v1/feature-flags/:key
DELETE /api/v1/feature-flags/:key
POST /api/v1/feature-flags/load/:orgId
+1 more