# bhavya173045/med_triage_pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/bhavya173045/med_triage_pipeline
- Repository: https://github.com/bhavya173045/med_triage_pipeline

## Overview

MED_TRIAGE_PIPELINE is a Streamlit hospital triage portal with a separate clinical-trial data and model-training pipeline. Staff enter clinical notes and a priority; the app loads the trained model, runs NLP analysis and risk fusion, checks for priority mismatches, and renders decision-support results. Patient history is read from a CSV. Separately, a pipeline fetches trial studies, preprocesses them, and trains the model artifact used by the portal. The README documents dashboard visualization and stress testing; source evidence shows the test hook, but not a separate patient-history persistence workflow.

Main entry points: [`src/app.py`](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/app.py) (Triage App), [`run.py`](https://github.com/bhavya173045/med_triage_pipeline/blob/main/run.py) (Pipeline Runner), [`src/scraper.py`](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/scraper.py) (Trial Scraper), [`src/processor.py`](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/processor.py) (Trial Preprocessor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Triage Portal"]
  node_app["Triage App<br/>[app.py]"]
  node_views["Result Views"]
end

subgraph group_assessment["Risk Assessment"]
  node_risk["Risk Engine<br/>[risk_engine.py]"]
end

subgraph group_training["Model Pipeline"]
  node_runner["Pipeline Runner<br/>[run.py]"]
  node_scraper["Trial Scraper<br/>[scraper.py]"]
  node_processor["Trial Preprocessor<br/>[processor.py]"]
  node_classifier["Model Trainer<br/>[classifier.py]"]
end

subgraph group_records["Clinical Data"]
  node_history[("Patient History")]
  node_model["Trained Model"]
  node_cleaned[("Processed Trials<br/>[cleaned_trials.csv]")]
end

subgraph group_safety["Safety Checks"]
  node_safetytest["Robustness Test<br/>[tests_robust.py]"]
end

node_staff(("Hospital Staff"))
node_trials(("ClinicalTrials.gov"))

node_staff -->|"enters triage"| node_app
node_app -->|"reads records"| node_history
node_app -->|"loads model"| node_model
node_app -->|"analyzes and scores"| node_risk
node_app -->|"renders results"| node_views
node_app -->|"runs checks"| node_safetytest
node_safetytest -->|"tests scoring"| node_risk
node_runner -->|"fetches studies"| node_scraper
node_scraper -->|"requests studies"| node_trials
node_runner -->|"transforms data"| node_processor
node_processor -->|"writes rows"| node_cleaned
node_runner -->|"trains model"| node_classifier
node_classifier -->|"saves artifact"| node_model

click node_app "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/app.py"
click node_history "https://github.com/bhavya173045/med_triage_pipeline/blob/main/data/patient_records.csv"
click node_model "https://github.com/bhavya173045/med_triage_pipeline/blob/main/models/clinical_trials_model.pkl"
click node_risk "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/risk_engine.py"
click node_views "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/streamlit_components.py"
click node_safetytest "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/tests_robust.py"
click node_runner "https://github.com/bhavya173045/med_triage_pipeline/blob/main/run.py"
click node_scraper "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/scraper.py"
click node_processor "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/processor.py"
click node_cleaned "https://github.com/bhavya173045/med_triage_pipeline/blob/main/data/processed/cleaned_trials.csv"
click node_classifier "https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/classifier.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_views toneBlue
class node_risk toneAmber
class node_runner,node_scraper,node_processor,node_classifier toneMint
class node_history,node_model,node_cleaned toneRose
class node_safetytest,node_staff,node_trials toneIndigo
```

## Components

### Triage Portal

- [Triage App](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/app.py): `src/app.py`
- [Result Views](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/streamlit_components.py): `src/streamlit_components.py`

### Risk Assessment

- [Risk Engine](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/risk_engine.py): `src/risk_engine.py`

### Model Pipeline

- [Pipeline Runner](https://github.com/bhavya173045/med_triage_pipeline/blob/main/run.py): `run.py`
- [Trial Scraper](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/scraper.py): `src/scraper.py`
- [Trial Preprocessor](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/processor.py): `src/processor.py`
- [Model Trainer](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/classifier.py): `src/classifier.py`

### Clinical Data

- [Patient History](https://github.com/bhavya173045/med_triage_pipeline/blob/main/data/patient_records.csv): `data/patient_records.csv`
- [Trained Model](https://github.com/bhavya173045/med_triage_pipeline/blob/main/models/clinical_trials_model.pkl): `models/clinical_trials_model.pkl`
- [Processed Trials](https://github.com/bhavya173045/med_triage_pipeline/blob/main/data/processed/cleaned_trials.csv): `data/processed/cleaned_trials.csv`

### Safety Checks

- [Robustness Test](https://github.com/bhavya173045/med_triage_pipeline/blob/main/src/tests_robust.py): `src/tests_robust.py`

### Other components

- **Hospital Staff**
- **ClinicalTrials.gov**

## Connections

- Hospital Staff → Triage App: enters triage (evidence: `README.md`)
- Triage App → Patient History: reads records (evidence: `src/app.py`)
- Triage App → Trained Model: loads model (evidence: `src/app.py`)
- Triage App → Risk Engine: analyzes and scores (evidence: `src/app.py`)
- Triage App → Result Views: renders results (evidence: `src/app.py`)
- Triage App → Robustness Test: runs checks (evidence: `src/app.py`)
- Robustness Test → Risk Engine: tests scoring (evidence: `src/tests_robust.py`)
- Pipeline Runner → Trial Scraper: fetches studies (evidence: `run.py`)
- Trial Scraper → ClinicalTrials.gov: requests studies (evidence: `src/scraper.py`)
- Pipeline Runner → Trial Preprocessor: transforms data (evidence: `run.py`)
- Trial Preprocessor → Processed Trials: writes rows (evidence: `src/processor.py`)
- Pipeline Runner → Model Trainer: trains model (evidence: `run.py`)
- Model Trainer → Trained Model: saves artifact (evidence: `src/classifier.py`)
