// developers
Plain data, pure functions, no backend.
Architecture
Pack format
src/core/schema.ts
A zod schema for questions, red flags, outcomes and routing. Plain data that clinicians can review.
Deterministic engine
src/core/engine
Pure, synchronous functions: same answers, same result. No I/O, timers or storage.
TriageBench
src/core/bench
Clinical vignettes that fail CI if any emergency is under-triaged.
<CareBot />
src/bot
The accessible bot UI, shared by this portal and the embeddable widget.
Embed widget
widget/
A Vite build of the <signpost-care> custom element in Shadow DOM, loaded by one script tag.
Relay
relay/
A stateless relay (Cloudflare Worker, Render or Docker) that holds the clinic's own key, owns the prompts and keeps no logs.
The pack format
A pack is one specialty bot: ordered multiple-choice questions, red-flag rules, navigation outcomes (a specialty and an urgency, never a diagnosis) and routing rules. Questions can be shown conditionally with a tiny JSON logic (showIf), and options add points to outcomes.
The full reference with a worked example is in docs/packs.md. The schema itself is src/core/schema.ts.
Contribute a pack
- Open a “New specialty pack” issue with the scope and the published guidelines you will use.
- Add
src/core/packs/<id>.tsexporting a typedPack, register it insrc/core/packs/index.ts, and start it asreview.status: "draft". - Add TriageBench vignettes for every emergency and urgent red flag, then run
npm test. - When it is complete, guideline-sourced and passing TriageBench, maintainers mark it
released(“Ready to use”). - It is marked
clinician-reviewedonly when a named, credentialed clinician signs off on that exact version.
Deploy the relay (Bring Your Own Key)
The relay is optional. It adds translations, friendlier outcome explanations and a short clinician narrative, never decisions. It runs with the clinic's own key for Anthropic Claude, OpenAI or any OpenAI-compatible provider, on Cloudflare Workers, Render or Docker. Set API_KEY as a secret and ALLOWED_ORIGINS to your site, then paste the relay URL into the setup wizard (step 3 shows the exact commands). It keeps no logs and never forwards IP addresses. Details are in relay/README.md.
Self-hosting
The portal is a static export. Build it and serve out/ from any static host. Keep the security headers from render.yaml, and make sure /widget/* is served with Access-Control-Allow-Origin: * and Cross-Origin-Resource-Policy: cross-origin so clinic sites can load it.
{
"schema": 1,
"id": "sleep",
"version": "0.1.0",
"title": "Sleep",
"specialty": "sleep-medicine",
"audience": "adult",
"demographics": ["age"],
"review": { "status": "draft", "reviewers": [], "sources": [{ "title": "…" }] },
"questions": [
{
"id": "main-concern",
"prompt": "What bothers you most about your sleep?",
"kind": "single",
"options": [
{ "id": "snoring", "label": "Loud snoring or pauses in breathing", "score": { "sleep-clinic": 3 } },
{ "id": "insomnia", "label": "Trouble falling or staying asleep", "score": { "primary": 2 } }
]
}
],
"redFlags": [ … ],
"outcomes": [ … ],
"routing": [ … ],
"fallbackOutcome": "primary"
}git clone https://github.com/drmedhealth/signpostcare.git
cd signpostcare
npm install
npm run dev # portal at http://localhost:3000
npm test # engine, packs and TriageBench
npm run build # widget + static export to ./out