How harshitsingh4321/appointy works
1. This repository is split into three main deployable parts: a patient-facing React app in frontend/, an admin/doctor-facing React app in admin/, and a Node/Express API in backend/. The architecture is a classic MERN-style split where both UIs consume the same backend and database.
2. The frontend/ app is the public booking experience. Its pages cover home, doctor browsing, appointment booking, profile management, login, about, and contact. The UI is organized around reusable components like the header, navbar, footer, doctor cards, speciality menu, and top-doctors lists.
3. The admin/ app is a separate React frontend for privileged users. It contains admin dashboards for analytics, doctor management, and appointment oversight, plus doctor-specific pages for doctor dashboard, appointments, and profile. This separation indicates role-specific UX and probably independent routing/auth guards per role.
4. Both frontends use React Context for shared client-side state. The patient app has AppContext, while the admin app includes AppContext, AdminContext, and DoctorContext. These contexts likely hold session data, current user/doctor records, appointment state, and shared API results that multiple components need.
5. The backend is an Express application entrypointed from backend/server.js. Routes are divided by role into userRoute.js, doctorRoute.js, and adminRoute.js, which keeps patient, doctor, and admin APIs separated at the boundary level rather than mixing them in one controller surface.
6. The backend data model is centered on three MongoDB collections: users, doctors, and appointments. userModel.js, doctorModel.js, and appointmentModel.js define the persistence layer and form the core data flow for booking, profile updates, dashboards, and status changes.
7. Authentication and authorization are enforced with role-specific middleware: authUser, authDoctor, and authAdmin. This is a key architectural boundary because each frontend can call only the APIs allowed for its role, and the backend can reject cross-role access even if a client is compromised.
8. File upload and image hosting are handled as a separate subsystem. multer.js suggests multipart upload handling on the API side, while cloudinary.js indicates uploaded doctor/user images are stored in Cloudinary rather than directly in MongoDB or the app server filesystem.
9. The main transactional flow is appointment booking. A patient selects a doctor in the frontend, submits booking details and payment choice, the backend creates an appointment record, and later doctor/admin panels update that appointment’s status to completed or canceled. The README mentions payment methods such as cash and Razorpay; the repo structure suggests payment logic is integrated into the appointment/API layer rather than isolated in a dedicated payment service.
10. The doctor/admin dashboards are derived views over appointment and user data. Admin pages aggregate totals like doctors, patients, and bookings; doctor pages aggregate earnings, appointment lists, and availability/profile state. These are read-heavy dashboard views backed by the same appointment and doctor collections.
11. Both frontends are built with Vite and styled with Tailwind/PostCSS, which affects architecture mainly at the presentation layer. The presence of vercel.json in both frontend folders suggests the React apps are deployed independently from the backend, likely as separate static SPA deployments.
12. A useful way to draw the system is: two browser clients on the left, a shared Express API in the middle, MongoDB plus Cloudinary as backend dependencies on the right, and role-based middleware guarding the API boundaries. The central business object connecting almost everything is the appointment.
Main entry points: userRoute.js User API · App.jsx Patient SPA · doctorRoute.js Doctor API · adminRoute.js Admin API
Components 18
Patient App
Public booking experience for patients.
- Patient SPA · Public-facing booking and profile experience.
frontend/src/App.jsx - App state · Shared client state for appointments, profile, and API data.
frontend/src/context/AppContext.jsx - UI shell · Header, navbar, footer, and home-page marketing sections.
frontend/src/components/Header.jsx - Doctor browsing · Doctor discovery, speciality filtering, and doctor detail listings.
frontend/src/pages/Doctors.jsx - Booking flow · Appointment creation, My Appointments, and profile management.
frontend/src/Appointment.jsx - Login & profile · Authentication entry and patient account pages.
frontend/src/pages/Login.jsx
Admin App
Privileged admin and doctor interface.
- Admin SPA · Separate privileged interface for admins and doctors.
admin/src/App.jsx - Role state · Admin, doctor, and shared app context for role-specific state.
admin/src/context/AdminContext.jsx - Admin shell · Sidebar and top navigation for the dashboard interface.
admin/src/components/Sidebar.jsx - Dashboards · Admin and doctor overview screens for totals, earnings, and activity.
admin/src/pages/Admin/Dashboard.jsx - Operations · Doctor management, appointment oversight, and doctor profile pages.
admin/src/pages/Admin/AddDoctor.jsx
API Server
Express backend with routes, auth, and persistence.
- Express API · Backend entrypoint that mounts role-specific routes.
backend/server.js - User API · Patient-facing endpoints for profiles, booking, and appointments.
backend/routes/userRoute.js - Doctor API · Doctor endpoints for dashboard data, appointments, and profile updates.
backend/routes/doctorRoute.js - Admin API · Admin endpoints for doctor management and aggregate reporting.
backend/routes/adminRoute.js - Role guards · Auth middleware for users, doctors, and admins.
backend/middlewares/authUser.js - Upload & cloud · Multipart upload handling and Cloudinary image storage.
backend/config/cloudinary.js - Core models · User, doctor, and appointment persistence models.
backend/models/appointmentModel.js
Connections 26
- Patient SPA → App state: uses · Patient UI reads shared client state.
- Patient SPA → UI shell: renders · Main app composes the shell and home experience.
- Patient SPA → Doctor browsing: routes to · Users browse doctors and specialities.
- Patient SPA → Booking flow: routes to · Users book and track appointments.
- Patient SPA → Login & profile: routes to · Users log in and manage profile.
- Booking flow → User API: calls · Booking and appointment actions go through user APIs.
- Doctor browsing → User API: calls · Doctor browsing uses backend data.
- Admin SPA → Role state: uses · Role-aware shared state in the admin area.
- Admin SPA → Admin shell: renders · Dashboard layout is built from shell components.
- Admin SPA → Dashboards: routes to · Admin and doctor overview screens.
- Admin SPA → Operations: routes to · Doctor and appointment management screens.
- Dashboards → Admin API: calls · Dashboard metrics come from admin endpoints.
- Operations → Admin API: calls · Management actions go through admin APIs.
- Dashboards → Doctor API: calls · Doctor dashboard pulls role-specific summaries.
- Operations → Doctor API: calls · Doctor profile and appointment views use doctor APIs.
- Express API → User API: mounts · Server exposes the patient route set.
- Express API → Doctor API: mounts · Server exposes doctor endpoints.
- Express API → Admin API: mounts · Server exposes admin endpoints.
- User API → Role guards: protected by · User requests are role-checked.
- Doctor API → Role guards: protected by · Doctor requests are role-checked.
- Admin API → Role guards: protected by · Admin requests are role-checked.
- User API → Core models: reads/writes · User flows touch users, doctors, and appointments.
- Doctor API → Core models: reads/writes · Doctor flows use appointments and doctor records.
- Admin API → Core models: reads/writes · Admin workflows manage core collections.
- User API → Upload & cloud: uploads · Profile/image uploads are handled separately.
- Upload & cloud → Core models: enriches · Stored image URLs and metadata support records.