How developer-joshi/healthmate works
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: src/App.jsx Patient journeys · src/App.jsx Role portal routes · userRoute.js Actor API routes · AppContext.jsx Patient app context
Components 18
Patient Web App
- Patient SPA
frontend/src/main.jsx - Patient journeys · Discovery, booking, appointments, and profile routes.
frontend/src/App.jsx - Patient app context
frontend/src/context/AppContext.jsx - Doctor discovery & booking
frontend/src/pages/Appointment.jsx - Video room
frontend/src/components/video/VideoRoom.jsx
Admin & Doctor Portal
- Portal SPA
admin/src/main.jsx - Role portal routes
admin/src/App.jsx - Admin & doctor contexts · Separate admin, doctor, and common application state.
admin/src/context/AdminContext.jsx - Operations & schedules · Admin oversight and doctor appointment/profile workflows.
admin/src/pages/Admin/AllAppointments.jsx - Video room
admin/src/components/video/VideoRoom.jsx
Express API
- API server
backend/server.js - Actor API routes · Separate API surfaces for patients, admins, and doctors.
backend/routes/userRoute.js - Role authentication · User, admin, and doctor request protection.
backend/middlewares/authUser.js - Domain controllers · Actor-specific authentication, profiles, and appointment lifecycle logic.
backend/controllers/userController.js - Multipart upload handling
backend/middlewares/multer.js
Persistence & Media
- MongoDB · Stores user, doctor, and appointment documents.
backend/config/mongodb.js - Domain models · Users, doctors/availability, and appointments.
backend/models/appointmentModel.js - Cloudinary · External profile and doctor image persistence.
backend/config/cloudinary.js
Connections 20
- 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