--- type: entity updated: 2026-07-11 tags: [software, frontend, react] --- # Frontend (`../frontend/`) The React control panel (built 2026-07-11, replacing the single-file vanilla-JS panel at the owner's request). Stack per the owner's spec: **Vite + TypeScript + React 19, React Router 7 (routing), zustand (auth/UI state), TanStack Query 5 (server state, polling)**. ## Dev / prod workflow - **Dev**: `npm run dev` in `frontend/` → Vite on `:5173`, **proxies `/api` to the backend on `:9000`** (`vite.config.ts`), so the session cookie flows normally. - **Prod**: `npm run build` → `frontend/dist/`; the [[backend]] serves it statically with an SPA fallback (exact files win, everything else gets `index.html`, `/api/*` and `/docs` excluded). No separate web server. - Fully self-contained: fonts (Archivo + IBM Plex Mono via Fontsource) are bundled into `dist/` — nothing loads from a CDN, so it works over [[netbird|NetBird]] without internet. ~94 kB gzipped JS. ## Pages | Route | Who | What | |---|---|---| | `/` (Control) | all | one "bay" card per gun — **every registry-declared gun always renders**, even offline; status lamp, Start/Stop gated by scope **and** gun readiness; live session shows who/via/duration; relay toggles with on-demand live read | | `/account` | all | **your permissions in plain words** (admin badge, or the guns/relays you may control) + self-service password change (current password required) | | `/history` | all | admins: the full audit table (**who charged, via Card or In-app, which gun, when, duration, kWh**); everyone else: **only their own sessions** | | `/cards` | admin | **pending cards awaiting review** (approve → name + owner + gun restrictions in one step; reject → silenced), enrolled cards with owner/guns editing, rejected list with un-reject | | `/users` | admin | user CRUD with the **permission matrix** — admin toggle, per-gun and per-relay checkboxes rendered from `GET /api/permissions` (no raw scope strings in the UI) | An amber **notification banner + nav badge** appears for admins whenever unknown cards are pending (count polled via `/api/status` every 5 s). ## Design Instrument-panel direction grounded in the hardware: porcelain/graphite surfaces (light + dark via `prefers-color-scheme`), **copper-busbar accent**, IBM Plex Mono for telemetry/identifiers, Archivo for UI. Signature element: the **indicator lamp** (radial LED with glow) encoding state everywhere, in the owner-specified language (2026-07-12): **gray = idle, pulsing blue = cable in the socket, green = charging**, red = fault/offline banner, amber = pending cards. Reduced motion respected; keyboard focus visible.