Introduction
Welcome to the Second Opinion documentation portal. This site covers the chronic-disease second medical opinion service built on Cloudflare Workers.
What is Second Opinion?
Section titled “What is Second Opinion?”Patients submit medical cases for expert review by specialist doctors. The worker manages the full lifecycle: case creation, payment, coordinator assignment, doctor opinions, and final report delivery.
Documentation sections
Section titled “Documentation sections”| Section | Description |
|---|---|
| API Reference | Interactive OpenAPI browser and detailed endpoint docs |
| Business Flows | Domain processes — case lifecycle, payment, notifications |
| API Flows | Sequence diagrams showing request paths through services |
| Database | D1 schema, ER diagram, and table reference |
Architecture at a glance
Section titled “Architecture at a glance”flowchart TB
subgraph clients [Clients]
PatientApp[Patient App]
ProApp[Pro App]
Dashboard[Admin Dashboard]
Cron[External Scheduler]
end
subgraph worker [second-opinion Worker]
Hono[Hono HTTP Router]
D1[(D1 SQLite)]
Queue[Scheduler Queue]
end
subgraph external [External Services]
PX[Persistence Proxy]
Pay[Payment Hub]
Sock[Socket Notifications]
JWKS[Key Service JWKS]
end
PatientApp -->|/app/*| Hono
ProApp -->|/pro/*| Hono
Dashboard -->|/admin/*| Hono
Cron -->|/scheduler/*| Hono
Hono --> D1
Hono --> PX
Hono --> Pay
Hono --> Sock
Hono --> JWKS
Hono --> Queue
Queue --> Sock
Auth audiences
Section titled “Auth audiences”| Prefix | JWT audience | Users |
|---|---|---|
/app | snr_usr | Patients |
/pro | snr_pro | Doctors and coordinators |
/admin | snr_dash | Dashboard administrators |
/health, /scheduler | none | Health checks and cron triggers |
All authenticated routes use an encrypted Authorization header (hex ciphertext): decrypt → JWT verify → persistence access-token check.
Response envelope
Section titled “Response envelope”All JSON responses follow { status, message, data?, pagination? }. Status 1000 indicates success.