# vikramthakare/agentic_ai architecture

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

- Interactive diagram: https://gitdiagram.com/vikramthakare/agentic_ai
- Repository: https://github.com/vikramthakare/agentic_ai

## Overview

This educational prototype streams simulated patient vitals through a dashboard and FastAPI into a per-patient LangGraph workflow. Persistent threshold breaches lead to category-filtered protocol retrieval, OpenRouter-generated recommendations, and a clinician pause; decisions resume the graph and write an audit entry. The README documents patient CRUD and review actions. Edges reflect the API and graph source excerpts, plus documented browser/API interactions; unsampled subsystems and undocumented data wiring are omitted.

Main entry points: [`graph/workflow.py`](https://github.com/vikramthakare/agentic_ai/blob/main/graph/workflow.py) (StateGraph routing), [`api/server.py`](https://github.com/vikramthakare/agentic_ai/blob/main/api/server.py) (REST API), [`rag/indexer.py`](https://github.com/vikramthakare/agentic_ai/blob/main/rag/indexer.py) (Protocol indexer), [`frontend/app.js`](https://github.com/vikramthakare/agentic_ai/blob/main/frontend/app.js) (Dashboard and charts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_dashboard["Dashboard and charts<br/>[app.js]"]
end

subgraph group_api["API and monitoring"]
  node_api_server["REST API<br/>[server.py]"]
  node_sim_data["Synthetic vitals stream"]
  node_patient_records["Patient records<br/>[patients.csv]"]
end

subgraph group_clinical["Clinical workflow"]
  node_graph_workflow["StateGraph routing<br/>[workflow.py]"]
  node_patient_state["Patient state schema<br/>[schema.py]"]
  node_ingest["Buffer readings<br/>[nodes.py]"]
  node_profile["Load patient context<br/>[nodes.py]"]
  node_trend["Detect persistent trends<br/>[nodes.py]"]
  node_retrieve_node["Retrieve alert evidence<br/>[nodes.py]"]
  node_reason["Generate recommendation<br/>[nodes.py]"]
  node_human_pause["Clinician review pause<br/>[nodes.py]"]
  node_audit["Audit log entry<br/>[nodes.py]"]
end

subgraph group_evidence["Protocol evidence"]
  node_retriever["Category-filtered search<br/>[retriever.py]"]
  node_vector_store[("Chroma vector store<br/>[vector_store.py]")]
  node_protocols["Clinical protocols"]
  node_indexer["Protocol indexer<br/>[indexer.py]"]
end

node_clinician(("Clinician"))
node_openrouter{{"OpenRouter LLM"}}

node_clinician -->|"reviews and decides"| node_dashboard
node_dashboard -->|"requests and streams"| node_api_server
node_api_server -.->|"serves generated stream"| node_sim_data
node_api_server -->|"reads and updates"| node_patient_records
node_api_server -->|"invokes and resumes"| node_graph_workflow
node_graph_workflow -->|"routes to"| node_ingest
node_graph_workflow -->|"routes to"| node_profile
node_graph_workflow -->|"routes to"| node_trend
node_graph_workflow -->|"routes on alert"| node_retrieve_node
node_graph_workflow -->|"routes to"| node_reason
node_graph_workflow -->|"routes to"| node_human_pause
node_graph_workflow -->|"routes to"| node_audit
node_graph_workflow -->|"uses state"| node_patient_state
node_profile -->|"reads context"| node_patient_records
node_retrieve_node -->|"requests protocol evidence"| node_retriever
node_retriever -->|"searches category"| node_vector_store
node_indexer -->|"reads and chunks"| node_protocols
node_indexer -->|"adds chunks"| node_vector_store
node_reason -->|"requests reasoning"| node_openrouter

click node_dashboard "https://github.com/vikramthakare/agentic_ai/blob/main/frontend/app.js"
click node_api_server "https://github.com/vikramthakare/agentic_ai/blob/main/api/server.py"
click node_sim_data "https://github.com/vikramthakare/agentic_ai/blob/main/generate_synthetic_data.py"
click node_patient_records "https://github.com/vikramthakare/agentic_ai/blob/main/patients.csv"
click node_graph_workflow "https://github.com/vikramthakare/agentic_ai/blob/main/graph/workflow.py"
click node_patient_state "https://github.com/vikramthakare/agentic_ai/blob/main/state/schema.py"
click node_ingest "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_profile "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_trend "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_retrieve_node "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_reason "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_human_pause "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_audit "https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py"
click node_retriever "https://github.com/vikramthakare/agentic_ai/blob/main/rag/retriever.py"
click node_vector_store "https://github.com/vikramthakare/agentic_ai/blob/main/rag/vector_store.py"
click node_protocols "https://github.com/vikramthakare/agentic_ai/tree/main/data/protocols"
click node_indexer "https://github.com/vikramthakare/agentic_ai/blob/main/rag/indexer.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_dashboard toneBlue
class node_api_server,node_sim_data,node_patient_records toneAmber
class node_graph_workflow,node_patient_state,node_ingest,node_profile,node_trend,node_retrieve_node,node_reason,node_human_pause,node_audit,node_openrouter toneMint
class node_retriever,node_vector_store,node_protocols,node_indexer toneRose
class node_clinician toneIndigo
```

## Components

### Dashboard

- [Dashboard and charts](https://github.com/vikramthakare/agentic_ai/blob/main/frontend/app.js): `frontend/app.js`

### API and monitoring

- [REST API](https://github.com/vikramthakare/agentic_ai/blob/main/api/server.py): `api/server.py`
- [Synthetic vitals stream](https://github.com/vikramthakare/agentic_ai/blob/main/generate_synthetic_data.py): `generate_synthetic_data.py`
- [Patient records](https://github.com/vikramthakare/agentic_ai/blob/main/patients.csv): `patients.csv`

### Clinical workflow

- [StateGraph routing](https://github.com/vikramthakare/agentic_ai/blob/main/graph/workflow.py): `graph/workflow.py`
- [Patient state schema](https://github.com/vikramthakare/agentic_ai/blob/main/state/schema.py): `state/schema.py`
- [Buffer readings](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`
- [Load patient context](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`
- [Detect persistent trends](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`
- [Retrieve alert evidence](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`
- [Generate recommendation](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`
- [Clinician review pause](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`
- [Audit log entry](https://github.com/vikramthakare/agentic_ai/blob/main/graph/nodes.py): `graph/nodes.py`

### Protocol evidence

- [Category-filtered search](https://github.com/vikramthakare/agentic_ai/blob/main/rag/retriever.py): `rag/retriever.py`
- [Chroma vector store](https://github.com/vikramthakare/agentic_ai/blob/main/rag/vector_store.py): `rag/vector_store.py`
- [Clinical protocols](https://github.com/vikramthakare/agentic_ai/tree/main/data/protocols): `data/protocols`
- [Protocol indexer](https://github.com/vikramthakare/agentic_ai/blob/main/rag/indexer.py): `rag/indexer.py`

### Other components

- **Clinician**
- **OpenRouter LLM**

## Connections

- Clinician → Dashboard and charts: reviews and decides (evidence: `README.md`)
- Dashboard and charts → REST API: requests and streams (evidence: `frontend/app.js`)
- REST API → Synthetic vitals stream: serves generated stream
- REST API → Patient records: reads and updates (evidence: `api/server.py`)
- REST API → StateGraph routing: invokes and resumes (evidence: `api/server.py`)
- StateGraph routing → Buffer readings: routes to (evidence: `graph/workflow.py`)
- StateGraph routing → Load patient context: routes to (evidence: `graph/workflow.py`)
- StateGraph routing → Detect persistent trends: routes to (evidence: `graph/workflow.py`)
- StateGraph routing → Retrieve alert evidence: routes on alert (evidence: `graph/workflow.py`)
- StateGraph routing → Generate recommendation: routes to (evidence: `graph/workflow.py`)
- StateGraph routing → Clinician review pause: routes to (evidence: `graph/workflow.py`)
- StateGraph routing → Audit log entry: routes to (evidence: `graph/workflow.py`)
- StateGraph routing → Patient state schema: uses state (evidence: `graph/workflow.py`)
- Load patient context → Patient records: reads context (evidence: `graph/nodes.py`)
- Retrieve alert evidence → Category-filtered search: requests protocol evidence (evidence: `graph/nodes.py`)
- Category-filtered search → Chroma vector store: searches category (evidence: `rag/retriever.py`)
- Protocol indexer → Clinical protocols: reads and chunks (evidence: `rag/indexer.py`)
- Protocol indexer → Chroma vector store: adds chunks (evidence: `rag/indexer.py`)
- Generate recommendation → OpenRouter LLM: requests reasoning (evidence: `graph/nodes.py`)
