Skip to documentation

Design system / Sources & standards

Current repository source

ADR-0036-tenant-console-theme-catalog-and-overrides.md

docs/decisions/ADR-0036-tenant-console-theme-catalog-and-overrides.md

This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.

# ADR-0036: Tenant console theme catalog and overrides

## Status

accepted

## Date

2026-07-20

## Context

The console must support tenant-specific branding without allowing arbitrary color combinations to weaken accessibility or force product components to carry tenant-specific styles. ADR-0030 established semantic token boundaries and deferred the override mechanism.

Theme selection must persist across browser sessions, resolve before console rendering, and provide a global default with a tenant-specific override.

## Options considered

- Allow tenants to edit every color token directly.
- Accept a primary, secondary, and accent color and derive the remaining tokens dynamically.
- Maintain an approved code-managed theme catalog and persist only the selected catalog identifier.

## Decision

- Maintain the approved theme catalog under `src/theming/tenant-themes.ts`. Every catalog entry supplies the console's semantic color-token contract in `oklch()` values.
- Use a dedicated Amplify-managed DynamoDB table for selection records. The partition key is `scope_key`, with `GLOBAL` for the fallback selection and `TENANT#{tenantId}` for a tenant override.
- Resolve a tenant selection first, then the global selection, then the code default. Apply the result as CSS custom properties at the authenticated console layout boundary so all nested console layouts and pages inherit it.
- Permit only Tenant Admins to select an approved catalog entry through an authorized console route. Persisted changes are audit logged.
- Seed the initial global DynamoDB selection as `ocean` when the deployed table is first read. The code default remains `default` so local or unavailable infrastructure does not prevent console rendering.

## Rationale

The catalog keeps color contrast, focus, feedback, and state tokens under platform control. DynamoDB fits a low-volume, independently deployable configuration record and avoids coupling presentation preferences to Aurora tenant migrations. Layout-scoped variables preserve the existing server-first route model and require no component-level theme branching.

## Consequences

- Theme catalog changes are code-reviewed and deployed with the application.
- Each tenant choice persists independently of browser storage and applies across authenticated console sessions.
- The console falls back safely to the base theme when theme infrastructure is unavailable; saving a choice requires the deployed DynamoDB output and SSR role permission.
- A future constrained brand-palette generator may create proposed catalog entries only after accessibility validation; it must not expose arbitrary semantic-token editing.

## Related decisions

- Extends ADR-0030.
- Uses the hybrid persistence model from ADR-0007.
- Uses the audit facade policy from ADR-0028.
All sources and standards
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.