medicaitutor-api · staging · snapshot 3 Nov 2026

MedicAITutor API, as it ran on 3 Nov

How a candidate's request reaches the API, what the API is made of, where it keeps data, and how a change gets from a pull request to staging. Read from the repositories and the live staging endpoints.

Snapshot from 3 Nov 2026. Since then production has been promoted twice (327d740 on 5 Nov, f473294 on 6 Nov), so the production notes below are out of date. Scaling, rate limits and the database setup have not been re-checked. For how a request is answered step by step, see the answer pipeline.

staging ac49636 · released 07:40 WAT 3 Nov NLP gpt-5-mini ASR gpt-4o-transcribe TTS Polly neural pods 0–6, scale to zero production 5834fb6 · 22 Sep

System drawing

Request path External AI providers Storage and config Behind staging
WHO CALLS IT EKS medicaitutor-staging-eks · namespace staging OUTSIDE THE CLUSTER Quluub app medic.quluub.com via its Railway backend one source address for all Station editor medicaitutor-web anonymous on staging Release gates GitHub Actions jobs on CodeBuild runners smoke, evidence, stations, live journeys Production · api.medicaitutor.com Separate deployment with its own image and load balancer. Last promoted 22 Sep 2026 (5834fb6), about six weeks behind staging. Promotion is manual: the "Promote MedicAITutor API To Production" workflow takes the attested staging digest. AWS load balancer api.staging.medicaitutor.com HTTPS 443, HTTP → 301 idle timeout 3600 s sticky sessions 1 h TLS 1.2 policy access logs → S3, 5 min KEDA HTTP interceptor wakes pods on request 20 requests per pod 0–6 pods, 15 min idle request timeout 3600 s Schedules scale-down 16:00 WAT daily scale-up 10:00 WAT weekdays (suspended) Spot nodes (Karpenter) API pod · FastAPI uvicorn :8000 · ≤2 vCPU · ≤4 GiB Public chat and grading /chat/text · /evaluate · /ask Live sessions (WebSocket) /realtime /ws/station/{slug}/… Stations and editor /stations, preview, history Sessions and feedback /sessions /evaluation /review Provider routes /nlp /asr /tts /avatar Health and metrics /health /ready /metrics Init: evidence corpus S3 → /mnt/evidence (SQLite) Postgres StatefulSet in the cluster sessions, attempts, interactions credentials from Secrets Manager OpenAI gpt-5-mini · patient, AMA, grading gpt-4o-transcribe · speech text-embedding-3-small Amazon Polly neural voices · TTS Avatars LiveAvatar (live default) HeyGen video (async) S3 · stations source of truth + history S3 · media recordings, request traces S3 · evidence pinned corpus for AMA Config and secrets SSM parameters + Secrets Manager, mounted by CSI

On a phone, scroll the drawing sideways. Teal arrows are the request path. Grey arrows are what the pod calls or reads.

What the API serves

AreaMain routesUsed by
Patient chat/chat/text, /chat/audioApp, gates
Live station/realtime, /ws/station/{slug}/sessionApp voice sessions
Grading/evaluate, /evaluation/*App after End
Ask Me Anything/askApp, evidence gate
Stations/stations, /{slug}, editor-preview, editor-versionEditor, app catalogue
Sessions/sessions, /session/start, /{id}/endApp
Mock exams/mock-exams, /{slug}/station-idsApp
Providers/nlp, /asr, /tts, /avatar, /providers/statusApp, ops
Health/healthz, /ready, /health/release, /metricsKubernetes, gates

What it is made of

services/nlp
Simulated patient replies and the checks on each reply.
services/evidence
Cited answers for Ask Me Anything, from the pinned corpus and embeddings.
services/evaluation
Rubric scoring against the station's marking domains.
services/station
Reads and writes stations in the S3 archive, keeping every revision. Also editor checks and example quality.
services/orchestration
Live station: speech in, patient reply, voice and avatar out.
services/asr · tts · avatar
Swappable providers behind one factory each: OpenAI, Deepgram, Azure, ElevenLabs, Whisper; Polly; LiveAvatar, HeyGen, D-ID, Tavus.
services/session
Session records and recordings in Postgres and S3.
services/assistant
Intent, safety and presentation rules for tutor answers.

How a patient reply is checked

Each candidate question goes through these stages in order and stops at the first reply that passes. Every stage is recorded as an audit span in the session trace.

draft

The model answers in character from the station's case facts.

clean_retry

If the draft breaks a rule (reveals too much, wrong voice), the model tries once more with the reason.

repair_example

Falls back to the station's own example reply for that fact. Since PR 364, copied or third-person examples are rephrased in the first person.

repair_value

Last resort: the fact itself, turned into first-person speech.

Station saves now reject an example that copies its notes or talks about the patient in the third person (422 unspeakable_example_responses).

From pull request to staging

  1. CI on the pull request~6 minBackend tests and avatar demo build on GitHub Actions, plus the CodeBuild staging check. The PR needs one release:* label.
  2. Merge to mainThe automatic push run is skipped on purpose.
  3. Dispatch "Staging release"~3 mindeploy.yml from main builds once and pushes an immutable digest to ECR.
  4. Infra records the digest~12 minmedicaitutor-infra commits it to the rendered manifest, and Argo CD rolls it out.
  5. Continue staging release~21 minFour validation jobs run against the live staging pods, then one attest job.
  6. Promote to productionmanualTakes the same attested digest. No rebuild.

Times are from the 31 Oct release of 34ad72b.

Things to watch

  • Production is six weeks behindIt still runs the 22 Sep image. None of the October patient, grading or station fixes are there.
  • Rate limits are a stopgap3000 HTTP and 600 WebSocket per minute, because every Quluub user arrives from one Railway address.
  • Cold startsWith no traffic the API scales to zero. The first request after idle waits for a pod (readiness timeout 300 s).
  • One shared OpenAI balanceStaging traffic, release gates and local tests draw from the same credit and limit.
  • Postgres runs inside the clusterA single StatefulSet on Spot capacity rather than a managed database.