# kavya4615/agentic-ai-intra-iit architecture

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

- Interactive diagram: https://gitdiagram.com/kavya4615/agentic-ai-intra-iit
- Repository: https://github.com/kavya4615/agentic-ai-intra-iit

## Overview

SentinelCare is a clinical deterioration and escalation copilot. Synthetic patient monitors generate live vitals that enter the backend, update patient state, pass through artifact filtering, trend analysis, risk scoring, and alert transitions. Escalations trigger context- and protocol-grounded SBAR reasoning; clinicians review alerts and choose a decision. The dashboard presents the live cohort, charts, explanations, and decision controls. README documents the broad system flow; sampled source and the SOURCE INDEX support several internal calls, while unsampled wiring is not inferred.

Main entry points: [`backend/agent/agent_service.py`](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/agent_service.py) (Agent service), [`frontend/src/components/Dashboard.tsx`](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/Dashboard.tsx) (Live dashboard), [`backend/alerts/pipeline.py`](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/pipeline.py) (Deterministic pipeline), [`backend/ingestion/main.py`](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/ingestion/main.py) (WebSocket gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Patient Simulation"]
  node_scenario_data["Clinical scenarios<br/>[scenarios.py]"]
  node_patient_profiles["Patient profiles<br/>[patients.py]"]
  node_vital_generator["Vital generator<br/>[generator.py]"]
end

subgraph group_ingest["Ingestion and State"]
  node_gateway["WebSocket gateway<br/>[main.py]"]
  node_patient_state[("Live patient state<br/>[patient_state.py]")]
end

subgraph group_pipeline["Risk and Alerts"]
  node_preprocessor["Artifact filter<br/>[preprocessor.py]"]
  node_trend_detector["Trend detector<br/>[trend_detector.py]"]
  node_risk_scorer["Risk scorer<br/>[risk_scorer.py]"]
  node_pipeline["Deterministic pipeline<br/>[pipeline.py]"]
  node_state_machine["Alert state machine<br/>[state_machine.py]"]
end

subgraph group_reasoning["Clinical Reasoning"]
  node_agent_service["Agent service<br/>[agent_service.py]"]
  node_context_data["Patient context data"]
  node_context_model["Patient context model<br/>[patient_context.py]"]
  node_knowledge_base["Clinical protocol RAG<br/>[rag.py]"]
  node_reasoning_agent["SBAR reasoning<br/>[reasoning.py]"]
end

subgraph group_review["Decisions and Audit"]
  node_decision_manager["Clinician decisions<br/>[decisions.py]"]
  node_audit_store[("Audit trail<br/>[audit.py]")]
end

subgraph group_frontend["Clinician Dashboard"]
  node_dashboard["Live dashboard<br/>[Dashboard.tsx]"]
  node_patient_card["Patient cards<br/>[PatientCard.tsx]"]
  node_detail_panel["Patient detail<br/>[DetailPanel.tsx]"]
  node_explanation_modal["SBAR and decisions"]
  node_toast["Escalation toasts<br/>[Toast.tsx]"]
  node_cohort_stats["Cohort statistics<br/>[CohortStatsBar.tsx]"]
  node_multi_chart["Vital charts"]
  node_sparkline["Patient sparklines<br/>[SparklineChart.tsx]"]
end

node_monitors(("Simulated monitors"))
node_clinician(("Clinician"))

node_scenario_data -->|"shapes scenarios"| node_vital_generator
node_patient_profiles -->|"supplies patients"| node_vital_generator
node_monitors -->|"stream vitals"| node_gateway
node_vital_generator -->|"sends readings"| node_gateway
node_gateway -->|"processes readings"| node_pipeline
node_pipeline -->|"filters readings"| node_preprocessor
node_pipeline -->|"updates state"| node_patient_state
node_pipeline -->|"analyses trends"| node_trend_detector
node_pipeline -->|"computes risk"| node_risk_scorer
node_pipeline -->|"evaluates risk"| node_state_machine
node_gateway -->|"maintains state"| node_patient_state
node_state_machine -->|"triggers escalation"| node_agent_service
node_agent_service -->|"reads patient state"| node_patient_state
node_agent_service -->|"loads context"| node_context_data
node_context_data -->|"creates profiles"| node_context_model
node_agent_service -->|"retrieves protocols"| node_knowledge_base
node_agent_service -->|"generates SBAR"| node_reasoning_agent
node_agent_service -->|"provides explanation"| node_decision_manager
node_clinician -->|"reviews cohort"| node_dashboard
node_gateway -->|"broadcasts updates"| node_dashboard
node_dashboard -->|"renders cards"| node_patient_card
node_dashboard -->|"opens explanation"| node_explanation_modal
node_dashboard -->|"renders detail"| node_detail_panel
node_dashboard -->|"shows alerts"| node_toast
node_dashboard -->|"renders statistics"| node_cohort_stats
node_patient_card -->|"renders trend"| node_sparkline
node_detail_panel -->|"renders vitals"| node_multi_chart
node_explanation_modal -->|"submits decisions"| node_decision_manager
node_decision_manager -->|"applies decision"| node_state_machine
node_gateway -->|"logs observations"| node_audit_store
node_agent_service -.->|"logs reasoning"| node_audit_store
node_state_machine -.->|"logs alerts"| node_audit_store
node_decision_manager -.->|"logs decisions"| node_audit_store

click node_scenario_data "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/scenarios.py"
click node_patient_profiles "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/patients.py"
click node_vital_generator "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/generator.py"
click node_gateway "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/ingestion/main.py"
click node_patient_state "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/state/patient_state.py"
click node_preprocessor "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/engine/preprocessor.py"
click node_trend_detector "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/engine/trend_detector.py"
click node_risk_scorer "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/engine/risk_scorer.py"
click node_pipeline "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/pipeline.py"
click node_state_machine "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/state_machine.py"
click node_agent_service "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/agent_service.py"
click node_context_data "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/patient_context_data.py"
click node_context_model "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/patient_context.py"
click node_knowledge_base "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/rag.py"
click node_reasoning_agent "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/reasoning.py"
click node_decision_manager "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/decisions.py"
click node_audit_store "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/database/audit.py"
click node_dashboard "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/Dashboard.tsx"
click node_patient_card "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/PatientCard.tsx"
click node_detail_panel "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/DetailPanel.tsx"
click node_explanation_modal "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/ExplanationModal.tsx"
click node_toast "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/Toast.tsx"
click node_cohort_stats "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/CohortStatsBar.tsx"
click node_multi_chart "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/MultiVitalChart.tsx"
click node_sparkline "https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/SparklineChart.tsx"

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_scenario_data,node_patient_profiles,node_vital_generator toneBlue
class node_gateway,node_patient_state toneAmber
class node_preprocessor,node_trend_detector,node_risk_scorer,node_pipeline,node_state_machine toneMint
class node_agent_service,node_context_data,node_context_model,node_knowledge_base,node_reasoning_agent toneRose
class node_decision_manager,node_audit_store,node_monitors,node_clinician toneIndigo
class node_dashboard,node_patient_card,node_detail_panel,node_explanation_modal,node_toast,node_cohort_stats,node_multi_chart,node_sparkline toneTeal
```

## Components

### Patient Simulation

- [Clinical scenarios](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/scenarios.py): `backend/simulator/scenarios.py`
- [Patient profiles](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/patients.py): `backend/simulator/patients.py`
- [Vital generator](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/generator.py): `backend/simulator/generator.py`

### Ingestion and State

- [WebSocket gateway](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/ingestion/main.py): `backend/ingestion/main.py`
- [Live patient state](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/state/patient_state.py): `backend/state/patient_state.py`

### Risk and Alerts

- [Artifact filter](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/engine/preprocessor.py): `backend/engine/preprocessor.py`
- [Trend detector](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/engine/trend_detector.py): `backend/engine/trend_detector.py`
- [Risk scorer](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/engine/risk_scorer.py): `backend/engine/risk_scorer.py`
- [Deterministic pipeline](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/pipeline.py): `backend/alerts/pipeline.py`
- [Alert state machine](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/state_machine.py): `backend/alerts/state_machine.py`

### Clinical Reasoning

- [Agent service](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/agent_service.py): `backend/agent/agent_service.py`
- [Patient context data](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/simulator/patient_context_data.py): `backend/simulator/patient_context_data.py`
- [Patient context model](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/patient_context.py): `backend/agent/patient_context.py`
- [Clinical protocol RAG](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/rag.py): `backend/agent/rag.py`
- [SBAR reasoning](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/agent/reasoning.py): `backend/agent/reasoning.py`

### Decisions and Audit

- [Clinician decisions](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/alerts/decisions.py): `backend/alerts/decisions.py`
- [Audit trail](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/backend/database/audit.py): `backend/database/audit.py`

### Clinician Dashboard

- [Live dashboard](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/Dashboard.tsx): `frontend/src/components/Dashboard.tsx`
- [Patient cards](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/PatientCard.tsx): `frontend/src/components/PatientCard.tsx`
- [Patient detail](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/DetailPanel.tsx): `frontend/src/components/DetailPanel.tsx`
- [SBAR and decisions](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/ExplanationModal.tsx): `frontend/src/components/ExplanationModal.tsx`
- [Escalation toasts](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/Toast.tsx): `frontend/src/components/Toast.tsx`
- [Cohort statistics](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/CohortStatsBar.tsx): `frontend/src/components/CohortStatsBar.tsx`
- [Vital charts](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/MultiVitalChart.tsx): `frontend/src/components/MultiVitalChart.tsx`
- [Patient sparklines](https://github.com/kavya4615/agentic-ai-intra-iit/blob/main/frontend/src/components/SparklineChart.tsx): `frontend/src/components/SparklineChart.tsx`

### Other components

- **Simulated monitors**
- **Clinician**

## Connections

- Clinical scenarios → Vital generator: shapes scenarios (evidence: `backend/simulator/generator.py`)
- Patient profiles → Vital generator: supplies patients (evidence: `backend/simulator/generator.py`)
- Simulated monitors → WebSocket gateway: stream vitals (evidence: `README.md`)
- Vital generator → WebSocket gateway: sends readings (evidence: `README.md`)
- WebSocket gateway → Deterministic pipeline: processes readings (evidence: `README.md`)
- Deterministic pipeline → Artifact filter: filters readings (evidence: `backend/alerts/pipeline.py`)
- Deterministic pipeline → Live patient state: updates state (evidence: `backend/alerts/pipeline.py`)
- Deterministic pipeline → Trend detector: analyses trends (evidence: `backend/alerts/pipeline.py`)
- Deterministic pipeline → Risk scorer: computes risk (evidence: `backend/alerts/pipeline.py`)
- Deterministic pipeline → Alert state machine: evaluates risk (evidence: `backend/alerts/pipeline.py`)
- WebSocket gateway → Live patient state: maintains state (evidence: `README.md`)
- Alert state machine → Agent service: triggers escalation (evidence: `README.md`)
- Agent service → Live patient state: reads patient state (evidence: `backend/agent/agent_service.py`)
- Agent service → Patient context data: loads context (evidence: `backend/agent/agent_service.py`)
- Patient context data → Patient context model: creates profiles (evidence: `backend/simulator/patient_context_data.py`)
- Agent service → Clinical protocol RAG: retrieves protocols (evidence: `backend/agent/agent_service.py`)
- Agent service → SBAR reasoning: generates SBAR (evidence: `backend/agent/agent_service.py`)
- Agent service → Clinician decisions: provides explanation (evidence: `README.md`)
- Clinician → Live dashboard: reviews cohort (evidence: `README.md`)
- WebSocket gateway → Live dashboard: broadcasts updates (evidence: `README.md`)
- Live dashboard → Patient cards: renders cards (evidence: `frontend/src/components/Dashboard.tsx`)
- Live dashboard → SBAR and decisions: opens explanation (evidence: `frontend/src/components/Dashboard.tsx`)
- Live dashboard → Patient detail: renders detail (evidence: `frontend/src/components/Dashboard.tsx`)
- Live dashboard → Escalation toasts: shows alerts (evidence: `frontend/src/components/Dashboard.tsx`)
- Live dashboard → Cohort statistics: renders statistics (evidence: `frontend/src/components/Dashboard.tsx`)
- Patient cards → Patient sparklines: renders trend (evidence: `frontend/src/components/PatientCard.tsx`)
- Patient detail → Vital charts: renders vitals (evidence: `frontend/src/components/DetailPanel.tsx`)
- SBAR and decisions → Clinician decisions: submits decisions (evidence: `README.md`)
- Clinician decisions → Alert state machine: applies decision (evidence: `README.md`)
- WebSocket gateway → Audit trail: logs observations (evidence: `backend/ingestion/main.py`)
- Agent service → Audit trail: logs reasoning (evidence: `README.md`)
- Alert state machine → Audit trail: logs alerts (evidence: `README.md`)
- Clinician decisions → Audit trail: logs decisions (evidence: `README.md`)
