Coding Standard: React (ui-admin-application)
React + MUI + Zustand is the platform’s one client framework for the tenant/admin management console — a CRUD-heavy dashboard, where MUI’s component depth and Zustand’s minimal boilerplate fit the workload — see ADR-00010 for why. This doc is the concrete rulebook ui-admin-application is actually held to; Architecture-00007 covers the client feature triads across both ui-admin-application and ui-application side by side.
The five-file Feature Triad
Every feature directory has exactly these five files:
<Feature>Types.ts— feature-scoped TypeScript interfaces, no logic.<Feature>Repository.ts— Axios calls, one file per microservice boundary; the only file that importsapiClient.<Feature>Service.ts— pure functions, data mapping & business transforms, no React.<Feature>Controller.ts— a custom hook doing state orchestration, readsauthStoreonce.<Feature>Page.tsx— stateless JSX, calls the controller.
A multi-level feature (e.g. Category) may share Types/Repository/Service across sub-pages while each sub-level gets its own Controller/Page pair.
TenantID propagation — one direction only, never shortcut
TenantID flows authStore → controller → service argument → repository argument → apiClient header, one direction only:
- Never inject
X-Tenant-IDinapiClient.ts. - Never read
authStoreinside repositories or services. - Never pass
tenantIdas a prop through component trees.
The browser never sends X-Tenant-ID itself — TenantID is carried inside the Firebase JWT; Nginx’s /_auth_verify subrequest decodes it and injects X-Tenant-Id upstream.
Firebase App Check — client mirror
- Activation:
firebaseConfig.ts→initializeAppCheck(app, { provider: new ReCaptchaV3Provider(siteKey) }), non-DEV builds only. - Dev/local bypass:
import.meta.env.DEVskipsinitializeAppCheck; the interceptor sendsVITE_FIREBASE_APPCHECK_DEBUG_TOKENdirectly. - Production:
getToken(firebaseAppCheck)fromfirebase/app-check, attached asX-Firebase-AppCheck. - The debug-token value must match across
ui-admin-application,ui-application, anduser-secure-engine’sFIREBASE_APPCHECK_DEBUG_TOKENS— a mismatch fails closed (401), not open, but silently.
Tracing
Browser clients initialize tracing and inject traceparent + X-Correlation-ID via an HTTP client interceptor — never X-Tenant-ID. traceparent/tracestate must be listed in Access-Control-Allow-Headers in development/nginx.conf, or the browser’s CORS preflight rejects the header.
No over-engineering
No extra abstractions, error handling, or features beyond what the task requires.
Comments
No comments unless the WHY is genuinely non-obvious.