Skip to content

Introduction

Welcome to the Second Opinion documentation portal. This site covers the chronic-disease second medical opinion service built on Cloudflare Workers.

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.

SectionDescription
API ReferenceInteractive OpenAPI browser and detailed endpoint docs
Business FlowsDomain processes — case lifecycle, payment, notifications
API FlowsSequence diagrams showing request paths through services
DatabaseD1 schema, ER diagram, and table reference
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
PrefixJWT audienceUsers
/appsnr_usrPatients
/prosnr_proDoctors and coordinators
/adminsnr_dashDashboard administrators
/health, /schedulernoneHealth checks and cron triggers

All authenticated routes use an encrypted Authorization header (hex ciphertext): decrypt → JWT verify → persistence access-token check.

All JSON responses follow { status, message, data?, pagination? }. Status 1000 indicates success.