Skip to content

API Flows Overview

API flows show how HTTP requests traverse the worker and external services. Each route group has a dedicated page with sequence diagrams for key operations.

Route groupAudiencePage
/app/*snr_usr (patients)App flows
/pro/*snr_pro (doctors)Pro flows
/admin/*snr_dash (dashboard)Admin flows
/scheduler/*none (cron)Scheduler flows

Sequence diagrams cover the main case journey endpoints. Admin configuration CRUD (review types, disease categories, coordinator mappings) is documented in API Reference without per-endpoint sequence diagrams — those are simple D1 read/write operations.

sequenceDiagram
  participant Client
  participant Worker as second_opinion
  participant Auth as Auth Middleware
  participant JWKS as Key Service
  participant PX as Persistence
  participant D1 as D1

  Client->>Worker: HTTP request + Authorization header
  Worker->>Auth: decrypt + verify JWT
  Auth->>JWKS: fetch public keys
  Auth->>PX: validate access token
  Auth-->>Worker: AuthUser context
  Worker->>D1: read/write
  Worker-->>Client: JSON response envelope

All handlers return { status, message, data?, pagination? }. Middleware logs request/response to R2 (REQUEST_RESPONSE_LOGS).