Curaway — Spec-Driven Development¶
Why specs?¶
Every feature gets a spec before code is written. Specs are not documentation — they are contracts that define what the system must do, why, and how to verify it.
Structure¶
Each spec follows three sections:
| Section | Purpose |
|---|---|
| What | Plain-language requirement. What the user/system should experience. |
| Why | Which user story, investor narrative, or technical debt this serves. |
| Tasks | Numbered, dependency-ordered checklist with assertions. |
Rules¶
- No branch without a spec file committed first.
- Specs are living documents — update them when implementation reveals new constraints.
- Assertions are pass/fail. If the Langfuse trace or system behavior matches the assertion, it works. If not, it's a bug.
- Keep specs scoped. One feature per file. If a spec grows beyond ~80 lines, split it.
Naming¶
Examples: sse-upload-progress.md, intake-agent.md, timezone-conversion.md
Workflow¶
1. Write spec → commit to branch
2. Implement against spec tasks (in order)
3. Verify assertions (manual or automated)
4. Update spec if implementation diverged (with a note on why)
5. Merge
Curaway Platform — Specs & Implementation Guide¶
MVP Use Case: Clinical Match Engine v1 Upload Medical Report → AI Clinical Understanding → FHIR Record → Provider Match → Explainable Reasoning
How This Directory Works¶
sdd-mvp/ — Software Design Documents (The What)¶
Modular markdown specs, one file per domain. Claude Code reads the relevant spec file(s) at the start of each session for context. Each file is self-contained, version-controlled, and updated surgically per session.
ai-steer/ — Implementation Session Guides (The How)¶
Paste-ready Claude Code prompts, each covering one implementation session across both repos. Each steer doc references its spec file(s) for context and includes a verification checklist.
deferred/ — Design-Complete, Implementation-Deferred Specs¶
Full design specs for features that are architecturally scoped but not yet scheduled for implementation. Each spec has a clear dependency chain and effort estimate. When ready to build, the spec moves into active implementation with an accompanying steer doc.
SDD Spec Index¶
| File | Domain | Key Contents |
|---|---|---|
| 00-overview.md | Scope & Constraints | MVP objective, Aisha TKR demo scenario, 8 workflow phases, user roles |
| 01-system-architecture.md | Architecture | Modular monolith, full stack table, domain boundaries, LLM routing |
| 02-event-driven-design.md | Real-Time Events | Events table, SSE streaming, QStash async bus, event type registry |
| 03-data-architecture.md | Data Layer | FHIR R4, Neo4j graph, Qdrant vectors, multilingual/multicurrency, ontology |
| 04-agent-pipeline.md | Agentic AI | 4 agents, orchestrator, guardrails, fallbacks, prompt strategy, LLM tiers |
| 05-ehr-builder.md | EHR Assembly | Real-time record assembly, data sources, merge rules, conflict resolution |
| 06-matching-engine.md | Matching | 4-stage pipeline, 5 scoring domains, shadow mode, A/B testing |
| 07-document-pipeline.md | Documents | Upload flow, 3-tier OCR, auto-chain to clinical agent, checklist |
| 08-conversation-design.md | Chat Interface | Unified /chat endpoint, message schema, state management |
| 09-consent-compliance.md | GDPR & Consent | Purpose-specific consent, data classification, audit, DSAR handler |
| 10-api-endpoints.md | API Contracts | All MVP endpoints, error code taxonomy, response envelope |
| 11-frontend-architecture.md | Frontend | 4-zone layout, component hierarchy, SSE client, brand system |
| 12-security-observability.md | Security & Ops | Auth, encryption, Langfuse, PostHog, Metabase, Grafana |
| 13-testing-deployment.md | Testing & Infra | Test pyramid, CI/CD, Railway/Vercel, Docker dev, git workflow |
| 14-sequence-diagrams.md | E2E Flows | Registration, upload+autochain, chat extraction, matching pipeline |
AI Steer Doc Index (Implementation Order)¶
| Steer | Session Focus | Spec Dependencies | Repos |
|---|---|---|---|
| steer-01 | EHR Builder | 05, 02, 03 | BE + FE |
| steer-02 | Event System & SSE | 02, 08 | BE + FE |
| steer-03 | Intake Agent v2 | 04, 05, 08 | BE + FE |
| steer-04 | Clinical Autochain | 04, 07, 05 | BE + FE |
| steer-05 | Matching Pipeline | 06, 04, 03 | BE + FE |
| steer-06 | Chat Entity Extraction | 04, 05, 08 | BE + FE |
| steer-07 | Explanation & Locale | 04, 06, 08 | BE + FE |
| steer-08 | Demo Sweep & Polish | All | BE + FE |
Repos¶
| Repo | Purpose | Live URL |
|---|---|---|
curaway-ai/curaway-backend |
FastAPI backend | services.curaway.ai |
curaway-ai/curaway-frontend |
Vite/React frontend | app.curaway.ai |
Demo Context¶
- Patient: Aisha (UAE, Arabic-speaking, TKR case ICD M17.11)
- Tenant: tenant-apollo-001
- Procedure: Total Knee Replacement (CPT 27447), Kellgren-Lawrence Grade 4
- Comorbidities: Type 2 diabetes (E11), mild hypertension (I10)