How plutonurmux/doctor-appiontment works
Project Type and Purpose
• This is a full-stack MERN (MongoDB, Express, React, Node.js) web application called “Online Doctor Appointment.”
• It comprises a React SPA in the root/src and public directories, and a TypeScript/JavaScript Express API in the api directory.
• Purpose: allow patients to browse doctors, book appointments, view or cancel them, and provide dashboards for admins, doctors, and patients.
High-Level Component Breakdown
a. Frontend (React)
• Location: /src + static assets in /public
• Key pieces:
– Context/AuthContext for auth state
– Components grouped by feature (Home, Appointment, Dashboard, Login)
– Routing via React Router, protected routes via PrivateRoute
• UI libraries: React-Bootstrap, Material-UI, custom CSS, preloader, animations
b. Backend (Express API)
• Location: /api/src
• Layered MVC structure per domain module (auth, appointment, doctor, patient, payment, etc.)
– Routes → Controllers → Services → Models
• Middleware: auth, error handlers, catchAsync, global logger
• Utilities: JWT helper, Winston logging, error handlers, Mongoose models
• Config & constants for environment variables, CORS, body-parser, image uploader
c. Database
• MongoDB accessed via Mongoose (models under api/models and api/src/app/modules/*/*.model.ts)
d. External Services & Infrastructure
• JWT for stateless authentication
• Winston for structured logging (success & error logs)
• (Optional) Firebase for hosting (firebase.json, .firebaserc) or image storage
• Deployment: Netlify (frontend) & Node host (backend) or Firebase Hosting
Component Interactions and Data Flow
• User’s browser → React App → HTTP(S) API calls (REST) → Express routes → Controllers → Service layer → Mongoose → MongoDB
• Auth flow: React login form → /api/auth/login → JWT issued → stored in client (localStorage or cookie) → used in Authorization header for protected calls → auth middleware verifies token → route handlers
• Booking flow: React appointment UI → POST /api/appointment → validate + create record → response → UI updates
• Admin flow: React dashboard → GET /api/patient or /api/doctor → list CRUD → respond
Architectural Patterns & Design Principles
• Layered MVC on the backend, with clear separation of concerns
• Module-per-domain organization (each feature in its own folder)
• Centralized error handling and logging
• Stateless authentication via JWT
• Feature-driven component organization on the frontend
Essential Details
• All domain modules (Auth, Appointment, Doctor, Patient, Payment) as sub-components of the API layer
• The middleware chain (Auth, error handler, logger) intercepting incoming API calls
• The JWT authentication flow
• Logging destinations (Winston success/error files)
• Hosting/deployment boundaries (where the React bundle and API run)