ModuleToggleRepository
Component Detail
Data Layer
medium complexity
backend
0
Dependencies
0
Dependents
2
Entities
0
Integrations
Description
Data access layer responsible for persisting and retrieving the enabled module configuration for each tenant. It maps tenant IDs to their enabled module sets and provides atomic update operations to prevent partial writes during concurrent admin changes. All reads are scoped to a single tenant to prevent cross-tenant data leakage.
module-toggle-repository
Sources & reasoning
Lines 232-248 define the module-toggle architecture as the core mechanism for serving four divergent organizations from one codebase. The Feature Toggles page is the sole configuration surface for this system. Always-on status (line 241) and the circular-dependency constraint confirm no deferral is possible - this is MVP.
-
docs/source/likeperson.md · line 232-235Module = Area. The canonical areas defined in the area taxonomy (section 8) are the unit of toggling. Each area ID (e.g. expense-reimbursement, encrypted-assignments, certification-training) is a module that can be enabled or disabled per tenant.
-
docs/source/likeperson.md · line 241admin-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).
-
docs/source/likeperson.md · line 237-238Backend is the source of truth. The API exposes the enabled module set for the current user's tenant as part of the session/bootstrap response. Every endpoint that belongs to a module checks the tenant's enabled set before executing
Responsibilities
- Store the enabled module set per tenant as durable configuration
- Retrieve the full enabled module list for a given tenant ID
- Perform atomic enable/disable writes to prevent race conditions
- Support bulk reads at tenant startup for client initialization
- Maintain an audit trail of who changed which module toggle and when
Interfaces
findByTenantId(tenantId: string): Promise<TenantModuleConfig>
updateModuleState(tenantId: string, moduleId: string, enabled: boolean, changedBy: string): Promise<void>
getAuditLog(tenantId: string, moduleId?: string): Promise<ToggleAuditEntry[]>
Related Data Entities (2)
Data entities managed by this component