# milefisher/kneexpert architecture

> Architecture diagram of the GitHub repository milefisher/kneexpert, 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/milefisher/kneexpert
- Repository: https://github.com/milefisher/kneexpert

## Overview

KneeXpert is a clinical knee-osteoarthritis diagnostics platform: clinicians manage patients, submit X-ray images or MRI volumes for inference, and review diagnostic results and reports. The React UI communicates with a separate FastAPI service over REST. The backend provides X-ray ensemble predictions with Grad-CAM and an MRI volume-to-grade pipeline, alongside structured clinical feedback and model-compute reporting. The graph preserves the documented admin, patient, and reporting areas; unsampled frontend internals are represented at their supported source paths.

Main entry points: [`backend/mri/pipeline.py`](https://github.com/milefisher/kneexpert/blob/main/backend/mri/pipeline.py) (MRI inference pipeline), [`frontend/src/App.tsx`](https://github.com/milefisher/kneexpert/blob/main/frontend/src/App.tsx) (App routes), [`backend/app.py`](https://github.com/milefisher/kneexpert/blob/main/backend/app.py) (FastAPI endpoints), [`backend/xray/ensemble.py`](https://github.com/milefisher/kneexpert/blob/main/backend/xray/ensemble.py) (X-ray ensemble)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clinical_ui["Clinical UI"]
  node_app_routes["App routes<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[DashboardPage.tsx]"]
  node_patients["Patient management<br/>[PatientsPage.tsx]"]
  node_diagnostics["Diagnostics workspace"]
  node_reports["Report hub<br/>[ReportsHubPage.tsx]"]
  node_report_detail["Report detail"]
  node_admin["Admin console<br/>[AdminPage.tsx]"]
  node_diagnostic_api["Diagnostic API client<br/>[diagnosticApi.ts]"]
end

subgraph group_api_services["API services"]
  node_backend_api["FastAPI endpoints<br/>[app.py]"]
  node_profiler["Model profiler<br/>[model_profiler.py]"]
end

subgraph group_xray_inference["X-ray inference"]
  node_xray_ensemble["X-ray ensemble<br/>[ensemble.py]"]
  node_xray_models["X-ray model loader<br/>[loader.py]"]
  node_xray_cam["X-ray Grad-CAM<br/>[gradcam.py]"]
end

subgraph group_mri_inference["MRI inference"]
  node_mri_pipeline["MRI inference pipeline<br/>[pipeline.py]"]
  node_volume_io["MRI volume loading<br/>[volume_io.py]"]
  node_mri_preprocess["Slice preprocessing<br/>[preprocess.py]"]
  node_macs["MACS-Net cleanup<br/>[macs_net.py]"]
  node_deit["DeiT classification<br/>[deit_classifier.py]"]
  node_mri_gradcam["MRI Grad-CAM<br/>[gradcam.py]"]
  node_label_summary["MRI label categories<br/>[label_summary.py]"]
end

subgraph group_clinical_logic["Clinical logic"]
  node_clinical_feedback["Clinical feedback<br/>[feedback_engine.py]"]
  node_shared_feedback["Shared findings"]
end

node_clinician(("Clinician"))

node_clinician -->|"uses"| node_app_routes
node_app_routes -->|"routes"| node_dashboard
node_app_routes -->|"routes"| node_patients
node_app_routes -->|"routes"| node_diagnostics
node_app_routes -->|"routes"| node_reports
node_app_routes -->|"routes"| node_report_detail
node_app_routes -->|"routes"| node_admin
node_diagnostics -.->|"requests analysis"| node_diagnostic_api
node_diagnostic_api -->|"calls REST"| node_backend_api
node_backend_api -->|"dispatches X-ray"| node_xray_ensemble
node_backend_api -->|"dispatches MRI"| node_mri_pipeline
node_backend_api -->|"generates feedback"| node_clinical_feedback
node_backend_api -->|"gets compute costs"| node_profiler
node_xray_ensemble -->|"loads models"| node_xray_models
node_xray_ensemble -->|"generates overlays"| node_xray_cam
node_xray_ensemble -->|"gets findings"| node_shared_feedback
node_mri_pipeline -->|"loads volumes"| node_volume_io
node_mri_pipeline -->|"prepares slices"| node_mri_preprocess
node_mri_pipeline -->|"cleans slices"| node_macs
node_mri_pipeline -->|"classifies slices"| node_deit
node_mri_pipeline -->|"generates overlays"| node_mri_gradcam
node_mri_pipeline -->|"resolves labels"| node_label_summary
node_mri_pipeline -->|"gets findings"| node_shared_feedback
node_shared_feedback -->|"delegates findings"| node_clinical_feedback

click node_app_routes "https://github.com/milefisher/kneexpert/blob/main/frontend/src/App.tsx"
click node_dashboard "https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/DashboardPage.tsx"
click node_patients "https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/PatientsPage.tsx"
click node_diagnostics "https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/DiagnosticsPage.tsx"
click node_reports "https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/ReportsHubPage.tsx"
click node_report_detail "https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/ReportDetailPage.tsx"
click node_admin "https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/AdminPage.tsx"
click node_diagnostic_api "https://github.com/milefisher/kneexpert/blob/main/frontend/src/lib/diagnosticApi.ts"
click node_backend_api "https://github.com/milefisher/kneexpert/blob/main/backend/app.py"
click node_xray_ensemble "https://github.com/milefisher/kneexpert/blob/main/backend/xray/ensemble.py"
click node_xray_models "https://github.com/milefisher/kneexpert/blob/main/backend/xray/loader.py"
click node_xray_cam "https://github.com/milefisher/kneexpert/blob/main/backend/xray/gradcam.py"
click node_mri_pipeline "https://github.com/milefisher/kneexpert/blob/main/backend/mri/pipeline.py"
click node_volume_io "https://github.com/milefisher/kneexpert/blob/main/backend/mri/volume_io.py"
click node_mri_preprocess "https://github.com/milefisher/kneexpert/blob/main/backend/mri/preprocess.py"
click node_macs "https://github.com/milefisher/kneexpert/blob/main/backend/mri/macs_net.py"
click node_deit "https://github.com/milefisher/kneexpert/blob/main/backend/mri/deit_classifier.py"
click node_mri_gradcam "https://github.com/milefisher/kneexpert/blob/main/backend/mri/gradcam.py"
click node_label_summary "https://github.com/milefisher/kneexpert/blob/main/backend/mri/label_summary.py"
click node_clinical_feedback "https://github.com/milefisher/kneexpert/blob/main/backend/feedback_engine.py"
click node_shared_feedback "https://github.com/milefisher/kneexpert/blob/main/backend/shared/clinical_feedback.py"
click node_profiler "https://github.com/milefisher/kneexpert/blob/main/backend/model_profiler.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_routes,node_dashboard,node_patients,node_diagnostics,node_reports,node_report_detail,node_admin,node_diagnostic_api toneBlue
class node_backend_api,node_profiler toneAmber
class node_xray_ensemble,node_xray_models,node_xray_cam toneMint
class node_mri_pipeline,node_volume_io,node_mri_preprocess,node_macs,node_deit,node_mri_gradcam,node_label_summary toneRose
class node_clinical_feedback,node_shared_feedback,node_clinician toneIndigo
```

## Components

### Clinical UI

- [App routes](https://github.com/milefisher/kneexpert/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard](https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [Patient management](https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/PatientsPage.tsx): `frontend/src/pages/PatientsPage.tsx`
- [Diagnostics workspace](https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/DiagnosticsPage.tsx): `frontend/src/pages/DiagnosticsPage.tsx`
- [Report hub](https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/ReportsHubPage.tsx): `frontend/src/pages/ReportsHubPage.tsx`
- [Report detail](https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/ReportDetailPage.tsx): `frontend/src/pages/ReportDetailPage.tsx`
- [Admin console](https://github.com/milefisher/kneexpert/blob/main/frontend/src/pages/AdminPage.tsx): `frontend/src/pages/AdminPage.tsx`
- [Diagnostic API client](https://github.com/milefisher/kneexpert/blob/main/frontend/src/lib/diagnosticApi.ts): `frontend/src/lib/diagnosticApi.ts`

### API services

- [FastAPI endpoints](https://github.com/milefisher/kneexpert/blob/main/backend/app.py): `backend/app.py`
- [Model profiler](https://github.com/milefisher/kneexpert/blob/main/backend/model_profiler.py): `backend/model_profiler.py`

### X-ray inference

- [X-ray ensemble](https://github.com/milefisher/kneexpert/blob/main/backend/xray/ensemble.py): `backend/xray/ensemble.py`
- [X-ray model loader](https://github.com/milefisher/kneexpert/blob/main/backend/xray/loader.py): `backend/xray/loader.py`
- [X-ray Grad-CAM](https://github.com/milefisher/kneexpert/blob/main/backend/xray/gradcam.py): `backend/xray/gradcam.py`

### MRI inference

- [MRI inference pipeline](https://github.com/milefisher/kneexpert/blob/main/backend/mri/pipeline.py): `backend/mri/pipeline.py`
- [MRI volume loading](https://github.com/milefisher/kneexpert/blob/main/backend/mri/volume_io.py): `backend/mri/volume_io.py`
- [Slice preprocessing](https://github.com/milefisher/kneexpert/blob/main/backend/mri/preprocess.py): `backend/mri/preprocess.py`
- [MACS-Net cleanup](https://github.com/milefisher/kneexpert/blob/main/backend/mri/macs_net.py): `backend/mri/macs_net.py`
- [DeiT classification](https://github.com/milefisher/kneexpert/blob/main/backend/mri/deit_classifier.py): `backend/mri/deit_classifier.py`
- [MRI Grad-CAM](https://github.com/milefisher/kneexpert/blob/main/backend/mri/gradcam.py): `backend/mri/gradcam.py`
- [MRI label categories](https://github.com/milefisher/kneexpert/blob/main/backend/mri/label_summary.py): `backend/mri/label_summary.py`

### Clinical logic

- [Clinical feedback](https://github.com/milefisher/kneexpert/blob/main/backend/feedback_engine.py): `backend/feedback_engine.py`
- [Shared findings](https://github.com/milefisher/kneexpert/blob/main/backend/shared/clinical_feedback.py): `backend/shared/clinical_feedback.py`

### Other components

- **Clinician**

## Connections

- Clinician → App routes: uses (evidence: `frontend/src/App.tsx`)
- App routes → Dashboard: routes (evidence: `frontend/src/App.tsx`)
- App routes → Patient management: routes (evidence: `frontend/src/App.tsx`)
- App routes → Diagnostics workspace: routes (evidence: `frontend/src/App.tsx`)
- App routes → Report hub: routes (evidence: `frontend/src/App.tsx`)
- App routes → Report detail: routes (evidence: `frontend/src/App.tsx`)
- App routes → Admin console: routes (evidence: `frontend/src/App.tsx`)
- Diagnostics workspace → Diagnostic API client: requests analysis
- Diagnostic API client → FastAPI endpoints: calls REST (evidence: `README.md`)
- FastAPI endpoints → X-ray ensemble: dispatches X-ray (evidence: `backend/app.py`)
- FastAPI endpoints → MRI inference pipeline: dispatches MRI (evidence: `backend/app.py`)
- FastAPI endpoints → Clinical feedback: generates feedback (evidence: `backend/app.py`)
- FastAPI endpoints → Model profiler: gets compute costs (evidence: `backend/app.py`)
- X-ray ensemble → X-ray model loader: loads models (evidence: `backend/xray/ensemble.py`)
- X-ray ensemble → X-ray Grad-CAM: generates overlays (evidence: `backend/xray/ensemble.py`)
- X-ray ensemble → Shared findings: gets findings (evidence: `backend/xray/ensemble.py`)
- MRI inference pipeline → MRI volume loading: loads volumes (evidence: `backend/mri/pipeline.py`)
- MRI inference pipeline → Slice preprocessing: prepares slices (evidence: `backend/mri/pipeline.py`)
- MRI inference pipeline → MACS-Net cleanup: cleans slices (evidence: `backend/mri/pipeline.py`)
- MRI inference pipeline → DeiT classification: classifies slices (evidence: `backend/mri/pipeline.py`)
- MRI inference pipeline → MRI Grad-CAM: generates overlays (evidence: `backend/mri/pipeline.py`)
- MRI inference pipeline → MRI label categories: resolves labels (evidence: `backend/mri/pipeline.py`)
- MRI inference pipeline → Shared findings: gets findings (evidence: `backend/mri/pipeline.py`)
- Shared findings → Clinical feedback: delegates findings (evidence: `backend/shared/clinical_feedback.py`)
