Architecture
This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.
Code is grouped by what it is for, not by what kind of file it is, and the dependencies run one way:
trips/schema ◄── everything
lib ──► features ──► app
| Layer | Path | Rule |
|---|---|---|
| Content | src/trips/ | schema/ is what a trip may say, split by content domain. Then one directory per destination, public content only. |
| Primitives | src/ui/ | Trip-agnostic. Nothing here knows what a Trip is. Import from the directory (index.ts), not the files. |
| Shared | src/lib/ | Only what two or more features need: lookup (areaOf/partyOf/dayOf), schedule (the one walk over a day's running order), load-trip, trip-context, land-on-hash (the jump to a lazy chapter's anchor on arrival). |
| Chapters | src/features/ | One directory per chapter. A component used by exactly one chapter lives in it. |
| Shell | src/app/ | Entry, routing, Layout and its 42px bar, the switcher, the landing page. |
Imports use @/… across a directory boundary and stay relative within one.
How a trip is registered and loaded
Every trip is two modules with a hard line between them, and the line is what the app shell can see:
<place>/meta.ts | eager | Areas, the week, and what the bar and the shelf say. Under a kilobyte. Reachable from the shell, so it must never import the content. |
<place>/index.tsx | lazy | The TripContent. Behind the meta's load(), one dynamic import per trip, so opening Prague does not download Belgium. |
src/trips/index.ts is now just the list of metas —
adding a destination is a directory and a line. It used to hold the metas
themselves, twenty-five lines each, in a file the trip's own directory could not
see.
The week is declared once, in the meta, through defineWeek
(src/trips/week.ts). days and pricing.days
spread week.day(n), and week.ticks is what the shelf paints. It used to be
three hand-written copies of the same facts, and it had already drifted — see
decisions-code.md.
chapters is the one field still declared rather than derived, because the bar
paints before any content is fetched and Boolean(trip.pricing) needs the thing
being deferred. TripOutlet warns in dev if it disagrees with the content in
either direction; CHAPTERS in Layout is the single table that says which
content makes which chapter real.
A trip's guide is a sibling directory (belgium-guide/), not a child of
belgium/, because it is a separately-loaded chunk and nothing may reach it
eagerly. Within belgium-guide/ it is one file per city, because a chapter is the
unit you actually edit — Antwerp alone is ~1,450 lines, and that is on purpose.
Routing and chunking
src/app/App.tsx: the Overview (/:slug) is a trip's
landing page and stays in the first chunk; every other chapter is lazy,
including Days (/:slug/days) since 2026-10-27, when the Overview went first. An
old /:slug#day-N redirects to /:slug/days#day-N, and the Days page makes
the jump to the day itself on arrival. The poster route sits
outside Layout — it is a bare sheet, and the bar would land in the
screenshot. Three error boundaries (app/ErrorBoundary.tsx) catch a load that
fails: the main one inside Layout, so the bar stays up and switching chapter
recovers. They reset on a resetKey (the path) rather than a React key, which
would remount everything below on each chapter change. Page titles are React 19
<title> elements in Layout and Home, hoisted into the head
("chapter · trip — The Field Journal"); no effect, no library.
The map's labels are Archivo, served from public/glyphs (about 1 MB of
signed-distance-field ranges). npm run glyphs (tools/glyphs/glyphs.mjs)
rebuilds them from Google Fonts with fontnik; only name:latin is drawn, so no
Cyrillic ranges are needed (2026-10-24).
vite.config.ts does four things worth knowing:
basecomes fromPUBLIC_BASE(default/trips/) — the site is served under a sub-path on a shared Caddy VPS.chunkFileNamesnames a directory's chunk after the directory, so a trip's content is not a second chunk calledindexsitting beside the app's entry.manualChunkssplitsmaplibre,base-ui,routerandvendorout — for caching, and so that a lazy dependency reappearing in the entry chunk is visible in the build output. The map is the heaviest code in the build (2026-10-24):maplibreis 1,047 kB (284 kB gzip) and its web worker, built by Vite from?worker&url, 512 kB (148 kB gzip), against Leaflet's ~150 kB. Its stylesheet is MapView's import and loads with it. Until 2026-10-28 the map's files were named intoassets/map/so the precache could leave them out; with offline gone they are ordinaryassets/.hidden()is the first plugin, because it edits the destination registry before anything else reads it, so a trip named inTRIPS_HIDDENnever enters the module graph. The precache plugin that ran last went with offline support on 2026-10-28;public/sw.jsis copied as-is.
Styling and offline
styling.md has the cascade, the layer order and which
stylesheet a rule belongs in. offline.md says why the site has
no offline copy since 2026-10-28 and what the worker left at the old address
does.
What stands in for tests
tools/fingerprint/ walks the DOM of every route at
two widths and records each element's box and ~38 computed properties, keyed by
DOM position rather than by class name — so it sees a change that rewrites every
class attribute. It has caught fourteen real bugs that a screenshot and a careful
read both missed. Playwright is not a dependency (~300 MB); the harness borrows
one from a sibling project.