Organization Feature Flag Service
Component Detail
Description
Provides read access to organization-level feature flags, including the driver administration feature toggle. Used by both UI guards and backend services to enforce org-scoped feature availability consistently across the application.
org-feature-flag-service
Summaries
This shared service controls which features are available to each organization, enabling the business to roll out new capabilities—such as the driver administration module—to specific clients without deploying separate software versions. This flexibility supports phased go-to-market strategies, reduces rollout risk, and allows the product team to run targeted pilots or A/B tests without engineering intervention. It protects revenue by ensuring premium features remain gated and reduces support burden by giving operations teams control over feature availability without requiring a release cycle.
Low-complexity shared service, but its cross-cutting nature means it is a dependency for both frontend UI guards and backend enforcement logic. Any delay in delivery or bugs in flag evaluation affect multiple features simultaneously. Planning should include a caching strategy review (TTL, invalidation on flag change) and a decision on flag storage backend (database vs. remote config service).
Runtime flag change support requires a watchFeatureFlag subscription mechanism that must be tested for consistency across UI and API layers. Estimate 2–3 days for initial implementation; budget additional time if a third-party feature flag platform integration is chosen.
Shared service (frontend + backend execution contexts) providing isFeatureEnabled, getOrgFeatureFlags, refreshFlags, and watchFeatureFlag interfaces. Caching is critical: flag reads occur on every authenticated request and UI route guard check, so implement an in-memory TTL cache with explicit invalidation on refreshFlags calls. The watchFeatureFlag callback pattern requires a pub/sub or polling mechanism on the client side; ensure the interface contract specifies unsubscribe behavior to prevent memory leaks. The service reads from the org_configuration data model—schema changes there must be coordinated with this service.
On the backend, integrate with row-level security so flag reads are scoped to the authenticated org context automatically.
Responsibilities
- Read org feature flags from configuration or database
- Provide synchronous flag checks for UI guards
- Cache flag values to avoid repeated database reads
- Support runtime flag changes without app restart
Interfaces
isFeatureEnabled(orgId, featureKey)
getOrgFeatureFlags(orgId)
refreshFlags(orgId)
watchFeatureFlag(orgId, featureKey, callback)
Relationships
Dependents (2)
Components that depend on this component
Related Data Entities (4)
Data entities managed by this component