How mahdiaziz97/rainbow-hospital works
Purpose and entry points
This is a hospital-facing system split into three applications: a public patient portal, an administrative portal, and a Node.js backend API. The React/Vite clients boot from Frontend/src/main.jsx and Admin/src/main.jsx; backend startup is Backend/server.js.
Public patient portal
The public frontend presents hospital content, services, departments, doctors, appointments, contact/enquiry, patient profile, and appointment history. Routing and top-level composition are centered in Frontend/src/App.jsx, with page-level flows including Frontend/src/pages/Home.jsx, Frontend/src/pages/Appointment.jsx, and Frontend/src/pages/MyAppointments.jsx.
Administrative and staff portal
The separate admin client supports privileged management of doctors, staff, health/OT packages, notices, appointments, and credentials. Application-wide state is divided into role-oriented React contexts: Admin/src/context/AdminContext.jsx, Admin/src/context/StaffContext.jsx, and Admin/src/context/AppContext.jsx. Admin CRUD screens include Admin/src/pages/Admin/Dashboard.jsx, Admin/src/pages/Admin/AddDoctor.jsx, and Admin/src/pages/Admin/AllAppointments.jsx; staff has its own dashboard at Admin/src/pages/Staff/SDashboard.jsx.
API and authorization boundary
The backend exposes role-segregated route surfaces for public/user, admin, and staff operations through Backend/routes/userRoute.js, Backend/routes/adminRoute.js, and Backend/routes/staffRoute.js. Controllers implement the corresponding request orchestration in Backend/controllers/userController.js, Backend/controllers/adminController.js, and Backend/controllers/staffController.js. Admin authentication is enforced by Backend/middlewares/authAdmin.js; password hashing support is isolated in Backend/Hashing/hashAdmin.js.
Domain persistence
MongoDB is the primary persistence layer, configured in Backend/config/mongodb.js. Core domain records cover doctors, staff, notices, packages, bookings, enquiries, and contact submissions: Backend/models/doctorModel.js, Backend/models/staffModel.js, Backend/models/allBookingModel.js, Backend/models/allEnquiryModel.js, Backend/models/healthPackageModel.js, and Backend/models/noticeModel.js. Update-field behavior is centralized in Backend/modelsModify/updateFields.js, creating a boundary between controller actions and partial-record mutation logic.
Content, uploads, and external infrastructure
The backend supports multipart/file handling via Backend/middlewares/multer.js, stores local uploaded documents under Backend/uploads/pdfs, and has a Cloudinary integration configuration at Backend/config/cloudinary.js. This creates a media boundary: browser clients submit managed content to API endpoints; the backend persists metadata in MongoDB and handles local or cloud-backed assets.
Primary flow
Public users consume content and submit appointment, enquiry, contact, or account-related requests through the frontend to user routes. Administrators and staff authenticate through the admin client, then use protected API operations to manage operational records. Updated doctors, packages, notices, and booking data are persisted in MongoDB and subsequently surfaced through the public-facing pages and admin/staff dashboards.
Main entry points: userController.js Request controllers · adminRoute.js Admin routes · server.js API server · AdminContext.jsx Role state contexts
Components 19
Patient Portal
- Patient client boot
Frontend/src/main.jsx - Patient routes · Composes public pages and navigation.
Frontend/src/App.jsx - Patient request flows · Home, appointment, and appointment-history experiences.
Frontend/src/pages/Appointment.jsx
Admin & Staff Portal
- Admin client boot
Admin/src/main.jsx - Role state contexts · Separates admin, staff, and shared application state.
Admin/src/context/AdminContext.jsx - Admin operations · Dashboard, doctor management, and appointment administration.
Admin/src/pages/Admin/Dashboard.jsx - Staff dashboard
Admin/src/pages/Staff/SDashboard.jsx
Backend API
- API server
Backend/server.js - Public/user routes
Backend/routes/userRoute.js - Admin routes
Backend/routes/adminRoute.js - Staff routes
Backend/routes/staffRoute.js - Request controllers · Orchestrates user, admin, and staff operations.
Backend/controllers/userController.js - Admin authorization
Backend/middlewares/authAdmin.js - Admin password hashing
Backend/Hashing/hashAdmin.js - Upload handling · Accepts managed file content for API operations.
Backend/middlewares/multer.js
Data & Media
- Hospital domain models · Doctors, staff, bookings, enquiries, packages, and notices.
Backend/models/doctorModel.js - Partial update policy
Backend/modelsModify/updateFields.js - MongoDB · Primary persistence for operational records and content metadata.
Backend/config/mongodb.js - Asset storage · Local PDFs with Cloudinary integration for managed assets.
Backend/config/cloudinary.js
Connections 22
- Patient client boot → Patient routes: boots
- Patient routes → Patient request flows: renders
- Patient request flows → Public/user routes: public requests
- Admin client boot → Role state contexts: provides state
- Role state contexts → Admin operations: drives
- Role state contexts → Staff dashboard: drives
- Admin operations → Admin routes: admin API calls
- Staff dashboard → Staff routes: staff API calls
- API server → Public/user routes: mounts
- API server → Admin routes: mounts
- API server → Staff routes: mounts
- Admin routes → Admin authorization: authorizes
- Admin authorization → Admin password hashing: credential support
- Public/user routes → Request controllers: dispatches
- Admin routes → Request controllers: dispatches
- Staff routes → Request controllers: dispatches
- Request controllers → Upload handling: handles files
- Request controllers → Partial update policy: applies partial updates
- Request controllers → Hospital domain models: reads and writes
- Hospital domain models → MongoDB: persists
- Upload handling → Asset storage: stores assets
- Request controllers → Asset storage: stores media metadata