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

Description

Next.js API route handler that manages CRUD on the terminology_overrides table scoped by organization_id, validating all writes against the server-defined closed term_key enum to prevent arbitrary string injection. Serializes the full override map into the session bootstrap response so mobile and web clients receive current org terminology on login without a separate round-trip.

Feature: Custom Terminology

terminology-override-service

Sources & reasoning

A dedicated service owns the business rules for term key validation (closed enum prevents injection), tenant isolation, and bootstrap distribution. Embedding the override map in the session bootstrap ensures mobile (Flutter/Drift) and web clients apply the correct org terminology from the moment of login without extra API calls.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • CRUD on terminology_overrides keyed by organization_id and server-defined term_key enum
  • Validate all inbound keys against the closed enum - reject unknown keys
  • Inject the full override map into the session bootstrap payload for all clients
  • Enforce tenant scoping so organizations cannot read or write each other's overrides
  • Handle reset-to-default by deleting the row so the client falls back to platform defaults

Interfaces

getOverrides(organizationId: string): Promise<TerminologyMap>
upsertOverride(organizationId: string, key: TermKey, value: string): Promise<void>
resetOverride(organizationId: string, key: TermKey): Promise<void>
getBootstrapPayload(organizationId: string): Promise<TerminologyMap>
validateTermKey(key: string): key is TermKey

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component