Skip to main content

Frontend structure

App Router​

Each app (apps/tracking, apps/portal) is a Next.js App Router project under src/app/:

  • page.tsx — login gate.
  • layout.tsx — root layout. Imports globals.css, mounts the prefetch <XLoader/> components from @enode/core, and runs a boot script that adds class="ios" to <html> on the Capacitor iOS build.
  • Feature routes — composed from co-located use-* hooks and presentational files.

Portal account and settings routes​

The portal's Account page has one route per tab (apps/portal/src/app/dashboard/account/):

RouteTab
/dashboard/account/profileProfile (/dashboard/account opens it)
/dashboard/account/planPlan & usage — owner only (owner role and the readLicense privilege); everyone else is sent to Profile
/dashboard/account/dataData & import

Help is not part of the Account: it is its own page, /dashboard/help (/dashboard/account/help forwards there). Its Guides card lists only the guides for the user's role (helpArticleIdsForRole in articles.ts): "Bring in your old data" for the owner, "Training stations and devices" for everyone but athletes, "Training without a connection" for all. The old address /dashboard/plan forwards to its tab; every forward keeps the query string and hash.

Devices is not part of the Account either (17.11.26): it is its own page, /dashboard/devices, an entry of the account menu (Account, Devices, Settings, Help); the old tab address /dashboard/account/devices forwards there.

Account entry in the sidebar​

The sidebar footer's account button shows the avatar, the user's name and the role word (muted) and opens the account menu (Account, Settings, Help, Sign out). Name and role truncate; the export and bell buttons keep their 40 px size (sidebar.tsx, sidebar-account.ts).

The owner's "Your plan is full" notice keeps the training-stations line while the device list loads or fails: it uses the last count seen for that user (readLastStationsUsed in plan-full-limits.ts).

Plan, access and the owner's sign-in email (both apps)​

  • Plan & usage. Portal and app show the same "Included" list (PlanFeatureList, plan-features.tsx). The app shows "n of m in use" for training stations only when GET /user_licenses/usage answered; without it only the plan total (stationsValue in account-plan-view.tsx). No "Manage subscription" until billing exists (backend P7-B17); the app offers "Compare plans" and "Talk to us about your plan", like the portal.
  • Your access. For coaches and athletes with a place, the Profile line "You have a place in {organisation}'s plan." opens a read-only sheet: what the role may do and "Need more? Ask the owner of {organisation}." (your-access-sheet.tsx). Members get no licence on their user read, so the plan name shows only if one arrives.
  • Owner sign-in email. Owners never change it in the app. "Contact support" opens "Change your sign-in email": one address field, sent as a support report through the same relay and offline queue as "Report a problem" (owner-email-change-sheet.tsx).

Devices​

The page is split by a segmented switch (17.11.26) into Recording (the device list, the default) and Sensors (?view=sensors, parsed in devices-part.ts): a read-only list of the account's sensors from GET /sensors (sensors-view.tsx); pairing and management stay in the tracking app.

devices-view.tsx lists the devices; the shared pieces live in apps/portal/src/app/dashboard/devices/.

  • Order. The list starts sorted by Last used, newest first; this device ("Now") stays on top under every column sort (orderDeviceRowsByLastUsed in device-rows.ts).
  • Training stations by role. Owners and coaches see the Training stations column, the station counts and the device sheet's Stations picker. Athletes don't hold or manage training stations: no column, no count in the subtitle or the phone cards, no Stations row and no station definition.
  • Feedback only. A phone or tablet with no training station reads "Feedback only" in the column, the phone cards and the Stations picker; browsers show "—".
  • Full plan in the device sheet. When the plan has too few training stations free, the counts out of reach are greyed in the Stations picker and a note under it gives the reason in full (stationPickerLimit in station-options.ts), then "Take 1 from …" for each other device holding stations (the page's confirmed take, "Take 1 station from …?") and, for the owner, a Plan & usage link.
  • Sign-out warnings. Every sign-out confirm (one device, the bulk "Sign out N", "Sign out of all other devices", and "Sign out of this device?" in both apps) adds "… holds n training stations; they become free." for each affected device that holds stations (stationsFreedLine in sign-out-device.ts). The app reads this device's stations from the device-session store when the sign-out is asked for.

/dashboard/account/data?action=delete opens the account deletion dialog once the signed-in user is known; the parameter is taken off the address right away (delete-action.ts).

The Settings page /dashboard/settings (page.tsx, settings-query.ts) is one underline tab per account-wide section, in the same tab row as the Account pages (the shared UnderlineTabs, underline-tabs.tsx, rendering Next's Link). "On all your devices" is stated once under the tabs. The tabs are composed in the portal from the shared section bodies (useSettingsSections in @enode/ui/settings/settings-screen); the tracking app's Settings screen (SettingsScreen) has the same tabs plus "This device", held in memory.

  • ?page=<id> picks the tab: training (the default), liveDisplay, notifications, languageUnits or tips. A missing, unknown or device-only id (such as thisDevice) shows Training. Switching tabs replaces the history entry, drops ?section= and keeps every other query parameter.
  • Account ids (account, profile, plan, signedInDevices, myData, help) forward to the matching Account route, keeping the rest of the query.
  • ?section=questionnaires (without ?page=) shows Training.
  • The Notifications tab is left out when the backend offers no notification topics; ?page=notifications then shows Training.

Styling & design tokens​

Tailwind v4 with the Enode design system in packages/ui/src/styles/design-system.css. Each app's globals.css composes it:

@import "tailwindcss";
@import "@enode/ui/styles/design-system.css";
  • Use semantic colour utilities (bg-surface-base, text-foreground-muted, border-surface-stroke, bg-foreground-red-orange, …) and type-style classes (heading-hero, body-normal, stat-large-digits, …).
  • Never raw gray/orange/emerald utilities. Tokens carry light + dark values and flip via prefers-color-scheme, so don't add dark: variants.
  • Destructive states still use raw red-* — the design system has no danger token (a known gap).
  • ios: is a custom variant scoped to the Capacitor iOS build.

Scroll model & page layout​

Both apps use inner-scroll: the window does not scroll; persistent chrome (sidebar, page header) stays put and a single content pane scrolls. The body is locked to the viewport — the tracking app at the root (<body class="h-full">), the portal inside AppShell (h-dvh) so its public / route can stay document-scroll. See ADR 0004.

  • The shell's <main> is a bounded, non-scrolling flex column (relative flex min-h-0 flex-1 flex-col overflow-hidden). Pages own their scroll region.
  • Portal pages use PageShell (apps/portal/src/components/page-shell.tsx) — it renders the pinned title bar (via the shared header kit) and the page's single overflow-y-auto body, so pages never hand-roll the min-h-0 / overflow chain. Pages with their own full-height layout (planner, performance) skip it and fill <main> directly with their own internal scroll.
  • PageShell sizes a page by content with width: narrow (72rem; forms, settings, prose), default (99rem; everything else), or full (no cap; table pages only — the planner, outside PageShell, is uncapped too). All three are centred, header and body alike. See ADR 0018.
  • Every flex ancestor between <main> and a scroll pane needs min-h-0, or the overflow lands back on the window.

Shared-component contract: components in @enode/ui that fill height or pin to a scroll container (e.g. Sidebar, the header-height kit) may assume a viewport-bounded flex parent — both apps now provide one. Components that must work regardless of the host's scroll model should establish their own scroll context (the fixed drawer/dialog/sheet pattern), not depend on the page's.

Per-device settings​

"Single rep review", "Show set summary" and the distance override are stored on the device, not on the account. Settings → Training shows "On this {device}: …" with Reset when an override is set.

Conventions​

  • State resets adjust state during render (the prev-value pattern), not via setState in useEffect — ESLint enforces this.
  • Local entity ids are crypto.randomUUID().
  • Reusable presentational components belong in @enode/ui; shared non-UI logic in @enode/core. App-specific views stay in the app.

See Components for the reusable component layer and Storybook.

Plan vocabulary​

Terms the portal and the app use for plans, so the same thing is never named two ways.

  • device — a phone, tablet or browser signed in to the account.
  • training station — what your plan counts: one device recording one group at a time (a tablet may hold up to 3).
  • column — a group on the screen of the app.
  • place in your plan — one athlete or coach the plan lets train.
  • Not in plan — an athlete or coach beyond the plan's places; they can train for live feedback, but nothing is saved for them.
  • Train without saving replaces "Feedback training" / "Feedback only" in limit contexts.
  • Feedback only — a device's setting with no training station (the portal's Devices list and device sheet).
  • Plan & usage — the owner's page in the portal (/dashboard/account/plan).

Never use these in UI copy: "licence", "privilege", "weight", "seat", "slot".

The shared sentences live in one place, packages/core/src/plan/words.ts (useStationDefinition, usePlaceDefinition, useNotInPlanLabel, useNotInPlanRule). Use those hooks instead of copying the wording.