# developer-joshi/healthmate architecture

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

- Interactive diagram: https://gitdiagram.com/developer-joshi/healthmate
- Repository: https://github.com/developer-joshi/healthmate

## Overview

#### 1. System Purpose and Deployables
Health Mate is a healthcare appointment platform with three separately deployed JavaScript applications:
- Patient-facing web client: doctor discovery, profiles, appointment booking, and appointment management.
- Administrative and doctor portal: operational dashboards, doctor onboarding, schedules/appointments, and profiles.
- API backend: authentication, user/doctor/admin operations, appointment lifecycle, and media uploads.

Primary client entry points are `frontend/src/main.jsx` and `admin/src/main.jsx`; the server entry point is `backend/server.js`.

#### 2. Patient Application
The Vite/React patient SPA composes route-level healthcare journeys from `frontend/src/App.jsx`. Its main domain pages cover discovery and booking (`frontend/src/pages/Doctors.jsx`, `frontend/src/pages/Appointment.jsx`) and patient account operations (`frontend/src/pages/MyAppointments.jsx`, `frontend/src/pages/MyProfile.jsx`).

Shared client state and backend communication are centralized through `frontend/src/context/AppContext.jsx`. Reusable doctor-oriented UI components, including doctor listings and related-doctor suggestions, sit at `frontend/src/components/TopDoctors.jsx` and `frontend/src/components/RelatedDoctors.jsx`.

#### 3. Admin and Doctor Portal
A distinct Vite/React SPA serves both admin and doctor roles, rooted at `admin/src/main.jsx` and routed from `admin/src/App.jsx`. Role-specific contexts separate admin, doctor, and common application state:
`admin/src/context/AdminContext.jsx`, `admin/src/context/DoctorContext.jsx`, and `admin/src/context/AppContext.jsx`.

Admin workflows include dashboarding, doctor creation/listing, and appointment oversight in `admin/src/pages/Admin/Dashboard.jsx`, `admin/src/pages/Admin/AddDoctor.jsx`, and `admin/src/pages/Admin/AllAppointments.jsx`. Doctor workflows expose appointments, dashboard, and profile through `admin/src/pages/Doctor/DoctorAppointments.jsx` and `admin/src/pages/Doctor/DoctorProfile.jsx`.

#### 4. API Boundary and Request Control
The Express server in `backend/server.js` exposes separate route surfaces by actor:
- Patient/user API: `backend/routes/userRoute.js`
- Admin API: `backend/routes/adminRoute.js`
- Doctor API: `backend/routes/doctorRoute.js`

Routes delegate business operations to actor-specific controllers: `backend/controllers/userController.js`, `backend/controllers/adminController.js`, and `backend/controllers/doctorController.js`. Authentication is enforced at this API boundary with separate role middleware in `backend/middlewares/authUser.js`, `backend/middlewares/authAdmin.js`, and `backend/middlewares/authDoctor.js`.

#### 5. Core Domain Persistence
MongoDB is the system of record, initialized through `backend/config/mongodb.js`. The core document model defines:
- Patients/accounts: `backend/models/userModel.js`
- Doctor identities, availability, and profile data: `backend/models/doctorModel.js`
- Patient-doctor bookings and appointment state: `backend/models/appointmentModel.js`

The principal flow is client authentication → role-protected API route → controller validation/state change → MongoDB model persistence → refreshed client context/UI. Appointment operations form the central cross-role boundary: patients create/manage bookings, doctors view/manage their appointments, and admins oversee global operations.

#### 6. Media and Video Capabilities
Doctor/profile image upload handling is split between multipart parsing in `backend/middlewares/multer.js` and Cloudinary integration in `backend/config/cloudinary.js`; Cloudinary is therefore an external persistence boundary for media rather than MongoDB.

Both SPAs include a video-room component (`frontend/src/components/video/VideoRoom.jsx`, `admin/src/components/video/VideoRoom.jsx`), indicating a shared consultation/video interaction surface, though its service integration is not represented in the supplied tree.

#### 7. Runtime and Infrastructure
Frontend and portal are React applications built with Vite (`frontend/vite.config.js`, `admin/vite.config.js`) and configured for Vercel deployment (`frontend/vercel.json`, `admin/vercel.json`). The README identifies deployed patient and admin sites on Vercel. The backend is a Node.js/Express service with MongoDB and Cloudinary as material external dependencies.

Main entry points: [`frontend/src/App.jsx`](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/App.jsx) (Patient journeys), [`admin/src/App.jsx`](https://github.com/developer-joshi/healthmate/blob/main/admin/src/App.jsx) (Role portal routes), [`backend/routes/userRoute.js`](https://github.com/developer-joshi/healthmate/blob/main/backend/routes/userRoute.js) (Actor API routes), [`frontend/src/context/AppContext.jsx`](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/context/AppContext.jsx) (Patient app context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient Web App"]
  node_patient_entry["Patient SPA<br/>React/Vite entry<br/>[main.jsx]"]
  node_patient_routes["Patient journeys<br/>route shell<br/>[App.jsx]"]
  node_patient_state["Patient app context<br/>client state/API client<br/>[AppContext.jsx]"]
  node_patient_booking["Doctor discovery &amp; booking<br/>patient pages<br/>[Appointment.jsx]"]
  node_patient_video["Video room<br/>consultation UI<br/>[VideoRoom.jsx]"]
end

subgraph group_portal["Admin &amp; Doctor Portal"]
  node_portal_entry["Portal SPA<br/>React/Vite entry<br/>[main.jsx]"]
  node_portal_routes["Role portal routes<br/>route shell<br/>[App.jsx]"]
  node_portal_contexts["Admin &amp; doctor contexts<br/>role state/API clients<br/>[AdminContext.jsx]"]
  node_portal_operations["Operations &amp; schedules<br/>admin/doctor pages"]
  node_portal_video["Video room<br/>consultation UI<br/>[VideoRoom.jsx]"]
end

subgraph group_api["Express API"]
  node_server{{"API server<br/>Node/Express runtime<br/>[server.js]"}}
  node_routes["Actor API routes<br/>user/admin/doctor routes<br/>[userRoute.js]"]
  node_auth["Role authentication<br/>middleware<br/>[authUser.js]"]
  node_controllers["Domain controllers<br/>business operations<br/>[userController.js]"]
  node_uploads["Multipart upload handling<br/>upload middleware<br/>[multer.js]"]
end

subgraph group_data["Persistence &amp; Media"]
  node_mongo[("MongoDB<br/>system of record<br/>[mongodb.js]")]
  node_models["Domain models<br/>Mongoose documents"]
  node_cloudinary[("Cloudinary<br/>media storage<br/>[cloudinary.js]")]
end

node_patient_entry -->|"mounts"| node_patient_routes
node_patient_routes -->|"renders"| node_patient_booking
node_patient_routes -->|"uses"| node_patient_state
node_patient_booking -->|"reads and updates"| node_patient_state
node_patient_state -->|"patient API requests"| node_server
node_patient_routes -.->|"consultation UI"| node_patient_video
node_portal_entry -->|"mounts"| node_portal_routes
node_portal_routes -->|"uses"| node_portal_contexts
node_portal_routes -->|"renders"| node_portal_operations
node_portal_operations -->|"reads and updates"| node_portal_contexts
node_portal_contexts -->|"admin/doctor API requests"| node_server
node_portal_routes -.->|"consultation UI"| node_portal_video
node_server -->|"exposes"| node_routes
node_routes -->|"protects role routes"| node_auth
node_auth -->|"authorizes"| node_controllers
node_routes -->|"delegates"| node_controllers
node_controllers -->|"validates and changes state"| node_models
node_models -->|"persists documents"| node_mongo
node_routes -->|"parses media requests"| node_uploads
node_uploads -->|"stores images"| node_cloudinary

click node_patient_entry "https://github.com/developer-joshi/healthmate/blob/main/frontend/src/main.jsx"
click node_patient_routes "https://github.com/developer-joshi/healthmate/blob/main/frontend/src/App.jsx"
click node_patient_state "https://github.com/developer-joshi/healthmate/blob/main/frontend/src/context/AppContext.jsx"
click node_patient_booking "https://github.com/developer-joshi/healthmate/blob/main/frontend/src/pages/Appointment.jsx"
click node_patient_video "https://github.com/developer-joshi/healthmate/blob/main/frontend/src/components/video/VideoRoom.jsx"
click node_portal_entry "https://github.com/developer-joshi/healthmate/blob/main/admin/src/main.jsx"
click node_portal_routes "https://github.com/developer-joshi/healthmate/blob/main/admin/src/App.jsx"
click node_portal_contexts "https://github.com/developer-joshi/healthmate/blob/main/admin/src/context/AdminContext.jsx"
click node_portal_operations "https://github.com/developer-joshi/healthmate/blob/main/admin/src/pages/Admin/AllAppointments.jsx"
click node_portal_video "https://github.com/developer-joshi/healthmate/blob/main/admin/src/components/video/VideoRoom.jsx"
click node_server "https://github.com/developer-joshi/healthmate/blob/main/backend/server.js"
click node_routes "https://github.com/developer-joshi/healthmate/blob/main/backend/routes/userRoute.js"
click node_auth "https://github.com/developer-joshi/healthmate/blob/main/backend/middlewares/authUser.js"
click node_controllers "https://github.com/developer-joshi/healthmate/blob/main/backend/controllers/userController.js"
click node_mongo "https://github.com/developer-joshi/healthmate/blob/main/backend/config/mongodb.js"
click node_models "https://github.com/developer-joshi/healthmate/blob/main/backend/models/appointmentModel.js"
click node_uploads "https://github.com/developer-joshi/healthmate/blob/main/backend/middlewares/multer.js"
click node_cloudinary "https://github.com/developer-joshi/healthmate/blob/main/backend/config/cloudinary.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_entry,node_patient_routes,node_patient_state,node_patient_booking,node_patient_video toneBlue
class node_portal_entry,node_portal_routes,node_portal_contexts,node_portal_operations,node_portal_video toneAmber
class node_server,node_routes,node_auth,node_controllers,node_uploads toneMint
class node_mongo,node_models,node_cloudinary toneRose
```

## Components

### Patient Web App

- [Patient SPA](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/main.jsx): React/Vite entry · `frontend/src/main.jsx`
- [Patient journeys](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/App.jsx): route shell · Discovery, booking, appointments, and profile routes. · `frontend/src/App.jsx`
- [Patient app context](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/context/AppContext.jsx): client state/API client · `frontend/src/context/AppContext.jsx`
- [Doctor discovery & booking](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/pages/Appointment.jsx): patient pages · `frontend/src/pages/Appointment.jsx`
- [Video room](https://github.com/developer-joshi/healthmate/blob/main/frontend/src/components/video/VideoRoom.jsx): consultation UI · `frontend/src/components/video/VideoRoom.jsx`

### Admin & Doctor Portal

- [Portal SPA](https://github.com/developer-joshi/healthmate/blob/main/admin/src/main.jsx): React/Vite entry · `admin/src/main.jsx`
- [Role portal routes](https://github.com/developer-joshi/healthmate/blob/main/admin/src/App.jsx): route shell · `admin/src/App.jsx`
- [Admin & doctor contexts](https://github.com/developer-joshi/healthmate/blob/main/admin/src/context/AdminContext.jsx): role state/API clients · Separate admin, doctor, and common application state. · `admin/src/context/AdminContext.jsx`
- [Operations & schedules](https://github.com/developer-joshi/healthmate/blob/main/admin/src/pages/Admin/AllAppointments.jsx): admin/doctor pages · Admin oversight and doctor appointment/profile workflows. · `admin/src/pages/Admin/AllAppointments.jsx`
- [Video room](https://github.com/developer-joshi/healthmate/blob/main/admin/src/components/video/VideoRoom.jsx): consultation UI · `admin/src/components/video/VideoRoom.jsx`

### Express API

- [API server](https://github.com/developer-joshi/healthmate/blob/main/backend/server.js): Node/Express runtime · `backend/server.js`
- [Actor API routes](https://github.com/developer-joshi/healthmate/blob/main/backend/routes/userRoute.js): user/admin/doctor routes · Separate API surfaces for patients, admins, and doctors. · `backend/routes/userRoute.js`
- [Role authentication](https://github.com/developer-joshi/healthmate/blob/main/backend/middlewares/authUser.js): middleware · User, admin, and doctor request protection. · `backend/middlewares/authUser.js`
- [Domain controllers](https://github.com/developer-joshi/healthmate/blob/main/backend/controllers/userController.js): business operations · Actor-specific authentication, profiles, and appointment lifecycle logic. · `backend/controllers/userController.js`
- [Multipart upload handling](https://github.com/developer-joshi/healthmate/blob/main/backend/middlewares/multer.js): upload middleware · `backend/middlewares/multer.js`

### Persistence & Media

- [MongoDB](https://github.com/developer-joshi/healthmate/blob/main/backend/config/mongodb.js): system of record · Stores user, doctor, and appointment documents. · `backend/config/mongodb.js`
- [Domain models](https://github.com/developer-joshi/healthmate/blob/main/backend/models/appointmentModel.js): Mongoose documents · Users, doctors/availability, and appointments. · `backend/models/appointmentModel.js`
- [Cloudinary](https://github.com/developer-joshi/healthmate/blob/main/backend/config/cloudinary.js): media storage · External profile and doctor image persistence. · `backend/config/cloudinary.js`

## Connections

- Patient SPA → Patient journeys: mounts
- Patient journeys → Doctor discovery & booking: renders
- Patient journeys → Patient app context: uses
- Doctor discovery & booking → Patient app context: reads and updates
- Patient app context → API server: patient API requests
- Patient journeys → Video room: consultation UI
- Portal SPA → Role portal routes: mounts
- Role portal routes → Admin & doctor contexts: uses
- Role portal routes → Operations & schedules: renders
- Operations & schedules → Admin & doctor contexts: reads and updates
- Admin & doctor contexts → API server: admin/doctor API requests
- Role portal routes → Video room: consultation UI
- API server → Actor API routes: exposes
- Actor API routes → Role authentication: protects role routes
- Role authentication → Domain controllers: authorizes
- Actor API routes → Domain controllers: delegates
- Domain controllers → Domain models: validates and changes state
- Domain models → MongoDB: persists documents
- Actor API routes → Multipart upload handling: parses media requests
- Multipart upload handling → Cloudinary: stores images
