# tanyax1205/healthprediction architecture

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

- Interactive diagram: https://gitdiagram.com/tanyax1205/healthprediction
- Repository: https://github.com/tanyax1205/healthprediction

## Overview

MultiDx is a multi-disease screening product: users select a task, enter clinical or symptom data, receive a model-based risk/differential with explanation, and can review performance, batch results, or local history. The React dashboard calls a FastAPI service, which loads trained artifacts at startup and exposes task schemas, predictions, metrics, and system status. Separately, the ML package loads datasets, trains and evaluates task models, and exports artifacts consumed by the service. The legacy Streamlit app is documented as reference-only. Some frontend and backend subsystems are included from README capabilities; their internal wiring was not sampled.

Main entry points: [`ml/train.py`](https://github.com/tanyax1205/healthprediction/blob/main/ml/train.py) (Training orchestration), [`backend/app/services/registry.py`](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/registry.py) (Artifact registry), [`backend/app/main.py`](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/services/predict.py`](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/predict.py) (Prediction service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Screening dashboard"]
  node_app["Dashboard app<br/>[App.tsx]"]
  node_pages["Screening pages"]
  node_form["Dynamic predictor form"]
  node_results["Risk and SHAP results"]
  node_batch["Batch screening<br/>[Batch.tsx]"]
  node_history[("Local history<br/>[history.ts]")]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Prediction API"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_task_routes["Task schema routes<br/>[tasks.py]"]
  node_predict_routes["Prediction routes<br/>[predict.py]"]
  node_metrics_routes["Metrics routes<br/>[metrics.py]"]
  node_system_routes["System routes<br/>[system.py]"]
  node_registry["Artifact registry<br/>[registry.py]"]
  node_prediction["Prediction service<br/>[predict.py]"]
  node_csv["CSV processing<br/>[csv.py]"]
end

subgraph group_ml["Model pipeline"]
  node_artifacts[("Trained artifacts")]
  node_config["Task and model configuration<br/>[config.py]"]
  node_loading["Dataset loading<br/>[data_loader.py]"]
  node_features["Feature schemas<br/>[features.py]"]
  node_training["Training orchestration<br/>[train.py]"]
  node_preprocessing["Preprocessing pipelines<br/>[preprocessing.py]"]
  node_models["Model implementations<br/>[models.py]"]
  node_evaluation["Evaluation and calibration<br/>[evaluate.py]"]
  node_export["Results export<br/>[export.py]"]
end

subgraph group_clinical["Clinical interpretation"]
  node_units["Clinical unit conversion<br/>[units.py]"]
  node_rules["Clinical rule sets"]
  node_explanation["SHAP explanations<br/>[explain.py]"]
end

node_user(("Clinician or user"))

node_user -->|"uses"| node_pages
node_pages -->|"opens predictor"| node_form
node_form -->|"submits inputs"| node_api_client
node_api_client -->|"requests prediction"| node_predict_routes
node_api_client -->|"loads task schemas"| node_task_routes
node_predict_routes -->|"invokes"| node_prediction
node_predict_routes -->|"processes batch CSV"| node_csv
node_task_routes -->|"reads task schemas"| node_registry
node_metrics_routes -->|"reads metrics"| node_registry
node_system_routes -->|"reads versions"| node_registry
node_api_app -->|"registers router"| node_task_routes
node_api_app -->|"registers router"| node_predict_routes
node_api_app -->|"registers router"| node_metrics_routes
node_api_app -->|"registers router"| node_system_routes
node_api_app -->|"loads at startup"| node_registry
node_registry -->|"loads models"| node_artifacts
node_registry -->|"builds schemas"| node_features
node_prediction -->|"converts units"| node_units
node_prediction -->|"evaluates clinical rules"| node_rules
node_prediction -->|"generates SHAP"| node_explanation
node_prediction -->|"returns interpretation"| node_results
node_pages -->|"requests performance data"| node_metrics_routes
node_batch -->|"uploads cohort CSV"| node_api_client
node_pages -->|"browses screenings"| node_history
node_training -->|"loads datasets"| node_loading
node_training -->|"builds pipelines"| node_preprocessing
node_training -->|"fits candidates"| node_models
node_training -->|"evaluates models"| node_evaluation
node_training -->|"uses task settings"| node_config
node_training -->|"saves models"| node_artifacts
node_loading -->|"uses dataset settings"| node_config
node_models -->|"uses model settings"| node_config
node_preprocessing -->|"uses task settings"| node_config
node_preprocessing -->|"builds model pipeline"| node_models
node_export -.->|"exports results"| node_artifacts

click node_app "https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/App.tsx"
click node_pages "https://github.com/tanyax1205/healthprediction/tree/main/frontend/src/pages"
click node_form "https://github.com/tanyax1205/healthprediction/tree/main/frontend/src/components/predictor"
click node_results "https://github.com/tanyax1205/healthprediction/tree/main/frontend/src/components/result"
click node_batch "https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/pages/Batch.tsx"
click node_history "https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/store/history.ts"
click node_api_client "https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/lib/api.ts"
click node_api_app "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/main.py"
click node_task_routes "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/tasks.py"
click node_predict_routes "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/predict.py"
click node_metrics_routes "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/metrics.py"
click node_system_routes "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/system.py"
click node_registry "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/registry.py"
click node_prediction "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/predict.py"
click node_csv "https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/csv.py"
click node_config "https://github.com/tanyax1205/healthprediction/blob/main/ml/config.py"
click node_loading "https://github.com/tanyax1205/healthprediction/blob/main/ml/data_loader.py"
click node_features "https://github.com/tanyax1205/healthprediction/blob/main/ml/schema/features.py"
click node_training "https://github.com/tanyax1205/healthprediction/blob/main/ml/train.py"
click node_preprocessing "https://github.com/tanyax1205/healthprediction/blob/main/ml/preprocessing.py"
click node_models "https://github.com/tanyax1205/healthprediction/blob/main/ml/models.py"
click node_evaluation "https://github.com/tanyax1205/healthprediction/blob/main/ml/evaluate.py"
click node_export "https://github.com/tanyax1205/healthprediction/blob/main/ml/export.py"
click node_units "https://github.com/tanyax1205/healthprediction/blob/main/ml/schema/units.py"
click node_rules "https://github.com/tanyax1205/healthprediction/tree/main/ml/rules"
click node_explanation "https://github.com/tanyax1205/healthprediction/blob/main/ml/explain.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,node_pages,node_form,node_results,node_batch,node_history,node_api_client,node_user toneBlue
class node_api_app,node_task_routes,node_predict_routes,node_metrics_routes,node_system_routes,node_registry,node_prediction,node_csv toneAmber
class node_artifacts,node_config,node_loading,node_features,node_training,node_preprocessing,node_models,node_evaluation,node_export toneMint
class node_units,node_rules,node_explanation toneRose
```

## Components

### Screening dashboard

- [Dashboard app](https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Screening pages](https://github.com/tanyax1205/healthprediction/tree/main/frontend/src/pages): `frontend/src/pages`
- [Dynamic predictor form](https://github.com/tanyax1205/healthprediction/tree/main/frontend/src/components/predictor): `frontend/src/components/predictor`
- [Risk and SHAP results](https://github.com/tanyax1205/healthprediction/tree/main/frontend/src/components/result): `frontend/src/components/result`
- [Batch screening](https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/pages/Batch.tsx): `frontend/src/pages/Batch.tsx`
- [Local history](https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/store/history.ts): `frontend/src/store/history.ts`
- [API client](https://github.com/tanyax1205/healthprediction/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Prediction API

- [FastAPI application](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/main.py): `backend/app/main.py`
- [Task schema routes](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/tasks.py): `backend/app/api/routes/tasks.py`
- [Prediction routes](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/predict.py): `backend/app/api/routes/predict.py`
- [Metrics routes](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/metrics.py): `backend/app/api/routes/metrics.py`
- [System routes](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/api/routes/system.py): `backend/app/api/routes/system.py`
- [Artifact registry](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/registry.py): `backend/app/services/registry.py`
- [Prediction service](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/predict.py): `backend/app/services/predict.py`
- [CSV processing](https://github.com/tanyax1205/healthprediction/blob/main/backend/app/services/csv.py): `backend/app/services/csv.py`

### Model pipeline

- **Trained artifacts**
- [Task and model configuration](https://github.com/tanyax1205/healthprediction/blob/main/ml/config.py): `ml/config.py`
- [Dataset loading](https://github.com/tanyax1205/healthprediction/blob/main/ml/data_loader.py): `ml/data_loader.py`
- [Feature schemas](https://github.com/tanyax1205/healthprediction/blob/main/ml/schema/features.py): `ml/schema/features.py`
- [Training orchestration](https://github.com/tanyax1205/healthprediction/blob/main/ml/train.py): `ml/train.py`
- [Preprocessing pipelines](https://github.com/tanyax1205/healthprediction/blob/main/ml/preprocessing.py): `ml/preprocessing.py`
- [Model implementations](https://github.com/tanyax1205/healthprediction/blob/main/ml/models.py): `ml/models.py`
- [Evaluation and calibration](https://github.com/tanyax1205/healthprediction/blob/main/ml/evaluate.py): `ml/evaluate.py`
- [Results export](https://github.com/tanyax1205/healthprediction/blob/main/ml/export.py): `ml/export.py`

### Clinical interpretation

- [Clinical unit conversion](https://github.com/tanyax1205/healthprediction/blob/main/ml/schema/units.py): `ml/schema/units.py`
- [Clinical rule sets](https://github.com/tanyax1205/healthprediction/tree/main/ml/rules): `ml/rules`
- [SHAP explanations](https://github.com/tanyax1205/healthprediction/blob/main/ml/explain.py): `ml/explain.py`

### Other components

- **Clinician or user**

## Connections

- Clinician or user → Screening pages: uses (evidence: `README.md`)
- Screening pages → Dynamic predictor form: opens predictor (evidence: `README.md`)
- Dynamic predictor form → API client: submits inputs (evidence: `README.md`)
- API client → Prediction routes: requests prediction (evidence: `README.md`)
- API client → Task schema routes: loads task schemas (evidence: `README.md`)
- Prediction routes → Prediction service: invokes (evidence: `backend/app/api/routes/predict.py`)
- Prediction routes → CSV processing: processes batch CSV (evidence: `backend/app/api/routes/predict.py`)
- Task schema routes → Artifact registry: reads task schemas (evidence: `backend/app/api/routes/tasks.py`)
- Metrics routes → Artifact registry: reads metrics (evidence: `backend/app/api/routes/metrics.py`)
- System routes → Artifact registry: reads versions (evidence: `backend/app/api/routes/system.py`)
- FastAPI application → Task schema routes: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Prediction routes: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Metrics routes: registers router (evidence: `backend/app/main.py`)
- FastAPI application → System routes: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Artifact registry: loads at startup (evidence: `backend/app/main.py`)
- Artifact registry → Trained artifacts: loads models (evidence: `backend/app/services/registry.py`)
- Artifact registry → Feature schemas: builds schemas (evidence: `backend/app/services/registry.py`)
- Prediction service → Clinical unit conversion: converts units (evidence: `backend/app/services/predict.py`)
- Prediction service → Clinical rule sets: evaluates clinical rules (evidence: `backend/app/services/predict.py`)
- Prediction service → SHAP explanations: generates SHAP (evidence: `backend/app/services/predict.py`)
- Prediction service → Risk and SHAP results: returns interpretation (evidence: `README.md`)
- Screening pages → Metrics routes: requests performance data (evidence: `README.md`)
- Batch screening → API client: uploads cohort CSV (evidence: `README.md`)
- Screening pages → Local history: browses screenings (evidence: `README.md`)
- Training orchestration → Dataset loading: loads datasets (evidence: `ml/train.py`)
- Training orchestration → Preprocessing pipelines: builds pipelines (evidence: `ml/train.py`)
- Training orchestration → Model implementations: fits candidates (evidence: `ml/train.py`)
- Training orchestration → Evaluation and calibration: evaluates models (evidence: `ml/train.py`)
- Training orchestration → Task and model configuration: uses task settings (evidence: `ml/train.py`)
- Training orchestration → Trained artifacts: saves models (evidence: `README.md`)
- Dataset loading → Task and model configuration: uses dataset settings (evidence: `ml/data_loader.py`)
- Model implementations → Task and model configuration: uses model settings (evidence: `ml/models.py`)
- Preprocessing pipelines → Task and model configuration: uses task settings (evidence: `ml/preprocessing.py`)
- Preprocessing pipelines → Model implementations: builds model pipeline (evidence: `ml/preprocessing.py`)
- Results export → Trained artifacts: exports results (evidence: `README.md`)
