# karthih2/discharge-and-follow-up architecture

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

- Interactive diagram: https://gitdiagram.com/karthih2/discharge-and-follow-up
- Repository: https://github.com/karthih2/discharge-and-follow-up

## Overview

CareBridge is a synthetic discharge-follow-up planner with patient/family, doctor, and management portals. Patients submit a discharge summary; the API ingests and processes it into source-linked plan items, dates, multilingual explanations, tasks, and review flags. Doctors resolve unclear items, while patients and permitted family viewers track plans and use reminders, callbacks, provider suggestions, and sharing features. Management handles staff, assignments, callbacks, and audit. The graph combines excerpted calls and README-documented capabilities; uninspected route and agent internals are represented only where paths and relationships are documented.

Main entry points: [`backend/app/agents/pipeline.py`](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/pipeline.py) (Processing orchestrator), [`backend/app/main.py`](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/main.py) (HTTP application), [`backend/app/models.py`](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/models.py) (SQLite records), [`backend/app/routes/documents.py`](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/documents.py) (Document intake)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portals["User portals"]
  node_patient["Patient and family app<br/>[PatientApp.tsx]"]
  node_doctor["Doctor workspace<br/>[DoctorApp.tsx]"]
  node_management["Management console<br/>[AdminApp.tsx]"]
  node_patient_pages["Plans and sharing"]
  node_doctor_pages["Review queue<br/>[Queue.tsx]"]
  node_admin_pages["Staff and audit<br/>[Pages.tsx]"]
end

subgraph group_processing["Plan processing"]
  node_document_routes["Document intake<br/>[documents.py]"]
  node_ingest["Text and PDF extraction<br/>[ingest.py]"]
  node_pipeline["Processing orchestrator<br/>[pipeline.py]"]
  node_extract["Clinical extraction<br/>[extractor.py]"]
  node_dates["Date resolution<br/>[dates.py]"]
  node_matching["Provider matching<br/>[matcher.py]"]
  node_triage["Safety triage<br/>[triage.py]"]
  node_verify["Verification<br/>[verifier.py]"]
  node_simplify["Multilingual explanations<br/>[simplifier.py]"]
  node_med_template["Medicine formatting<br/>[med_template.py]"]
  node_planner["Tasks and reminders<br/>[planner.py]"]
end

subgraph group_review["Clinical review"]
  node_routing["Reviewer assignment<br/>[routing.py]"]
  node_clinical_routes["Patient plan actions<br/>[clinical.py]"]
  node_plan_routes["Plan and task actions<br/>[plans.py]"]
  node_admin_routes["Management operations<br/>[admin.py]"]
  node_family_routes["Family access and sharing<br/>[family.py]"]
end

subgraph group_platform["Shared platform"]
  node_api_client["API client<br/>[api.ts]"]
  node_auth_ui["Portal authentication<br/>[auth.tsx]"]
  node_api_server["HTTP application<br/>[main.py]"]
  node_auth_backend["Role and access checks<br/>[auth.py]"]
  node_database[("SQLite records<br/>[models.py]")]
  node_db_access["Database and audit<br/>[db.py]"]
end

node_external_user(("Patient or staff"))
node_llm{{"Groq language model"}}

node_external_user -->|"uses"| node_patient
node_external_user -->|"uses"| node_doctor
node_external_user -->|"uses"| node_management
node_patient -->|"routes to"| node_patient_pages
node_doctor -->|"routes to"| node_doctor_pages
node_management -->|"routes to"| node_admin_pages
node_patient_pages -->|"requests"| node_api_client
node_doctor_pages -->|"requests"| node_api_client
node_admin_pages -->|"requests"| node_api_client
node_patient -->|"guards access"| node_auth_ui
node_api_client -->|"calls API"| node_api_server
node_api_server -->|"checks roles"| node_auth_backend
node_api_server -->|"registers routes"| node_document_routes
node_api_server -->|"registers routes"| node_clinical_routes
node_api_server -.->|"registers routes"| node_plan_routes
node_api_server -->|"registers routes"| node_admin_routes
node_api_server -->|"registers routes"| node_family_routes
node_document_routes -->|"extracts text"| node_ingest
node_document_routes -->|"starts processing"| node_pipeline
node_pipeline -->|"extracts items"| node_extract
node_pipeline -->|"resolves dates"| node_dates
node_pipeline -->|"finds providers"| node_matching
node_pipeline -->|"flags risks"| node_triage
node_pipeline -->|"verifies items"| node_verify
node_pipeline -->|"creates explanations"| node_simplify
node_pipeline -->|"formats medicines"| node_med_template
node_pipeline -->|"creates tasks"| node_planner
node_pipeline -->|"assigns review"| node_routing
node_simplify -.->|"rewrites text"| node_llm
node_triage -.->|"checks safety"| node_llm
node_document_routes -->|"stores documents"| node_database
node_pipeline -->|"stores plan results"| node_database
node_db_access -->|"reads and writes"| node_database
node_clinical_routes -->|"updates tasks"| node_planner
node_plan_routes -->|"rechecks safety"| node_triage
node_plan_routes -->|"formats medicines"| node_med_template
node_plan_routes -->|"reads and writes"| node_database
node_clinical_routes -->|"reads and writes"| node_database
node_routing -->|"assigns and notifies"| node_database
node_admin_routes -.->|"reassigns doctors"| node_routing
node_family_routes -.->|"filters shared plans"| node_database

click node_patient "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/apps/PatientApp.tsx"
click node_doctor "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/apps/DoctorApp.tsx"
click node_management "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/apps/AdminApp.tsx"
click node_patient_pages "https://github.com/karthih2/discharge-and-follow-up/tree/main/frontend/src/pages"
click node_doctor_pages "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/pages/doctor/Queue.tsx"
click node_admin_pages "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/pages/admin/Pages.tsx"
click node_api_client "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/lib/api.ts"
click node_auth_ui "https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/lib/auth.tsx"
click node_api_server "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/main.py"
click node_auth_backend "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/auth.py"
click node_database "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/models.py"
click node_db_access "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/db.py"
click node_document_routes "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/documents.py"
click node_ingest "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/ingest.py"
click node_pipeline "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/pipeline.py"
click node_extract "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/extractor.py"
click node_dates "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/dates.py"
click node_matching "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/matcher.py"
click node_triage "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/triage.py"
click node_verify "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/verifier.py"
click node_simplify "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/simplifier.py"
click node_med_template "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/med_template.py"
click node_planner "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/planner.py"
click node_routing "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routing.py"
click node_clinical_routes "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/clinical.py"
click node_plan_routes "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/plans.py"
click node_admin_routes "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/admin.py"
click node_family_routes "https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/family.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_patient,node_doctor,node_management,node_patient_pages,node_doctor_pages,node_admin_pages toneBlue
class node_document_routes,node_ingest,node_pipeline,node_extract,node_dates,node_matching,node_triage,node_verify,node_simplify,node_med_template,node_planner toneAmber
class node_routing,node_clinical_routes,node_plan_routes,node_admin_routes,node_family_routes toneMint
class node_api_client,node_auth_ui,node_api_server,node_auth_backend,node_database,node_db_access toneRose
class node_external_user,node_llm toneIndigo
```

## Components

### User portals

- [Patient and family app](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/apps/PatientApp.tsx): `frontend/src/apps/PatientApp.tsx`
- [Doctor workspace](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/apps/DoctorApp.tsx): `frontend/src/apps/DoctorApp.tsx`
- [Management console](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/apps/AdminApp.tsx): `frontend/src/apps/AdminApp.tsx`
- [Plans and sharing](https://github.com/karthih2/discharge-and-follow-up/tree/main/frontend/src/pages): `frontend/src/pages`
- [Review queue](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/pages/doctor/Queue.tsx): `frontend/src/pages/doctor/Queue.tsx`
- [Staff and audit](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/pages/admin/Pages.tsx): `frontend/src/pages/admin/Pages.tsx`

### Plan processing

- [Document intake](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/documents.py): `backend/app/routes/documents.py`
- [Text and PDF extraction](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/ingest.py): `backend/app/agents/ingest.py`
- [Processing orchestrator](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/pipeline.py): `backend/app/agents/pipeline.py`
- [Clinical extraction](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/extractor.py): `backend/app/agents/extractor.py`
- [Date resolution](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/dates.py): `backend/app/agents/dates.py`
- [Provider matching](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/matcher.py): `backend/app/agents/matcher.py`
- [Safety triage](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/triage.py): `backend/app/agents/triage.py`
- [Verification](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/verifier.py): `backend/app/agents/verifier.py`
- [Multilingual explanations](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/simplifier.py): `backend/app/agents/simplifier.py`
- [Medicine formatting](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/med_template.py): `backend/app/agents/med_template.py`
- [Tasks and reminders](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/agents/planner.py): `backend/app/agents/planner.py`

### Clinical review

- [Reviewer assignment](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routing.py): `backend/app/routing.py`
- [Patient plan actions](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/clinical.py): `backend/app/routes/clinical.py`
- [Plan and task actions](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/plans.py): `backend/app/routes/plans.py`
- [Management operations](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/admin.py): `backend/app/routes/admin.py`
- [Family access and sharing](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/routes/family.py): `backend/app/routes/family.py`

### Shared platform

- [API client](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Portal authentication](https://github.com/karthih2/discharge-and-follow-up/blob/main/frontend/src/lib/auth.tsx): `frontend/src/lib/auth.tsx`
- [HTTP application](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/main.py): `backend/app/main.py`
- [Role and access checks](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [SQLite records](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database and audit](https://github.com/karthih2/discharge-and-follow-up/blob/main/backend/app/db.py): `backend/app/db.py`

### Other components

- **Patient or staff**
- **Groq language model**

## Connections

- Patient or staff → Patient and family app: uses (evidence: `README.md`)
- Patient or staff → Doctor workspace: uses (evidence: `README.md`)
- Patient or staff → Management console: uses (evidence: `README.md`)
- Patient and family app → Plans and sharing: routes to (evidence: `frontend/src/apps/PatientApp.tsx`)
- Doctor workspace → Review queue: routes to
- Management console → Staff and audit: routes to
- Plans and sharing → API client: requests (evidence: `frontend/src/pages/admin/Pages.tsx`)
- Review queue → API client: requests (evidence: `frontend/src/pages/doctor/Queue.tsx`)
- Staff and audit → API client: requests (evidence: `frontend/src/pages/admin/Pages.tsx`)
- Patient and family app → Portal authentication: guards access (evidence: `frontend/src/apps/PatientApp.tsx`)
- API client → HTTP application: calls API (evidence: `README.md`)
- HTTP application → Role and access checks: checks roles (evidence: `backend/app/main.py`)
- HTTP application → Document intake: registers routes (evidence: `backend/app/main.py`)
- HTTP application → Patient plan actions: registers routes (evidence: `backend/app/main.py`)
- HTTP application → Plan and task actions: registers routes (evidence: `backend/app/main.py`)
- HTTP application → Management operations: registers routes (evidence: `backend/app/main.py`)
- HTTP application → Family access and sharing: registers routes (evidence: `backend/app/main.py`)
- Document intake → Text and PDF extraction: extracts text (evidence: `backend/app/routes/documents.py`)
- Document intake → Processing orchestrator: starts processing (evidence: `backend/app/routes/documents.py`)
- Processing orchestrator → Clinical extraction: extracts items (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Date resolution: resolves dates (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Provider matching: finds providers (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Safety triage: flags risks (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Verification: verifies items (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Multilingual explanations: creates explanations (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Medicine formatting: formats medicines (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Tasks and reminders: creates tasks (evidence: `backend/app/agents/pipeline.py`)
- Processing orchestrator → Reviewer assignment: assigns review (evidence: `backend/app/agents/pipeline.py`)
- Multilingual explanations → Groq language model: rewrites text (evidence: `README.md`)
- Safety triage → Groq language model: checks safety (evidence: `README.md`)
- Document intake → SQLite records: stores documents (evidence: `backend/app/routes/documents.py`)
- Processing orchestrator → SQLite records: stores plan results (evidence: `backend/app/agents/pipeline.py`)
- Database and audit → SQLite records: reads and writes (evidence: `backend/app/db.py`)
- Patient plan actions → Tasks and reminders: updates tasks (evidence: `backend/app/routes/clinical.py`)
- Plan and task actions → Safety triage: rechecks safety (evidence: `backend/app/routes/plans.py`)
- Plan and task actions → Medicine formatting: formats medicines (evidence: `backend/app/routes/plans.py`)
- Plan and task actions → SQLite records: reads and writes (evidence: `backend/app/routes/plans.py`)
- Patient plan actions → SQLite records: reads and writes (evidence: `backend/app/routes/clinical.py`)
- Reviewer assignment → SQLite records: assigns and notifies (evidence: `backend/app/routing.py`)
- Management operations → Reviewer assignment: reassigns doctors (evidence: `README.md`)
- Family access and sharing → SQLite records: filters shared plans (evidence: `README.md`)
