# douglas-moore-engineering/hospital-readmission-agent-workflow architecture

> Architecture diagram of the GitHub repository douglas-moore-engineering/hospital-readmission-agent-workflow, 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/douglas-moore-engineering/hospital-readmission-agent-workflow
- Repository: https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow

## Overview

The product trains and evaluates a hospital-readmission risk model, then serves predictions and health status through a FastAPI service. The notebook’s documented workflow supplies the training stages; the sampled API source shows request handling, artifact loading, and prediction. Notebook internals were not sampled, so training-stage links follow the README’s documented flow.

Main entry points: [`src/api.py`](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py) (Prediction endpoint), [`HealthCare_SmallDM.ipynb`](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb) (Recommendations), [`artifacts/readmission_agent_model.joblib`](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/artifacts/readmission_agent_model.joblib) (Trained model), [`artifacts/readmission_agent_report.json`](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/artifacts/readmission_agent_report.json) (Evaluation report)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_csv["Patient dataset"]
  node_load_clean["Load and clean"]
  node_split["Data split"]
  node_preprocess["Preprocessing pipeline"]
  node_train["Candidate training"]
  node_select["Model selection"]
end

subgraph group_evaluation["Evaluation outputs"]
  node_threshold["Threshold tuning"]
  node_holdout["Holdout evaluation"]
  node_audit["Explanations and audits"]
  node_recommend["Recommendations"]
end

subgraph group_service["Prediction service"]
  node_health["Health endpoint<br/>[api.py]"]
  node_predict_endpoint["Prediction endpoint<br/>[api.py]"]
  node_threshold_loader["Load threshold<br/>[api.py]"]
  node_predict["Score patient<br/>[api.py]"]
  node_model_loader["Load model<br/>[api.py]"]
  node_estimator["Loaded estimator<br/>[api.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_model_file["Trained model"]
  node_report_file["Evaluation report"]
end

node_operator(("Notebook operator"))
node_caller(("API client"))

node_operator -->|"runs notebook"| node_load_clean
node_csv -->|"loads data"| node_load_clean
node_load_clean -->|"cleaned data"| node_split
node_split -->|"split data"| node_preprocess
node_preprocess -->|"prepared data"| node_train
node_train -->|"candidate models"| node_select
node_select -->|"selected model"| node_threshold
node_threshold -->|"tuned threshold"| node_holdout
node_holdout -->|"evaluation results"| node_audit
node_audit -->|"audit findings"| node_recommend
node_recommend -->|"saves model"| node_model_file
node_recommend -->|"saves report"| node_report_file
node_caller -->|"requests health"| node_health
node_health -->|"loads threshold"| node_threshold_loader
node_caller -->|"submits patient"| node_predict_endpoint
node_predict_endpoint -->|"loads default"| node_threshold_loader
node_predict_endpoint -->|"scores patient"| node_predict
node_threshold_loader -->|"reads threshold"| node_report_file
node_threshold_loader -->|"returns threshold"| node_predict_endpoint
node_predict -->|"loads estimator"| node_model_loader
node_model_loader -->|"reads model"| node_model_file
node_model_loader -->|"returns model"| node_estimator
node_predict -->|"predicts probability"| node_estimator
node_predict_endpoint -->|"returns risk result"| node_caller
node_health -->|"returns status"| node_caller

click node_csv "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/Users/mooredouglas45/healthcare_small.csv"
click node_load_clean "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_split "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_preprocess "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_train "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_select "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_threshold "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_holdout "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_audit "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_recommend "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb"
click node_model_file "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/artifacts/readmission_agent_model.joblib"
click node_report_file "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/artifacts/readmission_agent_report.json"
click node_health "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py"
click node_predict_endpoint "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py"
click node_threshold_loader "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py"
click node_predict "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py"
click node_model_loader "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py"
click node_estimator "https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.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_csv,node_load_clean,node_split,node_preprocess,node_train,node_select,node_caller toneBlue
class node_threshold,node_holdout,node_audit,node_recommend toneAmber
class node_health,node_predict_endpoint,node_threshold_loader,node_predict,node_model_loader,node_estimator toneMint
class node_model_file,node_report_file toneRose
class node_operator toneIndigo
```

## Components

### Model training

- [Patient dataset](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/Users/mooredouglas45/healthcare_small.csv): `Users/mooredouglas45/healthcare_small.csv`
- [Load and clean](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Data split](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Preprocessing pipeline](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Candidate training](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Model selection](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`

### Evaluation outputs

- [Threshold tuning](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Holdout evaluation](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Explanations and audits](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`
- [Recommendations](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/HealthCare_SmallDM.ipynb): `HealthCare_SmallDM.ipynb`

### Prediction service

- [Health endpoint](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py): `src/api.py`
- [Prediction endpoint](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py): `src/api.py`
- [Load threshold](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py): `src/api.py`
- [Score patient](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py): `src/api.py`
- [Load model](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py): `src/api.py`
- [Loaded estimator](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/src/api.py): `src/api.py`

### Model artifacts

- [Trained model](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/artifacts/readmission_agent_model.joblib): `artifacts/readmission_agent_model.joblib`
- [Evaluation report](https://github.com/douglas-moore-engineering/hospital-readmission-agent-workflow/blob/main/artifacts/readmission_agent_report.json): `artifacts/readmission_agent_report.json`

### Other components

- **Notebook operator**
- **API client**

## Connections

- Notebook operator → Load and clean: runs notebook
- Patient dataset → Load and clean: loads data
- Load and clean → Data split: cleaned data
- Data split → Preprocessing pipeline: split data
- Preprocessing pipeline → Candidate training: prepared data
- Candidate training → Model selection: candidate models
- Model selection → Threshold tuning: selected model
- Threshold tuning → Holdout evaluation: tuned threshold
- Holdout evaluation → Explanations and audits: evaluation results
- Explanations and audits → Recommendations: audit findings
- Recommendations → Trained model: saves model
- Recommendations → Evaluation report: saves report
- API client → Health endpoint: requests health
- Health endpoint → Load threshold: loads threshold
- API client → Prediction endpoint: submits patient
- Prediction endpoint → Load threshold: loads default
- Prediction endpoint → Score patient: scores patient
- Load threshold → Evaluation report: reads threshold
- Load threshold → Prediction endpoint: returns threshold
- Score patient → Load model: loads estimator
- Load model → Trained model: reads model
- Load model → Loaded estimator: returns model
- Score patient → Loaded estimator: predicts probability
- Prediction endpoint → API client: returns risk result
- Health endpoint → API client: returns status
