# puni6553-collab/nethra-clinic architecture

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

- Interactive diagram: https://gitdiagram.com/puni6553-collab/nethra-clinic
- Repository: https://github.com/puni6553-collab/nethra-clinic

## Overview

NetraCare is a clinic booking and patient-chat portal: users sign in, find or request appointments, and receive clinic-document answers; backend rules and safety checks govern booking. Separate branches cover doctor-leave rebooking, clinical LLM features, partner integrations, and the documented evaluation harness. Edges use README and indexed source references; several implementation modules were not sampled, so their internal calls are not asserted.

Main entry points: [`backend/app/main.py`](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/database.py`](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/database.py) (Clinic database), [`backend/app/routers/appointments.py`](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/appointments.py) (Appointment routes), [`backend/app/routers/chat.py`](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/chat.py) (Chat routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Portal experience"]
  node_react["React routes<br/>[App.jsx]"]
  node_screens["Booking and role screens"]
  node_client["API client<br/>[api.js]"]
end

subgraph group_clinic["Clinic operations"]
  node_api["FastAPI application<br/>[main.py]"]
  node_auth["Login and identity<br/>[security.py]"]
  node_authroutes["Auth routes<br/>[auth.py]"]
  node_appointments["Appointment routes<br/>[appointments.py]"]
  node_rules["Clinic rules<br/>[rules.py]"]
  node_slots["Slot generation<br/>[slots.py]"]
  node_actions["Booking actions<br/>[actions.py]"]
  node_leave["Leave rebooking<br/>[leave.py]"]
  node_leaveroutes["Leave routes<br/>[leave.py]"]
  node_data[("Clinic database<br/>[database.py]")]
  node_models["Clinic records<br/>[models.py]"]
  node_seed["Clinic data loading<br/>[seed.py]"]
end

subgraph group_intelligence["Chat and clinical AI"]
  node_chatroutes["Chat routes<br/>[chat.py]"]
  node_agent["Booking agent<br/>[agent.py]"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_rag["Document search and answers<br/>[rag.py]"]
  node_llm["Clinical LLM services<br/>[llm.py]"]
  node_llmroutes["Clinical AI routes<br/>[llm_routes.py]"]
  node_skills["Agent skills<br/>[skills.py]"]
end

subgraph group_integrations["Partner integrations"]
  node_mcp["NetraCare MCP server<br/>[mcp_server.py]"]
  node_labclient["Partner lab client<br/>[lab.py]"]
  node_labserver["CityCare lab server"]
end

subgraph group_evaluation["Evaluation"]
  node_evals["Evaluation harness and judges<br/>[harness.py]"]
end

node_visitor(("Patient, staff, doctor"))
node_partner(("Partner applications"))

node_visitor -->|"uses portal"| node_react
node_react -->|"routes to"| node_screens
node_screens -->|"requests data"| node_client
node_client -->|"calls API"| node_api
node_api -->|"mounts routes"| node_authroutes
node_api -->|"mounts routes"| node_appointments
node_api -->|"mounts routes"| node_chatroutes
node_api -->|"mounts routes"| node_leaveroutes
node_api -->|"mounts routes"| node_llmroutes
node_api -->|"loads data"| node_seed
node_authroutes -->|"delegates identity"| node_auth
node_authroutes -->|"reads and writes"| node_data
node_appointments -->|"checks identity"| node_auth
node_appointments -->|"gets availability"| node_slots
node_appointments -->|"invokes actions"| node_actions
node_appointments -->|"applies rules"| node_rules
node_appointments -->|"reads and writes"| node_data
node_leaveroutes -.->|"delegates rebooking"| node_leave
node_leave -.->|"updates bookings"| node_data
node_seed -->|"loads records"| node_data
node_data -->|"creates tables"| node_models
node_chatroutes -->|"checks identity"| node_auth
node_chatroutes -->|"runs booking agent"| node_agent
node_chatroutes -->|"uses document answers"| node_rag
node_agent -.->|"uses tools"| node_tools
node_chatroutes -->|"checks red flags"| node_llm
node_llmroutes -->|"runs AI services"| node_llm
node_llm -.->|"summarizes records"| node_data
node_tools -.->|"loads skills"| node_skills
node_api -->|"connects optionally"| node_labclient
node_labclient -.->|"calls partner service"| node_labserver
node_partner -->|"finds slots, books"| node_mcp
node_mcp -->|"runs clinic booking"| node_actions
node_mcp -->|"finds availability"| node_slots
node_mcp -->|"reads and writes"| node_data
node_evals -->|"exercises endpoints"| node_api
node_evals -->|"uses LLM judges"| node_llm

click node_react "https://github.com/puni6553-collab/nethra-clinic/blob/main/frontend/src/App.jsx"
click node_screens "https://github.com/puni6553-collab/nethra-clinic/tree/main/frontend/src/screens"
click node_client "https://github.com/puni6553-collab/nethra-clinic/blob/main/frontend/src/api.js"
click node_api "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/main.py"
click node_auth "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/security.py"
click node_authroutes "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/auth.py"
click node_appointments "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/appointments.py"
click node_rules "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/rules.py"
click node_slots "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/slots.py"
click node_actions "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/actions.py"
click node_leave "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/leave.py"
click node_leaveroutes "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/leave.py"
click node_data "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/database.py"
click node_models "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/models.py"
click node_seed "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/seed.py"
click node_chatroutes "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/chat.py"
click node_agent "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/agent.py"
click node_tools "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/tools.py"
click node_rag "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/rag.py"
click node_llm "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/llm.py"
click node_llmroutes "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/llm_routes.py"
click node_skills "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/skills.py"
click node_mcp "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/mcp_server.py"
click node_labclient "https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/lab.py"
click node_labserver "https://github.com/puni6553-collab/nethra-clinic/blob/main/partner-lab/citycare_lab_mcp.py"
click node_evals "https://github.com/puni6553-collab/nethra-clinic/blob/main/evals/harness.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_react,node_screens,node_client toneBlue
class node_api,node_auth,node_authroutes,node_appointments,node_rules,node_slots,node_actions,node_leave,node_leaveroutes,node_data,node_models,node_seed toneAmber
class node_chatroutes,node_agent,node_tools,node_rag,node_llm,node_llmroutes,node_skills toneMint
class node_mcp,node_labclient,node_labserver toneRose
class node_evals,node_visitor,node_partner toneIndigo
```

## Components

### Portal experience

- [React routes](https://github.com/puni6553-collab/nethra-clinic/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Booking and role screens](https://github.com/puni6553-collab/nethra-clinic/tree/main/frontend/src/screens): `frontend/src/screens`
- [API client](https://github.com/puni6553-collab/nethra-clinic/blob/main/frontend/src/api.js): `frontend/src/api.js`

### Clinic operations

- [FastAPI application](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/main.py): `backend/app/main.py`
- [Login and identity](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/security.py): `backend/app/security.py`
- [Auth routes](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Appointment routes](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/appointments.py): `backend/app/routers/appointments.py`
- [Clinic rules](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/rules.py): `backend/app/rules.py`
- [Slot generation](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/slots.py): `backend/app/slots.py`
- [Booking actions](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/actions.py): `backend/app/actions.py`
- [Leave rebooking](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/leave.py): `backend/app/leave.py`
- [Leave routes](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/leave.py): `backend/app/routers/leave.py`
- [Clinic database](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/database.py): `backend/app/database.py`
- [Clinic records](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/models.py): `backend/app/models.py`
- [Clinic data loading](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/seed.py): `backend/app/seed.py`

### Chat and clinical AI

- [Chat routes](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/chat.py): `backend/app/routers/chat.py`
- [Booking agent](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/agent.py): `backend/app/agent.py`
- [Agent tools](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/tools.py): `backend/app/tools.py`
- [Document search and answers](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/rag.py): `backend/app/rag.py`
- [Clinical LLM services](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/llm.py): `backend/app/llm.py`
- [Clinical AI routes](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/routers/llm_routes.py): `backend/app/routers/llm_routes.py`
- [Agent skills](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/skills.py): `backend/app/skills.py`

### Partner integrations

- [NetraCare MCP server](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/mcp_server.py): `backend/mcp_server.py`
- [Partner lab client](https://github.com/puni6553-collab/nethra-clinic/blob/main/backend/app/lab.py): `backend/app/lab.py`
- [CityCare lab server](https://github.com/puni6553-collab/nethra-clinic/blob/main/partner-lab/citycare_lab_mcp.py): `partner-lab/citycare_lab_mcp.py`

### Evaluation

- [Evaluation harness and judges](https://github.com/puni6553-collab/nethra-clinic/blob/main/evals/harness.py): `evals/harness.py`

### Other components

- **Patient, staff, doctor**
- **Partner applications**

## Connections

- Patient, staff, doctor → React routes: uses portal
- React routes → Booking and role screens: routes to (evidence: `frontend/src/App.jsx`)
- Booking and role screens → API client: requests data (evidence: `frontend/src/screens/DoctorHome.jsx`)
- API client → FastAPI application: calls API (evidence: `frontend/src/api.js`)
- FastAPI application → Auth routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Appointment routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Chat routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Leave routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Clinical AI routes: mounts routes (evidence: `backend/app/main.py`)
- FastAPI application → Clinic data loading: loads data (evidence: `backend/app/main.py`)
- Auth routes → Login and identity: delegates identity (evidence: `backend/app/routers/auth.py`)
- Auth routes → Clinic database: reads and writes (evidence: `backend/app/routers/auth.py`)
- Appointment routes → Login and identity: checks identity (evidence: `backend/app/routers/appointments.py`)
- Appointment routes → Slot generation: gets availability (evidence: `backend/app/routers/appointments.py`)
- Appointment routes → Booking actions: invokes actions (evidence: `backend/app/routers/appointments.py`)
- Appointment routes → Clinic rules: applies rules (evidence: `backend/app/routers/appointments.py`)
- Appointment routes → Clinic database: reads and writes (evidence: `backend/app/routers/appointments.py`)
- Leave routes → Leave rebooking: delegates rebooking
- Leave rebooking → Clinic database: updates bookings
- Clinic data loading → Clinic database: loads records (evidence: `backend/app/seed.py`)
- Clinic database → Clinic records: creates tables (evidence: `backend/app/database.py`)
- Chat routes → Login and identity: checks identity (evidence: `backend/app/routers/chat.py`)
- Chat routes → Booking agent: runs booking agent (evidence: `backend/app/routers/chat.py`)
- Chat routes → Document search and answers: uses document answers (evidence: `backend/app/routers/chat.py`)
- Booking agent → Agent tools: uses tools
- Chat routes → Clinical LLM services: checks red flags
- Clinical AI routes → Clinical LLM services: runs AI services (evidence: `backend/app/routers/llm_routes.py`)
- Clinical LLM services → Clinic database: summarizes records
- Agent tools → Agent skills: loads skills
- FastAPI application → Partner lab client: connects optionally (evidence: `backend/app/main.py`)
- Partner lab client → CityCare lab server: calls partner service
- Partner applications → NetraCare MCP server: finds slots, books
- NetraCare MCP server → Booking actions: runs clinic booking (evidence: `backend/mcp_server.py`)
- NetraCare MCP server → Slot generation: finds availability (evidence: `backend/mcp_server.py`)
- NetraCare MCP server → Clinic database: reads and writes (evidence: `backend/mcp_server.py`)
- Evaluation harness and judges → FastAPI application: exercises endpoints (evidence: `evals/harness.py`)
- Evaluation harness and judges → Clinical LLM services: uses LLM judges
