Skip to content

Doctor Appointment Booking System is a full-stack MERN app (MongoDB, Express.js, React.js, Node.js) that enables Admins, Doctors, and Users to manage profiles, schedules, and appointments. It features secure authentication, Cloudinary image uploads, appointment management, role-based dashboards, and a responsive, interactive React frontend.

Notifications You must be signed in to change notification settings

Mahmud-Alam/mern-doctor-appointment-booking-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Doctor Appointment Booking System (MERN)

License: ISC Backend CI Frontend CI MongoDB Atlas

πŸ“Œ Project Overview

The Doctor Appointment Booking System is a full-stack web application built using the MERN Stack: MongoDB, Express.js, React.js, and Node.js. This platform streamlines the process of booking medical appointments online by enabling Admins, Doctors, and Users to manage profiles, schedules, and appointments with ease.

The backend features secure authentication, image upload with Cloudinary, appointment management, and role-based dashboards, while the frontend (React) provides a responsive and interactive UI.


πŸ“‹ Table of Contents

  1. Key Features
  2. Project Structure
  3. Tech Stack
  4. Installation & Setup
  5. API Endpoints
  6. Testing
  7. Deployment
  8. Future Improvements
  9. Author
  10. Acknowledgments

πŸš€ Key Features

πŸ‘€ User Capabilities

  • Secure registration and login with JWT authentication
  • Profile management, including uploading and updating profile photos
  • Intuitive appointment booking, viewing, and cancellation
  • Seamless and secure online payment processing

🩺 Doctor Capabilities

  • Secure doctor login and role-based dashboard access
  • Full control over appointment management: view, confirm, complete, or cancel
  • Ability to update profile and professional details, including image uploads
  • Access to a personalized dashboard summarizing key performance metrics

πŸ› οΈ Admin Capabilities

  • Role-restricted admin authentication with elevated privileges
  • Doctor onboarding: add new doctors with image uploads and role assignments
  • View and manage the list of all registered doctors
  • Toggle doctor availability and manage platform compliance
  • Access to comprehensive appointment analytics and system dashboard

πŸ” Security & Middleware Architecture

  • JWT-based token authentication for all user roles (Admin, Doctor, User)
  • Passwords encrypted using bcrypt hashing
  • Middleware-layered access control ensures secure and role-specific route access
  • Image handling via Cloudinary (CDN) + Multer (upload middleware)
  • Global error handling, request validation, and secure RESTful API conventions
  • Standardized HTTP status codes and response structure for consistent API usage

🌐 Modern React Frontend

  • Built with React (Vite) for lightning-fast performance and optimized build pipeline
  • Styled using Tailwind CSS with full mobile responsiveness
  • Organized in a scalable component architecture for maintainability and reusability
  • Integrated with Axios and React Router for robust API communication and navigation
  • Enhanced UX with Toast notifications and role-based conditional rendering

πŸ“ Project Structure

πŸ“¦ DOCTOR-APPOINTMENT-SYSTEM
β”œβ”€β”€ backend (Express + Node + MongoDB)
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ cloudinary.js
β”‚   β”‚   └── mongodb.js
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ adminController.js
β”‚   β”‚   β”œβ”€β”€ doctorController.js
β”‚   β”‚   └── userController.js
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   β”œβ”€β”€ authAdmin.js
β”‚   β”‚   β”œβ”€β”€ authDoctor.js
β”‚   β”‚   β”œβ”€β”€ authUser.js
β”‚   β”‚   └── multer.js
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ appointmentModel.js
β”‚   β”‚   β”œβ”€β”€ doctorModel.js
β”‚   β”‚   └── userModel.js
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ adminRoute.js
β”‚   β”‚   β”œβ”€β”€ doctorRoute.js
β”‚   β”‚   └── userRoute.js
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ server.js
β”‚   └── package.json
β”‚
β”‚
β”œβ”€β”€ admin-portal (React + Vite)
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ DoctorCard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”‚   └── Sidebar.jsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminContext.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AppContext.jsx
β”‚   β”‚   β”‚   └── DoctorContext.jsx
β”‚   β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminLayout.jsx
β”‚   β”‚   β”‚   └── DoctorLayout.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AddDoctor.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AllAppointments.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚   β”‚   β”‚   └── DoctorList.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ NotAuthorized.jsx
β”‚   β”‚   β”‚   β”‚   └── NotFound.jsx
β”‚   β”‚   β”‚   └── doctor/
β”‚   β”‚   β”‚       β”œβ”€β”€ DoctorAppointments.jsx
β”‚   β”‚   β”‚       β”œβ”€β”€ DoctorDashboard.jsx
β”‚   β”‚   β”‚       └── DoctorProfile.jsx
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── package.json
β”‚
β”‚
β”œβ”€β”€ frontend (React + Vite)
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Banner.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ConfirmModal.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ DoctorCard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Hero.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ RelatedDoctors.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ScrollToTop.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SpecialityMenu.jsx
β”‚   β”‚   β”‚   └── TopDoctors.jsx
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AppContext.jsx
β”‚   β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminLayout.jsx
β”‚   β”‚   β”‚   └── DoctorLayout.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ About.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Appointment.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Appointments.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Contact.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Doctors.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ NotFound.jsx
β”‚   β”‚   β”‚   └── Profile.jsx
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ index.css
β”‚   β”‚   └── main.jsx
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── package.json


πŸ› οΈ Tech Stack

Backend

  • Node.js & Express.js – API and server logic
  • MongoDB + Mongoose – Database & data modeling
  • JWT – Role-based authentication
  • bcrypt – Secure password hashing
  • Cloudinary – Image hosting
  • Multer – File upload handling
  • dotenv – Environment variable management
  • cors – Cross-origin resource sharing

Frontend

  • React – Component-based UI
  • Vite – Lightning-fast build tool
  • Tailwind CSS – Utility-first styling
  • Axios – HTTP client
  • React Router – SPA routing
  • React Toastify – User notifications

πŸ”§ Installation & Setup

πŸ“¦ Prerequisites

πŸš€ Getting Started

1. Clone the repository

git clone https://github.com/Mahmud-Alam/mern-doctor-appointment-booking-system.git
cd mern-doctor-appointment-booking-system/

2. Backend Setup

cd backend
npm install

Create a .env file with:

PORT=8000
MONGODB_URI='mongodb+srv://<user>:<pass>@cluster.mongodb.net'
JWT_SECRET=<your_secret>
CLOUDINARY_NAME=<name>
CLOUDINARY_API_KEY=<key>
CLOUDINARY_API_SECRET=<secret>
ADMIN_EMAIL=<email>
ADMIN_PASSWORD=<pass>

Start dev server:

npm run server

3. Frontend Setup

cd ../frontend
npm install

Create .env at project root:

VITE_BACKEND_URL='http://localhost:8000'

Start the client:

npm run dev

4. Test Full Flow

  1. Admin: login β†’ add doctors β†’ update availability.
  2. Doctor: login β†’ manage appointments.
  3. User: register/login β†’ update profile β†’ book/cancel β†’ make payment.

🌐 API Endpoints

πŸ‘€ User Routes (/api/user)

  • POST /register: Register a new user
  • POST /login: Login user and return token
  • GET /get-profile: Get logged-in user profile
  • POST /update-profile: Update profile with image upload
  • POST /book-appointment: Book an appointment with a doctor
  • GET /appointments: List all appointments
  • POST /cancel-appointment: Cancel a booking
  • POST /make-payment: Make a mock payment (expandable)

🩺 Doctor Routes (/api/doctor)

  • GET /list: Get list of doctors
  • POST /login: Doctor login
  • GET /appointments: View all appointments
  • POST /complete-appointment: Mark appointment as complete
  • POST /cancel-appointment: Cancel an appointment
  • GET /dashboard: Doctor dashboard
  • GET /profile: Get doctor profile
  • POST /update-profile: Update doctor profile

πŸ› οΈ Admin Routes (/api/admin)

  • POST /login: Admin login
  • POST /add-doctor: Add new doctor with image
  • GET /all-doctors: View all registered doctors
  • POST /change-availability: Change doctor’s available status
  • GET /appointments: View all appointments in system
  • POST /cancel-appointment: Cancel appointments manually
  • GET /dashboard: Admin dashboard metrics

πŸ§ͺ Testing

Backend

  • Use tools like Postman, Thunder Client or Insomnia.
  • Implement unit tests later using Jest or Mocha.

Frontend

  • Build and deploy test versions.
  • Use React Testing Library or Cypress for integration tests.

πŸ“¦ Deployment

  • Backend: Deploy on Render, Heroku, or DigitalOcean.
  • Frontend: Deploy on Vercel, Netlify, or AWS.
  • Configure environment variables on the platform.
  • Use services like MongoDB Atlas and Cloudinary for production assets and images.

πŸš€ Future Improvements

  • Email notifications for bookings and cancellations
  • Payment integration
  • Doctor availability calendar view
  • Admin analytics dashboard
  • Pagination and filtering for large appointment datasets

πŸ‘¨β€πŸ’» Author

Mahmud Alam


πŸŽ‰ Acknowledgments

  • MongoDB Atlas for the scalable cloud database
  • Cloudinary for seamless image management
  • The MERN community for open-source knowledge and resources

Happy Coding! πŸš€

About

Doctor Appointment Booking System is a full-stack MERN app (MongoDB, Express.js, React.js, Node.js) that enables Admins, Doctors, and Users to manage profiles, schedules, and appointments. It features secure authentication, Cloudinary image uploads, appointment management, role-based dashboards, and a responsive, interactive React frontend.

Topics

Resources

Stars

Watchers

Forks

Languages