Skip to main content

0016 — The tracking app inside the portal demo, on one demo backend

Status: Accepted · Date: 2026-11-12

Context​

The portal demo (ADR 0015) shows the portal on a fake in-browser backend. The product is two apps: a coach records a training on the tracking app's tablet, and the portal shows it. A demo of the whole system has to let a visitor do that circle, still without any backend.

The tracking app reaches the backend through the same @enode/core transport seams as the portal, and core already has a simulated Enode sensor for its tests (ble/testing/fake-enode-ble.ts). The alternatives were a drawn, scripted tablet (not the product, and it drifts from it), tracking screens rendered inside the portal (would need the tracking UI moved into @enode/ui first), and a second copy of the demo backend in the tracking app (the two apps would never see each other's changes).

Decision​

  1. The real tracking app, built in demo mode, in a frame inside the portal demo. A tracking-demo build (NEXT_PUBLIC_DEMO=1, base path /tracking) is served next to the portal demo on the same origin; the combined demo target builds both and copies tracking into the portal demo's output. It is wired in through one module name, @tracking-demo/entry, so the store builds and the native apps bundle no demo code.
  2. One backend for both apps: a bridge in @enode/core. @enode/core/demo-bridge carries what the transport seams carry (HTTP requests, realtime streams) from the frame to the portal tab over postMessage, which answers from its own fake transports. It answers only frames on its own origin. It also carries commands from the portal to the tablet ("Simulate a set") and the tablet's status (whether a training runs). The top page serves every same-origin frame, so the portal pages the tablet frames (wellness check-in, video player) come from the demo's own origin and use the same club instead of the real portal. Only the two demo entries import it.
  3. The tablet's offline data in its own database, kept per visit. Tracking needs its offline database (upload queue, sessions in progress), so it can't be switched off as in the portal demo. switchToSeparateOfflineDatabase (@enode/core/offline/stores) moves it to enode-offline-demo, emptied when a demo visit starts and kept when only the tablet reloads; the real enode-offline is never opened.
  4. Small session switches in shared code, off unless the demo calls them. Back-button guards stay out of the browser history in the frame (keepBackGuardsOutOfHistory; a frame shares the outer page's history), chart lists can be marked stale after a recording (markChartsStale), and URLs written in code get the base path (@enode/ui/public-asset).
  5. A virtual sensor and simulated motion traces. The test fake becomes the tablet's Bluetooth; "Simulate a set" plays the set in progress at the athlete's speeds, streaming a simulated motion trace (ble/testing/rep-trajectory.ts) that the portal demo also uses for its generated history.

Consequences​

  • The demo shows the real tracking app and never drifts from it; a new tracking endpoint needs a demo handler, or the inspector and the route sweep (npm run test:demo) report it.
  • Shared code gained demo-only seams (points 2–4). Each is inert unless a demo entry calls it, and each is documented where it lives.
  • Simulated values stay simulated: motion traces are plausible curves, not measurements; "Simulate a set" picks the athlete whose open set changed last, because the station's selected athlete lives in page state.
  • Not built: opening the tablet in its own window (later, if presenters ask).

See docs/demo.md ("Tracking app in the demo") for how it works in detail.