Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

35 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Doctor Appointment Booking System

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.

πŸš€ Features

Patient Features

  • 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 Features

  • 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 Features

  • 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

πŸ› οΈ Tech Stack

Frontend

  • 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

Backend

  • 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

πŸ“ Project Structure

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

πŸ”§ Installation & Setup

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (local or MongoDB Atlas)
  • Cloudinary account (for image storage)
  • Razorpay account (optional, for payments)

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create a .env file 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
  1. Start the backend server:
# Development mode
npm run dev

# Production mode
npm start

The backend server will run on http://localhost:4000

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create a .env file in the frontend directory:
VITE_BACKEND_URL=http://localhost:4000
  1. Start the development server:
npm run dev

The frontend will run on http://localhost:5173 (or another port if 5173 is busy)

Admin Setup

  1. Navigate to the admin directory:
cd admin
  1. Install dependencies:
npm install
  1. Create a .env file in the admin directory:
VITE_BACKEND_URL=http://localhost:4000
  1. Start the development server:
npm run dev

The admin panel will run on http://localhost:5174 (or another port)

πŸ“‘ API Endpoints

User Routes (/api/user)

  • POST /register - Register a new user
  • POST /login - User login
  • GET /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)

Doctor Routes (/api/doctor)

  • GET /list - Get list of all doctors (public)
  • POST /login - Doctor login
  • GET /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)

Admin Routes (/api/admin)

  • POST /login - Admin login
  • POST /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)

πŸ” Authentication

The application uses JWT (JSON Web Tokens) for authentication. Protected routes require a valid token in the request headers:

Authorization: Bearer <token>

πŸ“Š Database Models

User Model

  • name, email, password
  • image (profile picture URL)
  • address, gender, date of birth, phone

Doctor Model

  • name, email, password
  • image, speciality, degree, experience
  • about, fees, address
  • available (boolean)
  • slots_booked (object tracking booked time slots)

Appointment Model

  • userId, docId
  • slotDate, slotTime
  • userData, docData (snapshots)
  • amount, date
  • cancelled, payment, isCompleted (status flags)

🎨 Key Features Implementation

Slot Management

  • 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_booked object

Image Upload

  • Profile images are uploaded using Multer middleware
  • Images are stored on Cloudinary cloud storage
  • Secure URLs are returned and stored in the database

Appointment Status

  • Pending: Newly booked appointment
  • Completed: Marked as completed by doctor
  • Cancelled: Cancelled by user, doctor, or admin

🚦 Running the Application

  1. Start MongoDB (if running locally)
  2. Start Backend Server: cd backend && npm run dev
  3. Start Frontend: cd frontend && npm run dev
  4. 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

πŸ”’ Security Features

  • 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

πŸ“ Environment Variables

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

🎯 Future Enhancements

  • 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

πŸ“„ License

ISC

πŸ‘₯ Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ž Support

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages