Coding Standard: React (ui-admin-application)

By Engineering Team•September 27, 2026•5 min read

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:

  1. <Feature>Types.ts — feature-scoped TypeScript interfaces, no logic.
  2. <Feature>Repository.ts — Axios calls, one file per microservice boundary; the only file that imports apiClient.
  3. <Feature>Service.ts — pure functions, data mapping & business transforms, no React.
  4. <Feature>Controller.ts — a custom hook doing state orchestration, reads authStore once.
  5. <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-ID in apiClient.ts.
  • Never read authStore inside repositories or services.
  • Never pass tenantId as 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.DEV skips initializeAppCheck; the interceptor sends VITE_FIREBASE_APPCHECK_DEBUG_TOKEN directly.
  • Production: getToken(firebaseAppCheck) from firebase/app-check, attached as X-Firebase-AppCheck.
  • The debug-token value must match across ui-admin-application, ui-application, and user-secure-engine’s FIREBASE_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.