Routing
Each app uses the Next.js App Router (apps/<app>/src/app/). Because the
production build is a static export, routing is file-based and fully
client-rendered after the initial static HTML — there is no server routing layer.
Per-app entry points
| Path | File | Purpose |
|---|---|---|
/ | src/app/page.tsx | Login gate |
| feature routes | src/app/<feature>/page.tsx | App-specific screens |
The tracking app additionally ships a styleguide route that renders the
design system as a live reference.
TODO: enumerate each app's concrete feature routes here once they stabilise — derive them from
apps/*/src/app/**/page.tsxrather than guessing.
Auth gating
@enode/core's auth-guard.tsx (AuthGuard, mounted in each app's
layout.tsx) gates access on the stored bearer token. Login happens at /, and
the prefetch loaders re-run after login.
Find a setting in the address (portal)
?find=<key> on any portal page asks the app shell to scroll to the setting
whose label has the i18n content hash key, then drops the parameter. The
global search sets it; see Global search.
View state in the address (portal)
A portal page's view — its search text, filter facets, toggles, sort, table page, tab and shown period — lives in the URL query. A reload, the browser's Back from another page and a copied link therefore all show the same view. Decision: ADR 0017.
The shared hooks are in
apps/portal/src/app/dashboard/url-state.ts:
useInitialSearchParams()returns the query the page was opened with, frozen at mount. The page seeds its ordinaryuseStatefields from it.useSyncSearchParams(owned)writes the page's keys back withhistory.replaceState, debounced. Filtering makes no history entries, so Back leaves the page instead of undoing a filter.
Each page has a pure codec next to it (<page>-view.ts, e.g.
data/history/history-view.ts):
read…View(params) reads missing or malformed keys as the defaults, and
…ViewParams(view) lists every key the page owns, a default writing nothing —
a page at its defaults has a clean address. Keys the page doesn't own (another
feature's deep link such as ?edit=) are left alone.
Key names
The same names on every page: q (search text), tag (tag ids, repeated),
match=all, archived=1, sort + dir, page, view / tab,
date=yyyy-mm-dd. Multi-select facets repeat their key. A page with two
searches prefixes them (Profiles: athleteq / exerciseq, athletetag /
exercisetag).
Two existing deep-link contracts keep their meaning: on History, athlete and
tag are names (the search tokens), not ids.
Pages and their keys
| Page | Keys |
|---|---|
| Overview | range, exerciserank, athleterank |
| History | athlete, exercise, variation, equipment, tag (+ tagID), from / to or range=all, video, source, archived, page |
| Profiles | athlete, exercise (the pairing), athleteq, athletetag, exerciseq, exercisetag, exercisefav, exercisesort |
| Insights | tab |
| Users | q, role, tag, match, archived, notinplan, sort / dir, page |
| Exercises | q, tag, match, muscle, equipment, usage, athlete, athletetag, sort / dir (sort=none: sorting switched off), page |
| Workouts | q, tag, page |
| Tags | q, scope (scope=all: no scope chip), archived, sort / dir, page |
| Planner | view, date, athlete, tag |
| Devices | q, station, who, sort / dir, page (view=sensors is the tab, not the list's) |
| Notifications | filter |
The codecs are the source of truth; each sits next to its page as
*-view.ts (Devices: devices-view-state.ts).
What stays out of the address
Selections, open drawers, dialogs and menus, walkthroughs, and preferences
that are already per browser in localStorage (table columns, the Profiles
chart range). The sidebar always opens a page at its defaults. One selection
is view state on purpose: the Profiles athlete × exercise pairing, which is
what the page shows.
Constraints
- The query is read once, on mount: a link to the page that is already open does not re-seed it.
useSearchParamsneeds a Suspense boundary in a static export; the dashboard layout wraps every page in one.- A paginated
DataTablekeeps its page in the address through its controlledpageStateprop. A new filter starts the list over at page 1 (usePageReset); the page read from the address on mount is kept. - A link that replaces the query of the page already open (the bell's
?expand=) gets the page's keys written back onto it.
Constraints
- No request-time routing. No Route Handlers that read the request, no Server Actions, no request-dependent middleware — the static export forbids them.
trailingSlash: truein prod so exported paths resolve as directories.