Skip to content

ADR-0010: Public demo deployment

  • Status: Accepted
  • Date: 2026-07-28
  • Supersedes: None
  • Superseded by: None

Context

The application cannot be shown without being run, and running it means a server, a database and a file store. ADR-0001 makes local-first storage the point of the product, so any hosted instance is a deliberate exception that has to be bounded rather than a change of direction.

Three properties are in tension. A demo must hold data, or there is nothing to look at. It must not hold anyone's real data, including data a visitor types into it believing it is private. And it must not become a second, drifting deployment target that the local-first path has to stay compatible with.

The imaging samples in samples/imaging/ are third-party research data, and publishing a container image containing them is redistribution. All three sources permit it: TCIA COVID-19-AR under CC BY 4.0, OpenNeuro ds003826 under CC0, PTB-XL 1.0.3 under CC BY 4.0. The two CC BY sources require attribution wherever the demo is published.

Decision

Publish the demo as a container whose dataset is baked in at build time and restored from a read-only copy on every boot, deployed to Cloud Run with --max-instances 1 and scale-to-zero.

No record in the demo belongs to anybody. Patient records come from the existing seed-demo.mjs and seed-genetics.mjs scripts and are invented. Imaging is the de-identified research samples in samples/imaging/, and only those: the synthetic smoke fixtures prove the pipeline accepts each format but are deliberately featureless, so seeding them would put four rows of noise in front of the studies worth opening. They stay in scripts/ui-smoke.mjs, which is what they are for. The CC BY attribution travels with the image in docs/operations/demo.md, served at /docs/.

Studies are retitled after import, keyed on Study Instance UID. A demo is read before it is used, and "XR CHEST AP ONLY" is what an institution typed, not what the record is called.

Imaging is seeded through the application's own /imaging/import endpoint rather than by inserting rows. DEMO_MODE=1 renders a banner on every page stating that the instance is public, synthetic, and discarded on restart.

Alternatives considered

  • A persistent hosted instance with a durable disk. Turns the demo into a real deployment holding real data typed by real visitors, which is the outcome ADR-0001 exists to avoid.
  • One container per visitor (Cloudflare Containers with a Durable Object per session). Gives genuine isolation, but bills memory for wall-clock time, requires a paid plan before the first visitor, and answers a scaling problem the demo does not have.
  • A static screenshot tour. Cheapest and leaks nothing, but cannot show the imaging viewer, which is a large part of what there is to show.
  • Seeding at container start. Moves migration and DICOM import into the request that triggers the cold start, which the visitor waits through.

Consequences

A restart is a reset, and no state survives it — which is the safety property, not a limitation to be fixed later. All visitors share one instance and therefore see each other's edits until the next cold start; the banner is what makes that honest.

Because the seed is baked, changing demo data requires a rebuild. The single instance caps both cost and blast radius; it also means the demo cannot be used to observe behaviour under real concurrency.

The demo runs the same server.mjs entry point, migrations and build as a local install, so it exercises the supported path rather than a parallel one. Cloud Run's request-based billing keeps an unvisited demo at effectively zero cost; switching it to always-allocated CPU would silently remove that and is called out in the deploy script.

Verification

npm run seed:demo produces a complete dataset locally against a built app, and fails loudly if build/handler.js is absent or if an imaging upload returns anything other than imported or duplicate. The deploy script reads the minted service URL back into ORIGIN; without it every form action answers 403.

Reusable lesson

This decision is project-specific and does not currently propose a global lesson. The licence check it required — read the terms of every sample before a build context becomes a published artefact, and carry any attribution into something the artefact itself serves — is general, but it is a habit rather than a rule worth writing down.