Service Layer medium complexity backend
0
Dependencies
0
Dependents
2
Entities
0
Integrations

Description

Business logic layer that enforces module dependency rules and persists toggle state changes. It validates that enabling or disabling a module does not violate declared dependencies in the module registry before committing the change. It also invalidates the tenant bootstrap cache so clients receive the updated module list on next load.

Feature: Feature Toggles

module-toggle-service

Sources & reasoning

The module-toggle system is the central architectural decision of the entire platform (lines 232-248). It is listed as an always-on admin-organization capability (line 241) and is required from day one to support the four organizations with divergent needs. Assigned MVP because no meaningful multi-tenant operation is possible without it.

  • Not every organization needs every capability... the platform treats each functional area as an independently toggleable module... Backend is the source of truth... Clients load generically.
  • `admin-organization` is always-on because it hosts the Feature Toggles UI itself - disabling it would remove the only place toggles can be re-enabled (circular dependency).

Responsibilities

  • Validate module dependency constraints before applying a toggle change
  • Persist the new toggle state via ModuleToggleRepository
  • Invalidate or refresh the tenant bootstrap cache after a state change
  • Enforce that only Org Admins can invoke toggle operations
  • Return the updated full module state after each operation

Interfaces

getModuleStates(orgId: string): Promise<ModuleToggleState[]>
setModuleEnabled(orgId: string, moduleId: string, enabled: boolean): Promise<ModuleToggleState[]>
validateDependencies(moduleId: string, enabled: boolean): DependencyValidationResult
refreshBootstrapCache(orgId: string): Promise<void>

Related Data Entities (2)

Data entities managed by this component