Skip to content

BiobadamexAI architecture

This page shows the BiobadamexAI components and how they connect. Figure 1 shows intake and extraction. Figure 2 shows review and submission.

Term Meaning
Surface A group of API routes for one type of client.
Job One unit of work in a pg-boss queue.
Extractor The code that turns a note into a typed record.
Registry worker The Playwright program that fills the BIOBADAMEX forms.
Tri-state A field that keeps three cases apart: a documented value, an explicit negation (false) and unknown.
System map: four entry points call the API, the API stores in R2 and PostgreSQL, the extractor writes the draftReact consoleService intakeHono APIR2encrypted originalsPostgreSQLmetadata and draftspg-bossClinician agentdedicatedAgent APIExtractorRheumAI audit proxyAudit APINebiusde-identified noteTri-state schemaDAS-28 · completeness
Figure 1. Intake and extraction. Arrows are calls or writes. Cylinders are stores.

Figure 1 shows these connections:

  • The React console and the service intake call the Hono API.
  • The Hono API stores the encrypted originals in R2.
  • The Hono API stores the metadata and the drafts in PostgreSQL.
  • The Hono API and the Agent API put extraction jobs into pg-boss.
  • The RheumAI audit proxy calls the Audit API. The Audit API calls the extractor directly.
  • pg-boss gives each job to the extractor.
  • The extractor sends the de-identified note to Nebius.
  • The extractor applies the tri-state schema, DAS-28 and completeness. The result goes to PostgreSQL.

A draft goes through these steps after extraction. The numbers in Figure 2 are the numbers in this list.

Review and submission sequence between the console, the API, the registry-submit queue, the Tenki microVM and BIOBADAMEXReactConsoleHonoAPIpg-bossregistry-submitPlaywrightTenki microVMASP.NETBIOBADAMEXThe clinician reviews the draft1 · correct1 · save record2 · approve2 · state approved3 · request submission3 · queue a job4 · start a microVM5 · crdA to crdE6 · idpac after crdA7 · summary with idpac8 · idpac + summary8 · save the result
Figure 2. Review and submission. Time goes down. Solid arrows are calls. Dashed arrows are replies.
  1. Correct. The clinician reviews and corrects the draft in the console. The API saves the correction in record, in PostgreSQL.
  2. Approve. The clinician approves the draft. The API changes the state to approved.
  3. Request the submission. The clinician requests the submission. The API puts a job into the registry-submit queue.
  4. Start the microVM. The registry worker runs in a disposable Tenki microVM.
  5. Fill the forms. The worker logs in to BIOBADAMEX and goes through crdA to crdE.
  6. Read the idpac. The worker gets the idpac after it saves crdA.
  7. Confirm the summary. The worker requires the final summary to show the same idpac.
  8. Save the result. The idpac and the summary come back as a receipt. The receipt stays in PostgreSQL.

The React console puts daily work into one list of notes. Filters show which notes need attention. Each row has an action for its state: extract, review or view. Review screens show the source document, the structured record, the corrections and the treatment episodes. A separate confirmation comes before submission.

The Hono API mounts these surfaces:

Route Function
/api/biobadamex/intake Pasted text, files and service intake.
/api/biobadamex/uploads Inventory, on-demand extraction and retrieval of the original.
/api/biobadamex/drafts Review queue, detail, correction, approval, rejection and submission.
/api/biobadamex/audit Grading and submission for review from RheumAI.
/api/biobadamex/agent Limited access for an agent that works for one clinician.
/api/flujos Operational timeline with a reduced, PHI-light view.

Console routes require a session, a resolved user and research access. Machine-to-machine surfaces use separate service keys.

  • R2 keeps the original file, encrypted with AES-256-GCM.
  • PostgreSQL stores the file metadata, jobs, drafts, audit and submission outcomes.
  • The working copy of the record keeps the tri-state values.
  • agentRecord keeps the original extraction and does not change. record is the copy that the clinician can correct.
  • The system encrypts the draft source text when a valid master key is available.

pg-boss keeps extraction separate from registration. The API registers the workers only when BIOBADAMEX_QUEUE_ENABLED=1. The extraction queue has retries and a dead letter. Registration uses a different queue. Each worker processes one registration job at a time. An installation with more than one instance needs extra coordination for global serialization.

@poktahealth/biobadamex-registry contains the record schema, the unknown semantics and the disease rules. It also contains DAS-28, the job contracts, the external field map and the correction and completeness rules.

The Playwright worker runs in a disposable microVM. The worker logs in and goes through crdA to crdE. It reads the idpac after it saves crdA. It requires the final summary to show the same identifier.

Boundary What it controls What it does not prove
Extraction It turns a note into a typed record. That every value is correct.
Clinical review It lets the clinician correct and approve. That the external platform received every field.
Worker confirmation It reads the idpac and the summary. A field-by-field read-back after submission.