A comprehensive full-stack web application for booking doctor appointments online. This platform provides separate interfaces for patients, doctors, and administrators, enabling seamless appointment management, doctor profiles, and administrative oversight.
-
User Registration & Authentication
- Secure user registration with email validation
- Password hashing using bcrypt
- JWT-based authentication
- User profile management with image upload
-
Doctor Discovery
- Browse all available doctors
- Filter doctors by specialty
- View detailed doctor profiles including:
- Name, specialty, degree, and experience
- Doctor's bio and consultation fees
- Availability status
- Address information
-
Appointment Booking
- Select available time slots (7 days in advance)
- Real-time slot availability checking
- Book appointments with preferred date and time
- View appointment history
- Cancel appointments
-
Profile Management
- Update personal information
- Upload profile picture (stored on Cloudinary)
- Manage address, gender, date of birth, and phone number
-
Doctor Dashboard
- View appointment statistics
- Track earnings
- Monitor patient appointments
-
Appointment Management
- View all appointments assigned to the doctor
- Mark appointments as completed
- Cancel appointments when necessary
- Track appointment status (pending, completed, cancelled)
-
Profile Management
- Update doctor profile information
- Manage availability status
-
Admin Dashboard
- Overview of system statistics
- View total appointments
- Monitor doctor and patient counts
- Track earnings
-
Doctor Management
- Add new doctors to the system
- Upload doctor profile images
- Set doctor specialties, fees, and availability
- View all registered doctors
- Toggle doctor availability status
-
Appointment Management
- View all appointments across the system
- Cancel appointments
- Monitor appointment statuses
-
System Administration
- Secure admin authentication
- Manage overall system operations
- React 19 - Modern UI library
- React Router DOM - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Axios - HTTP client for API requests
- React Toastify - Toast notifications
- Vite - Fast build tool and dev server
- Node.js - JavaScript runtime
- Express.js 5 - Web application framework
- MongoDB - NoSQL database
- Mongoose - MongoDB object modeling
- JWT (JSON Web Tokens) - Authentication
- bcrypt - Password hashing
- Multer - File upload handling
- Cloudinary - Cloud-based image storage
- Razorpay - Payment gateway integration (configured)
- Validator - Input validation
- CORS - Cross-origin resource sharing
docBooking/
βββ backend/ # Backend API server
β βββ config/ # Configuration files (MongoDB, Cloudinary)
β βββ controllers/ # Route controllers
β βββ middlewares/ # Authentication & file upload middlewares
β βββ models/ # Database models (User, Doctor, Appointment)
β βββ routes/ # API routes
β βββ server.js # Entry point
β
βββ frontend/ # Patient-facing React application
β βββ src/
β β βββ components/ # Reusable components
β β βββ context/ # React context providers
β β βββ pages/ # Page components
β β βββ assets/ # Images and static assets
β
βββ admin/ # Admin & Doctor React application
βββ src/
β βββ components/ # Navbar, Sidebar
β βββ context/ # Admin & Doctor contexts
β βββ pages/ # Admin & Doctor pages
- Node.js (v14 or higher)
- MongoDB (local or MongoDB Atlas)
- Cloudinary account (for image storage)
- Razorpay account (optional, for payments)
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Create a
.envfile in the backend directory:
PORT=4000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
ADMIN_EMAIL=your_admin_email
ADMIN_PASSWORD=your_admin_password
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret- Start the backend server:
# Development mode
npm run dev
# Production mode
npm startThe backend server will run on http://localhost:4000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Create a
.envfile in the frontend directory:
VITE_BACKEND_URL=http://localhost:4000- Start the development server:
npm run devThe frontend will run on http://localhost:5173 (or another port if 5173 is busy)
- Navigate to the admin directory:
cd admin- Install dependencies:
npm install- Create a
.envfile in the admin directory:
VITE_BACKEND_URL=http://localhost:4000- Start the development server:
npm run devThe admin panel will run on http://localhost:5174 (or another port)
POST /register- Register a new userPOST /login- User loginGET /get-profile- Get user profile (protected)PUT /update-profile- Update user profile (protected)POST /book-appointment- Book an appointment (protected)GET /appointments- Get user's appointments (protected)POST /cancel-appointment- Cancel an appointment (protected)
GET /list- Get list of all doctors (public)POST /login- Doctor loginGET /appointments- Get doctor's appointments (protected)POST /complete-appointment- Mark appointment as completed (protected)POST /cancel-appointment- Cancel appointment (protected)GET /dashboard- Get doctor dashboard data (protected)GET /profile- Get doctor profile (protected)POST /update-profile- Update doctor profile (protected)
POST /login- Admin loginPOST /add-doctor- Add a new doctor (protected)POST /all-doctors- Get all doctors (protected)POST /change-availability- Toggle doctor availability (protected)GET /appointments- Get all appointments (protected)PUT /cancel-appointment- Cancel appointment (protected)GET /dashborad- Get admin dashboard data (protected)
The application uses JWT (JSON Web Tokens) for authentication. Protected routes require a valid token in the request headers:
Authorization: Bearer <token>
- name, email, password
- image (profile picture URL)
- address, gender, date of birth, phone
- name, email, password
- image, speciality, degree, experience
- about, fees, address
- available (boolean)
- slots_booked (object tracking booked time slots)
- userId, docId
- slotDate, slotTime
- userData, docData (snapshots)
- amount, date
- cancelled, payment, isCompleted (status flags)
- Doctors have time slots from 10:00 AM to 9:00 PM
- Slots are available for booking 7 days in advance
- Real-time slot availability checking prevents double booking
- Slots are stored in the doctor's
slots_bookedobject
- Profile images are uploaded using Multer middleware
- Images are stored on Cloudinary cloud storage
- Secure URLs are returned and stored in the database
- Pending: Newly booked appointment
- Completed: Marked as completed by doctor
- Cancelled: Cancelled by user, doctor, or admin
- Start MongoDB (if running locally)
- Start Backend Server:
cd backend && npm run dev - Start Frontend:
cd frontend && npm run dev - Start Admin Panel:
cd admin && npm run dev
Access the applications:
- Patient Portal:
http://localhost:5173 - Admin/Doctor Portal:
http://localhost:5174 - Backend API:
http://localhost:4000
- Password hashing with bcrypt
- JWT token-based authentication
- Protected API routes with middleware
- Input validation using validator library
- CORS configuration for secure cross-origin requests
- Environment variables for sensitive data
Make sure to set up all required environment variables in the .env files:
Backend .env:
- Database connection string
- JWT secret key
- Cloudinary credentials
- Admin credentials
- Razorpay credentials (optional)
Frontend/Admin .env:
- Backend API URL
- Payment integration with Razorpay (currently configured but commented)
- Email notifications for appointments
- SMS reminders
- Video consultation integration
- Prescription management
- Medical records storage
- Rating and review system
- Multi-language support
ISC
Contributions are welcome! Please feel free to submit a Pull Request.
For support, email hsheraz271@gmail.com or create an issue in the repository.
Note: Make sure to configure all environment variables before running the application. The application requires MongoDB, Cloudinary, and optionally Razorpay accounts to function properly.