# abirshandilya07/cad-vision architecture

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

- Interactive diagram: https://gitdiagram.com/abirshandilya07/cad-vision
- Repository: https://github.com/abirshandilya07/cad-vision

## Overview

CAD-Vision is a clinical decision-support demo that predicts overall CAD and LAD/LCX/RCA stenosis from patient features, then presents probabilities and vessel-level risk in an interactive dashboard. Users enter or load a sample patient, run prediction, and can inspect an optional SHAP explanation and change a feature in a what-if control. The README also documents schema-driven inputs and a leakage-safe model-training workflow. Some frontend/API wiring and ML implementation details were not excerpted; uncertain connections are omitted or marked unverified.

Main entry points: [`frontend/src/App.tsx`](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/App.tsx) (Dashboard shell), [`backend/app/main.py`](https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/main.py) (FastAPI routes), [`backend/app/services/model_store.py`](https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/services/model_store.py) (Prediction and explanation), [`frontend/src/store/useAppStore.ts`](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/store/useAppStore.ts) (App state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Patient dashboard"]
  node_app["Dashboard shell<br/>[App.tsx]"]
  node_form["Patient form<br/>[PatientForm.tsx]"]
  node_store["App state<br/>[useAppStore.ts]"]
  node_api_client["API client<br/>[client.ts]"]
  node_heart["3D heart view<br/>[HeartScene.tsx]"]
  node_risk_color["Risk color mapping<br/>[riskColor.ts]"]
  node_vessel_paths["Vessel geometry paths<br/>[vesselPaths.ts]"]
  node_vitals["Vitals dashboard<br/>[VitalsTable.tsx]"]
  node_what_if["What-if control<br/>[WhatIfSlider.tsx]"]
end

subgraph group_service["Prediction service"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_model_store["Prediction and explanation<br/>[model_store.py]"]
  node_narrative["Explanation narrative<br/>[narrative.py]"]
end

subgraph group_ml["Model development"]
  node_training["Training and evaluation<br/>[train.py]"]
  node_prediction_code["ML prediction code<br/>[predict.py]"]
  node_config["Target configuration<br/>[config.py]"]
end

subgraph group_data["Clinical data"]
  node_schema["Feature schema"]
  node_samples["Example patients"]
  node_dataset["Z-Alizadeh Sani dataset"]
  node_artifacts[("Trained model artifacts")]
end

node_clinician(("Clinician / user"))

node_clinician -->|"uses"| node_app
node_app -->|"renders"| node_form
node_app -->|"dispatches actions"| node_store
node_form -->|"updates inputs"| node_store
node_app -->|"renders"| node_heart
node_app -->|"renders"| node_vitals
node_app -->|"renders"| node_what_if
node_heart -->|"gets risk colors"| node_risk_color
node_heart -->|"uses paths"| node_vessel_paths
node_store -->|"calls"| node_api_client
node_store -->|"provides state"| node_app
node_api_client -.->|"sends API requests"| node_api
node_api -->|"calls prediction service"| node_model_store
node_api -->|"serves feature definitions"| node_schema
node_api -->|"serves sample patients"| node_samples
node_model_store -->|"loads trained models"| node_artifacts
node_model_store -->|"loads feature contract"| node_schema
node_model_store -.->|"uses narrative logic"| node_narrative
node_training -.->|"trains from"| node_dataset
node_training -.->|"uses feature definitions"| node_schema
node_training -.->|"produces models"| node_artifacts
node_prediction_code -.->|"uses target settings"| node_config

click node_app "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/App.tsx"
click node_form "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/components/PatientForm.tsx"
click node_store "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/store/useAppStore.ts"
click node_api_client "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/api/client.ts"
click node_heart "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/scene/HeartScene.tsx"
click node_risk_color "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/scene/riskColor.ts"
click node_vessel_paths "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/scene/vesselPaths.ts"
click node_vitals "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/components/VitalsTable.tsx"
click node_what_if "https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/components/WhatIfSlider.tsx"
click node_api "https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/main.py"
click node_model_store "https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/services/model_store.py"
click node_narrative "https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/services/narrative.py"
click node_training "https://github.com/abirshandilya07/cad-vision/blob/main/ml/src/train.py"
click node_prediction_code "https://github.com/abirshandilya07/cad-vision/blob/main/ml/src/predict.py"
click node_config "https://github.com/abirshandilya07/cad-vision/blob/main/ml/config.py"
click node_schema "https://github.com/abirshandilya07/cad-vision/blob/main/ml/schema/feature_schema.json"
click node_samples "https://github.com/abirshandilya07/cad-vision/tree/main/data/samples"
click node_dataset "https://github.com/abirshandilya07/cad-vision/blob/main/data/raw/z_alizadeh_sani.xlsx"
click node_artifacts "https://github.com/abirshandilya07/cad-vision/tree/main/ml/artifacts/models"

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_form,node_store,node_api_client,node_heart,node_risk_color,node_vessel_paths,node_vitals,node_what_if,node_clinician toneBlue
class node_api,node_model_store,node_narrative toneAmber
class node_training,node_prediction_code,node_config toneMint
class node_schema,node_samples,node_dataset,node_artifacts toneRose
```

## Components

### Patient dashboard

- [Dashboard shell](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Patient form](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/components/PatientForm.tsx): `frontend/src/components/PatientForm.tsx`
- [App state](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/store/useAppStore.ts): `frontend/src/store/useAppStore.ts`
- [API client](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [3D heart view](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/scene/HeartScene.tsx): `frontend/src/scene/HeartScene.tsx`
- [Risk color mapping](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/scene/riskColor.ts): `frontend/src/scene/riskColor.ts`
- [Vessel geometry paths](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/scene/vesselPaths.ts): `frontend/src/scene/vesselPaths.ts`
- [Vitals dashboard](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/components/VitalsTable.tsx): `frontend/src/components/VitalsTable.tsx`
- [What-if control](https://github.com/abirshandilya07/cad-vision/blob/main/frontend/src/components/WhatIfSlider.tsx): `frontend/src/components/WhatIfSlider.tsx`

### Prediction service

- [FastAPI routes](https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/main.py): `backend/app/main.py`
- [Prediction and explanation](https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/services/model_store.py): `backend/app/services/model_store.py`
- [Explanation narrative](https://github.com/abirshandilya07/cad-vision/blob/main/backend/app/services/narrative.py): `backend/app/services/narrative.py`

### Model development

- [Training and evaluation](https://github.com/abirshandilya07/cad-vision/blob/main/ml/src/train.py): `ml/src/train.py`
- [ML prediction code](https://github.com/abirshandilya07/cad-vision/blob/main/ml/src/predict.py): `ml/src/predict.py`
- [Target configuration](https://github.com/abirshandilya07/cad-vision/blob/main/ml/config.py): `ml/config.py`

### Clinical data

- [Feature schema](https://github.com/abirshandilya07/cad-vision/blob/main/ml/schema/feature_schema.json): `ml/schema/feature_schema.json`
- [Example patients](https://github.com/abirshandilya07/cad-vision/tree/main/data/samples): `data/samples`
- [Z-Alizadeh Sani dataset](https://github.com/abirshandilya07/cad-vision/blob/main/data/raw/z_alizadeh_sani.xlsx): `data/raw/z_alizadeh_sani.xlsx`
- [Trained model artifacts](https://github.com/abirshandilya07/cad-vision/tree/main/ml/artifacts/models): `ml/artifacts/models`

### Other components

- **Clinician / user**

## Connections

- Clinician / user → Dashboard shell: uses (evidence: `README.md`)
- Dashboard shell → Patient form: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → App state: dispatches actions (evidence: `frontend/src/App.tsx`)
- Patient form → App state: updates inputs (evidence: `frontend/src/components/PatientForm.tsx`)
- Dashboard shell → 3D heart view: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → Vitals dashboard: renders (evidence: `frontend/src/App.tsx`)
- Dashboard shell → What-if control: renders (evidence: `frontend/src/App.tsx`)
- 3D heart view → Risk color mapping: gets risk colors (evidence: `frontend/src/scene/HeartScene.tsx`)
- 3D heart view → Vessel geometry paths: uses paths (evidence: `frontend/src/scene/HeartScene.tsx`)
- App state → API client: calls (evidence: `frontend/src/store/useAppStore.ts`)
- App state → Dashboard shell: provides state (evidence: `frontend/src/App.tsx`)
- API client → FastAPI routes: sends API requests
- FastAPI routes → Prediction and explanation: calls prediction service (evidence: `backend/app/main.py`)
- FastAPI routes → Feature schema: serves feature definitions (evidence: `README.md`)
- FastAPI routes → Example patients: serves sample patients (evidence: `README.md`)
- Prediction and explanation → Trained model artifacts: loads trained models (evidence: `backend/app/services/model_store.py`)
- Prediction and explanation → Feature schema: loads feature contract (evidence: `backend/app/services/model_store.py`)
- Prediction and explanation → Explanation narrative: uses narrative logic (evidence: `backend/app/services/model_store.py`)
- Training and evaluation → Z-Alizadeh Sani dataset: trains from (evidence: `README.md`)
- Training and evaluation → Feature schema: uses feature definitions (evidence: `README.md`)
- Training and evaluation → Trained model artifacts: produces models (evidence: `README.md`)
- ML prediction code → Target configuration: uses target settings
