AGENTS.md@demo-apps/destination-wedding-planner/apps/web · git:20261111.44e6ed3 · 2026-11-11 · sha256 05e5e7e076f3a01c

AGENTS.md@demo-apps/destination-wedding-planner/apps/web git:20261111.44e6ed3A

Immutable. This exact content never changes and is served at /api/v1/blob/05e5e7e076f3a01c.

<!-- geeknative:begin (managed by geeknative: replaced on upgrade. Add your own rules under "Project rules" at the end.) -->
# Web app (React + TanStack Start)

Read the root AGENTS.md first. This file covers how the web app is built.

## Stack

- React 19 and TanStack Start (server rendering), with TanStack Router file routes and TanStack Query.
- Tailwind CSS v4 with the generated design tokens, and Lucide icons.
- TypeScript (strict), Vite, Vitest. Tests run in Node; a test that renders into a DOM starts with `// @vitest-environment happy-dom` and renders the app with `renderApp(path, testContainer(...))` from src/testing/renderApp.tsx. Add each new repository to `testContainer`.
- Supports Safari 16.4+, Chrome 111+ and Firefox 128+ (Tailwind v4's minimum).

## Layout

```
apps/web/src/
  router.tsx              Creates the router with { queryClient, container } as context
  routes/                 One thin file per URL: head, loader, then render a feature's screen
    __root.tsx            HTML shell, desktop site header, AppearanceEffect
  core/                   AppContainer, AppearanceEffect
    navigation/           SiteHeader (desktop-first top bar, side drawer below md)
    designsystem/         Shared components (AppCard, ...)
  features/<name>/        <Name>Screen.tsx, use<Name>ViewModel.ts, <Name>Repository.ts, implementations, tests
  generated/              From contracts/ by `make gen`. Never edit.
  styles.css              Tailwind entry; imports generated/tokens.css
  routeTree.gen.ts        Generated by TanStack Router. Never edit.
```

## Patterns

Same names and responsibilities as the iOS and Android apps.

| Concept | Web |
|---|---|
| Screen | `NotesScreen` in features/notes/, rendered by routes/notes.tsx, with its content in `<Page>` (core/designsystem/Page.tsx): a centered readable column, or `<Page width="full">` for grids and side-by-side layouts. Never cap a screen's width without centering it. Unprefixed classes are the desktop layout; hide the top-bar links with `max-md:hidden` and open a side drawer below `md`. Do not start from a phone layout and add `lg:` later. |
| State and actions | `useNotesViewModel()`: reads data with TanStack Query, returns state and actions |
| Data | `NotesRepository` interface, plus implementations such as `LocalStorageNotesRepository` |
| Dependencies | `AppContainer`, in router context: `useRouteContext({ from: '__root__' }).container` |
| Navigation | A file in routes/ per screen; link with `<Link to="/notes">` |
| Copy | `strings.notesEmptyTitle` (generated) |
| Colors, spacing, radii, icon sizes, type | Tailwind token classes: `bg-primary`, `p-md`, `rounded-lg`, `size-icon-md`, `min-h-touch-target`, `text-title` (the typeface comes with `font-sans`) |
| Token values as numbers | `AppTextSize.title`, `AppSpacing.md`, `AppSize.touchTarget` from `#/generated/tokens` (the same numbers iOS and Android get), for showing or computing with a size. Style with the classes, not with these. |
| Widths and sizes | `w-*`, `min-w-*` and `max-w-*` with a size name (`max-w-md`, `w-xl`) are Tailwind's container widths, for layout. For a spacing-sized width write `w-(--spacing-md)`. `size-*`, `h-*`, `p-*` and `gap-*` with a token name use the spacing tokens (`size-xs` is 4px). |
| Motion and shadows | `motion-safe:transition duration-fast ease-standard`; a spring is `ease-snappy duration-snappy`; `shadow-low`. Never raw durations, curves or shadow values, and wrap motion in `motion-safe:`. |
| Icons | `<AppIcons.settings className="size-icon-md" />` (generated) |
| Config | `AppConfig.apiBaseUrl`, `environment` from `#/generated/config` (generated from contracts/config.json) |
| Secrets | `AppSecrets.mapsApiKey` from `#/generated/secrets.server` (server functions and API routes only) |
| Test IDs | `data-testid="notes.addButton"` |

Follow features/settings as the reference implementation.

## Rules

- Never hardcode user-facing text, colors or spacing. Add them to contracts/ and run `make gen`. Use token classes (`bg-surface`, `p-lg`), not arbitrary values (`bg-[#fff]`, `p-[13px]`).
- The browser tab title is web chrome, like the iOS navigation bar: build it in a route's `head` from the screen's title string and `AppIdentity.name` (`${strings.notesTitle} · ${AppIdentity.name}`). Its separator is exempt from the no-literal-text rule. All other user-visible text still comes from contracts/.
- Server functions and API routes are only for web-only concerns (rendering, cookies, SEO). Logic the mobile apps need too goes through repositories, so a future backend can serve all three apps.
- Never import `generated/secrets.server` from a component: secrets are server-only and the module throws in the browser.
- Code that uses browser APIs (localStorage, window) must also run safely during server rendering.
- Use semantic HTML, give icon-only links and buttons an `aria-label` from strings, and keep focus visible.
- For dialogs, use the native `<dialog>` element with `showModal()`: it's accessible, traps focus and needs no dependency. For primitives HTML doesn't cover well (menus, popovers, comboboxes), add shadcn/ui, which isn't installed by default: the tokens already map onto its CSS variables.
- Name tests after acceptance criteria: `test('AC-notes-2: ...')`.

## Commands

- `make check-web`: type-check, unit tests and a production build. Full log: .geeknative/logs/web.log.
- `make run-web`: dev server at http://localhost:3000.
- To look at a production build: `npx vite build`, then (re)start `npx vite preview` in apps/web. A running preview server keeps serving the previous build's files, so restart it after every build.
<!-- geeknative:end -->

## Project rules

<!-- Your web-specific rules. They override the defaults above, and geeknative upgrades never touch them. -->