Skip to content

0021. The public demo is files only: no Worker code, no database, no login ​

  • Status: Accepted
  • Date: 2026-12-04

Context ​

The demo is deployed on Cloudflare behind Access, backed by a real D1 database that holds the made-up Addams household and one real person's Access login (step 12 of "Deploy the demo" links it). It is meant to be shown to anyone eventually. It can't be opened as it stands: the database links a real login, the Worker carries backup and SimpleFIN code and secrets, and its writes would persist whatever a stranger types.

Options for making it safe to open:

  1. API-backed, read-only, anonymous. The Worker answers every request as a fictional person and refuses writes. Exercises the real stack in public, but needs new auth code that is the opposite of everything the Worker is built to do, a way to keep the database free of the real login, and a demo that can't show Add it, Undo or Move money.
  2. API-backed, writes allowed, periodic reset. The database refuses deletes (archive-only, guard triggers), so a reset means dropping and rebuilding tables from a cron job, and abuse persists until it runs. The most moving parts.
  3. Files only. Serve the default (mock) build as static assets: no Worker code, no database, no secrets. The demo already exists as that build (the Addams household, "Log in as" buttons, in-memory writes).

Decision ​

Option 3. config:generate --mode public-demo writes an assets-only config: the built apps/web/dist, a name, a date and an empty cron list (so the old demo's hourly trigger is removed on deploy), and nothing else (no main, bindings, variables, observability or secret). A visitor can only be given a file, so there is no identity to leak, no write to persist, no secret to reach and no code to rate limit. Static asset requests are answered by Cloudflare without running code.

  • Same Worker name as the Access-protected demo (home-budget-demo), so one deploy replaces it and there is never a second Worker to keep covered by Access. workers_dev is on only when no CUSTOM_DOMAIN is given, so the demo has one address.
  • The visitor is a fictional person by choice, not by sign-in: the demo's "Log in as Gomez / Morticia" buttons set ?as=, and every change lives in the tab and is gone on reload.
  • Proof, in code: the config's exact text is a fixture and tests assert it has no binding, variable or code, whatever the environment holds; the default bundle is scanned for emails, Access words and the API client; and npm run security:check:public -- <address> asks the deployed site, as a stranger, whether Access is still in front, whether the headers and CSP are strict, whether any /api address answers with data, and whether the files are the demo build.
  • The footer says "Demo data: nothing you do here is saved." instead of "Can't reach the server right now" when no server answers on the demo build (it is built that way). A demo run next to a Worker still reads "Connected".
  • The demo follows today. The fixtures are one Thursday; left alone the public demo would show a December 2026 week for ever. The public demo build (--mode publicdemo) moves the ordinary state by whole weeks, in the visitor's browser, to the latest Thursday on or before the household's day (followDays, packages/mocks/src/follow-today.ts). Whole weeks keep every weekday and fortnight rhythm; monthly and yearly rules and dated settings stay on the calendar. Only that build does it, so tests and checks stay on fixed dates. Rejected: moving by days (breaks paydays), a scheduled rebuild (a second moving part for a static site), and re-dating the monthly rules (they already follow the calendar).
  • The Access-protected demo mode stays (--mode demo) for proving the stack before production. Only one of the two is deployed under the name at a time.

Consequences ​

  • The public demo proves nothing about the API, the database, the backup or Access. That is the Access-protected demo's job.
  • Taking the old demo's database, bucket, secrets and Access application out of the account is a manual step list (docs/deploy.md, Public demo); nothing in the repository can do it.
  • Rate limiting is Cloudflare's edge, not application code (there is none to put it in). A per-address cap is an optional WAF rule, in the same doc.
  • The demo is indexable by search engines (only /gallery sends noindex) unless X-Robots-Tag is added to /* in apps/web/public/_headers.