Skip to main content

0015 — A portal demo build on a fake in-browser backend

Status: Accepted · Date: 2026-11-10

Context​

Sales demos and self-serve visitors need a portal account that shows every feature with believable data. A real account on the backend can't be reset between prospects, depends on backend availability, and holds real data. The idea of overriding the stores with mock data was considered and rejected: many views read the API directly, every write calls the API, and charts and statistics are computed by the backend.

The portal already sends every request through replaceable transports: setHttpTransport (@enode/core/api/transport) and setRealtimeTransport (@enode/core/realtime/client).

Decision​

  1. A fake backend behind the transport seams. In the demo, both transports are replaced by fakes that answer from an in-browser router and an in-memory database. An unknown route answers 404 and is never passed on. Everything above the transports runs unchanged.
  2. A build parameter. The demo is the portal built with NEXT_PUBLIC_DEMO=1 (npm run <dev|build|run> portal-demo). It is wired in through one module name, @portal-demo/entry, which next.config.ts resolves to the demo or to an empty stub. A normal build bundles no demo code. How the demo is deployed, on its own origin or inside the normal portal, is decided later.
  3. The offline database is off in the demo. disableOfflineDatabase() in @enode/core/offline/stores keeps the demo from writing snapshots next to (or wiping) a real account's offline data.
  4. Static data comes from committed snapshots, translations included. Most static catalogues need a signed-in user on the backend, and the demo has none. npm run demo:snapshot signs in to backdev as a dedicated snapshot account and writes every catalogue and both translation catalogues to apps/portal/src/demo/reference/. The demo never calls a backend. Every language is snapshotted, but the demo offers English only for now.
  5. No persistence. The demo's data lives in memory. A reload starts from a fresh seed.

Consequences​

  • The demo is the real portal, so it stays current without a second copy of the UI.
  • Every new endpoint needs a demo handler, or the demo shows that part as "not available". The demo inspector lists those routes.
  • Business rules copied into demo handlers can drift from the backend. They are kept to what a demo path needs.
  • A feature that works in the demo proves nothing about the real backend. The demo does not replace testing against backdev.

See Portal demo build for how it works and how to run it.