Skip to content

Public demo

A published demo of the application, running the same server and migrations as a local install, with a synthetic dataset baked into the image. See ADR-0010 for why it is built this way and what it deliberately does not do.

Seed the dataset locally

npm ci
npm run build          # demo-seed drives the built server, so this comes first
npm run seed:demo      # writes data/health.db and data/files

The command initializes the schema, runs seed-demo.mjs and seed-genetics.mjs, then starts the built server on an ephemeral port and pushes imaging through /imaging/import — the real pipeline, so studies, series and viewability come out the way the application decides them rather than the way a fixture guessed.

--out demo-data writes somewhere other than data/, and --fresh starts from an empty directory. --fresh refuses to run against the default data/ without --force, because there it would delete a real local record store.

Imaging comes from samples/imaging/ and nothing else. The synthetic smoke fixtures are not seeded: they exist to prove the pipeline accepts each format and are deliberately featureless, so as demo records they only stand between a visitor and the studies worth opening. scripts/ui-smoke.mjs still builds them, which is where they belong.

The seed produces four studies — Chest X-Ray, Chest CT — Lung Nodules, MRI Brain and ECG Report — plus the two PDFs as documents. Studies are retitled after import, keyed on Study Instance UID, because the description a source institution typed ("XR CHEST AP ONLY") is not what a person calls the record.

A WFDB .hea/.dat pair used to be seeded alongside them, to show that the pipeline preserves a format no viewer can render rather than rejecting it. It was dropped: the two files list as separate untitled rows that open into nothing. That is the correct behaviour and a poor demo record, and isInstanceViewable covers the rule in unit tests instead.

The seed also rewrites source patient identity on the imported studies to match the profile. The samples keep the pseudonyms their sources de-identified them to — the chest X-ray is COVID-19-AR-16406488, the ECG is Anonymized, both sex M — so against a profile reading Sarah Johnson the app correctly warned "Source patient identity differs from your profile" on two of four studies. That is the honest consequence of building one person's record out of several donors' files, and it reads to a visitor as a broken app. Only the demo seed does this; nothing in the app writes source identity, which is kept verbatim so that a real mismatch survives.

Attribution

The demo redistributes third-party research data. Three of the four sources are CC BY and require credit wherever the demo is published; this page ships inside the image and is served at /docs/, which is where that credit lives. Full citations are in samples/imaging/README.md.

Sample Source Licence
Chest X-ray TCIA COVID-19-AR — Desai, S. et al., Chest imaging with clinical and genomic correlates representing a rural COVID-19 positive population (The Cancer Imaging Archive, 2020) CC BY 4.0
Chest CT TCIA LIDC-IDRI — Armato III, S. G. et al., Data From LIDC-IDRI (The Cancer Imaging Archive, 2015) CC BY 3.0
Brain MRI OpenNeuro ds003826 (sub-02_T1w) CC0
ECG PhysioNet PTB-XL 1.0.3, converted from SCP-ECG to DICOM waveform CC BY 4.0

LIDC-IDRI additionally asks that users state: "The authors acknowledge the National Cancer Institute and the Foundation for the National Institutes of Health, and their critical role in the creation of the free publicly available LIDC/IDRI Database used in this study."

The structured reports are synthetic. The one over the CT ships as a file because its identifiers match the slices beside it; the chest X-ray's is generated during seeding, since an SR has to name the exact images imported.

Both imaging collections are de-identified and carry pseudonymous patient ids, as released. Nothing here is anyone's actual record.

Build the image

npm run demo:image
docker run --rm -p 8080:8080 -e ORIGIN=http://localhost:8080 personal-health-demo

Seeding happens at build time. The entrypoint copies /app/seed to /app/data on every boot, so a restart discards whatever visitors did. Set DEMO_RESET_ON_BOOT=0 to keep state across restarts of the same container.

Deploy to Cloud Run

gcloud auth login
gcloud config set project <project-id>
npm run demo:deploy

Override SERVICE, REGION or PROJECT in the environment. A first deploy also needs the APIs enabled and the build service account permitted:

gcloud services enable run.googleapis.com cloudbuild.googleapis.com \
  artifactregistry.googleapis.com --project "$PROJECT"
gcloud artifacts repositories create cloud-run-source-deploy \
  --repository-format=docker --location=europe-west1 --project "$PROJECT"
gcloud projects add-iam-policy-binding "$PROJECT" --condition=None \
  --member="serviceAccount:<project-number>-compute@developer.gserviceaccount.com" \
  --role=roles/cloudbuild.builds.builder

New projects no longer grant the default compute service account build rights, so without that last binding the deploy fails on reading its own source upload.

The script then deploys and, in a second call, sets PROTOCOL_HEADER and HOST_HEADER so adapter-node derives its origin per request. It cannot infer one from the listening socket, and a mismatch answers 403 on every form action with nothing logged. A fixed ORIGIN is the wrong fix here: Cloud Run serves the same revision on two hostnames — SERVICE-PROJECTNUMBER.REGION.run.app and a legacy SERVICE-HASH-REGION.a.run.app — and pinning one 403s everybody who arrived on the other. Cross-origin posts are still rejected.

The address

Cloud Run mints https://SERVICE-PROJECT_NUMBER.REGION.run.app, so the defaults here give https://personal-health-demo-<project-number>.europe-west1.run.app. That is the project number, not the id, and it is not changeable; SERVICE and REGION are. The URL is stable once deployed.

For a domain of your own, put Firebase Hosting in front — a rewrite to the Cloud Run service, which brings <project>.web.app and a custom domain with managed certificates at no cost. Cloud Run's own domain mapping is still preview and cannot disable TLS 1.0/1.1; a global external load balancer works but bills a forwarding rule whether or not anyone visits.

Cloud Run also answers on a second, legacy SERVICE-HASH-REGION.a.run.app hostname, which is the reason not to pin a single origin.

Firebase Hosting in front

firebase.json rewrites every path to the Cloud Run service; hosting/ is an empty public directory, because Hosting requires one and anything in it would shadow a route. The Hosting site must live in the same project as the service — a run rewrite names only a service and region, so it cannot cross a project boundary.

firebase projects:addfirebase <project-id>     # once, if it is not a Firebase project
firebase deploy --only hosting --project <project-id>

A custom domain is added in the Firebase console under Hosting, which prints the DNS records to create.

Hosting rewrites the Host header, so HOST_HEADER=host breaks form actions. Every POST answers 403 Cross-site POST form submissions are forbidden while GETs look perfect. Hosting replaces Host with the legacy a.run.app name and strips its own x-fh-requested-host before the container sees it, so the app computes the Cloud Run origin and rejects an Origin naming the public domain. x-forwarded-host carries the requested host and is what the deploy script sets. Because adapter-node falls back to host when that header is absent, requests straight to run.app keep working, which is what makes it possible to tell an application fault from a proxy fault.

Setting Value Why
--max-instances 1 one instance each instance owns its own copy of the database; a second would serve a second, divergent record
--min-instances 0 scale to zero an unvisited demo costs nothing
--memory 1Gi — Cloud Run's writable layer is in memory, and the restored seed lives there
--cpu-boost on shortens the cold start the first visitor waits through
request-based billing default CPU and memory bill only while a request is in flight. --no-cpu-throttling switches to always-allocated and removes this

DEMO_MODE=1 renders a banner on every page stating the instance is public, synthetic and reset on restart. Leave it set.

What the demo does not have

The catalogue variables in deployment stay unset, so the demo never reaches the network: no snapshot is fetched and contributions cannot be sent. LABEL_OCR_URL is unset, so supplement photo capture reports that OCR is not configured while barcode and pasted-text parsing still work.

Changing demo data means rebuilding the image. That is the cost of not running migrations and DICOM import inside the request that triggers a cold start.