Skip to content

Data flow

  1. A user enters a record or uploads an original document through a SvelteKit route.
  2. Server code writes structured data to the local database; file storage writes originals once under their content hash.
  3. Extracted document values retain document/page/region provenance and are held for review before they are treated as confirmed clinical information.
  4. Read-side services assemble views such as the unified timeline from source tables rather than a denormalized event store.
  5. Export routes assemble selected records into patient-facing packages or a complete archive.
  6. An opened imaging record loads a private annotation snapshot for its selected series. Cornerstone annotation events trigger a bounded, debounced save; the server updates only the revision the browser originally loaded.

Steps 1–6 involve no network. Everything below is the one subsystem that does, and it is optional: with no catalogue configured the app is unchanged.

The community catalogue

Two flows that never share a store. Reads are a whole signed file; writes are a moderated queue. See ADR-0009 for why.

   ┌── device ──────────────────┐
   │  record                    │
   │    │ explicit "contribute" │
   │    ▼                       │
   │  contribution_outbox  ─────┼──┐  held here until you press Send, so the
   └────────────────────────────┘  │  moment you started something is not
                                   │  what the receiver timestamps
        browser solves Turnstile   │
                    └──────────────┤  token rides along in the same request
                                   ▼
                        ┌── Worker (edge) ─────────────┐
                        │  siteverify — token, once    │
                        │  allowlist validation/item   │
                        │  rate limit/item, salted IP  │
                        │  content hash RE-DERIVED     │
                        └──────────────┬───────────────┘
                                       ▼
                                D1: one row per distinct
                                claim, corroborations++
                                       │
                        ═══════════════╪═══ manual gate 1 ═══
                                       ▼
                         npm run catalogue:review
                           --approve / --reject
                           --export → claims/<version>.json
                                       │
                        ═══════════════╪═══ manual gate 2 ═══
                                       ▼
                         you commit it to the catalogue
                         repository and push a v* tag
                                       ▼
                        ┌── GitHub Actions ────────────┐
                        │  checks out BOTH repos:      │
                        │   · catalogue → claims/      │
                        │   · this app  → builder +    │
                        │                 schema       │
                        │  build → sign (Ed25519)      │
                        └──────────────┬───────────────┘
                                       ▼
                        release assets: catalogue-<v>.sqlite
                                        manifest.json
                                       │
   ┌── device ──────────────────┐      │
   │  verify signature vs       │◀─────┘  read path: whole file, never a query
   │  PINNED key, then sha256   │
   │    ▼                       │
   │  local snapshot, queried   │
   │  offline                   │
   └────────────────────────────┘

Properties worth stating plainly, because each is load-bearing:

  • Nothing leaves the device without an explicit action. Contributions are built per record, shown in full before consent, and held in an outbox. There is no background upload and no settings toggle that enables one.
  • Nothing flows from D1 to a release automatically. The two gates above are manual and deliberate. D1 holds proposals; a submission becomes published data only when a person approves it and tags a release. An empty release list is the normal state.
  • The Worker trusts nothing from the client. It re-derives the content hash rather than accepting one, because a forged hash would make two unlike claims count as corroboration — the one input that could push wrong data into a release.
  • The app trusts nothing from the host. It verifies the manifest signature against a key compiled into the build, then the snapshot digest, before reading a byte. A compromised CDN can serve different bytes; it cannot serve bytes that key signed.
  • There is no read API. The app downloads whole releases and answers lookups locally. Asking a server "what is in package X?" would disclose interest in X, which is the disclosure the local-first design exists to prevent.