How mugetsu-1/hospital-booking-system works
Patients discover doctors, inspect computed availability, and book or manage appointments; doctors operate their queues and update visit status or governed notes; administrators manage directory/accounts and the hospital ledger. The React role-specific screens call an Express API whose controllers enforce domain rules and persist through Prisma/PostgreSQL. JWT/RBAC, slot computation, serialization, and cache invalidation support that workflow. Redis, Socket.IO, and email are documented as optional fail-open enhancements. Some frontend-to-backend and optional integration links rely on README statements because the relevant runtime wiring is not fully excerpted.
Main entry points: App.jsx Role-based screens · appointmentController.js Booking and visit rules · client.js HTTP API client · app.js Express API
Components 28
Web application
- Role-based screens
frontend/src/App.jsx - Doctor search
frontend/src/pages/patient/BrowseDoctors.jsx - Appointment history
frontend/src/pages/patient/MyAppointments.jsx - Doctor queue
frontend/src/pages/doctor/DoctorDashboard.jsx - Admin ledger
frontend/src/pages/admin/AdminDashboard.jsx - Sign-in and registration
frontend/src/context/AuthContext.jsx - HTTP API client
frontend/src/api/client.js - Realtime client
frontend/src/realtime.js
API and access
- Express API
backend/src/app.js - Authentication routes
backend/src/routes/authRoutes.js - Patient routes
backend/src/routes/patientRoutes.js - Doctor routes
backend/src/routes/doctorRoutes.js - Appointment routes
backend/src/routes/appointmentRoutes.js - JWT and RBAC
backend/src/middleware/auth.js
Appointment operations
- Booking and visit rules
backend/src/controllers/appointmentController.js - Slot computation
backend/src/utils/slots.js - Appointment states
backend/src/domain/appointment.js
Directory and identity
- Account operations
backend/src/controllers/authController.js - Patient profiles
backend/src/controllers/patientController.js - Doctor directory and slots
backend/src/controllers/doctorController.js
Persistence and integrations
- Prisma data access
backend/src/db.js - PostgreSQL
- Redis cache
backend/src/utils/cache.js - Socket.IO service
backend/src/services/realtime.js - Email notifications
backend/src/services/mailer.js
Other components
- Patient
- Doctor
- Administrator
Connections 41
- Patient → Role-based screens: uses
README.md - Doctor → Role-based screens: uses
README.md - Administrator → Role-based screens: uses
README.md - Role-based screens → Doctor search: routes to
frontend/src/App.jsx - Role-based screens → Appointment history: routes to
frontend/src/App.jsx - Role-based screens → Doctor queue: routes to
frontend/src/App.jsx - Role-based screens → Admin ledger: routes to
frontend/src/App.jsx - Role-based screens → Sign-in and registration: provides auth
frontend/src/App.jsx - Doctor search → HTTP API client: requests
frontend/src/pages/patient/BrowseDoctors.jsx - Appointment history → HTTP API client: requests
frontend/src/pages/patient/MyAppointments.jsx - Doctor queue → HTTP API client: requests
frontend/src/pages/doctor/DoctorDashboard.jsx - Admin ledger → HTTP API client: requests
frontend/src/pages/admin/AdminDashboard.jsx - Sign-in and registration → HTTP API client: auth requests
frontend/src/context/AuthContext.jsx - HTTP API client → Express API: sends API calls
README.md - Sign-in and registration → Realtime client: connects session
frontend/src/context/AuthContext.jsx - Realtime client → Socket.IO service: opens realtime link
README.md - Express API → Authentication routes: mounts
backend/src/app.js - Express API → Patient routes: mounts
backend/src/app.js - Express API → Doctor routes: mounts
backend/src/app.js - Express API → Appointment routes: mounts
backend/src/app.js - Authentication routes → Account operations: dispatches
backend/src/routes/authRoutes.js - Patient routes → Patient profiles: dispatches
backend/src/routes/patientRoutes.js - Doctor routes → Doctor directory and slots: dispatches
backend/src/routes/doctorRoutes.js - Appointment routes → Booking and visit rules: dispatches
backend/src/routes/appointmentRoutes.js - Authentication routes → JWT and RBAC: guards routes
backend/src/routes/authRoutes.js - Patient routes → JWT and RBAC: guards routes
backend/src/routes/patientRoutes.js - Doctor routes → JWT and RBAC: guards routes
backend/src/routes/doctorRoutes.js - Appointment routes → JWT and RBAC: guards routes
backend/src/routes/appointmentRoutes.js - Account operations → Prisma data access: reads and writes
backend/src/controllers/authController.js - Patient profiles → Prisma data access: reads and writes
backend/src/controllers/patientController.js - Doctor directory and slots → Prisma data access: reads and writes
backend/src/controllers/doctorController.js - Booking and visit rules → Prisma data access: reads and writes
backend/src/controllers/appointmentController.js - Doctor directory and slots → Slot computation: computes availability
backend/src/controllers/doctorController.js - Booking and visit rules → Slot computation: validates slots
backend/src/controllers/appointmentController.js - Appointment routes → Appointment states: uses states
backend/src/routes/appointmentRoutes.js - Prisma data access → PostgreSQL: persists data
README.md - Doctor directory and slots → Redis cache: caches directory and slots
backend/src/controllers/doctorController.js - Booking and visit rules → Redis cache: invalidates slots
backend/src/controllers/appointmentController.js - Doctor directory and slots → Socket.IO service: emits slot changes
backend/src/controllers/doctorController.js - Booking and visit rules → Socket.IO service: emits appointment events
backend/src/controllers/appointmentController.js - Booking and visit rules → Email notifications: sends notifications
backend/src/controllers/appointmentController.js