# manjot-hub/healthcare architecture

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

- Interactive diagram: https://gitdiagram.com/manjot-hub/healthcare
- Repository: https://github.com/manjot-hub/healthcare

## Overview

This is a local-first Practo clinic-support agent: users ask policy questions or provide an appointment ID and receive grounded policy answers or appointment status and escalation details. The request path applies a token budget and input guardrails, resolves session context, then caches a CrewAI draft and reviews it before returning a structured response. Policy retrieval, appointment lookup, generated appointment data, observability, and end-to-end evaluation are distinct product capabilities. Some API wiring and evaluation internals were not excerpted; those links rely on README documentation or are omitted where evidence is insufficient.

Main entry points: [`orchestrator.py`](https://github.com/manjot-hub/healthcare/blob/main/orchestrator.py) (Turn orchestrator), [`app.py`](https://github.com/manjot-hub/healthcare/blob/main/app.py) (FastAPI endpoints), [`crew.py`](https://github.com/manjot-hub/healthcare/blob/main/crew.py) (Crew agents), [`tools.py`](https://github.com/manjot-hub/healthcare/blob/main/tools.py) (Agent tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Request interface"]
  node_api["FastAPI endpoints<br/>[app.py]"]
end

subgraph group_runtime["Answer runtime"]
  node_orchestrator["Turn orchestrator<br/>[orchestrator.py]"]
  node_crew["Crew agents<br/>[crew.py]"]
  node_mock["Offline LLM<br/>[mock_llm.py]"]
  node_review["Answer review<br/>[review.py]"]
  node_schemas["Response schemas<br/>[schemas.py]"]
end

subgraph group_knowledge["Knowledge and records"]
  node_rag["Policy retrieval<br/>[rag_core.py]"]
  node_kb["Clinic policy documents"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_dataset["Appointment dataset<br/>[dataset.py]"]
end

subgraph group_safety["Safety and governance"]
  node_guardrails["Input and grounding checks<br/>[guardrails.py]"]
  node_governance["Budget and response cache<br/>[governance.py]"]
  node_memory["Session memory<br/>[memory.py]"]
  node_settings["Runtime configuration<br/>[settings.py]"]
end

subgraph group_operations["Operations"]
  node_logging["Request telemetry<br/>[obs.py]"]
  node_evaluation["End-to-end evaluation<br/>[evaluate.py]"]
end

node_user(("User"))

node_user -->|"submits request"| node_api
node_api -->|"handles turns"| node_orchestrator
node_api -->|"logs requests"| node_logging
node_orchestrator -->|"checks budget and cache"| node_governance
node_orchestrator -->|"checks input"| node_guardrails
node_orchestrator -->|"resolves and saves context"| node_memory
node_orchestrator -->|"requests draft"| node_crew
node_orchestrator -->|"reviews draft"| node_review
node_orchestrator -->|"returns structured response"| node_schemas
node_crew -->|"builds agent tools"| node_tools
node_crew -->|"uses offline model"| node_mock
node_tools -->|"retrieves policy"| node_rag
node_tools -->|"looks up appointments"| node_dataset
node_rag -->|"loads policy documents"| node_kb
node_evaluation -->|"evaluates responses"| node_orchestrator
node_settings -->|"configures retrieval"| node_rag
node_settings -->|"sets runtime limits"| node_orchestrator

click node_api "https://github.com/manjot-hub/healthcare/blob/main/app.py"
click node_orchestrator "https://github.com/manjot-hub/healthcare/blob/main/orchestrator.py"
click node_crew "https://github.com/manjot-hub/healthcare/blob/main/crew.py"
click node_mock "https://github.com/manjot-hub/healthcare/blob/main/mock_llm.py"
click node_review "https://github.com/manjot-hub/healthcare/blob/main/review.py"
click node_schemas "https://github.com/manjot-hub/healthcare/blob/main/schemas.py"
click node_rag "https://github.com/manjot-hub/healthcare/blob/main/rag_core.py"
click node_kb "https://github.com/manjot-hub/healthcare/tree/main/kb"
click node_tools "https://github.com/manjot-hub/healthcare/blob/main/tools.py"
click node_dataset "https://github.com/manjot-hub/healthcare/blob/main/dataset.py"
click node_guardrails "https://github.com/manjot-hub/healthcare/blob/main/guardrails.py"
click node_governance "https://github.com/manjot-hub/healthcare/blob/main/governance.py"
click node_memory "https://github.com/manjot-hub/healthcare/blob/main/memory.py"
click node_settings "https://github.com/manjot-hub/healthcare/blob/main/settings.py"
click node_logging "https://github.com/manjot-hub/healthcare/blob/main/obs.py"
click node_evaluation "https://github.com/manjot-hub/healthcare/blob/main/evaluate.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_api,node_user toneBlue
class node_orchestrator,node_crew,node_mock,node_review,node_schemas toneAmber
class node_rag,node_kb,node_tools,node_dataset toneMint
class node_guardrails,node_governance,node_memory,node_settings toneRose
class node_logging,node_evaluation toneIndigo
```

## Components

### Request interface

- [FastAPI endpoints](https://github.com/manjot-hub/healthcare/blob/main/app.py): `app.py`

### Answer runtime

- [Turn orchestrator](https://github.com/manjot-hub/healthcare/blob/main/orchestrator.py): `orchestrator.py`
- [Crew agents](https://github.com/manjot-hub/healthcare/blob/main/crew.py): `crew.py`
- [Offline LLM](https://github.com/manjot-hub/healthcare/blob/main/mock_llm.py): `mock_llm.py`
- [Answer review](https://github.com/manjot-hub/healthcare/blob/main/review.py): `review.py`
- [Response schemas](https://github.com/manjot-hub/healthcare/blob/main/schemas.py): `schemas.py`

### Knowledge and records

- [Policy retrieval](https://github.com/manjot-hub/healthcare/blob/main/rag_core.py): `rag_core.py`
- [Clinic policy documents](https://github.com/manjot-hub/healthcare/tree/main/kb): `kb`
- [Agent tools](https://github.com/manjot-hub/healthcare/blob/main/tools.py): `tools.py`
- [Appointment dataset](https://github.com/manjot-hub/healthcare/blob/main/dataset.py): `dataset.py`

### Safety and governance

- [Input and grounding checks](https://github.com/manjot-hub/healthcare/blob/main/guardrails.py): `guardrails.py`
- [Budget and response cache](https://github.com/manjot-hub/healthcare/blob/main/governance.py): `governance.py`
- [Session memory](https://github.com/manjot-hub/healthcare/blob/main/memory.py): `memory.py`
- [Runtime configuration](https://github.com/manjot-hub/healthcare/blob/main/settings.py): `settings.py`

### Operations

- [Request telemetry](https://github.com/manjot-hub/healthcare/blob/main/obs.py): `obs.py`
- [End-to-end evaluation](https://github.com/manjot-hub/healthcare/blob/main/evaluate.py): `evaluate.py`

### Other components

- **User**

## Connections

- User → FastAPI endpoints: submits request (evidence: `README.md`)
- FastAPI endpoints → Turn orchestrator: handles turns (evidence: `README.md`)
- FastAPI endpoints → Request telemetry: logs requests (evidence: `README.md`)
- Turn orchestrator → Budget and response cache: checks budget and cache (evidence: `orchestrator.py`)
- Turn orchestrator → Input and grounding checks: checks input (evidence: `orchestrator.py`)
- Turn orchestrator → Session memory: resolves and saves context (evidence: `orchestrator.py`)
- Turn orchestrator → Crew agents: requests draft (evidence: `orchestrator.py`)
- Turn orchestrator → Answer review: reviews draft (evidence: `orchestrator.py`)
- Turn orchestrator → Response schemas: returns structured response (evidence: `orchestrator.py`)
- Crew agents → Agent tools: builds agent tools (evidence: `crew.py`)
- Crew agents → Offline LLM: uses offline model (evidence: `README.md`)
- Agent tools → Policy retrieval: retrieves policy (evidence: `tools.py`)
- Agent tools → Appointment dataset: looks up appointments (evidence: `tools.py`)
- Policy retrieval → Clinic policy documents: loads policy documents (evidence: `rag_core.py`)
- End-to-end evaluation → Turn orchestrator: evaluates responses (evidence: `README.md`)
- Runtime configuration → Policy retrieval: configures retrieval (evidence: `settings.py`)
- Runtime configuration → Turn orchestrator: sets runtime limits (evidence: `settings.py`)
