# aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data architecture

> Architecture diagram of the GitHub repository aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data
- Repository: https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data

## Overview

This is a Streamlit clinical decision-support app for hourly sepsis-risk prediction, with a separate Airflow retraining product. The user workflow runs from patient-file upload and validation through manifest-selected inference to risk timelines, escalation cues, and a generated narrative; other app branches provide a multi-patient watchlist and model monitoring. Retraining covers batch ingestion, data quality, feature preparation, model training/evaluation, and registry promotion. The index and excerpts support the named modules and some calls; unsampled training and monitoring internals are represented conservatively, with uncertain connections omitted.

Main entry points: [`dags/sepsis_retraining_dag.py`](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/dags/sepsis_retraining_dag.py) (Retraining orchestrator), [`app/pages/1_predict.py`](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/1_predict.py) (Prediction page), [`app/pages/2_unit_watchlist.py`](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/2_unit_watchlist.py) (Unit watchlist), [`src/inference/predictor.py`](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/predictor.py) (Prediction runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clinical_app["Clinical app"]
  node_predict_page["Prediction page<br/>[1_predict.py]"]
  node_upload["Upload UI<br/>[upload.py]"]
  node_validation_panel["Validation panel"]
  node_results["Results view<br/>[results_view.py]"]
  node_checklist["Care checklist"]
  node_watchlist["Unit watchlist"]
  node_monitoring_page["Model monitoring"]
end

subgraph group_inference["Prediction runtime"]
  node_validator["Input validator<br/>[validator.py]"]
  node_predictor["Prediction runner<br/>[predictor.py]"]
  node_model_loader["Model loader<br/>[loader.py]"]
  node_pipeline_dispatch["Inference pipelines"]
  node_prediction_log["Prediction logging<br/>[logger.py]"]
  node_monitoring["Usage monitoring<br/>[monitoring.py]"]
end

subgraph group_narrative["Narrative generation"]
  node_narrative_panel["Narrative panel<br/>[narrative_panel.py]"]
  node_narrative_service["Narrative service<br/>[service.py]"]
  node_summary["Prediction summary<br/>[context.py]"]
  node_providers["Narrative providers<br/>[providers.py]"]
end

subgraph group_retraining["Model retraining"]
  node_retraining_dag["Retraining orchestrator"]
  node_batch_detection["Batch detection<br/>[batch_detector.py]"]
  node_bronze["Bronze ingestion<br/>[bronze_pipeline.py]"]
  node_silver["Silver processing<br/>[silver_pipeline.py]"]
  node_quality_gate["Data quality gate<br/>[quality_gate.py]"]
  node_gold["Gold features<br/>[gold_pipeline.py]"]
  node_training["Training workflow<br/>[trainer.py]"]
  node_cv_search["Cross-validation search<br/>[cv_search.py]"]
  node_evaluation["Model evaluation<br/>[evaluator.py]"]
  node_dataset_registry[("Dataset registry")]
  node_model_registry[("Model registry<br/>[model_registry.py]")]
end

subgraph group_shared["Shared contracts"]
  node_manifest[("Current model manifest<br/>[paths.py]")]
  node_schema["Patient data schema<br/>[schema.py]"]
end

node_clinician(("Clinical user"))
node_patient_files["Patient files"]
node_llm{{"LLM provider"}}
node_airflow(("Airflow scheduler"))

node_clinician -->|"uploads for"| node_predict_page
node_patient_files -->|"supplies"| node_upload
node_predict_page -->|"renders"| node_upload
node_predict_page -->|"renders"| node_validation_panel
node_predict_page -->|"runs prediction"| node_predictor
node_upload -->|"validates with"| node_validator
node_validation_panel -->|"displays validation"| node_validator
node_predictor -->|"validates input"| node_validator
node_predictor -->|"loads artifact"| node_model_loader
node_predictor -->|"dispatches inference"| node_pipeline_dispatch
node_model_loader -->|"reads manifest"| node_manifest
node_predict_page -->|"renders results"| node_results
node_predict_page -->|"logs predictions"| node_prediction_log
node_results -->|"renders checklist"| node_checklist
node_results -->|"renders narrative"| node_narrative_panel
node_clinician -->|"reviews patients"| node_watchlist
node_watchlist -->|"runs prediction"| node_predictor
node_watchlist -->|"loads artifact"| node_model_loader
node_watchlist -->|"logs predictions"| node_prediction_log
node_watchlist -->|"renders checklist"| node_checklist
node_clinician -->|"reviews monitoring"| node_monitoring_page
node_monitoring_page -->|"reads monitoring"| node_monitoring
node_narrative_panel -->|"requests narrative"| node_narrative_service
node_narrative_service -->|"builds summary"| node_summary
node_narrative_service -->|"resolves provider"| node_providers
node_providers -.->|"optionally calls"| node_llm
node_airflow -->|"schedules"| node_retraining_dag
node_retraining_dag -->|"detects batch"| node_batch_detection
node_retraining_dag -->|"creates bronze"| node_bronze
node_retraining_dag -->|"builds silver"| node_silver
node_retraining_dag -->|"checks quality"| node_quality_gate
node_retraining_dag -->|"builds features"| node_gold
node_retraining_dag -->|"registers dataset"| node_dataset_registry
node_retraining_dag -->|"cross-validates"| node_cv_search
node_cv_search -->|"supports training"| node_training
node_retraining_dag -->|"trains candidate"| node_training
node_retraining_dag -->|"evaluates candidate"| node_evaluation
node_retraining_dag -->|"registers and promotes"| node_model_registry
node_retraining_dag -->|"updates shared manifest"| node_manifest
node_schema -->|"defines required fields"| node_validator

click node_predict_page "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/1_predict.py"
click node_upload "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/upload.py"
click node_validation_panel "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/validation_panel.py"
click node_results "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/results_view.py"
click node_checklist "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/bundle_checklist.py"
click node_watchlist "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/2_unit_watchlist.py"
click node_monitoring_page "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/3_model_monitoring.py"
click node_validator "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/validator.py"
click node_predictor "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/predictor.py"
click node_model_loader "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/loader.py"
click node_pipeline_dispatch "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/tree/main/src/inference/pipelines"
click node_prediction_log "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/logger.py"
click node_monitoring "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/monitoring.py"
click node_narrative_panel "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/narrative_panel.py"
click node_narrative_service "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/narrative/service.py"
click node_summary "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/narrative/context.py"
click node_providers "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/narrative/providers.py"
click node_retraining_dag "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/dags/sepsis_retraining_dag.py"
click node_batch_detection "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/ingestion/batch_detector.py"
click node_bronze "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/ingestion/bronze_pipeline.py"
click node_silver "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/processing/silver_pipeline.py"
click node_quality_gate "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/validation/quality_gate.py"
click node_gold "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/processing/gold_pipeline.py"
click node_training "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/training/trainer.py"
click node_cv_search "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/training/cv_search.py"
click node_evaluation "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/training/evaluator.py"
click node_dataset_registry "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/registry/dataset_registry.py"
click node_model_registry "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/registry/model_registry.py"
click node_manifest "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/shared/paths.py"
click node_schema "https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/shared/schema.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_predict_page,node_upload,node_validation_panel,node_results,node_checklist,node_watchlist,node_monitoring_page,node_clinician toneBlue
class node_validator,node_predictor,node_model_loader,node_pipeline_dispatch,node_prediction_log,node_monitoring toneAmber
class node_narrative_panel,node_narrative_service,node_summary,node_providers toneMint
class node_retraining_dag,node_batch_detection,node_bronze,node_silver,node_quality_gate,node_gold,node_training,node_cv_search,node_evaluation,node_dataset_registry,node_model_registry,node_airflow toneRose
class node_manifest,node_schema,node_patient_files,node_llm toneIndigo
```

## Components

### Clinical app

- [Prediction page](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/1_predict.py): `app/pages/1_predict.py`
- [Upload UI](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/upload.py): `app/components/upload.py`
- [Validation panel](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/validation_panel.py): `app/components/validation_panel.py`
- [Results view](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/results_view.py): `app/components/results_view.py`
- [Care checklist](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/bundle_checklist.py): `app/components/bundle_checklist.py`
- [Unit watchlist](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/2_unit_watchlist.py): `app/pages/2_unit_watchlist.py`
- [Model monitoring](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/pages/3_model_monitoring.py): `app/pages/3_model_monitoring.py`

### Prediction runtime

- [Input validator](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/validator.py): `src/inference/validator.py`
- [Prediction runner](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/predictor.py): `src/inference/predictor.py`
- [Model loader](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/loader.py): `src/inference/loader.py`
- [Inference pipelines](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/tree/main/src/inference/pipelines): `src/inference/pipelines`
- [Prediction logging](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/logger.py): `src/inference/logger.py`
- [Usage monitoring](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/inference/monitoring.py): `src/inference/monitoring.py`

### Narrative generation

- [Narrative panel](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/app/components/narrative_panel.py): `app/components/narrative_panel.py`
- [Narrative service](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/narrative/service.py): `src/narrative/service.py`
- [Prediction summary](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/narrative/context.py): `src/narrative/context.py`
- [Narrative providers](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/narrative/providers.py): `src/narrative/providers.py`

### Model retraining

- [Retraining orchestrator](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/dags/sepsis_retraining_dag.py): `dags/sepsis_retraining_dag.py`
- [Batch detection](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/ingestion/batch_detector.py): `src/pipelines/ingestion/batch_detector.py`
- [Bronze ingestion](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/ingestion/bronze_pipeline.py): `src/pipelines/ingestion/bronze_pipeline.py`
- [Silver processing](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/processing/silver_pipeline.py): `src/pipelines/processing/silver_pipeline.py`
- [Data quality gate](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/validation/quality_gate.py): `src/pipelines/validation/quality_gate.py`
- [Gold features](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/processing/gold_pipeline.py): `src/pipelines/processing/gold_pipeline.py`
- [Training workflow](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/training/trainer.py): `src/pipelines/training/trainer.py`
- [Cross-validation search](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/training/cv_search.py): `src/pipelines/training/cv_search.py`
- [Model evaluation](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/training/evaluator.py): `src/pipelines/training/evaluator.py`
- [Dataset registry](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/registry/dataset_registry.py): `src/pipelines/registry/dataset_registry.py`
- [Model registry](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/pipelines/registry/model_registry.py): `src/pipelines/registry/model_registry.py`

### Shared contracts

- [Current model manifest](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/shared/paths.py): `src/shared/paths.py`
- [Patient data schema](https://github.com/aivietnam-aio-phamtien/early-sepsis-prediction-from-icu-clinical-data/blob/main/src/shared/schema.py): `src/shared/schema.py`

### Other components

- **Clinical user**
- **Patient files**
- **LLM provider**
- **Airflow scheduler**

## Connections

- Clinical user → Prediction page: uploads for (evidence: `README.md`)
- Patient files → Upload UI: supplies (evidence: `README.md`)
- Prediction page → Upload UI: renders (evidence: `app/pages/1_predict.py`)
- Prediction page → Validation panel: renders (evidence: `app/pages/1_predict.py`)
- Prediction page → Prediction runner: runs prediction (evidence: `app/pages/1_predict.py`)
- Upload UI → Input validator: validates with (evidence: `app/components/upload.py`)
- Validation panel → Input validator: displays validation (evidence: `app/components/validation_panel.py`)
- Prediction runner → Input validator: validates input (evidence: `src/inference/predictor.py`)
- Prediction runner → Model loader: loads artifact (evidence: `src/inference/predictor.py`)
- Prediction runner → Inference pipelines: dispatches inference (evidence: `src/inference/predictor.py`)
- Model loader → Current model manifest: reads manifest (evidence: `src/inference/loader.py`)
- Prediction page → Results view: renders results (evidence: `app/pages/1_predict.py`)
- Prediction page → Prediction logging: logs predictions (evidence: `app/pages/1_predict.py`)
- Results view → Care checklist: renders checklist (evidence: `app/components/results_view.py`)
- Results view → Narrative panel: renders narrative (evidence: `app/components/results_view.py`)
- Clinical user → Unit watchlist: reviews patients (evidence: `README.md`)
- Unit watchlist → Prediction runner: runs prediction (evidence: `app/pages/2_unit_watchlist.py`)
- Unit watchlist → Model loader: loads artifact (evidence: `app/pages/2_unit_watchlist.py`)
- Unit watchlist → Prediction logging: logs predictions (evidence: `app/pages/2_unit_watchlist.py`)
- Unit watchlist → Care checklist: renders checklist (evidence: `app/pages/2_unit_watchlist.py`)
- Clinical user → Model monitoring: reviews monitoring (evidence: `README.md`)
- Model monitoring → Usage monitoring: reads monitoring (evidence: `app/pages/3_model_monitoring.py`)
- Narrative panel → Narrative service: requests narrative (evidence: `app/components/narrative_panel.py`)
- Narrative service → Prediction summary: builds summary (evidence: `src/narrative/service.py`)
- Narrative service → Narrative providers: resolves provider (evidence: `src/narrative/service.py`)
- Narrative providers → LLM provider: optionally calls (evidence: `README.md`)
- Airflow scheduler → Retraining orchestrator: schedules (evidence: `README.md`)
- Retraining orchestrator → Batch detection: detects batch (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Bronze ingestion: creates bronze (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Silver processing: builds silver (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Data quality gate: checks quality (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Gold features: builds features (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Dataset registry: registers dataset (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Cross-validation search: cross-validates (evidence: `dags/sepsis_retraining_dag.py`)
- Cross-validation search → Training workflow: supports training (evidence: `src/pipelines/training/cv_search.py`)
- Retraining orchestrator → Training workflow: trains candidate (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Model evaluation: evaluates candidate (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Model registry: registers and promotes (evidence: `dags/sepsis_retraining_dag.py`)
- Retraining orchestrator → Current model manifest: updates shared manifest (evidence: `README.md`)
- Patient data schema → Input validator: defines required fields (evidence: `src/inference/validator.py`)
