# codewitheshayoutube/caresync-ai architecture

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

- Interactive diagram: https://gitdiagram.com/codewitheshayoutube/caresync-ai
- Repository: https://github.com/codewitheshayoutube/caresync-ai

## Overview

CareSync AI is presented as a hospital-operations intelligence dashboard: staff review facility resources and risks, investigate alerts, and use procurement assistance to evaluate suppliers and prepare orders. The sampled code supports a React dashboard, FastAPI operations endpoints, a LangGraph procurement agent with database tools, and SQL-backed domain models. README capabilities such as live web intelligence and predictive shortage analysis are documented, but their implementation and wiring are not present in the excerpts; those links are therefore not inferred.

Main entry points: [`backend/db/models/base.py`](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/base.py) (PostgreSQL), [`client/caresync/src/App.jsx`](https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx) (Dashboard app), [`backend/main.py`](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py) (FastAPI endpoints), [`backend/agents/procurement_agent.py`](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/agents/procurement_agent.py) (Procurement agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Dashboard experience"]
  node_app["Dashboard app<br/>[App.jsx]"]
  node_map["Hospital map<br/>[App.jsx]"]
  node_inventory_view["Inventory view<br/>[App.jsx]"]
  node_alerts_view["Alerts view<br/>[App.jsx]"]
  node_chat_view["AI chat panel<br/>[App.jsx]"]
end

subgraph group_api["Operations API"]
  node_api_main["FastAPI endpoints<br/>[main.py]"]
  node_health_ops["Hospital operations<br/>[main.py]"]
  node_alert_ops["Alert operations<br/>[main.py]"]
  node_order_ops["Order operations<br/>[main.py]"]
  node_chat_ops["Chat endpoint<br/>[main.py]"]
end

subgraph group_agents["Agent procurement"]
  node_proc_agent["Procurement agent"]
  node_agent_state["Agent context<br/>[state.py]"]
  node_proc_tools["Procurement tools"]
end

subgraph group_data["Operational data"]
  node_sql_store[("PostgreSQL<br/>[base.py]")]
  node_inventory_data["Inventory history<br/>[inventory.py]"]
  node_risk_data["Risk scores<br/>[risk.py]"]
  node_alert_data["Alerts and logs<br/>[alert.py]"]
  node_order_data["Procurement orders<br/>[procurement.py]"]
  node_supplier_data["Supplier catalog<br/>[supplier.py]"]
end

node_staff(("Hospital staff"))
node_claude{{"Claude"}}
node_redis[("Redis cache")]

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_map
node_app -->|"renders"| node_inventory_view
node_app -->|"renders"| node_alerts_view
node_app -->|"renders"| node_chat_view
node_api_main -->|"dispatches"| node_health_ops
node_api_main -->|"dispatches"| node_alert_ops
node_api_main -->|"dispatches"| node_order_ops
node_api_main -->|"dispatches"| node_chat_ops
node_proc_agent -->|"prompts"| node_claude
node_proc_agent -->|"invokes"| node_proc_tools
node_proc_agent -->|"uses context"| node_agent_state
node_proc_tools -->|"queries and writes"| node_sql_store
node_proc_tools -->|"reads cache"| node_redis
node_health_ops -->|"queries"| node_sql_store
node_alert_ops -->|"queries"| node_sql_store
node_order_ops -->|"reads and writes"| node_sql_store
node_sql_store -->|"stores"| node_inventory_data
node_sql_store -->|"stores"| node_risk_data
node_sql_store -->|"stores"| node_alert_data
node_sql_store -->|"stores"| node_order_data
node_sql_store -->|"stores"| node_supplier_data

click node_app "https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx"
click node_map "https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx"
click node_inventory_view "https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx"
click node_alerts_view "https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx"
click node_chat_view "https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx"
click node_api_main "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py"
click node_health_ops "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py"
click node_alert_ops "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py"
click node_order_ops "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py"
click node_chat_ops "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py"
click node_proc_agent "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/agents/procurement_agent.py"
click node_agent_state "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/agents/state.py"
click node_proc_tools "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/tools/procurement_tools.py"
click node_sql_store "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/base.py"
click node_inventory_data "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/inventory.py"
click node_risk_data "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/risk.py"
click node_alert_data "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/alert.py"
click node_order_data "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/procurement.py"
click node_supplier_data "https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/supplier.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_map,node_inventory_view,node_alerts_view,node_chat_view toneBlue
class node_api_main,node_health_ops,node_alert_ops,node_order_ops,node_chat_ops,node_redis toneAmber
class node_proc_agent,node_agent_state,node_proc_tools toneMint
class node_sql_store,node_inventory_data,node_risk_data,node_alert_data,node_order_data,node_supplier_data toneRose
class node_staff,node_claude toneIndigo
```

## Components

### Dashboard experience

- [Dashboard app](https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx): `client/caresync/src/App.jsx`
- [Hospital map](https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx): `client/caresync/src/App.jsx`
- [Inventory view](https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx): `client/caresync/src/App.jsx`
- [Alerts view](https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx): `client/caresync/src/App.jsx`
- [AI chat panel](https://github.com/codewitheshayoutube/caresync-ai/blob/main/client/caresync/src/App.jsx): `client/caresync/src/App.jsx`

### Operations API

- [FastAPI endpoints](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py): `backend/main.py`
- [Hospital operations](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py): `backend/main.py`
- [Alert operations](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py): `backend/main.py`
- [Order operations](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py): `backend/main.py`
- [Chat endpoint](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/main.py): `backend/main.py`

### Agent procurement

- [Procurement agent](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/agents/procurement_agent.py): `backend/agents/procurement_agent.py`
- [Agent context](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/agents/state.py): `backend/agents/state.py`
- [Procurement tools](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/tools/procurement_tools.py): `backend/tools/procurement_tools.py`

### Operational data

- [PostgreSQL](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/base.py): `backend/db/models/base.py`
- [Inventory history](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/inventory.py): `backend/db/models/inventory.py`
- [Risk scores](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/risk.py): `backend/db/models/risk.py`
- [Alerts and logs](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/alert.py): `backend/db/models/alert.py`
- [Procurement orders](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/procurement.py): `backend/db/models/procurement.py`
- [Supplier catalog](https://github.com/codewitheshayoutube/caresync-ai/blob/main/backend/db/models/supplier.py): `backend/db/models/supplier.py`

### Other components

- **Hospital staff**
- **Claude**
- **Redis cache**

## Connections

- Hospital staff → Dashboard app: uses
- Dashboard app → Hospital map: renders
- Dashboard app → Inventory view: renders
- Dashboard app → Alerts view: renders
- Dashboard app → AI chat panel: renders
- FastAPI endpoints → Hospital operations: dispatches
- FastAPI endpoints → Alert operations: dispatches
- FastAPI endpoints → Order operations: dispatches
- FastAPI endpoints → Chat endpoint: dispatches
- Procurement agent → Claude: prompts
- Procurement agent → Procurement tools: invokes
- Procurement agent → Agent context: uses context
- Procurement tools → PostgreSQL: queries and writes
- Procurement tools → Redis cache: reads cache
- Hospital operations → PostgreSQL: queries
- Alert operations → PostgreSQL: queries
- Order operations → PostgreSQL: reads and writes
- PostgreSQL → Inventory history: stores
- PostgreSQL → Risk scores: stores
- PostgreSQL → Alerts and logs: stores
- PostgreSQL → Procurement orders: stores
- PostgreSQL → Supplier catalog: stores
