# sreansh-sudo/panacea architecture

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

- Interactive diagram: https://gitdiagram.com/sreansh-sudo/panacea
- Repository: https://github.com/sreansh-sudo/panacea

## Overview

PANACEA is a research clinical early-warning application: it turns ICU vital-sign records into engineered features, trains a risk model, and serves patient risk summaries and per-patient SHAP explanations through a dashboard and API. The README documents health, patient-list, patient-detail, and dashboard capabilities; the sampled sources show the prediction and dashboard paths. Health routing is documented but its implementation was not sampled, so its internal behavior is not expanded. Training writes to `models/` in sampled code, while runtime settings load from `artifacts/`; these artifact locations do not visibly align.

Main entry points: [`app/main.py`](https://github.com/sreansh-sudo/panacea/blob/master/app/main.py) (FastAPI application), [`app/api/v1/predict.py`](https://github.com/sreansh-sudo/panacea/blob/master/app/api/v1/predict.py) (Patient predictions), [`app/static/script.js`](https://github.com/sreansh-sudo/panacea/blob/master/app/static/script.js) (Dashboard behavior), [`app/core/model.py`](https://github.com/sreansh-sudo/panacea/blob/master/app/core/model.py) (Model and data loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_feature_pipeline["Vital features"]
  node_feature_set[("Feature dataset")]
end

subgraph group_model["Model lifecycle"]
  node_trainer["Model training<br/>[train_model.py]"]
  node_artifacts["Model artifacts"]
  node_model_loader["Model and data loader<br/>[model.py]"]
end

subgraph group_api["API service"]
  node_settings["App settings<br/>[config.py]"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_predict["Patient predictions<br/>[predict.py]"]
  node_schemas["Response schemas<br/>[response.py]"]
  node_health["Health endpoint<br/>[health.py]"]
end

subgraph group_ui["Monitoring interface"]
  node_dashboard["Dashboard page<br/>[dashboard.html]"]
  node_browser_logic["Dashboard behavior<br/>[script.js]"]
  node_styles["Dashboard styles<br/>[styles.css]"]
end

node_clinician(("Clinical staff"))
node_mimic[("MIMIC-III data")]

node_mimic -->|"reads vitals"| node_feature_pipeline
node_feature_pipeline -->|"writes features"| node_feature_set
node_feature_set -->|"trains on"| node_trainer
node_trainer -->|"writes model"| node_artifacts
node_settings -->|"provides paths"| node_model_loader
node_artifacts -->|"loads artifacts"| node_model_loader
node_feature_set -->|"loads features"| node_model_loader
node_fastapi -->|"mounts router"| node_health
node_fastapi -->|"mounts router"| node_predict
node_fastapi -->|"serves page"| node_dashboard
node_fastapi -->|"serves static"| node_browser_logic
node_clinician -->|"views dashboard"| node_browser_logic
node_browser_logic -->|"requests patients"| node_predict
node_predict -->|"uses loaded state"| node_model_loader
node_predict -->|"validates responses"| node_schemas
node_browser_logic -.->|"checks status"| node_health

click node_feature_pipeline "https://github.com/sreansh-sudo/panacea/blob/master/pipeline/mimic3_feature_pipeline.py"
click node_trainer "https://github.com/sreansh-sudo/panacea/blob/master/pipeline/train_model.py"
click node_settings "https://github.com/sreansh-sudo/panacea/blob/master/app/config.py"
click node_model_loader "https://github.com/sreansh-sudo/panacea/blob/master/app/core/model.py"
click node_fastapi "https://github.com/sreansh-sudo/panacea/blob/master/app/main.py"
click node_predict "https://github.com/sreansh-sudo/panacea/blob/master/app/api/v1/predict.py"
click node_schemas "https://github.com/sreansh-sudo/panacea/blob/master/app/schemas/response.py"
click node_health "https://github.com/sreansh-sudo/panacea/blob/master/app/api/v1/health.py"
click node_dashboard "https://github.com/sreansh-sudo/panacea/blob/master/app/templates/dashboard.html"
click node_browser_logic "https://github.com/sreansh-sudo/panacea/blob/master/app/static/script.js"
click node_styles "https://github.com/sreansh-sudo/panacea/blob/master/app/static/styles.css"

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_feature_pipeline,node_feature_set toneBlue
class node_trainer,node_artifacts,node_model_loader,node_mimic toneAmber
class node_settings,node_fastapi,node_predict,node_schemas,node_health toneMint
class node_dashboard,node_browser_logic,node_styles toneRose
class node_clinician toneIndigo
```

## Components

### Data preparation

- [Vital features](https://github.com/sreansh-sudo/panacea/blob/master/pipeline/mimic3_feature_pipeline.py): `pipeline/mimic3_feature_pipeline.py`
- **Feature dataset**

### Model lifecycle

- [Model training](https://github.com/sreansh-sudo/panacea/blob/master/pipeline/train_model.py): `pipeline/train_model.py`
- **Model artifacts**
- [Model and data loader](https://github.com/sreansh-sudo/panacea/blob/master/app/core/model.py): `app/core/model.py`

### API service

- [App settings](https://github.com/sreansh-sudo/panacea/blob/master/app/config.py): `app/config.py`
- [FastAPI application](https://github.com/sreansh-sudo/panacea/blob/master/app/main.py): `app/main.py`
- [Patient predictions](https://github.com/sreansh-sudo/panacea/blob/master/app/api/v1/predict.py): `app/api/v1/predict.py`
- [Response schemas](https://github.com/sreansh-sudo/panacea/blob/master/app/schemas/response.py): `app/schemas/response.py`
- [Health endpoint](https://github.com/sreansh-sudo/panacea/blob/master/app/api/v1/health.py): `app/api/v1/health.py`

### Monitoring interface

- [Dashboard page](https://github.com/sreansh-sudo/panacea/blob/master/app/templates/dashboard.html): `app/templates/dashboard.html`
- [Dashboard behavior](https://github.com/sreansh-sudo/panacea/blob/master/app/static/script.js): `app/static/script.js`
- [Dashboard styles](https://github.com/sreansh-sudo/panacea/blob/master/app/static/styles.css): `app/static/styles.css`

### Other components

- **Clinical staff**
- **MIMIC-III data**

## Connections

- MIMIC-III data → Vital features: reads vitals
- Vital features → Feature dataset: writes features
- Feature dataset → Model training: trains on
- Model training → Model artifacts: writes model
- App settings → Model and data loader: provides paths
- Model artifacts → Model and data loader: loads artifacts
- Feature dataset → Model and data loader: loads features
- FastAPI application → Health endpoint: mounts router
- FastAPI application → Patient predictions: mounts router
- FastAPI application → Dashboard page: serves page
- FastAPI application → Dashboard behavior: serves static
- Clinical staff → Dashboard behavior: views dashboard
- Dashboard behavior → Patient predictions: requests patients
- Patient predictions → Model and data loader: uses loaded state
- Patient predictions → Response schemas: validates responses
- Dashboard behavior → Health endpoint: checks status
