# shreyas-bala/syntax-ai architecture

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

- Interactive diagram: https://gitdiagram.com/shreyas-bala/syntax-ai
- Repository: https://github.com/shreyas-bala/syntax-ai

## Overview

SYNTAX-AI turns coronary angiography into SYNTAX estimates and explainability outputs intended to support treatment decisions. The documented Streamlit workflow accepts LCA/RCA studies, reports scores and uncertainty, and explores dominance, segmentation, stenosis, and a stepwise decision tree. The sampled FastAPI backend exposes separate endpoints for scoring, dominance, and segmentation. Its module calls are visible in source; Streamlit capabilities are documented, but the relevant implementation sections are only partially excerpted, so those internal links are not asserted.

Main entry points: [`api/main.py`](https://github.com/shreyas-bala/syntax-ai/blob/main/api/main.py) (FastAPI endpoints), [`api/syntax_model.py`](https://github.com/shreyas-bala/syntax-ai/blob/main/api/syntax_model.py) (LCA/RCA models), [`api/segmentation_model.py`](https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py) (Vessel segmentation), [`backend/finaldeploy.py`](https://github.com/shreyas-bala/syntax-ai/blob/main/backend/finaldeploy.py) (Streamlit app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Clinical interface"]
  node_streamlit["Streamlit app<br/>[finaldeploy.py]"]
end

subgraph group_api["Inference API"]
  node_http_api["FastAPI endpoints<br/>[main.py]"]
  node_video_decode["Video decoding<br/>[utils.py]"]
end

subgraph group_score["SYNTAX scoring"]
  node_score_inference["Score inference<br/>[syntax_model.py]"]
  node_seq_models["LCA/RCA models<br/>[syntax_model.py]"]
  node_score_decision["Score aggregation<br/>[main.py]"]
  node_seq_weights["Sequence weights"]
end

subgraph group_explain["Explainability"]
  node_dominance["Dominance heuristic<br/>[utils.py]"]
  node_seg_inference["Vessel segmentation"]
  node_seg_weights["Segmentation weights"]
  node_seg_overlay["Segmentation overlay"]
  node_stenosis["Stenosis localization"]
end

node_clinician(("Cardiology user"))
node_api_client(("API client"))

node_clinician -->|"uploads studies"| node_streamlit
node_streamlit -->|"shows results"| node_clinician
node_api_client -.->|"submits studies"| node_http_api
node_http_api -->|"decodes videos"| node_video_decode
node_http_api -->|"runs scoring"| node_score_inference
node_score_inference -->|"evaluates model"| node_seq_models
node_http_api -->|"loads weights"| node_seq_models
node_seq_models -.->|"loads checkpoint"| node_seq_weights
node_http_api -->|"aggregates scores"| node_score_decision
node_http_api -->|"predicts dominance"| node_dominance
node_http_api -->|"runs segmentation"| node_seg_inference
node_http_api -->|"loads generator"| node_seg_inference
node_seg_inference -.->|"loads checkpoint"| node_seg_weights
node_http_api -->|"creates overlay"| node_seg_overlay
node_http_api -->|"localizes stenosis"| node_stenosis

click node_streamlit "https://github.com/shreyas-bala/syntax-ai/blob/main/backend/finaldeploy.py"
click node_http_api "https://github.com/shreyas-bala/syntax-ai/blob/main/api/main.py"
click node_video_decode "https://github.com/shreyas-bala/syntax-ai/blob/main/api/utils.py"
click node_dominance "https://github.com/shreyas-bala/syntax-ai/blob/main/api/utils.py"
click node_score_inference "https://github.com/shreyas-bala/syntax-ai/blob/main/api/syntax_model.py"
click node_seq_models "https://github.com/shreyas-bala/syntax-ai/blob/main/api/syntax_model.py"
click node_score_decision "https://github.com/shreyas-bala/syntax-ai/blob/main/api/main.py"
click node_seg_inference "https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py"
click node_seg_weights "https://github.com/shreyas-bala/syntax-ai/blob/main/models/patchgan_model/continued_best_patchgan.pth"
click node_seg_overlay "https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py"
click node_stenosis "https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py"
click node_seq_weights "https://github.com/shreyas-bala/syntax-ai/blob/main/models/seq_models/LeftBinSyntax_R3D_fold00_mean_post_best.pt"

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_streamlit,node_clinician,node_api_client toneBlue
class node_http_api,node_video_decode toneAmber
class node_score_inference,node_seq_models,node_score_decision,node_seq_weights toneMint
class node_dominance,node_seg_inference,node_seg_weights,node_seg_overlay,node_stenosis toneRose
```

## Components

### Clinical interface

- [Streamlit app](https://github.com/shreyas-bala/syntax-ai/blob/main/backend/finaldeploy.py): `backend/finaldeploy.py`

### Inference API

- [FastAPI endpoints](https://github.com/shreyas-bala/syntax-ai/blob/main/api/main.py): `api/main.py`
- [Video decoding](https://github.com/shreyas-bala/syntax-ai/blob/main/api/utils.py): `api/utils.py`

### SYNTAX scoring

- [Score inference](https://github.com/shreyas-bala/syntax-ai/blob/main/api/syntax_model.py): `api/syntax_model.py`
- [LCA/RCA models](https://github.com/shreyas-bala/syntax-ai/blob/main/api/syntax_model.py): `api/syntax_model.py`
- [Score aggregation](https://github.com/shreyas-bala/syntax-ai/blob/main/api/main.py): `api/main.py`
- [Sequence weights](https://github.com/shreyas-bala/syntax-ai/blob/main/models/seq_models/LeftBinSyntax_R3D_fold00_mean_post_best.pt): `models/seq_models/LeftBinSyntax_R3D_fold00_mean_post_best.pt`

### Explainability

- [Dominance heuristic](https://github.com/shreyas-bala/syntax-ai/blob/main/api/utils.py): `api/utils.py`
- [Vessel segmentation](https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py): `api/segmentation_model.py`
- [Segmentation weights](https://github.com/shreyas-bala/syntax-ai/blob/main/models/patchgan_model/continued_best_patchgan.pth): `models/patchgan_model/continued_best_patchgan.pth`
- [Segmentation overlay](https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py): `api/segmentation_model.py`
- [Stenosis localization](https://github.com/shreyas-bala/syntax-ai/blob/main/api/segmentation_model.py): `api/segmentation_model.py`

### Other components

- **Cardiology user**
- **API client**

## Connections

- Cardiology user → Streamlit app: uploads studies (evidence: `README.md`)
- Streamlit app → Cardiology user: shows results (evidence: `README.md`)
- API client → FastAPI endpoints: submits studies
- FastAPI endpoints → Video decoding: decodes videos (evidence: `api/main.py`)
- FastAPI endpoints → Score inference: runs scoring (evidence: `api/main.py`)
- Score inference → LCA/RCA models: evaluates model (evidence: `api/syntax_model.py`)
- FastAPI endpoints → LCA/RCA models: loads weights (evidence: `api/main.py`)
- LCA/RCA models → Sequence weights: loads checkpoint
- FastAPI endpoints → Score aggregation: aggregates scores (evidence: `api/main.py`)
- FastAPI endpoints → Dominance heuristic: predicts dominance (evidence: `api/main.py`)
- FastAPI endpoints → Vessel segmentation: runs segmentation (evidence: `api/main.py`)
- FastAPI endpoints → Vessel segmentation: loads generator (evidence: `api/main.py`)
- Vessel segmentation → Segmentation weights: loads checkpoint
- FastAPI endpoints → Segmentation overlay: creates overlay (evidence: `api/main.py`)
- FastAPI endpoints → Stenosis localization: localizes stenosis (evidence: `api/main.py`)
