# krishb404/therapyco architecture

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

- Interactive diagram: https://gitdiagram.com/krishb404/therapyco
- Repository: https://github.com/krishb404/therapyco

## Overview

Therapy Co is a patient-facing therapy booking and care platform with separate doctor/admin tools. Patients discover clinicians, book or request consultations, attend video sessions, and manage appointments; the product also documents an AI assistant, prescriptions, pharmacy, payments, and reminders. The backend provides API, persistence, scheduling, and signaling services. Several feature implementations are represented by README statements or indexed paths rather than sampled code, so those connections are documented or left unverified.

Main entry points: [`frontend/src/App.jsx`](https://github.com/krishb404/therapyco/blob/main/frontend/src/App.jsx) (Patient web app), [`backend/server.js`](https://github.com/krishb404/therapyco/blob/main/backend/server.js) (API and signaling server), [`backend/controllers/userController.js`](https://github.com/krishb404/therapyco/blob/main/backend/controllers/userController.js) (Patient API handlers), [`backend/controllers/adminController.js`](https://github.com/krishb404/therapyco/blob/main/backend/controllers/adminController.js) (Admin API handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient experience"]
  node_patient_app["Patient web app<br/>[App.jsx]"]
  node_booking["Appointment booking<br/>[Appointment.jsx]"]
  node_appointments["My appointments<br/>[MyAppointments.jsx]"]
  node_video_patient["Patient video room<br/>[VideoRoom.jsx]"]
  node_pharmacy["Medicine store<br/>[Medicines.jsx]"]
  node_medicine_detail["Medicine details<br/>[MedicineDetail.jsx]"]
  node_cart["Shopping cart<br/>[Cart.jsx]"]
  node_cart_state["Cart state<br/>[CartContext.jsx]"]
  node_chat_ui["Chat assistant UI<br/>[ChatWindow.jsx]"]
  node_chat_state["Chat state<br/>[ChatbotContext.jsx]"]
end

subgraph group_care["Clinical services"]
end

subgraph group_operations["Doctor and admin portal"]
  node_doctor_portal["Doctor portal<br/>[App.jsx]"]
  node_doctor_context["Doctor operations state<br/>[DoctorContext.jsx]"]
  node_request_overlay["Consult request overlay<br/>[RequestOverlay.jsx]"]
  node_doctor_video["Doctor video room<br/>[VideoRoom.jsx]"]
  node_admin_context["Admin management state<br/>[AdminContext.jsx]"]
end

subgraph group_platform["Backend and integrations"]
  node_backend["API and signaling server<br/>[server.js]"]
  node_user_api["Patient API handlers<br/>[userController.js]"]
  node_doctor_api["Doctor API handlers"]
  node_admin_api["Admin API handlers<br/>[adminController.js]"]
  node_consultation_api["Consultation handlers"]
  node_chat_api["Chatbot endpoint<br/>[chatbotRoute.js]"]
  node_reminders["Email reminders<br/>[reminderService.js]"]
  node_appointment_store[("Appointment records")]
  node_doctor_store[("Doctor records<br/>[doctorModel.js]")]
  node_user_store[("Patient records<br/>[userModel.js]")]
  node_notification_store[("Notifications")]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))
node_gemini["Gemini AI"]
node_razorpay["Razorpay"]
node_email_service["SMTP email service"]
node_cloudinary["Cloudinary"]

node_patient -->|"uses"| node_patient_app
node_patient_app -->|"routes to"| node_booking
node_patient_app -->|"routes to"| node_appointments
node_patient_app -->|"routes to"| node_video_patient
node_patient_app -->|"routes to"| node_pharmacy
node_patient_app -->|"routes to"| node_medicine_detail
node_patient_app -->|"routes to"| node_cart
node_patient_app -->|"renders"| node_chat_ui
node_chat_ui -->|"uses"| node_chat_state
node_pharmacy -.->|"opens product"| node_medicine_detail
node_cart -.->|"uses"| node_cart_state
node_booking -.->|"submits booking"| node_user_api
node_appointments -.->|"loads appointments"| node_user_api
node_video_patient -.->|"signals session"| node_backend
node_doctor -->|"uses"| node_doctor_portal
node_admin -->|"uses"| node_doctor_portal
node_doctor_portal -->|"routes to"| node_doctor_video
node_doctor_portal -->|"renders request"| node_request_overlay
node_request_overlay -->|"invokes actions"| node_doctor_context
node_doctor_video -->|"uses"| node_doctor_context
node_doctor_video -.->|"signals session"| node_backend
node_doctor_context -->|"schedules consultation"| node_consultation_api
node_doctor_portal -->|"uses"| node_admin_context
node_admin_context -->|"requests management data"| node_admin_api
node_backend -->|"routes requests"| node_user_api
node_backend -->|"routes requests"| node_doctor_api
node_backend -->|"routes requests"| node_admin_api
node_backend -->|"routes requests"| node_consultation_api
node_backend -->|"mounts endpoint"| node_chat_api
node_user_api -->|"creates and reads"| node_appointment_store
node_user_api -->|"updates slots"| node_doctor_store
node_user_api -->|"reads and creates"| node_user_store
node_doctor_api -->|"manages appointments"| node_appointment_store
node_doctor_api -->|"manages doctors"| node_doctor_store
node_admin_api -->|"manages appointments"| node_appointment_store
node_admin_api -->|"manages doctors"| node_doctor_store
node_admin_api -->|"reads patients"| node_user_store
node_consultation_api -->|"reads patient data"| node_user_store
node_consultation_api -->|"reads doctor data"| node_doctor_store
node_consultation_api -->|"creates appointments"| node_appointment_store
node_consultation_api -->|"creates notifications"| node_notification_store
node_backend -->|"starts job"| node_reminders
node_reminders -->|"checks and marks"| node_appointment_store
node_reminders -->|"sends reminders"| node_email_service
node_chat_api -.->|"answers queries"| node_gemini
node_user_api -->|"verifies payment"| node_razorpay
node_user_api -->|"uploads images"| node_cloudinary
node_admin_api -->|"uploads doctor images"| node_cloudinary

click node_patient_app "https://github.com/krishb404/therapyco/blob/main/frontend/src/App.jsx"
click node_booking "https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/Appointment.jsx"
click node_appointments "https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/MyAppointments.jsx"
click node_video_patient "https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/VideoRoom.jsx"
click node_pharmacy "https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/Medicines.jsx"
click node_medicine_detail "https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/MedicineDetail.jsx"
click node_cart "https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/Cart.jsx"
click node_cart_state "https://github.com/krishb404/therapyco/blob/main/frontend/src/context/CartContext.jsx"
click node_chat_ui "https://github.com/krishb404/therapyco/blob/main/frontend/src/components/ChatWindow.jsx"
click node_chat_state "https://github.com/krishb404/therapyco/blob/main/frontend/src/context/ChatbotContext.jsx"
click node_doctor_portal "https://github.com/krishb404/therapyco/blob/main/admin/src/App.jsx"
click node_doctor_context "https://github.com/krishb404/therapyco/blob/main/admin/src/context/DoctorContext.jsx"
click node_request_overlay "https://github.com/krishb404/therapyco/blob/main/admin/src/components/RequestOverlay.jsx"
click node_doctor_video "https://github.com/krishb404/therapyco/blob/main/admin/src/pages/Doctor/VideoRoom.jsx"
click node_admin_context "https://github.com/krishb404/therapyco/blob/main/admin/src/context/AdminContext.jsx"
click node_backend "https://github.com/krishb404/therapyco/blob/main/backend/server.js"
click node_user_api "https://github.com/krishb404/therapyco/blob/main/backend/controllers/userController.js"
click node_doctor_api "https://github.com/krishb404/therapyco/blob/main/backend/controllers/doctorController.js"
click node_admin_api "https://github.com/krishb404/therapyco/blob/main/backend/controllers/adminController.js"
click node_consultation_api "https://github.com/krishb404/therapyco/blob/main/backend/controllers/consultationController.js"
click node_chat_api "https://github.com/krishb404/therapyco/blob/main/backend/routes/chatbotRoute.js"
click node_reminders "https://github.com/krishb404/therapyco/blob/main/backend/jobs/reminderService.js"
click node_appointment_store "https://github.com/krishb404/therapyco/blob/main/backend/models/appointmentModel.js"
click node_doctor_store "https://github.com/krishb404/therapyco/blob/main/backend/models/doctorModel.js"
click node_user_store "https://github.com/krishb404/therapyco/blob/main/backend/models/userModel.js"
click node_notification_store "https://github.com/krishb404/therapyco/blob/main/backend/models/notificationModel.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_patient_app,node_booking,node_appointments,node_video_patient,node_pharmacy,node_medicine_detail,node_cart,node_cart_state,node_chat_ui,node_chat_state toneBlue
class node_doctor_portal,node_doctor_context,node_request_overlay,node_doctor_video,node_admin_context toneMint
class node_backend,node_user_api,node_doctor_api,node_admin_api,node_consultation_api,node_chat_api,node_reminders,node_appointment_store,node_doctor_store,node_user_store,node_notification_store toneRose
class node_patient,node_doctor,node_admin,node_gemini,node_razorpay,node_email_service,node_cloudinary toneIndigo
```

## Components

### Patient experience

- [Patient web app](https://github.com/krishb404/therapyco/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Appointment booking](https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/Appointment.jsx): `frontend/src/pages/Appointment.jsx`
- [My appointments](https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/MyAppointments.jsx): `frontend/src/pages/MyAppointments.jsx`
- [Patient video room](https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/VideoRoom.jsx): `frontend/src/pages/VideoRoom.jsx`
- [Medicine store](https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/Medicines.jsx): `frontend/src/pages/Medicines.jsx`
- [Medicine details](https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/MedicineDetail.jsx): `frontend/src/pages/MedicineDetail.jsx`
- [Shopping cart](https://github.com/krishb404/therapyco/blob/main/frontend/src/pages/Cart.jsx): `frontend/src/pages/Cart.jsx`
- [Cart state](https://github.com/krishb404/therapyco/blob/main/frontend/src/context/CartContext.jsx): `frontend/src/context/CartContext.jsx`
- [Chat assistant UI](https://github.com/krishb404/therapyco/blob/main/frontend/src/components/ChatWindow.jsx): `frontend/src/components/ChatWindow.jsx`
- [Chat state](https://github.com/krishb404/therapyco/blob/main/frontend/src/context/ChatbotContext.jsx): `frontend/src/context/ChatbotContext.jsx`

### Doctor and admin portal

- [Doctor portal](https://github.com/krishb404/therapyco/blob/main/admin/src/App.jsx): `admin/src/App.jsx`
- [Doctor operations state](https://github.com/krishb404/therapyco/blob/main/admin/src/context/DoctorContext.jsx): `admin/src/context/DoctorContext.jsx`
- [Consult request overlay](https://github.com/krishb404/therapyco/blob/main/admin/src/components/RequestOverlay.jsx): `admin/src/components/RequestOverlay.jsx`
- [Doctor video room](https://github.com/krishb404/therapyco/blob/main/admin/src/pages/Doctor/VideoRoom.jsx): `admin/src/pages/Doctor/VideoRoom.jsx`
- [Admin management state](https://github.com/krishb404/therapyco/blob/main/admin/src/context/AdminContext.jsx): `admin/src/context/AdminContext.jsx`

### Backend and integrations

- [API and signaling server](https://github.com/krishb404/therapyco/blob/main/backend/server.js): `backend/server.js`
- [Patient API handlers](https://github.com/krishb404/therapyco/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Doctor API handlers](https://github.com/krishb404/therapyco/blob/main/backend/controllers/doctorController.js): `backend/controllers/doctorController.js`
- [Admin API handlers](https://github.com/krishb404/therapyco/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`
- [Consultation handlers](https://github.com/krishb404/therapyco/blob/main/backend/controllers/consultationController.js): `backend/controllers/consultationController.js`
- [Chatbot endpoint](https://github.com/krishb404/therapyco/blob/main/backend/routes/chatbotRoute.js): `backend/routes/chatbotRoute.js`
- [Email reminders](https://github.com/krishb404/therapyco/blob/main/backend/jobs/reminderService.js): `backend/jobs/reminderService.js`
- [Appointment records](https://github.com/krishb404/therapyco/blob/main/backend/models/appointmentModel.js): `backend/models/appointmentModel.js`
- [Doctor records](https://github.com/krishb404/therapyco/blob/main/backend/models/doctorModel.js): `backend/models/doctorModel.js`
- [Patient records](https://github.com/krishb404/therapyco/blob/main/backend/models/userModel.js): `backend/models/userModel.js`
- [Notifications](https://github.com/krishb404/therapyco/blob/main/backend/models/notificationModel.js): `backend/models/notificationModel.js`

### Other components

- **Patient**
- **Doctor**
- **Administrator**
- **Gemini AI**
- **Razorpay**
- **SMTP email service**
- **Cloudinary**

## Connections

- Patient → Patient web app: uses (evidence: `frontend/src/App.jsx`)
- Patient web app → Appointment booking: routes to (evidence: `frontend/src/App.jsx`)
- Patient web app → My appointments: routes to (evidence: `frontend/src/App.jsx`)
- Patient web app → Patient video room: routes to (evidence: `frontend/src/App.jsx`)
- Patient web app → Medicine store: routes to (evidence: `frontend/src/App.jsx`)
- Patient web app → Medicine details: routes to (evidence: `frontend/src/App.jsx`)
- Patient web app → Shopping cart: routes to (evidence: `frontend/src/App.jsx`)
- Patient web app → Chat assistant UI: renders (evidence: `frontend/src/App.jsx`)
- Chat assistant UI → Chat state: uses (evidence: `frontend/src/components/ChatWindow.jsx`)
- Medicine store → Medicine details: opens product
- Shopping cart → Cart state: uses
- Appointment booking → Patient API handlers: submits booking
- My appointments → Patient API handlers: loads appointments
- Patient video room → API and signaling server: signals session
- Doctor → Doctor portal: uses (evidence: `admin/src/App.jsx`)
- Administrator → Doctor portal: uses (evidence: `admin/src/App.jsx`)
- Doctor portal → Doctor video room: routes to (evidence: `admin/src/App.jsx`)
- Doctor portal → Consult request overlay: renders request (evidence: `admin/src/App.jsx`)
- Consult request overlay → Doctor operations state: invokes actions (evidence: `admin/src/App.jsx`)
- Doctor video room → Doctor operations state: uses (evidence: `admin/src/pages/Doctor/VideoRoom.jsx`)
- Doctor video room → API and signaling server: signals session
- Doctor operations state → Consultation handlers: schedules consultation (evidence: `admin/src/context/DoctorContext.jsx`)
- Doctor portal → Admin management state: uses (evidence: `admin/src/App.jsx`)
- Admin management state → Admin API handlers: requests management data (evidence: `admin/src/context/AdminContext.jsx`)
- API and signaling server → Patient API handlers: routes requests (evidence: `backend/server.js`)
- API and signaling server → Doctor API handlers: routes requests (evidence: `backend/server.js`)
- API and signaling server → Admin API handlers: routes requests (evidence: `backend/server.js`)
- API and signaling server → Consultation handlers: routes requests (evidence: `backend/server.js`)
- API and signaling server → Chatbot endpoint: mounts endpoint (evidence: `backend/server.js`)
- Patient API handlers → Appointment records: creates and reads (evidence: `backend/controllers/userController.js`)
- Patient API handlers → Doctor records: updates slots (evidence: `backend/controllers/userController.js`)
- Patient API handlers → Patient records: reads and creates (evidence: `backend/controllers/userController.js`)
- Doctor API handlers → Appointment records: manages appointments (evidence: `backend/controllers/doctorController.js`)
- Doctor API handlers → Doctor records: manages doctors (evidence: `backend/controllers/doctorController.js`)
- Admin API handlers → Appointment records: manages appointments (evidence: `backend/controllers/adminController.js`)
- Admin API handlers → Doctor records: manages doctors (evidence: `backend/controllers/adminController.js`)
- Admin API handlers → Patient records: reads patients (evidence: `backend/controllers/adminController.js`)
- Consultation handlers → Patient records: reads patient data (evidence: `backend/controllers/consultationController.js`)
- Consultation handlers → Doctor records: reads doctor data (evidence: `backend/controllers/consultationController.js`)
- Consultation handlers → Appointment records: creates appointments (evidence: `backend/controllers/consultationController.js`)
- Consultation handlers → Notifications: creates notifications (evidence: `backend/controllers/consultationController.js`)
- API and signaling server → Email reminders: starts job (evidence: `backend/server.js`)
- Email reminders → Appointment records: checks and marks (evidence: `backend/jobs/reminderService.js`)
- Email reminders → SMTP email service: sends reminders (evidence: `backend/jobs/reminderService.js`)
- Chatbot endpoint → Gemini AI: answers queries (evidence: `README.md`)
- Patient API handlers → Razorpay: verifies payment (evidence: `backend/controllers/userController.js`)
- Patient API handlers → Cloudinary: uploads images (evidence: `backend/controllers/userController.js`)
- Admin API handlers → Cloudinary: uploads doctor images (evidence: `backend/controllers/adminController.js`)
