# nayarr/chiron architecture

> Architecture diagram of the GitHub repository nayarr/chiron, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nayarr/chiron
- Repository: https://github.com/nayarr/chiron

## Overview

WiGo is a patient-record and medical-imaging platform. Its main workflow runs from patient and image intake to a patient case view, then into either DICOM radiology review or digitized-biopsy analysis and extraction. A separate pathology workflow guides extraction reporting through four ordered OLGA-defined forms; InstanSeg provides optional decision support. The graph combines sampled source relationships with README-documented capabilities; some imaging details are documented but their implementation paths were not sampled.

Main entry points: [`backend/main.py`](https://github.com/nayarr/chiron/blob/main/backend/main.py) (FastAPI endpoints), [`frontend/src/services/api.ts`](https://github.com/nayarr/chiron/blob/main/frontend/src/services/api.ts) (REST client), [`frontend/src/pages/Viewer.tsx`](https://github.com/nayarr/chiron/blob/main/frontend/src/pages/Viewer.tsx) (Biopsy viewer), [`frontend/src/App.tsx`](https://github.com/nayarr/chiron/blob/main/frontend/src/App.tsx) (App routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Clinical interface"]
  node_app["App routing<br/>[App.tsx]"]
  node_dashboard["Patient dashboard<br/>[Dashboard.tsx]"]
  node_patient_ui["Patient and upload UI<br/>[PatientCard.tsx]"]
  node_upload_ui["Image upload UI"]
  node_api_client["REST client<br/>[api.ts]"]
  node_viewer["Biopsy viewer<br/>[Viewer.tsx]"]
  node_radiology_viewer["Radiology viewer"]
end

subgraph group_backend["API and domain"]
  node_backend_api["FastAPI endpoints<br/>[main.py]"]
  node_domain_models["Patient and case models<br/>[models.py]"]
  node_db[("PostgreSQL<br/>[database.py]")]
end

subgraph group_imaging["Imaging services"]
  node_object_storage[("Slide object storage<br/>[storage.py]")]
  node_tile_service["DZI tile generation and serving<br/>[main.py]"]
  node_image_seeder["Slide tile recovery<br/>[seed_images.py]"]
  node_orthanc[("Orthanc PACS")]
  node_instanseg_client["Segmentation client"]
  node_instanseg["InstanSeg service<br/>[api.py]"]
end

subgraph group_workflow["Pathology workflow"]
  node_workflow_ui["Workflow interface<br/>[OlgaFormPanel.tsx]"]
  node_workflow_hooks["Workflow state hooks<br/>[useWorkflow.ts]"]
  node_workflow_api["Workflow REST client<br/>[workflowApi.ts]"]
  node_form_loader["OLGA form loader<br/>[useOlgaForm.ts]"]
  node_olga_adapter["Schema adapter<br/>[olgaAdapter.ts]"]
  node_form_renderer["Schema form renderer<br/>[JsonSchemaForm.tsx]"]
  node_olga["OLGA forms"]
  node_workflow_router["Workflow routes<br/>[router.py]"]
  node_workflow_service["Workflow state engine<br/>[service.py]"]
  node_workflow_state[("Workflow persistence<br/>[models.py]")]
end

node_clinician(("Clinician"))

node_clinician -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_viewer
node_app -->|"routes to"| node_radiology_viewer
node_dashboard -->|"renders"| node_patient_ui
node_dashboard -->|"renders"| node_upload_ui
node_dashboard -->|"loads cases"| node_api_client
node_patient_ui -->|"calls"| node_api_client
node_upload_ui -->|"uploads to"| node_api_client
node_api_client -->|"calls REST"| node_backend_api
node_api_client -->|"requests DICOM via API"| node_orthanc
node_backend_api -->|"queries"| node_domain_models
node_backend_api -->|"uses sessions"| node_db
node_domain_models -->|"maps to"| node_db
node_backend_api -->|"resolves slide source"| node_object_storage
node_backend_api -->|"generates and serves tiles"| node_tile_service
node_tile_service -->|"reads slide source"| node_object_storage
node_image_seeder -->|"recovers slide source"| node_object_storage
node_image_seeder -->|"regenerates tiles"| node_tile_service
node_backend_api -->|"imports and reads studies"| node_orthanc
node_radiology_viewer -.->|"uses REST"| node_api_client
node_viewer -.->|"uses REST"| node_api_client
node_viewer -->|"renders"| node_workflow_ui
node_viewer -->|"manages progress"| node_workflow_hooks
node_workflow_ui -->|"loads form"| node_form_loader
node_workflow_ui -->|"renders schema"| node_form_renderer
node_workflow_hooks -->|"calls"| node_workflow_api
node_workflow_hooks -.->|"saves progress via API"| node_backend_api
node_form_loader -->|"fetches definitions"| node_olga
node_form_loader -->|"uses client adapter"| node_olga_adapter
node_form_loader -.->|"converts fallback schema"| node_olga_adapter
node_form_renderer -->|"renders adapted schema"| node_olga_adapter
node_workflow_api -.->|"calls workflow routes"| node_workflow_router
node_backend_api -->|"mounts routes"| node_workflow_router
node_workflow_router -->|"delegates"| node_workflow_service
node_workflow_service -->|"updates extraction"| node_domain_models
node_workflow_service -->|"reads and writes state"| node_workflow_state
node_backend_api -->|"requests segmentation"| node_instanseg_client
node_instanseg_client -.->|"sends analysis request"| node_instanseg
node_instanseg -.->|"returns overlays and metrics"| node_viewer

click node_app "https://github.com/nayarr/chiron/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/nayarr/chiron/blob/main/frontend/src/pages/Dashboard.tsx"
click node_patient_ui "https://github.com/nayarr/chiron/blob/main/frontend/src/components/PatientCard.tsx"
click node_upload_ui "https://github.com/nayarr/chiron/blob/main/frontend/src/components/UploadMedicalImage.tsx"
click node_api_client "https://github.com/nayarr/chiron/blob/main/frontend/src/services/api.ts"
click node_viewer "https://github.com/nayarr/chiron/blob/main/frontend/src/pages/Viewer.tsx"
click node_radiology_viewer "https://github.com/nayarr/chiron/blob/main/frontend/src/pages/RadiologyViewer.tsx"
click node_workflow_ui "https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/components/OlgaFormPanel.tsx"
click node_workflow_hooks "https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/useWorkflow.ts"
click node_workflow_api "https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/workflowApi.ts"
click node_form_loader "https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/useOlgaForm.ts"
click node_olga_adapter "https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/olga/olgaAdapter.ts"
click node_form_renderer "https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/components/JsonSchemaForm.tsx"
click node_backend_api "https://github.com/nayarr/chiron/blob/main/backend/main.py"
click node_workflow_router "https://github.com/nayarr/chiron/blob/main/backend/workflow/router.py"
click node_workflow_service "https://github.com/nayarr/chiron/blob/main/backend/workflow/service.py"
click node_domain_models "https://github.com/nayarr/chiron/blob/main/backend/models.py"
click node_db "https://github.com/nayarr/chiron/blob/main/backend/database.py"
click node_object_storage "https://github.com/nayarr/chiron/blob/main/backend/storage.py"
click node_tile_service "https://github.com/nayarr/chiron/blob/main/backend/main.py"
click node_image_seeder "https://github.com/nayarr/chiron/blob/main/backend/seed_images.py"
click node_instanseg_client "https://github.com/nayarr/chiron/blob/main/backend/instanseg_client.py"
click node_instanseg "https://github.com/nayarr/chiron/blob/main/instanseg/api.py"
click node_workflow_state "https://github.com/nayarr/chiron/blob/main/backend/models.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_dashboard,node_patient_ui,node_upload_ui,node_api_client,node_viewer,node_radiology_viewer toneBlue
class node_backend_api,node_domain_models,node_db toneAmber
class node_object_storage,node_tile_service,node_image_seeder,node_orthanc,node_instanseg_client,node_instanseg toneMint
class node_workflow_ui,node_workflow_hooks,node_workflow_api,node_form_loader,node_olga_adapter,node_form_renderer,node_olga,node_workflow_router,node_workflow_service,node_workflow_state toneRose
class node_clinician toneIndigo
```

## Components

### Clinical interface

- [App routing](https://github.com/nayarr/chiron/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Patient dashboard](https://github.com/nayarr/chiron/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Patient and upload UI](https://github.com/nayarr/chiron/blob/main/frontend/src/components/PatientCard.tsx): `frontend/src/components/PatientCard.tsx`
- [Image upload UI](https://github.com/nayarr/chiron/blob/main/frontend/src/components/UploadMedicalImage.tsx): `frontend/src/components/UploadMedicalImage.tsx`
- [REST client](https://github.com/nayarr/chiron/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Biopsy viewer](https://github.com/nayarr/chiron/blob/main/frontend/src/pages/Viewer.tsx): `frontend/src/pages/Viewer.tsx`
- [Radiology viewer](https://github.com/nayarr/chiron/blob/main/frontend/src/pages/RadiologyViewer.tsx): `frontend/src/pages/RadiologyViewer.tsx`

### API and domain

- [FastAPI endpoints](https://github.com/nayarr/chiron/blob/main/backend/main.py): `backend/main.py`
- [Patient and case models](https://github.com/nayarr/chiron/blob/main/backend/models.py): `backend/models.py`
- [PostgreSQL](https://github.com/nayarr/chiron/blob/main/backend/database.py): `backend/database.py`

### Imaging services

- [Slide object storage](https://github.com/nayarr/chiron/blob/main/backend/storage.py): `backend/storage.py`
- [DZI tile generation and serving](https://github.com/nayarr/chiron/blob/main/backend/main.py): `backend/main.py`
- [Slide tile recovery](https://github.com/nayarr/chiron/blob/main/backend/seed_images.py): `backend/seed_images.py`
- **Orthanc PACS**
- [Segmentation client](https://github.com/nayarr/chiron/blob/main/backend/instanseg_client.py): `backend/instanseg_client.py`
- [InstanSeg service](https://github.com/nayarr/chiron/blob/main/instanseg/api.py): `instanseg/api.py`

### Pathology workflow

- [Workflow interface](https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/components/OlgaFormPanel.tsx): `frontend/src/features/workflow/components/OlgaFormPanel.tsx`
- [Workflow state hooks](https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/useWorkflow.ts): `frontend/src/features/workflow/useWorkflow.ts`
- [Workflow REST client](https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/workflowApi.ts): `frontend/src/features/workflow/workflowApi.ts`
- [OLGA form loader](https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/useOlgaForm.ts): `frontend/src/features/workflow/useOlgaForm.ts`
- [Schema adapter](https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/olga/olgaAdapter.ts): `frontend/src/features/workflow/olga/olgaAdapter.ts`
- [Schema form renderer](https://github.com/nayarr/chiron/blob/main/frontend/src/features/workflow/components/JsonSchemaForm.tsx): `frontend/src/features/workflow/components/JsonSchemaForm.tsx`
- **OLGA forms**
- [Workflow routes](https://github.com/nayarr/chiron/blob/main/backend/workflow/router.py): `backend/workflow/router.py`
- [Workflow state engine](https://github.com/nayarr/chiron/blob/main/backend/workflow/service.py): `backend/workflow/service.py`
- [Workflow persistence](https://github.com/nayarr/chiron/blob/main/backend/models.py): `backend/models.py`

### Other components

- **Clinician**

## Connections

- Clinician → App routing: uses (evidence: `README.md`)
- App routing → Patient dashboard: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Biopsy viewer: routes to (evidence: `frontend/src/App.tsx`)
- App routing → Radiology viewer: routes to (evidence: `frontend/src/App.tsx`)
- Patient dashboard → Patient and upload UI: renders (evidence: `frontend/src/pages/Dashboard.tsx`)
- Patient dashboard → Image upload UI: renders (evidence: `frontend/src/pages/Dashboard.tsx`)
- Patient dashboard → REST client: loads cases (evidence: `frontend/src/pages/Dashboard.tsx`)
- Patient and upload UI → REST client: calls (evidence: `frontend/src/components/PatientCard.tsx`)
- Image upload UI → REST client: uploads to (evidence: `frontend/src/components/UploadMedicalImage.tsx`)
- REST client → FastAPI endpoints: calls REST (evidence: `frontend/src/services/api.ts`)
- REST client → Orthanc PACS: requests DICOM via API (evidence: `README.md`)
- FastAPI endpoints → Patient and case models: queries (evidence: `backend/main.py`)
- FastAPI endpoints → PostgreSQL: uses sessions (evidence: `backend/main.py`)
- Patient and case models → PostgreSQL: maps to (evidence: `backend/models.py`)
- FastAPI endpoints → Slide object storage: resolves slide source (evidence: `backend/storage.py`)
- FastAPI endpoints → DZI tile generation and serving: generates and serves tiles (evidence: `README.md`)
- DZI tile generation and serving → Slide object storage: reads slide source (evidence: `README.md`)
- Slide tile recovery → Slide object storage: recovers slide source (evidence: `backend/seed_images.py`)
- Slide tile recovery → DZI tile generation and serving: regenerates tiles (evidence: `README.md`)
- FastAPI endpoints → Orthanc PACS: imports and reads studies (evidence: `backend/main.py`)
- Radiology viewer → REST client: uses REST
- Biopsy viewer → REST client: uses REST
- Biopsy viewer → Workflow interface: renders (evidence: `frontend/src/pages/Viewer.tsx`)
- Biopsy viewer → Workflow state hooks: manages progress (evidence: `frontend/src/pages/Viewer.tsx`)
- Workflow interface → OLGA form loader: loads form (evidence: `frontend/src/features/workflow/components/OlgaFormPanel.tsx`)
- Workflow interface → Schema form renderer: renders schema (evidence: `frontend/src/features/workflow/components/OlgaFormPanel.tsx`)
- Workflow state hooks → Workflow REST client: calls (evidence: `frontend/src/features/workflow/useWorkflow.ts`)
- Workflow state hooks → FastAPI endpoints: saves progress via API
- OLGA form loader → OLGA forms: fetches definitions (evidence: `README.md`)
- OLGA form loader → Schema adapter: uses client adapter
- OLGA form loader → Schema adapter: converts fallback schema
- Schema form renderer → Schema adapter: renders adapted schema (evidence: `frontend/src/features/workflow/components/JsonSchemaForm.tsx`)
- Workflow REST client → Workflow routes: calls workflow routes
- FastAPI endpoints → Workflow routes: mounts routes (evidence: `backend/main.py`)
- Workflow routes → Workflow state engine: delegates (evidence: `backend/workflow/router.py`)
- Workflow state engine → Patient and case models: updates extraction (evidence: `backend/workflow/service.py`)
- Workflow state engine → Workflow persistence: reads and writes state (evidence: `backend/workflow/service.py`)
- FastAPI endpoints → Segmentation client: requests segmentation (evidence: `backend/main.py`)
- Segmentation client → InstanSeg service: sends analysis request
- InstanSeg service → Biopsy viewer: returns overlays and metrics (evidence: `README.md`)
