# manis30/careflow architecture

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

- Interactive diagram: https://gitdiagram.com/manis30/careflow
- Repository: https://github.com/manis30/careflow

## Overview

CareFlow is a multi-tenant clinic and consultation platform for patients, clinicians, front-desk staff, and administrators. The main patient journey is discovering a doctor, booking an available slot, settling payment, attending a consultation, and accessing records or prescriptions. The graph preserves documented clinical, operational, AI, and administration capabilities. The excerpts show application route mounting and AI orchestration; several domain implementations and frontend API calls were not sampled, so those links are marked unverified rather than asserted as source-confirmed calls.

Main entry points: [`backend/src/app.js`](https://github.com/manis30/careflow/blob/main/backend/src/app.js) (HTTP API application), [`backend/src/service/appointment.js`](https://github.com/manis30/careflow/blob/main/backend/src/service/appointment.js) (Appointment lifecycle), [`frontend/src/App.jsx`](https://github.com/manis30/careflow/blob/main/frontend/src/App.jsx) (React application), [`backend/src/service/ai/aiGateway.js`](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/aiGateway.js) (AI gateway)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Role-based experience"]
  node_frontend["React application<br/>[App.jsx]"]
  node_role_routes["Role-based routes<br/>[AppRoutes.jsx]"]
  node_auth_context["Authentication state<br/>[AuthContext.jsx]"]
  node_booking_ui["Appointment booking"]
  node_meeting_ui["Video consultation<br/>[MeetingRoom.jsx]"]
  node_admin_ui["Clinic administration<br/>[Dashboard.jsx]"]
end

subgraph group_clinical["Clinical operations"]
  node_clinic_directory["Clinics and doctors<br/>[doctor.js]"]
  node_appointments["Appointment lifecycle<br/>[appointment.js]"]
  node_records["Medical records<br/>[medicalRecord.js]"]
  node_prescriptions["Prescriptions and medication<br/>[prescription.js]"]
  node_messaging["Messaging and telehealth<br/>[chat.js]"]
  node_video_service["Video consultation service<br/>[meetingService.js]"]
end

subgraph group_platform["Platform services"]
  node_api_app["HTTP API application<br/>[app.js]"]
  node_auth_domain["Accounts and access<br/>[user.js]"]
  node_payments["Payments<br/>[payment.js]"]
  node_persistent_data[("MongoDB domain data<br/>[appointment.js]")]
end

subgraph group_intelligence["AI assistance"]
  node_ai_gateway["AI gateway<br/>[aiGateway.js]"]
  node_ai_orchestrator["Agent orchestration"]
  node_workflow_planner["Workflow planning<br/>[workflowPlanner.js]"]
  node_clinical_qa["Document Q&amp;A and OCR"]
  node_embeddings["Document embeddings"]
  node_gemini["Gemini provider client<br/>[geminiClient.js]"]
end

node_patients(("Patients"))
node_clinicians(("Clinicians and staff"))
node_razorpay["Razorpay"]

node_patients -->|"use platform"| node_frontend
node_clinicians -->|"use platform"| node_frontend
node_frontend -->|"renders routes"| node_role_routes
node_frontend -->|"provides auth"| node_auth_context
node_role_routes -->|"routes to"| node_booking_ui
node_role_routes -->|"routes to"| node_meeting_ui
node_booking_ui -.->|"submits booking"| node_api_app
node_meeting_ui -.->|"joins consultation"| node_video_service
node_frontend -.->|"requests API"| node_api_app
node_api_app -->|"mounts routes"| node_auth_domain
node_api_app -->|"mounts routes"| node_clinic_directory
node_api_app -->|"mounts routes"| node_appointments
node_api_app -->|"mounts routes"| node_records
node_api_app -->|"mounts routes"| node_prescriptions
node_api_app -->|"mounts routes"| node_payments
node_api_app -->|"mounts routes"| node_messaging
node_clinic_directory -.->|"supports booking"| node_appointments
node_appointments -.->|"queues payment"| node_payments
node_appointments -.->|"enables consultation"| node_video_service
node_appointments -.->|"records encounter"| node_records
node_records -.->|"archives prescription"| node_prescriptions
node_payments -.->|"verifies payments"| node_razorpay
node_appointments -.->|"persists lifecycle"| node_persistent_data
node_api_app -->|"mounts AI route"| node_ai_gateway
node_ai_gateway -.->|"dispatches assistant"| node_ai_orchestrator
node_ai_orchestrator -->|"plans workflow"| node_workflow_planner
node_ai_orchestrator -->|"synthesizes response"| node_gemini
node_ai_gateway -.->|"supports document Q&amp;A"| node_clinical_qa
node_clinical_qa -->|"generates vectors"| node_embeddings
node_clinical_qa -->|"synthesizes answer"| node_gemini
node_gemini -->|"uses provider gateway"| node_ai_gateway

click node_frontend "https://github.com/manis30/careflow/blob/main/frontend/src/App.jsx"
click node_role_routes "https://github.com/manis30/careflow/blob/main/frontend/src/routes/AppRoutes.jsx"
click node_auth_context "https://github.com/manis30/careflow/blob/main/frontend/src/context/AuthContext.jsx"
click node_booking_ui "https://github.com/manis30/careflow/blob/main/frontend/src/pages/patient/BookAppointment.jsx"
click node_meeting_ui "https://github.com/manis30/careflow/blob/main/frontend/src/pages/common/MeetingRoom.jsx"
click node_admin_ui "https://github.com/manis30/careflow/blob/main/frontend/src/pages/admin/Dashboard.jsx"
click node_api_app "https://github.com/manis30/careflow/blob/main/backend/src/app.js"
click node_auth_domain "https://github.com/manis30/careflow/blob/main/backend/src/controller/user.js"
click node_clinic_directory "https://github.com/manis30/careflow/blob/main/backend/src/controller/doctor.js"
click node_appointments "https://github.com/manis30/careflow/blob/main/backend/src/service/appointment.js"
click node_records "https://github.com/manis30/careflow/blob/main/backend/src/controller/medicalRecord.js"
click node_prescriptions "https://github.com/manis30/careflow/blob/main/backend/src/controller/prescription.js"
click node_payments "https://github.com/manis30/careflow/blob/main/backend/src/controller/payment.js"
click node_messaging "https://github.com/manis30/careflow/blob/main/backend/src/controller/chat.js"
click node_persistent_data "https://github.com/manis30/careflow/blob/main/backend/src/model/appointment.js"
click node_ai_gateway "https://github.com/manis30/careflow/blob/main/backend/src/service/ai/aiGateway.js"
click node_ai_orchestrator "https://github.com/manis30/careflow/blob/main/backend/src/service/ai/orchestrator/agentOrchestrator.js"
click node_workflow_planner "https://github.com/manis30/careflow/blob/main/backend/src/service/ai/orchestrator/workflowPlanner.js"
click node_clinical_qa "https://github.com/manis30/careflow/blob/main/backend/src/service/ai/documentQaService.js"
click node_embeddings "https://github.com/manis30/careflow/blob/main/backend/src/service/ai/embeddingService.js"
click node_gemini "https://github.com/manis30/careflow/blob/main/backend/src/service/ai/geminiClient.js"
click node_video_service "https://github.com/manis30/careflow/blob/main/backend/src/service/meetingService.js"

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_frontend,node_role_routes,node_auth_context,node_booking_ui,node_meeting_ui,node_admin_ui toneBlue
class node_clinic_directory,node_appointments,node_records,node_prescriptions,node_messaging,node_video_service toneAmber
class node_api_app,node_auth_domain,node_payments,node_persistent_data toneMint
class node_ai_gateway,node_ai_orchestrator,node_workflow_planner,node_clinical_qa,node_embeddings,node_gemini toneRose
class node_patients,node_clinicians,node_razorpay toneIndigo
```

## Components

### Role-based experience

- [React application](https://github.com/manis30/careflow/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Role-based routes](https://github.com/manis30/careflow/blob/main/frontend/src/routes/AppRoutes.jsx): `frontend/src/routes/AppRoutes.jsx`
- [Authentication state](https://github.com/manis30/careflow/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Appointment booking](https://github.com/manis30/careflow/blob/main/frontend/src/pages/patient/BookAppointment.jsx): `frontend/src/pages/patient/BookAppointment.jsx`
- [Video consultation](https://github.com/manis30/careflow/blob/main/frontend/src/pages/common/MeetingRoom.jsx): `frontend/src/pages/common/MeetingRoom.jsx`
- [Clinic administration](https://github.com/manis30/careflow/blob/main/frontend/src/pages/admin/Dashboard.jsx): `frontend/src/pages/admin/Dashboard.jsx`

### Clinical operations

- [Clinics and doctors](https://github.com/manis30/careflow/blob/main/backend/src/controller/doctor.js): `backend/src/controller/doctor.js`
- [Appointment lifecycle](https://github.com/manis30/careflow/blob/main/backend/src/service/appointment.js): `backend/src/service/appointment.js`
- [Medical records](https://github.com/manis30/careflow/blob/main/backend/src/controller/medicalRecord.js): `backend/src/controller/medicalRecord.js`
- [Prescriptions and medication](https://github.com/manis30/careflow/blob/main/backend/src/controller/prescription.js): `backend/src/controller/prescription.js`
- [Messaging and telehealth](https://github.com/manis30/careflow/blob/main/backend/src/controller/chat.js): `backend/src/controller/chat.js`
- [Video consultation service](https://github.com/manis30/careflow/blob/main/backend/src/service/meetingService.js): `backend/src/service/meetingService.js`

### Platform services

- [HTTP API application](https://github.com/manis30/careflow/blob/main/backend/src/app.js): `backend/src/app.js`
- [Accounts and access](https://github.com/manis30/careflow/blob/main/backend/src/controller/user.js): `backend/src/controller/user.js`
- [Payments](https://github.com/manis30/careflow/blob/main/backend/src/controller/payment.js): `backend/src/controller/payment.js`
- [MongoDB domain data](https://github.com/manis30/careflow/blob/main/backend/src/model/appointment.js): `backend/src/model/appointment.js`

### AI assistance

- [AI gateway](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/aiGateway.js): `backend/src/service/ai/aiGateway.js`
- [Agent orchestration](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/orchestrator/agentOrchestrator.js): `backend/src/service/ai/orchestrator/agentOrchestrator.js`
- [Workflow planning](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/orchestrator/workflowPlanner.js): `backend/src/service/ai/orchestrator/workflowPlanner.js`
- [Document Q&A and OCR](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/documentQaService.js): `backend/src/service/ai/documentQaService.js`
- [Document embeddings](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/embeddingService.js): `backend/src/service/ai/embeddingService.js`
- [Gemini provider client](https://github.com/manis30/careflow/blob/main/backend/src/service/ai/geminiClient.js): `backend/src/service/ai/geminiClient.js`

### Other components

- **Patients**
- **Clinicians and staff**
- **Razorpay**

## Connections

- Patients → React application: use platform
- Clinicians and staff → React application: use platform
- React application → Role-based routes: renders routes (evidence: `frontend/src/App.jsx`)
- React application → Authentication state: provides auth (evidence: `frontend/src/App.jsx`)
- Role-based routes → Appointment booking: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Role-based routes → Video consultation: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Appointment booking → HTTP API application: submits booking
- Video consultation → Video consultation service: joins consultation
- React application → HTTP API application: requests API
- HTTP API application → Accounts and access: mounts routes (evidence: `backend/src/app.js`)
- HTTP API application → Clinics and doctors: mounts routes (evidence: `backend/src/app.js`)
- HTTP API application → Appointment lifecycle: mounts routes (evidence: `backend/src/app.js`)
- HTTP API application → Medical records: mounts routes (evidence: `backend/src/app.js`)
- HTTP API application → Prescriptions and medication: mounts routes (evidence: `backend/src/app.js`)
- HTTP API application → Payments: mounts routes (evidence: `backend/src/app.js`)
- HTTP API application → Messaging and telehealth: mounts routes (evidence: `backend/src/app.js`)
- Clinics and doctors → Appointment lifecycle: supports booking
- Appointment lifecycle → Payments: queues payment
- Appointment lifecycle → Video consultation service: enables consultation
- Appointment lifecycle → Medical records: records encounter
- Medical records → Prescriptions and medication: archives prescription
- Payments → Razorpay: verifies payments
- Appointment lifecycle → MongoDB domain data: persists lifecycle
- HTTP API application → AI gateway: mounts AI route (evidence: `backend/src/app.js`)
- AI gateway → Agent orchestration: dispatches assistant (evidence: `backend/src/service/ai/orchestrator/agentOrchestrator.js`)
- Agent orchestration → Workflow planning: plans workflow (evidence: `backend/src/service/ai/orchestrator/agentOrchestrator.js`)
- Agent orchestration → Gemini provider client: synthesizes response (evidence: `backend/src/service/ai/orchestrator/agentOrchestrator.js`)
- AI gateway → Document Q&A and OCR: supports document Q&A
- Document Q&A and OCR → Document embeddings: generates vectors (evidence: `backend/src/service/ai/documentQaService.js`)
- Document Q&A and OCR → Gemini provider client: synthesizes answer (evidence: `backend/src/service/ai/documentQaService.js`)
- Gemini provider client → AI gateway: uses provider gateway (evidence: `backend/src/service/ai/geminiClient.js`)
