# olveraalec/preventive-health-ai architecture

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

- Interactive diagram: https://gitdiagram.com/olveraalec/preventive-health-ai
- Repository: https://github.com/olveraalec/preventive-health-ai

## Overview

Preventive Health Intelligence is a research prototype for time-aware sepsis-risk inference and evidence-aware model allocation, with React and Streamlit research interfaces. The main workflow is hourly observations through causal features, static/temporal inference and bounded allocation, to a decision-summary API and inspectable UI; retrospective replay and cohort evaluation are separate evidence paths. Edges follow shown imports/calls or README statements. Some subsystems are represented by their exact enclosing directories because their implementation was not sampled; unverified wiring is omitted.

Main entry points: [`frontend/src/App.tsx`](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/App.tsx) (React application), [`src/healthcare_ai_lab/models/sepsis_inference.py`](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/models/sepsis_inference.py) (Static and temporal experts), [`src/healthcare_ai_lab/api/main.py`](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/api/main.py) (Research API), [`frontend/src/hooks/useResearchWorkspace.ts`](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/hooks/useResearchWorkspace.ts) (Research workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Inference and control"]
  node_preprocess["Causal features"]
  node_artifact["Model artifacts<br/>[artifact.py]"]
  node_experts["Static and temporal experts"]
  node_allocation["Adaptive allocation<br/>[adaptive.py]"]
  node_trajectory["Trajectory inference<br/>[service.py]"]
  node_contracts["Decision contracts<br/>[contracts.py]"]
  node_controller_service["Controller service<br/>[service.py]"]
  node_controller_contracts["Controller contracts<br/>[contracts.py]"]
end

subgraph group_research["Research and evaluation"]
  node_agent["Agent workflow<br/>[workflow.py]"]
  node_memory["Memory selection<br/>[selector.py]"]
  node_evaluation["Patient and policy evaluation"]
  node_experiments["Controller experiments"]
end

subgraph group_backend["API and persistence"]
  node_api["Research API<br/>[main.py]"]
  node_database[("Research repository<br/>[repository.py]")]
end

subgraph group_web["React experience"]
  node_app["React application<br/>[App.tsx]"]
  node_workspace["Research workspace"]
  node_api_client["API client<br/>[client.ts]"]
  node_canonical["Canonical response adapter<br/>[canonical.ts]"]
  node_contracts_front["UI data contracts<br/>[contracts.ts]"]
  node_decision_ui["Decision interpretation"]
  node_monitoring_ui["Patient monitoring"]
  node_evidence_ui["Observation evidence"]
  node_evaluation_ui["Model evaluation view"]
  node_retrospective["Retrospective import<br/>[retrospective.ts]"]
end

subgraph group_explorer["Research explorer"]
  node_streamlit["Streamlit explorer<br/>[app.py]"]
  node_adaptive_page["Adaptive decisions"]
  node_evaluation_page["Explorer evaluation"]
end

node_icu[("Historical ICU data")]
node_user(("Research user"))

node_icu -->|"provides observations"| node_preprocess
node_preprocess -->|"builds features"| node_experts
node_artifact -->|"supplies models"| node_experts
node_experts -->|"provides predictions"| node_allocation
node_allocation -->|"blends predictions"| node_experts
node_trajectory -->|"runs inference"| node_experts
node_trajectory -->|"returns trajectory"| node_contracts
node_user -->|"uses"| node_app
node_app -->|"renders workspace"| node_workspace
node_app -->|"renders decisions"| node_decision_ui
node_app -->|"renders monitoring"| node_monitoring_ui
node_app -->|"renders evidence"| node_evidence_ui
node_app -->|"renders evaluation"| node_evaluation_ui
node_workspace -->|"requests trajectory"| node_api_client
node_workspace -->|"imports export"| node_retrospective
node_api_client -->|"parses response"| node_canonical
node_api_client -->|"validates evaluation"| node_contracts_front
node_workspace -->|"parses request"| node_contracts_front
node_api -->|"serves inference"| node_trajectory
node_api -->|"persists agent runs"| node_database
node_api -->|"invokes workflow"| node_agent
node_agent -->|"selects memories"| node_memory
node_api -->|"dispatches decisions"| node_controller_service
node_controller_service -->|"accepts input"| node_controller_contracts
node_user -->|"explores research"| node_streamlit
node_streamlit -->|"offers decisions"| node_adaptive_page
node_streamlit -->|"offers evaluation"| node_evaluation_page
node_evaluation -.->|"evaluates policies"| node_experiments

click node_preprocess "https://github.com/olveraalec/preventive-health-ai/tree/master/src/healthcare_ai_lab/preprocessing"
click node_artifact "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/models/artifact.py"
click node_experts "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/models/sepsis_inference.py"
click node_allocation "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/controllers/adaptive.py"
click node_trajectory "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/trajectories/service.py"
click node_contracts "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/trajectories/contracts.py"
click node_controller_service "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/controller/service.py"
click node_controller_contracts "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/controller/contracts.py"
click node_api "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/api/main.py"
click node_database "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/database/repository.py"
click node_agent "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/agent/workflow.py"
click node_memory "https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/memory/selector.py"
click node_evaluation "https://github.com/olveraalec/preventive-health-ai/tree/master/src/healthcare_ai_lab/evaluation"
click node_experiments "https://github.com/olveraalec/preventive-health-ai/tree/master/src/healthcare_ai_lab/experiments"
click node_app "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/App.tsx"
click node_workspace "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/hooks/useResearchWorkspace.ts"
click node_api_client "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/client.ts"
click node_canonical "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/canonical.ts"
click node_contracts_front "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/contracts.ts"
click node_decision_ui "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/DecisionInterpretation.tsx"
click node_monitoring_ui "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/PatientMonitoring.tsx"
click node_evidence_ui "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/ObservationEvidence.tsx"
click node_evaluation_ui "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/ModelEvaluation.tsx"
click node_retrospective "https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/retrospective.ts"
click node_streamlit "https://github.com/olveraalec/preventive-health-ai/blob/master/dashboard/app.py"
click node_adaptive_page "https://github.com/olveraalec/preventive-health-ai/blob/master/dashboard/pages/1_Adaptive_Decisions.py"
click node_evaluation_page "https://github.com/olveraalec/preventive-health-ai/blob/master/dashboard/pages/2_Model_Evaluation.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_preprocess,node_artifact,node_experts,node_allocation,node_trajectory,node_contracts,node_controller_service,node_controller_contracts,node_user toneBlue
class node_agent,node_memory,node_evaluation,node_experiments,node_icu toneAmber
class node_api,node_database toneMint
class node_app,node_workspace,node_api_client,node_canonical,node_contracts_front,node_decision_ui,node_monitoring_ui,node_evidence_ui,node_evaluation_ui,node_retrospective toneRose
class node_streamlit,node_adaptive_page,node_evaluation_page toneIndigo
```

## Components

### Inference and control

- [Causal features](https://github.com/olveraalec/preventive-health-ai/tree/master/src/healthcare_ai_lab/preprocessing): `src/healthcare_ai_lab/preprocessing`
- [Model artifacts](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/models/artifact.py): `src/healthcare_ai_lab/models/artifact.py`
- [Static and temporal experts](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/models/sepsis_inference.py): `src/healthcare_ai_lab/models/sepsis_inference.py`
- [Adaptive allocation](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/controllers/adaptive.py): `src/healthcare_ai_lab/controllers/adaptive.py`
- [Trajectory inference](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/trajectories/service.py): `src/healthcare_ai_lab/trajectories/service.py`
- [Decision contracts](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/trajectories/contracts.py): `src/healthcare_ai_lab/trajectories/contracts.py`
- [Controller service](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/controller/service.py): `src/healthcare_ai_lab/controller/service.py`
- [Controller contracts](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/controller/contracts.py): `src/healthcare_ai_lab/controller/contracts.py`

### Research and evaluation

- [Agent workflow](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/agent/workflow.py): `src/healthcare_ai_lab/agent/workflow.py`
- [Memory selection](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/memory/selector.py): `src/healthcare_ai_lab/memory/selector.py`
- [Patient and policy evaluation](https://github.com/olveraalec/preventive-health-ai/tree/master/src/healthcare_ai_lab/evaluation): `src/healthcare_ai_lab/evaluation`
- [Controller experiments](https://github.com/olveraalec/preventive-health-ai/tree/master/src/healthcare_ai_lab/experiments): `src/healthcare_ai_lab/experiments`

### API and persistence

- [Research API](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/api/main.py): `src/healthcare_ai_lab/api/main.py`
- [Research repository](https://github.com/olveraalec/preventive-health-ai/blob/master/src/healthcare_ai_lab/database/repository.py): `src/healthcare_ai_lab/database/repository.py`

### React experience

- [React application](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Research workspace](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/hooks/useResearchWorkspace.ts): `frontend/src/hooks/useResearchWorkspace.ts`
- [API client](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Canonical response adapter](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/canonical.ts): `frontend/src/api/canonical.ts`
- [UI data contracts](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/contracts.ts): `frontend/src/api/contracts.ts`
- [Decision interpretation](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/DecisionInterpretation.tsx): `frontend/src/components/DecisionInterpretation.tsx`
- [Patient monitoring](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/PatientMonitoring.tsx): `frontend/src/components/PatientMonitoring.tsx`
- [Observation evidence](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/ObservationEvidence.tsx): `frontend/src/components/ObservationEvidence.tsx`
- [Model evaluation view](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/components/ModelEvaluation.tsx): `frontend/src/components/ModelEvaluation.tsx`
- [Retrospective import](https://github.com/olveraalec/preventive-health-ai/blob/master/frontend/src/api/retrospective.ts): `frontend/src/api/retrospective.ts`

### Research explorer

- [Streamlit explorer](https://github.com/olveraalec/preventive-health-ai/blob/master/dashboard/app.py): `dashboard/app.py`
- [Adaptive decisions](https://github.com/olveraalec/preventive-health-ai/blob/master/dashboard/pages/1_Adaptive_Decisions.py): `dashboard/pages/1_Adaptive_Decisions.py`
- [Explorer evaluation](https://github.com/olveraalec/preventive-health-ai/blob/master/dashboard/pages/2_Model_Evaluation.py): `dashboard/pages/2_Model_Evaluation.py`

### Other components

- **Historical ICU data**
- **Research user**

## Connections

- Historical ICU data → Causal features: provides observations (evidence: `README.md`)
- Causal features → Static and temporal experts: builds features (evidence: `README.md`)
- Model artifacts → Static and temporal experts: supplies models (evidence: `src/healthcare_ai_lab/models/artifact.py`)
- Static and temporal experts → Adaptive allocation: provides predictions (evidence: `src/healthcare_ai_lab/models/sepsis_inference.py`)
- Adaptive allocation → Static and temporal experts: blends predictions (evidence: `src/healthcare_ai_lab/models/sepsis_inference.py`)
- Trajectory inference → Static and temporal experts: runs inference (evidence: `src/healthcare_ai_lab/trajectories/service.py`)
- Trajectory inference → Decision contracts: returns trajectory (evidence: `src/healthcare_ai_lab/trajectories/service.py`)
- Research user → React application: uses (evidence: `README.md`)
- React application → Research workspace: renders workspace (evidence: `frontend/src/App.tsx`)
- React application → Decision interpretation: renders decisions (evidence: `frontend/src/App.tsx`)
- React application → Patient monitoring: renders monitoring (evidence: `frontend/src/App.tsx`)
- React application → Observation evidence: renders evidence (evidence: `frontend/src/App.tsx`)
- React application → Model evaluation view: renders evaluation (evidence: `frontend/src/App.tsx`)
- Research workspace → API client: requests trajectory (evidence: `frontend/src/hooks/useResearchWorkspace.ts`)
- Research workspace → Retrospective import: imports export (evidence: `frontend/src/hooks/useResearchWorkspace.ts`)
- API client → Canonical response adapter: parses response (evidence: `frontend/src/api/client.ts`)
- API client → UI data contracts: validates evaluation (evidence: `frontend/src/api/client.ts`)
- Research workspace → UI data contracts: parses request (evidence: `frontend/src/hooks/useResearchWorkspace.ts`)
- Research API → Trajectory inference: serves inference (evidence: `src/healthcare_ai_lab/api/main.py`)
- Research API → Research repository: persists agent runs (evidence: `src/healthcare_ai_lab/api/main.py`)
- Research API → Agent workflow: invokes workflow (evidence: `src/healthcare_ai_lab/api/main.py`)
- Agent workflow → Memory selection: selects memories (evidence: `src/healthcare_ai_lab/agent/workflow.py`)
- Research API → Controller service: dispatches decisions (evidence: `src/healthcare_ai_lab/api/main.py`)
- Controller service → Controller contracts: accepts input (evidence: `src/healthcare_ai_lab/controller/service.py`)
- Research user → Streamlit explorer: explores research (evidence: `README.md`)
- Streamlit explorer → Adaptive decisions: offers decisions (evidence: `README.md`)
- Streamlit explorer → Explorer evaluation: offers evaluation (evidence: `README.md`)
- Patient and policy evaluation → Controller experiments: evaluates policies
