Portal demo build
Status: phase 5 of the demo plan, 2026-11-10. Every dashboard page except Live Hub shows the demo club: dashboard, Users, Tags, Exercises, Workouts, Planner, History, Performance, Insights, Notifications, Questionnaires and Devices (see What the club serves and Plan, charts and the other pages). Since phase 7, changes stay for the visit (see Changes during a visit). Earlier status notes follow. The demo starts, is signed in as a Pro Owner, and makes no backend request. The backend's static data (catalogues, translations, roles, media) comes from a committed snapshot. The demo club itself (athletes, tags, sessions…) doesn't exist yet: its lists are empty or not answered, and the demo inspector lists what is still missing. The decisions behind it are in ADR 0015.
What the demo build is
The demo build is the real portal, built with NEXT_PUBLIC_DEMO=1. Every API
request and live stream is answered by a fake backend that runs in the browser
tab. The real screens, stores, hooks and error engine run unchanged. Nothing is
sent to a backend, and nothing is written to the device's offline database.
Running the demo
| Command | What it does |
|---|---|
npm run dev portal-demo | Dev server on http://localhost:3003, next to the normal portal on :3001 |
npm run build portal-demo | Static demo build in apps/portal/out-demo/ |
npm run run portal-demo | Serves out-demo/ on :3003 (build first) |
npm run dev demo | The whole demo: the portal demo on :3003 with the tracking app inside it (see Tracking app in the demo) |
npm run build demo | Builds both demos and copies the tracking export into apps/portal/out-demo/tracking/ |
npm run run demo | Serves the combined out-demo/ on :3003 (build first) |
The demo uses its own folders (.next-demo/, out-demo/), so it never shares
a dev cache with the normal portal or overwrites its out/. Both are
git-ignored.
Opening / forwards straight to /dashboard: the demo is signed in as a
built-in Pro Owner from the first render.
| Environment variable | Effect |
|---|---|
NEXT_PUBLIC_DEMO_EXIT_URL | Where the banner's Exit demo button leads. Without it, there is no Exit button |
Where the demo is deployed
The demo is deployed separately from the portal, at
https://demo.portal.enode.ai. The real portal's sign-in page
(apps/portal/src/app/page.tsx) links to it
with a Try the demo button on the welcome step. The demo build hides that
button, because it is already the demo.
To bring visitors back, set NEXT_PUBLIC_DEMO_EXIT_URL to the real portal's
address in the demo deployment.
TODO: record the demo deployment's hosting setup (project, branch, environment variables) once it exists.
How a normal build stays free of demo code
The demo is wired in at one place, the module name @portal-demo/entry.
apps/portal/next.config.ts resolves it through turbopack.resolveAlias:
- in the demo build, to
src/demo/entry.ts(the realinstallDemoand the demo inspector); - in every other build, to
src/demo/entry-off.ts, where both arenull.
A build-time if (NEXT_PUBLIC_DEMO) around a static import did not keep the
demo modules out of the normal bundle, so the alias does that job. In the other
direction, ApiConfigInit.tsx branches on the build-time flag, which drops the
real API configuration, including the api-key, from the demo bundle.
To check both after a change, build both apps and search the output:
npm run build portal && npm run build portal-demo
grep -rl "Demo inspector" apps/portal/out # must find nothing
grep -rl "<the portal api-key>" apps/portal/out-demo # must find nothing
The demo bundle still contains the backend server list from
packages/core/src/api/servers.ts (URLs, no credentials), because shared
modules import it. The network guard blocks every request to those URLs.
What installDemo does
apps/portal/src/demo/install.ts runs once, when ApiConfigInit is loaded:
- Configures the API with a fake base URL (
/demo-api) and no real api-key. - Switches the offline database off with
disableOfflineDatabase()from@enode/core/offline/stores. The reference cache and account snapshots then do nothing, and the ownership check has nothing to stamp or wipe. - Installs the fake HTTP transport (
setHttpTransport), which hands every request to the demo router after a short simulated delay. - Installs the fake realtime transport (
setRealtimeTransport). The Owner's topic is scripted (see "Live streams"); every other topic only gets heartbeats. - In the browser only: installs the network guard, stores the demo Owner's token, and schedules the visit's live notifications.
The parts of src/demo/
| File | Responsibility |
|---|---|
entry-types.ts, entry.ts, entry-off.ts | The @portal-demo/entry switch |
install.ts | Wires everything in (above) |
router.ts | Matches METHOD /path/:param to a handler |
handlers/reference.ts | Serves the snapshot: every catalogue route, the server texts per language, English-only app languages |
handlers/shell.ts | The start-up answers that belong to the account: the Owner, their settings, the dismissed first-run surfaces (none at first, kept for the visit), empty tag and notification lists, no announcements or guidance |
reference/ | The snapshot files, entries.ts (route ↔ file) and load.ts (lazy loading) |
fake-http.ts | The fake transport. An unmatched route answers 404 and is recorded |
fake-realtime.ts | The fake stream transport and its scripts: script(topic, onOpen) and publish(topic, event, data). Unscripted topics only get heartbeats and are recorded |
notices.ts | Dead-end notices raised by handlers |
frame.tsx | The sample-club banner (Start over, Exit demo) and the notice toasts |
handlers/roster.ts | The CSV roster upload, streamed row by row |
handlers/dead-ends.ts | Server exports, the migration wizard |
network-guard.ts | Installs the shared network guard (@enode/core/demo-bridge/network-guard) and records what it blocks |
tablet-bridge.ts | Answers the tracking app in the tablet frame from the same fake transports |
tablet-panel.tsx | The tablet panel and the banner's Mobile app button |
tablet-bridge.ts | Serves every same-origin frame (the tablet, the pages it frames) from this page's club; commands and status for the tablet |
framed.ts | Whether this page runs framed inside the demo (then it uses the top page's club and shows no banner) |
db.ts | In-memory tables. Empty until the seed exists |
clock.ts | "Now", frozen when the demo starts |
identity.ts | The demo Owner's id and its unsigned token |
inspector-log.ts, inspector.tsx | The demo inspector |
The static data snapshot
The backend's static data is served from JSON files in
apps/portal/src/demo/reference/, created by one command:
DEMO_SNAPSHOT_EMAIL=<snapshot account email> npm run demo:snapshot
The email is never committed. Ask the team for the snapshot account.
What the script does
scripts/demo/snapshot.ts:
- Signs in to backdev as the dedicated snapshot account, a Pro Owner with
an empty club. It requests a login code, then uses backdev's fixed dev code
(
FIXED_OTPintests/live/support/config.ts), so it runs unattended. The live suite's host allow-list refuses any other backend, production included. - Calls every route in
reference/entries.ts(SNAPSHOT_ENTRIES) through the real@enode/coreAPI client: the same paths and headers as the portal. - Fetches the server texts (
/text_contents) once per language the backend offers, astext-contents.<locale>.json. - Replaces the snapshot account's id, email and name with the demo Owner's
(
identity.ts) before anything is written. - Writes normalized JSON (keys sorted, records sorted by
id), so a refresh's diff shows only real changes, and prints what was added or removed per file. Removed ids are flagged, because the seed may use them. - Writes
manifest.json: backend host, date, languages, and the entry count and size of each file. No account data goes into it.
It only reads; it never writes to the backend.
The files
| Folder | Content | Served |
|---|---|---|
catalogues/ | Metrics, display bases, tracking sources, feedback modes, data package types, training goals, exercise bases, equipment, roles, media icons and animations, UI texts (every language in one file), server texts per language, app languages | As they are |
seed-input/ | The snapshot account's answers for per-user data: shared exercises, predefined test blocks (workout-item-templates), exercise variations, muscles, its own user and settings (already turned into the demo Owner) | As they are, until the seed builds the demo club from them (phase 3) |
About 8 MB in total, most of it the UI texts. Each file is its own chunk, loaded
the first time a request needs it (reference/load.ts). None of it is in the
pages' start-up scripts, and none of it is in the normal portal build.
Languages
The snapshot holds every language the backend offers (English, German, Japanese
and Chinese on 2026-11-10). The demo offers English only: /app_languages
answers with English alone, and the server texts are served in English whatever
the request asks for. To switch on more languages, add them to DEMO_LOCALES in
handlers/reference.ts.
When to refresh
Re-run the script when the backend's catalogue or translations change in a way
the demo should show, when a catalogue DTO changes, or when a new reference
store is added. Then run npm test: the snapshot checks below run there.
The snapshot checks
reference/snapshot.test.ts runs in npm test and never touches a backend:
- Coverage: every key in
REFERENCE_KEY(core/offline/reference-cache.ts) names where the demo gets its data. A new reference store fails the test until it is added. Every entry has its file. - Shape: each file is read through the real
@enode/coreAPI function, the fake transport and the demo handlers, and must come back non-empty. This catches a snapshot the current client no longer reads. - Owner: the demo user is the Owner, has privileges, and has settings.
- Privacy: no file contains the snapshot account's email.
- Age: a snapshot older than 120 days prints a warning, without failing.
The demo club (seed)
apps/portal/src/demo/seed/ generates the demo club and its whole history
from one moment, "now". It is pure: the same moment always gives the same
data. Phase 3 built the model and its tests. No handler serves it yet; that
starts in phase 4.
Who is in it
This section describes the default club. The other flavours are described in "Club flavours".
seed/cast.ts: one invented American school, Cedar Ridge Athletics, with a
Football, a Girls Basketball and a Baseball team (26 athletes), the
demo Owner (Director of Strength & Conditioning), an Athletic Director
(administrator), and one strength coach per team. Every athlete is tagged with
their team and position. All names are invented.
Four athletes carry the story, so each feature has an obvious athlete to look at:
| Role | Athlete | What the data shows |
|---|---|---|
| Improving | Tyler Brooks (Football, QB) | The same loads move faster week by week |
| Slowing | Noah Simmons (Football, DL) | Slower and uneven sets |
| Low wellness | Chloe Rivera (Girls Basketball) | Readiness dipping over the last 10 days |
| Absent | Carlos Mendez (Baseball) | Has missed every session for two weeks |
How the history reaches today
- Window: 12 weeks of history before the current week, and 3 weeks of planned training after it.
- Weekly slots: each team trains on fixed weekdays and times (football Mon, Wed and Fri at 06:30; basketball Tue and Thu at 15:30 and Sat at 10:00; baseball Mon and Thu at 16:00), built from local calendar fields, so daylight-saving days don't shift them.
- Today is split at the current time: a session that hasn't ended yet is planned, and one that has ended is completed or missed.
- Same story every day: every random value is keyed by what it is for and by its position relative to "now", never by the date. Visiting on another day gives the same club and story, shifted in time.
Sets and reps
seed/reps.ts generates a session's sets and reps the first time they are
needed (setsOf), and keeps them. Loads follow the programme: a share of the 1RM
the athlete was tested at when the history starts, in a 4-week wave (+0, +2.5,
+5, −10 %). Velocities follow each lift's load–velocity line (seed/lifts.ts) at
the athlete's current 1RM, with fatigue within the set, rep-to-rep noise, and the
day's readiness. Planned and missed sessions have no sets.
The lifts point at exercises in the snapshot (seed-input/exercises.json, the
barbell variants).
The seed checks
seed/seed.test.ts, in npm test:
- Invariants at awkward moments (Monday 00:01, during a session, Sunday 23:59, New Year's Eve, both US and EU daylight-saving days), in two time zones: no completed session ends after now, every team trained in the last 7 days and has training in the next 7, every athlete who still shows up trained in the last two weeks, and the absent athlete missed everything recently.
- Determinism, and "a later visit only moves the dates".
- Story: the improving athlete gets faster and the slowing one slower on the same loads, readiness dips for the low-wellness athlete, and velocities stay believable.
- Seed ids exist in the snapshot: every lift's exercise and every role. A snapshot refresh that removes one fails here.
- Speed: seeding takes well under 400 ms (about 1,100 session headers).
The invariants, the story and the cast checks run once per club flavour.
Club flavours
The demo club comes in four flavours, called presets (study tab 14). A visitor picks one; the club, its plan, charts and notifications follow it.
| Preset key | Program | School | Teams |
|---|---|---|---|
cedar-ridge (default) | Multi-sport department | Cedar Ridge Athletics | Football, Girls Basketball, Baseball (26 athletes, hand-written) |
football | Football program | Lakeview High Football | Varsity Football (14), JV Football (12) |
baseball-softball | Baseball & softball | Riverside Diamond Sports | Baseball (12), Softball (12) |
track | Track & field | Summit Track & Field | Boys Track & Field (12), Girls Track & Field (12) |
How a flavour is defined
- Sport catalogue (
seed/sports.ts): each sport once — weekly slots of prescribed lifts, test days, the story lift, the coach's title, a tag colour, and positions (event groups for track) with body ranges per gender. - Presets (
seed/presets.ts): a small recipe per flavour — school name, administrator, and teams (sport, name, gender, size, coach, optional slot label, time shift and colour). Only presets exist; there is no free mix. - Club builder (
seed/club.ts): turns a preset into teams, staff and athletes. The default keeps its hand-written cast (seed/cast.ts). The others get generated athletes: names from curated lists, bodies from the position's ranges, every value from a random stream named after the preset, so a preset shows the same people on every visit. - Story casting:
castStoryRolesgives the four roles by rule. Improving and slowing go to the first team, in two different positions; low wellness to the second team; absent to the third team, or else the last one. - Handlers read roles, not names:
storyAthlete(seed, role)andstoryTeam(seed)(seed/generate.ts). The story board and the notifications name whoever plays the role, with the story team's story lift (back squat for football, hex bar deadlift for baseball, power clean for track).
Track & field uses four lifts only it trains: Olympic Clean (shown as power clean), Hang Snatch, barbell Step Up and Squat Jump, all from the snapshot.
How a flavour is picked
club-choice.ts reads the preset once, before the seed is built
(installDemo):
?club=<preset key>in the URL, for example/dashboard/?club=track. This is the link to send a prospect.- Otherwise the tab's last choice, kept in sessionStorage, so Start over and in-app navigation keep the club.
- Otherwise the default. An unknown key falls back to the default and is not kept.
The first-run card
When a tab has no club yet (no valid ?club= and no earlier answer),
first-run-card.tsx opens over the page: "This is a sample club. Look around,
change anything, and nothing is saved", then "Which program do you run?" with
one card per preset. The default club is preselected.
- Start the demo with the club already shown keeps it and closes the card. With another club, the demo starts over with that one.
- Escape keeps the club shown.
- The answer is kept for the tab, so the card doesn't come back on reloads.
A sales link with
?club=never shows it. - If the browser blocks sessionStorage (some private windows), the card comes back after every reload.
The card and the banner switcher take their choices from club-options.ts,
so both use the same words.
The banner's club name opens the switcher (see "The demo frame"). Picking
another club loads the page with the new ?club=, which starts the demo over.
Units
Every preset starts metric, as the snapshot's settings do. The coach switches to imperial in Settings → "Metric System". The demo keeps that setting for the visit.
The flavour checks
seed/seed.test.tsruns the invariants, the story and the cast checks per preset. It also checks that the story roles land as described, that no two people share a name, that no two teams train at the same time, and that every test block exists in the snapshot.handlers/flavours.test.tsruns every preset through the real core clients: story charts with data, notifications naming the story athletes, the plan per team, exercise usage, and no unhandled route.club-choice.test.ts: URL, tab memory, unknown keys, switching.- The route sweep visits every page once per preset.
What the club serves
handlers/club.ts answers from the seed, and handlers/club-dto.ts turns the
seed into the backend's response shapes. The seed is built once, when the demo
starts (install.ts).
| Route | Answer |
|---|---|
GET /users/all_roles | The staff (without the Owner) and the 26 athletes, with roles and team and position tags |
GET /users/:id | One athlete, or a coach with the athletes they reach |
GET /users/plan_capacity | 50 places, nobody blocked |
POST /users/coaching_figures | Week, 8 weeks, training days, readiness (0–25) and session-RPE load, from the seed |
POST /users/training/read | Weekly target sets per muscle: what the team's programme prescribes |
GET /entity_tags, /entity_tags/with_relations | The team and position tags, with their athletes |
POST /workout_sessions/search, GET /workout_sessions/empty_search | Completed sessions, newest first, paged, filtered by athlete or exercise name |
GET /workout_sessions/:id | One session, with sets, reps and measurements |
GET /workout_sets/:id | One set with its reps. The session drawer reads every set this way before its other tabs can show |
GET /history/sessions/last/:user/exercise/:exercise | The five sessions before one, for the session summary's comparison |
POST /history/v2/week, POST /history/day, POST /history/session, GET /history/session/:id | Stats computed from the same reps (seed/stats.ts) |
GET /measurements/user/:id/metric/:metric | The daily wellness score; other metrics answer an empty list |
How a training becomes sessions
On the backend, a session is one exercise of one athlete. A demo training
with three exercises therefore becomes three sessions, 15 minutes apart. Each
holds its sets (load, rep count, RIR, tracked by the mounted Enode sensor: the Reps tab lists rep rows only for sensor-tracked sets), its reps (mean and peak velocity, jump
height for jumps) and an estimated 1RM. Measurements carry only their
metricID; the portal resolves the metric from the catalogue.
How the stats are computed
seed/stats.ts sums the same sets the session responses hold, so the cards and
History always agree (tested in handlers/club.test.ts):
- Tonnage: Σ load × reps of barbell sets.
- Muscles: each set counts toward the muscles its exercise engages, weighted
by the same mapping table the portal uses (
@enode/core/muscle-map/exercise-usage). - Zones: Power below 60 % of 1RM (and every jump), Hypertrophy below 82 %, Strength above.
- Targets: what the team's weekly programme prescribes per muscle, so an athlete who attends every session meets them.
Known simplifications
- No technique charts. The real backend stores each rep's raw sensor stream, and the technique tab draws from it. Demo reps have none, so that tab is empty.
- Shared exercise instances. On the backend every athlete has their own
exercise instances. The demo uses the snapshot account's instances for
everyone, and tells athletes apart by
session.user. - No session tags or videos. A tag, equipment, variation or video filter in History finds nothing.
- Training goals are not set, and target zones are an even split.
Plan, charts and the other pages
| File | Routes | Answer |
|---|---|---|
handlers/workouts.ts | GET /workouts/recurring, /workouts/schedules, /workouts/:id, /workout_definitions/templates, /workout_definitions/:id | One recurring workout per team slot, following the team tag. Three dated test days built from the snapshot's predefined test blocks (load–velocity profile for football, CMJ test for basketball). The team slots as templates |
handlers/charts.ts | GET /charts/:type/data, /charts/:type/data/:id, POST /charts/:type/preview, POST/PUT/DELETE /charts/:type… | All five Insights chart types, computed from the seed's sets and reps. A story board of five saved charts about the story roles (default club: Tyler vs Noah, Football 1RM ranking, load vs bar speed, rep distribution, Noah against the squad). Charts saved in the builder stay for the visit |
handlers/analysis.ts | GET /history/scope, /history/profile_scope, /analysis/relevant_*, /analysis/velocityprofile/data/…, /analysis/exertionprofile/data/…, POST /analysis/volume_over_time/data, /analysis/intensity_over_time/data | Performance: a real least-squares velocity profile per athlete and exercise (with R² and the 1RM at the lift's minimum velocity threshold), exertion, weekly volume and intensity |
handlers/exercises.ts | POST /exercises/usage, /exercises/usage/detail, GET /exercise_descriptions | Who trained each exercise, the best set, what is planned, which templates hold it. Descriptions: empty (the club shares nothing) |
handlers/notifications.ts | GET /events, /events/unread-count, POST /events/:id/read, /events/read-all, DELETE /events/:id | Six notifications pointing at the story, two unread. Read state stays for the visit |
handlers/shell.ts | GET /user_device_sessions, /entity_tags/colors | Three weight-room stations and the coach's phone, the tag colour palette |
handlers/plan.ts | (used by the Owner, plan usage and plan capacity) | One demo plan everywhere: 5 stations and 50 people. The snapshot's license is the empty backdev account's (2 and 2) and is overridden, so Devices, the sidebar and Plan agree ("4 of 5 stations") |
Times in the plan are "universal", as the Planner saves them: the UTC part of a
workout's date is its wall-clock time.
Not covered yet: the per-rep "inspect and clean" drawer behind a velocity
profile (/analysis/velocityprofile/sets/…, …/at_date), Live Hub, and every
save except saved charts, settings and notification read state (phase 7).
Changes during a visit
Everything a coach can change lives in apps/portal/src/demo/state.ts, built
from the seed when the demo starts and kept in memory. A reload starts over.
Every handler reads people and tags from it, so a change shows on the next read
everywhere: rename an athlete, and History shows the new name.
| Area | File | Writes |
|---|---|---|
| People | handlers/people.ts | Add (straight into the roster with an open invitation, no email), batch add, edit, archive, unarchive, delete, assign and unassign managers, training goal, per-muscle targets |
| Tags | handlers/tags.ts | Create, rename, delete, assign and unassign (users, exercises, workouts, sessions…), archive, unarchive, merge (moves everything, archives the source) |
| Sessions | handlers/club.ts | Session note, tags and exercise; set and rep batch edits (warm-up, side, note, load, validity, phase, tags) and deletes; delete a session |
| Plan | handlers/workouts.ts | Create, update and delete schedules and recurring workouts; templates (create, update, copy, delete) |
| Exercises | handlers/exercises.ts | Create a custom exercise (copying the snapshot exercise with the same base and equipment), rename, delete |
| Insights | handlers/charts.ts | Saved charts (since phase 5) |
A person's tags are the tags whose members include them, one source, so the roster and the tag pages always agree. Plan-by-tag workouts read their participants live from the followed tags.
The shared-definition conflict (313)
As on the backend, a schedule save that changes a workout definition other
workouts also use answers 313 on the first attempt, and the Planner asks.
The re-sent request either edits the shared definition for everyone
(…/schedule_and_definition, …_with_definition_update) or forks a private copy
for this workout (…_with_definition_copy). A template update with
checkRelatedWorkouts answers 313 the same way when a scheduled workout uses it.
Known simplifications
- Stats (dashboard cards, Insights, Performance) are computed from the seeded reps. They leave out deleted sessions, but not set or rep edits: marking a rep invalid doesn't change a chart. The real backend recalculates in a queued job.
- New people have no training history.
- Inviting and resending an invitation send no email; the demo shows a notice instead (see "Dead ends"). Profile pictures are not stored.
Live streams
The portal follows one realtime topic, the Owner's pro:user:<id>. The demo
scripts it in handlers/notifications.ts:
- On every connect, the stream sends
notification.snapshot, as the real server does. - Two scripted arrivals (
scheduleStoryArrivals) come asnotification.created, 45 seconds and 2½ minutes after the demo opens: Chloe Rivera's dropping readiness, and the latest session finished today (only when one has finished). The bell rings and the arrival peek shows, as for a real notification. - A CSV roster upload (
handlers/roster.ts) answers at once, then streamsroster.started, oneroster.progressper row (every 350 ms, while each person joins the roster),roster.completed, and the completion notification whosereferenceIDis the csvID, which replaces the live progress card.
Live Hub's session topics stay unscripted (out of scope, study 10.Q10). The club has no live session; Live Hub shows its intro, and its Watch the demo plays the built-in sample session (see "Dead ends").
Dead ends
Some features do their real work outside the browser. Their routes answer like
the real backend, so the screen behaves as for a customer, and raise a notice
(notices.ts). The demo frame shows each notice as an info toast. A burst of
the same notice (a bulk action sends one request per person) shows once.
| Feature | Routes | Notice |
|---|---|---|
| Server exports, emailed | POST /file_export, POST /ms/questionnaire/export | No email is sent |
| Inviting a person | POST /users/:creatorId with an email, POST /users/:id/invitation/resend, POST /users/batch with an email | No invitation email is sent |
| Moving data from another account | GET /users/requestMigration/otp, GET /users/migrate/otp | No code is sent; any code is accepted |
| Starting that import | POST /migrations/enode_pro | Nothing is moved |
| Live Hub | GET /workout_live_sessions (no sessions), POST /workout_live_sessions (refused, 404) | Once per visit on opening: the club has no live session, Watch the demo plays one. On starting a session: devices would join it from the tracking app |
The migration wizard reads a small sample account (sampleMigrationContent:
five people in one track team). Its exercise step answers no mappings, like the
real backend today. In-page exports (CSV, images, PDF) are built in the browser
and work in full.
The demo frame
frame.tsx puts the demo controls, a card that says plainly it is a demo, in
a corner of the screen (bottom right by default). From left to right:
- a drag handle and an orange Demo badge;
- Sample club with the school's name and a ▾: the club switcher, one option per preset (see "Club flavours"); "Changes aren't saved" below it on wide screens;
- Mobile app (builds with the tracking app, 1000 px and wider): the primary action, with a small pulsing dot until it is opened once in the tab;
- Start over (reloads the page, which builds the club again; nothing is
kept between visits) and, when
NEXT_PUBLIC_DEMO_EXIT_URLis set, Exit demo; - a minimize button that folds the card down to its badge, kept for the tab.
The card can be dragged to any corner and snaps to the nearest one on
release, so it never has to cover a page's own buttons. The corner is
remembered in the browser, and a short press still clicks a button
(banner-corner.ts). Its copy is user-facing, so it goes through t(),
unlike the inspector.
The route sweep
npm run test:demo builds the whole static demo (npm run build demo: the
portal with the tracking app inside), serves it on port 3013, and visits every
covered page in a headless Chromium of its own (Playwright, tests/demo/). A
page fails when it sends a request out of the browser (YouTube and Vimeo
embeds excepted), or when the demo inspector lists an unhandled route, a
failed handler, an error report or a blocked request. Every page is visited
once per club flavour (?club=<preset key>). Run it after changing the demo,
a page it covers, or the tracking app.
tests/demo/tablet.spec.ts opens the tablet panel and requires the tablet to
reach its start screen with the same checks for both apps (the inspector lists
the tablet's requests as tracking · …), no "Simulate a set" without a
training, and no tablet button below 1000 px. Starting a workout and
simulating sets are not automated: the tracking screens have no stable test
ids for that yet, so they are in the manual protocol below.
The first run downloads Chromium once: npx playwright install chromium.
Unhandled routes
A request without a handler is answered with HTTP 404 and the body
{ "reason": "Not available in the demo: GET /path" }. The error engine
classifies a 404 as graceful (errors/status-table.ts), so the page shows its
normal error or empty state. Nothing is passed on to the network.
The 404 has no userMessage, so the presenter shows its generic text. An
unhandled route is a gap in the demo backend, not a feature the demo leaves
out: features that can't work in a browser are scripted as dead ends instead
(see "Dead ends").
The network guard
The guard lives in @enode/core/demo-bridge/network-guard.ts, shared with the
tracking demo; the portal's network-guard.ts installs it and records what it
blocks. It catches requests that bypass the fake transports, such as
the Live Hub dashboard bridge's raw fetch and native EventSource:
- same-origin app files (pages, scripts, fonts,
data:andblob:URLs) pass; - the dev server's backend proxy (
/api,/api-<name>) is always blocked; - every other origin is blocked.
A blocked fetch rejects with a TypeError. A blocked EventSource reports
itself closed. Both are recorded in the inspector.
Not covered: <img>, <video> and <iframe> sources, which the browser loads
without JavaScript. Demo data must point those at bundled files.
Tracking app in the demo
Status: phases T1–T5 of the tracking plan (study tab 16), 2026-11-12: the tracking app runs inside the portal demo on the portal's demo backend, records with a virtual sensor ("Simulate a set"), and a finished training appears in the portal. A visitor opens it from the banner's Mobile app button. Checks and docs (T6) and the deployment (T7) follow.
How the two apps share one backend
The tracking app is built in demo mode (NEXT_PUBLIC_DEMO=1, target
tracking-demo) with the base path /tracking and served next to the portal
demo, on the same origin. It runs in a frame inside the portal demo. Its
ApiConfigInit calls installTrackingDemo (apps/tracking/src/demo/install.ts)
instead of configuring the real API:
- Every
apiRequestand realtime stream crosses the demo bridge (packages/core/src/demo-bridge/) to the portal tab overpostMessage. The portal answers it from the same fake transports as its own requests (tablet-bridge.ts), so both apps show one club. - Only messages from the tablet frame, on the demo's own origin, are answered.
- Requests from the tablet are marked with the
x-demo-client: trackingheader; the inspector lists them astracking · GET /…. - The tablet's network guard reports what it blocks to the portal's inspector.
- The app uses its own offline database,
enode-offline-demo(switchToSeparateOfflineDatabaseincore/offline/stores.ts). It is emptied when a demo visit starts (each load of the portal demo: Start over, a club switch, a reload) and kept when only the tablet reloads, so a workout in progress comes back (core/demo-bridge/visit.ts). The device's realenode-offlineis never opened. - It reports itself as a tablet. Signing in needs nothing: the demo Owner's token, stored by the portal demo, is in the shared origin's localStorage.
- Its back-button guards (sheets, the training exit guard) stay out of the
browser history (
keepBackGuardsOutOfHistoryincore/back-button-guard.ts). A frame shares one history with the page around it, so closing a sheet withhistory.back()would switch the portal's page or navigate the frame away. The browser's Back button belongs to the portal; the edge swipe closes the tablet's top sheet directly (swipeBack).
Opened on its own, outside the portal demo, every request answers that the tracking demo runs inside the portal demo.
Pages the tablet frames
The tracking app frames two portal pages: the wellness check-in and session
RPE (/questionnaire/) and the exercise video player (/video/). In the store
apps they come from the real portal. In the demo they come from the demo's own
origin: the tablet demo sets __ENODE_QUESTIONNAIRE_URL__, the same runtime
hook a native shell uses, to its own origin.
A portal page that finds itself in a frame of the demo (framed.ts) builds no
club of its own. It answers through the top page's club over the bridge, like
the tablet. It starts no new visit and shows no banner or inspector. The top
page serves every same-origin frame that talks to it
(core/demo-bridge/frames.ts) and labels each one's requests by its path in
the inspector (tracking · …, frame questionnaire · …). A check-in answered
on the tablet is stored for the visit (/ms/questionnaire/wellness) and shows
with the athlete's wellness; a session RPE is accepted, linked to no workout.
The tablet bundle still contains the real portal's address as the app's
default. These are addresses, not credentials, and the demo never uses them.
How the store apps stay free of demo code
The same switch as the portal: the module name @tracking-demo/entry resolves
to src/demo/entry.ts in the demo build and to the empty entry-off.ts in
every other build. The demo build writes to .next-demo/ and out-demo/;
Capacitor packs out/, so a demo build can't reach a native app. Checked by
searching a normal npm run build tracking output for demo markers.
Running it
npm run dev demo starts both dev servers (tracking on :3004); open
http://localhost:3003. The portal demo's dev server forwards /tracking/* to
:3004.
The tablet panel
The banner's Mobile app button (tablet-panel.tsx) shows the app as an
iPad in landscape (1180×820), scaled to fit, with its controls underneath:
Simulate a set (only during a training, see below) and Hide mobile app.
- Hiding keeps it running: "Hide mobile app", a click on the backdrop, Escape, or the banner button. Focus returns to the banner button.
- Showing it again reloads the tablet, so it reads the club as it is now, for example a workout moved in the Planner meanwhile. The tracking app has no live update for plan changes, and on its own only re-reads when it returns to the foreground, which hiding a frame never is. The reload keeps the tablet's offline data, so a workout in progress comes back.
- Where it shows: only in builds made with the
demotarget (NEXT_PUBLIC_DEMO_TABLET=1), and only on screens at least 1000 px wide; on narrower ones the tablet would be too small to use, so the demo is portal-only there. The first-run card points to it in one line. - Not built: opening the tablet in its own window (study 15.Q2: later, if presenters ask).
The virtual sensor and "Simulate a set"
The tablet's Bluetooth is one virtual Enode sensor ("VMP_DEMO") behind the
simulated native plugin from the tests (core/ble/testing/fake-enode-ble.ts),
installed by apps/tracking/src/demo/virtual-sensor.ts. The app's real sensor
stack runs on it unchanged, and Connect finds it without a Bluetooth
prompt. Like a real sensor it streams its motion: "lying still", ten times a
second (restSample), so the app counts it as ready (steady) instead of
showing "Wait after impact". The stream pauses while a set plays, so the
reps carry no flat motion data.
Simulate a set, under the tablet, shows only while a training runs on the
tablet. The tablet reports that over the bridge (training-status.ts, which
checks once a second whether a running training is saved for recovery). A
feedback-only training is never saved, so the button doesn't show for it.
It sends the tablet a simulate-set
command over the bridge (core/demo-bridge/commands.ts), which plays a set on
the sensor, one rep every 1.6 s:
- Speeds: the athlete's load–velocity profile (from their exercise instance)
at the set's load, never below their speed at their 1RM; each rep a little
slower than the one before, with a little variation. Without a profile, a
typical bar speed (
simulated-set.ts). - Rep count: the set's prescribed reps, else five.
- Which athlete: the open set changed most recently. Which athlete the sensor's reps go to is the page's own state, which the demo can't read, so that is the closest guess: normally the athlete the coach just prepared.
- The control says when there is nothing to play: no sensor connected, or no set open (the sensor isn't in a recording mode yet).
Motion traces and the technique tab
The technique charts draw each rep's motion trace, which the backend keeps as one data package per rep (the rep-data blob, gzipped, base64). In the demo:
- Recorded on the tablet: while "Simulate a set" plays a rep, the virtual
sensor streams a simulated trace in the sensor's own packet layout
(
liftWithTrace), so the tracking app records a real trajectory, shows it in its own technique tab and uploads it. The upload handler keeps the packages as they came. - Generated history: each rep gets a simulated trace built from its own
mean and peak speed and the lift's typical range of motion
(
seed/traces.ts), seeded by the rep's id so it reads the same every time, and encoded with the upload mapper's own encoder. - Where: only
GET /workout_sets/:idcarries traces (the session drawer reads every set this way; so does the Performance raw view). Lists don't, so History stays fast.
The trace itself (core/ble/testing/rep-trajectory.ts) is a plausible curve,
not a measured one. Strength reps get a bar speed that leaves rest and comes
back to it with zero acceleration, with the rep's mean speed and peak. So force
builds from body weight to its peak within about a tenth of a second, as in a
real lift, rather than jumping there in the first sample. They also get the
vertical distance those speeds cover, a few centimetres of fore-aft bar path, a
slight tilt and a little sensor noise. Jumps get a smooth push-off to take-off
at the peak speed.
Force, power and rate of force development are per kg and multiplied by the
load, so the figures in the virtual sensor's rep event (peak power, peak RFD,
propulsive mean velocity) are computed from the same trace
(simulatedRepFigures; peak power with the app's own calculation). At 0.8 m/s
and 100 kg that is about 1,800 N peak force, 1,350 W peak power and
8,000 N/s peak RFD. Earlier the event carried fixed values, which, multiplied
by the load, gave absurd power and RFD; the test fake now defaults them to 0,
"not measured".
What only the tablet asks for
The tablet reads the same club as the portal, through the same handlers. Five routes exist only for it (phase T2):
| Route | Handler | What it answers |
|---|---|---|
GET /exercise_bases/:id | handlers/reference.ts | One base from the exercise-bases snapshot |
GET /measurements/user/:userId | handlers/club.ts | The athlete's morning check-ins in the window: the five measures and their score, daily at 07:00 (today's once 07:00 has passed). Without from and to, a 400, like the backend |
POST /exercises/exercise_for_user/workout | handlers/exercises.ts | One instance per (definition × athlete) for every definition the coach owns: the athlete's 1RM today and the load–velocity profile their history was generated from (velocityProfileOf in seed/lifts.ts). Jumps and lifts the athlete doesn't train have neither |
GET /user_licenses/usage | handlers/club.ts | Five stations, held by the three weight-room tablets; the club's people inside the plan |
GET /workout_sessions/exercise/:id | handlers/exercises.ts | The athlete's last completed sessions of one exercise, newest first, found by the instance id above. Sets carry their measurements but no reps, like the backend |
Trainings recorded on the tablet
handlers/uploads.ts answers POST /workout_sessions, the tablet's upload
queue. As on the backend, each session is one exercise of one athlete, found
through its exercise instance, and the answer lists one outcome per session:
created, alreadyPresent for an id already stored (the queue retries), or
rejected.
- Where it goes: the recorded exercise completes the athlete's training of today that holds it and isn't done yet. The training then counts as done from the upload's time, with only the exercises the tablet sent. Without such a training, the recording becomes a training of its own.
- What is kept: the tablet's session, set and rep ids, the loads, and each
rep's recorded speeds (
recordSetsinseed/reps.ts). A set typed in by hand has a rep count but no speeds; its reps get the speeds the athlete's load–velocity line predicts, so charts treat it like any other set. - What follows: handlers that index the club's sessions rebuild their
index (
state.sessionsVersion), and the bell rings once per athlete ("… finished a workout"). - An exercise outside the club's programme is accepted, so the tablet doesn't retry it forever, but not shown; the inspector lists it as failed.
- Pages that cache: Insights reuses a chart list read in the last five
minutes. After a recording,
markChartsStale()(core/charts/store.ts) makes the next open read every list again. History and the dashboard read fresh on every open; only the bell updates while a page stays open.
Reloading loses the visit
Everything lives in the page, so a reload builds a new club and a recording
is gone with the old one. In the real portal a reload is the normal way to
refresh; in the demo it is a trap. Once the tablet has recorded something, a
reload or closing the tab asks first, with the browser's own "Leave site?"
prompt (leave-guard.ts). The demo's own ways out (Start over, the club
switch, Exit demo) don't ask. To see a recording, open the page again from the
sidebar instead of reloading.
Files from public/ under the base path
Next adds /tracking to its own links and assets, not to a URL written in
code: an <img src>, a CSS url(), or a 3D model a loader fetches. Such code
uses publicAsset(path) (packages/ui/src/public-asset.ts), which puts
NEXT_PUBLIC_BASE_PATH in front. Only the tracking demo build sets it, so every
other build gets the path unchanged. It covers the sensor icons, the 3D sensor
models of the connect sheet (@enode/ui/sensor-3d) and the sensor-placement
images. The fonts load from /fonts/… in shared CSS and resolve to the portal
demo's copies, which are the same files.
The demo inspector
It is developer tooling, so visitors of a deployed demo don't see it. It shows
under npm run dev …, and in a built demo only after adding ?inspector=1 to
the address (kept for the tab; ?inspector=0 hides it again). The route sweep
reads its lists directly and doesn't need the panel.
A button in the bottom-left corner (Demo · <n>) opens a panel with five
lists, each counted per entry:
- Unhandled API routes, with ids collapsed (
GET /users/:id). This is the list of endpoints the demo backend still needs. - Demo handlers that failed: a handler threw. That is a demo bug. The request is answered 404, so the failure stays on its page instead of looking like an outage.
- Error reports (kept, not sent): the support reports the app tried to send, for example after an uncaught error, with the error message, where it was thrown, and the last HTTP request. The demo never sends them.
- Blocked network requests.
- Unscripted live topics.
Copy list copies all five as Markdown. Clear empties them. The panel is developer tooling like the debug pages, so its copy is not translated.
The inspector's first line says when this page built its demo club ("Club built at …"). Every page load builds a new club, so a later time than expected means the page reloaded, and the visit's changes (a training recorded on the tablet, edits) went with the old club.
Checking club flavours
npm run dev portal-demoand openhttp://localhost:3003.- First run: the welcome card asks which program you run. Pick Football program and press Start the demo: the demo starts over as Lakeview High Football, and the card doesn't come back on reload. In another new tab, press Escape: the card closes on Cedar Ridge Athletics.
- Switcher: press "Sample club: …" in the banner and pick Track & field. The demo starts over as Summit Track & Field: two teams on the Users and Tags pages, track slots in the Planner.
- Story: Insights opens on a power clean trend of two track athletes moving in opposite directions. The notifications name the same athletes.
- Memory: press Start over and navigate between pages: the club
stays. Open
http://localhost:3003/dashboard/?club=footballin a new tab: that tab shows Lakeview High Football without the welcome card, and the first tab is unchanged. - Units: switch "Metric System" off in Settings. Loads show in pounds.
Checking the tablet app
The full circle, on the static build or npm run dev demo:
npm run build demo, thennpm run run demo, and openhttp://localhost:3003/dashboard/?club=cedar-ridge&inspector=1(the inspector shows only on request in a built demo).- Open: press Mobile app in the banner. The tablet shows today's workouts of the same club as the Planner.
- Record: start today's workout, press Connect (the virtual sensor connects without a prompt, and the red "Wait after impact" tint clears within a second), set a load and press Simulate a set: reps arrive one by one with bar speeds; the line under the tablet says how many, at which load. Open the set's technique tab on the tablet: curves show.
- Finish: finish the set and the workout. The portal's bell rings ("… finished a workout").
- See it in the portal: press Hide mobile app and open History from the sidebar (not a reload): the session is first, and its technique tab shows the recorded curves. Insights and the athlete's charts include it on their next open.
- Keep and reset: start another workout, hide the tablet, move today's workout in the Planner, show the tablet again: it reloads, shows the new time, and the workout in progress is still there. A page reload asks first; Start over resets both apps.
- Narrow: below 1000 px of width, the Mobile app button is gone.
- Store builds:
npm run build trackingand searchapps/tracking/outforenode-demo-bridgeandVMP_DEMO: no hits. (Back upout/first if it holds a native build.)
Checking phase 8
npm run dev portal-demoand openhttp://localhost:3003.- Banner: "Sample club: Cedar Ridge Athletics" is visible. Make a change, press Start over: the change is gone.
- Notifications: stay on any page for about a minute. The bell rings for Chloe Rivera; a second arrival follows later if a session has finished today.
- Roster upload (Users → upload CSV): the progress card fills row by row, then turns into a "Roster upload finished" notification. The new people are in the roster.
- Dead ends: each shows its notice and never an error toast — a server export (Data → Export), adding a person with an email, resending an invitation, and the migration wizard all the way to the start.
Checking phase 4
npm run dev portal-demoand openhttp://localhost:3003.- Dashboard: this week's sessions, volume, muscle map and muscle qualities.
- Users: 29 people, with team and position tags and coaching columns. Open Tyler Brooks (improving), Noah Simmons (slowing), Chloe Rivera (low wellness) and Carlos Mendez (absent).
- History and the session drawer: sessions with sets and reps. The summary compares with earlier sessions. The technique tab stays empty (see above).
- The inspector should list no route for these pages. Routes from other pages (Planner, Workouts, Insights…) are expected until phase 5.
Checking phase 2
npm run dev portal-demoand openhttp://localhost:3003.- The sidebar, page titles and settings show translated texts. The settings drawer shows metrics and display bases. The language picker offers English only.
- The Network tab shows
/_nextchunks (snapshot files included) and fonts, and nothing from a backend. - Pages that only need start-up data no longer show "We can't reach enode". Pages that need demo club data still do, until phase 4. The inspector lists their routes.
Checking phase 1
npm run dev portal-demoand openhttp://localhost:3003. The page forwards to the dashboard.- Open every sidebar entry. In the browser's Network tab, only
/_next, font and page requests appear. No/apirequest and no other host. - In the browser's Application → IndexedDB panel, no
enode-offlinedatabase is created or changed. - The inspector lists the unhandled routes. That list is the endpoint inventory for the next phases.