Files
poorBird/web
Thomas KarnerandClaude Opus 5 384b09371a UI: scaffold the web app - shell, themes, i18n, auth plumbing
React 19 + TypeScript + Vite + TanStack Query/Router in web/, built on the
dev machine and shipped as static files (SPEC section 6). Typechecks and
builds clean; the System page reads live /health through the Vite proxy,
which proves browser -> proxy -> FastAPI -> PostgreSQL end to end.

Themes: light, dark and blue (dark navy), as design tokens on data-theme.
An inline script applies the stored theme before first paint. No colour
literal lives outside tokens.css.

check-contrast.mjs asserts WCAG AA for every text/background pair in every
theme, with no dependencies. It failed on its first run and found three
--border-strong values below the 3:1 that WCAG 1.4.11 wants for interactive
boundaries; all three are fixed and 36 pairs now pass. Colour contrast is
the classic silently-regressing property, so it gets a test rather than a
promise.

i18n is hand-written and typed rather than react-i18next: en.ts defines the
key set, de.ts is typed against it, so a missing German string fails the
build instead of quietly showing English to a German user.

Authentication is built but NOT enforced, deliberately. /auth/session,
/auth/login and /auth/logout do not exist yet, so router.tsx does not wrap
routes in RequireAuth and a banner says so plainly. There is no development
bypass: a bypass that works is the kind of code that survives into
production, and an auth bypass that works is the worst possible bug.

Gallery and Devices render honest empty states rather than mock rows. Fake
data hides the layout problems real data exposes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-21 01:17:07 +02:00
..

poorBird web

Phase 3 scaffolding: shell, themes, i18n and the auth plumbing. Built on the dev machine and shipped to the server as static files — nothing here runs on the server (SPEC §6).

cd web
npm install
npm run dev          # http://localhost:5173

The dev server proxies /api to http://127.0.0.1:8090, so start the API too (see ../server/README.md). Both must be running or the System page shows "cannot reach the server", which is the honest answer rather than a blank screen.

Script Does
npm run dev Vite dev server with HMR
npm run build typecheck, then production bundle into dist/
npm run typecheck tsc --noEmit on its own
npm run check:contrast assert WCAG contrast for all three themes

On Windows, Vite binds IPv6 localhost. Use http://localhost:5173, not http://127.0.0.1:5173.


What is real and what is not

Only GET /api/v1/health exists on the server today, so only the System page shows live data. It is the end-to-end proof: browser → Vite proxy → FastAPI → PostgreSQL.

Gallery and Devices render an honest empty state. They are deliberately not filled with mock rows — fake data hides exactly the layout problems that real data exposes, and Phase 2 is what brings real captures.

Authentication is built but not enforced. /auth/session, /auth/login and /auth/logout are Phase 3 server work and do not exist yet. So:

  • AuthProvider and RequireAuth are written and typechecked
  • router.tsx does not wrap routes in RequireAuth yet, and says why
  • a banner in the layout states plainly that sign-in is not enforced
  • there is no development bypass, on purpose — a bypass that works is the kind of code that survives into production, and an auth bypass that works is the worst possible bug

Wiring it up when the endpoints land is three lines in router.tsx plus deleting the banner.


Conventions

No user-facing string literal in a component. Ever. Every one goes through useT(). src/i18n/en.ts defines the key set; de.ts is typed as Catalogue, so a missing or misspelled German key fails npm run build rather than showing English to a German user at runtime.

No colour literal outside src/styles/tokens.css. Components reference tokens, which is what makes a fourth theme a single CSS block. Run npm run check:contrast after touching any colour — it caught three failing --border-strong values the first time it ran.

Themes are data-theme on <html>: light, dark, blue (dark navy). An inline script in index.html applies the stored choice before first paint to avoid a flash of the wrong theme; it must stay in sync with theme/ThemeProvider.tsx — same storage key, same attribute, same default. Once accounts exist, users.theme becomes the source of truth and localStorage stays as the pre-login default.


Layout

src/
  main.tsx              providers, in order
  router.tsx            the whole route table, one flat file
  i18n/                 en.ts (source of truth), de.ts (typed against it)
  theme/                data-theme on <html>
  auth/                 provider, login form, route guard (not wired yet)
  lib/api.ts            the only place that calls fetch
  components/           layout and shared pieces
  pages/                one per route
  styles/               tokens.css (themes), global.css (everything else)
scripts/check-contrast.mjs

Notes on the stack

TypeScript is strict, including noUncheckedIndexedAccess and verbatimModuleSyntax. Learning TypeScript with the checks off teaches a different language than the one everyone else writes. The error messages say what to do.

i18n is hand-written, not react-i18next. Two languages and a few hundred strings do not need a library, and the typed catalogue gives compile-time completeness that i18next does not provide by default. If real plural grammar is ever needed, ICU MessageFormat is the upgrade and the call sites keep their shape.

TanStack Router with code-based routes, per SPEC §6, rather than the file-based convention — one visible route table, no codegen step. Its payoff is that <Link to="/devices"> is typechecked, so a typo in a path is a build error instead of a 404 found later.

No ESLint yet. tsc --noEmit catches the important class of mistakes; ESLint is worth adding but its flat-config setup is a distraction during scaffolding.