# chandana1515/medical-imaging-annotation-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/chandana1515/medical-imaging-annotation-viewer
- Repository: https://github.com/chandana1515/medical-imaging-annotation-viewer

## Overview

This is a medical-imaging annotation viewer: users load a generated demo/MRI image or local DICOM, inspect it with zoom controls, click to place markers, and the app retrieves or persists markers through the API. The graph separates UI orchestration, image viewing, API handling, and persistence. The README documents optional PostgreSQL; unsampled deployment wiring is not mapped. The legacy annotations router is present, but the sampled main API defines its own endpoints, so no connection to that router is asserted.

Main entry points: [`frontend/src/App.tsx`](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/App.tsx) (App workflow), [`frontend/src/components/Viewer.tsx`](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx) (Cornerstone viewer), [`backend/app/main.py`](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/main.py) (FastAPI endpoints), [`frontend/src/components/Toolbar.tsx`](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Toolbar.tsx) (Image and zoom controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Viewer UI"]
  node_bootstrap["React bootstrap<br/>[main.tsx]"]
  node_app["App workflow<br/>[App.tsx]"]
  node_toolbar["Image and zoom controls<br/>[Toolbar.tsx]"]
  node_panel["Marker list"]
end

subgraph group_imaging["Image Viewing"]
  node_viewer["Cornerstone viewer<br/>[Viewer.tsx]"]
  node_demo["Demo image generation<br/>[Viewer.tsx]"]
  node_dicom["DICOM loading<br/>[Viewer.tsx]"]
end

subgraph group_api["Annotation API"]
  node_backend["FastAPI endpoints<br/>[main.py]"]
end

subgraph group_storage["Persistence"]
  node_schema["Annotation ORM model<br/>[models.py]"]
  node_dbsession["Database sessions<br/>[database.py]"]
  node_database[("Annotation database<br/>[annotations.db]")]
end

node_user(("Viewer user"))
node_cornerstone["Cornerstone runtime"]
node_browserfile["Local DICOM file"]
node_postgres[("PostgreSQL option")]

node_user -->|"uses"| node_app
node_bootstrap -->|"renders"| node_app
node_app -->|"renders"| node_toolbar
node_app -->|"renders"| node_panel
node_app -->|"renders"| node_viewer
node_toolbar -->|"dispatches actions"| node_app
node_user -->|"selects"| node_browserfile
node_browserfile -->|"provides file"| node_app
node_app -->|"sets image and zoom"| node_viewer
node_viewer -->|"loads demo"| node_demo
node_viewer -->|"registers loader"| node_dicom
node_viewer -->|"renders image"| node_cornerstone
node_viewer -->|"submits marker"| node_app
node_app -->|"requests annotations"| node_backend
node_backend -->|"maps records"| node_schema
node_backend -->|"opens session"| node_dbsession
node_dbsession -->|"connects"| node_database
node_user -->|"clicks to annotate"| node_viewer
node_backend -.->|"can configure"| node_postgres

click node_bootstrap "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/main.tsx"
click node_app "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/App.tsx"
click node_toolbar "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Toolbar.tsx"
click node_panel "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/AnnotationPanel.tsx"
click node_viewer "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx"
click node_demo "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx"
click node_dicom "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx"
click node_backend "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/main.py"
click node_schema "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/models.py"
click node_dbsession "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/database.py"
click node_database "https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/annotations.db"

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_bootstrap,node_app,node_toolbar,node_panel,node_user toneBlue
class node_viewer,node_demo,node_dicom,node_postgres toneAmber
class node_backend toneMint
class node_schema,node_dbsession,node_database toneRose
class node_cornerstone,node_browserfile toneIndigo
```

## Components

### Viewer UI

- [React bootstrap](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [App workflow](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Image and zoom controls](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Toolbar.tsx): `frontend/src/components/Toolbar.tsx`
- [Marker list](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/AnnotationPanel.tsx): `frontend/src/components/AnnotationPanel.tsx`

### Image Viewing

- [Cornerstone viewer](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx): `frontend/src/components/Viewer.tsx`
- [Demo image generation](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx): `frontend/src/components/Viewer.tsx`
- [DICOM loading](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/frontend/src/components/Viewer.tsx): `frontend/src/components/Viewer.tsx`

### Annotation API

- [FastAPI endpoints](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/main.py): `backend/app/main.py`

### Persistence

- [Annotation ORM model](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database sessions](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/app/database.py): `backend/app/database.py`
- [Annotation database](https://github.com/chandana1515/medical-imaging-annotation-viewer/blob/main/backend/annotations.db): `backend/annotations.db`

### Other components

- **Viewer user**
- **Cornerstone runtime**
- **Local DICOM file**
- **PostgreSQL option**

## Connections

- Viewer user → App workflow: uses (evidence: `README.md`)
- React bootstrap → App workflow: renders (evidence: `frontend/src/main.tsx`)
- App workflow → Image and zoom controls: renders (evidence: `frontend/src/App.tsx`)
- App workflow → Marker list: renders (evidence: `frontend/src/App.tsx`)
- App workflow → Cornerstone viewer: renders (evidence: `frontend/src/App.tsx`)
- Image and zoom controls → App workflow: dispatches actions (evidence: `frontend/src/App.tsx`)
- Viewer user → Local DICOM file: selects (evidence: `README.md`)
- Local DICOM file → App workflow: provides file (evidence: `frontend/src/App.tsx`)
- App workflow → Cornerstone viewer: sets image and zoom (evidence: `frontend/src/App.tsx`)
- Cornerstone viewer → Demo image generation: loads demo (evidence: `frontend/src/components/Viewer.tsx`)
- Cornerstone viewer → DICOM loading: registers loader (evidence: `frontend/src/components/Viewer.tsx`)
- Cornerstone viewer → Cornerstone runtime: renders image (evidence: `frontend/src/components/Viewer.tsx`)
- Cornerstone viewer → App workflow: submits marker (evidence: `frontend/src/App.tsx`)
- App workflow → FastAPI endpoints: requests annotations (evidence: `frontend/src/App.tsx`)
- FastAPI endpoints → Annotation ORM model: maps records (evidence: `backend/app/main.py`)
- FastAPI endpoints → Database sessions: opens session (evidence: `backend/app/main.py`)
- Database sessions → Annotation database: connects (evidence: `backend/app/database.py`)
- Viewer user → Cornerstone viewer: clicks to annotate (evidence: `README.md`)
- FastAPI endpoints → PostgreSQL option: can configure (evidence: `README.md`)
