A full-stack MERN application for booking doctor appointments with User, Doctor, and Admin roles.
- React (Vite)
- React Router v6
- Redux Toolkit
- Bootstrap 5
- React Toastify
- Fetch API (with credentials: include)
- Node.js
- Express.js
- MongoDB + Mongoose
- JWT Authentication (HTTP-only cookies)
- Multer (file uploads)
- bcrypt (password hashing)
- Register/Login with profile image
- View approved doctors
- Search doctors by speciality
- View doctor details
- Book appointments
- View own appointments
- Cancel appointments
- Apply to become a doctor
- Doctor dashboard
- View appointments
- Approve/Complete appointments
- Update doctor profile
- Admin dashboard with stats
- Manage all users
- Delete users (except admins)
- Manage all doctors
- Approve/Block/Unblock doctors
- Node.js (v18+)
- MongoDB (local or Atlas)
-
Clone the repository
-
Setup Backend:
cd server
npm install
# Create .env file (copy from .env.example)
cp .env.example .env
# Edit .env with your credentials:
# - MONGODB_URI
# - JWT_SECRET- Setup Frontend:
cd client
npm install- Create Admin User:
cd server
node scripts/seed.jsAdmin credentials:
- Email: admin@docbook.com
- Password: admin123
Terminal 1 - Backend (port 5000):
cd server
npm run devTerminal 2 - Frontend (port 5173):
cd client
npm run devOpen http://localhost:5173 in your browser.
PORT=5000
MONGODB_URI=mongodb://localhost:27017/doctor-appointment
JWT_SECRET=your_super_secret_jwt_key_change_this
FRONTEND_URL=http://localhost:5173
- POST
/register- Register user - POST
/login- Login user - POST
/logout- Logout user - GET
/me- Get current user
- GET
/profile- Get user profile - PUT
/profile- Update user profile
- GET
/- Get all approved doctors - GET
/speciality/:speciality- Get doctors by speciality - GET
/:id- Get single doctor - POST
/apply- Apply to become doctor - GET
/profile/me- Get doctor's own profile - PUT
/profile- Update doctor profile - GET
/application/status- Check application status
- POST
/book- Book appointment - GET
/my-appointments- Get user's appointments - GET
/doctor-appointments- Get doctor's appointments - PUT
/:id/status- Update appointment status - PUT
/:id/cancel- Cancel appointment
- GET
/users- Get all users - DELETE
/users/:id- Delete user - GET
/doctors- Get all doctors - PUT
/doctors/:id/approve- Approve doctor - PUT
/doctors/:id/block- Block doctor - PUT
/doctors/:id/unblock- Unblock doctor - GET
/stats- Get dashboard stats
├── server/
│ ├── middleware/
│ │ ├── authVerify.js
│ │ └── upload.js
│ ├── models/
│ │ ├── User.js
│ │ ├── Doctor.js
│ │ └── Appointment.js
│ ├── routes/
│ │ ├── authRoutes.js
│ │ ├── userRoutes.js
│ │ ├── doctorRoutes.js
│ │ ├── appointmentRoutes.js
│ │ └── adminRoutes.js
│ ├── scripts/
│ │ └── seed.js
│ ├── index.js
│ ├── package.json
│ └── .env.example
│
├── client/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ │ ├── admin/
│ │ │ └── doctor/
│ │ ├── redux/
│ │ │ └── slices/
│ │ ├── App.jsx
│ │ ├── main.jsx
│ │ └── index.css
│ ├── index.html
│ ├── vite.config.js
│ └── package.json
│
└── README.md
Images are stored as base64 strings directly in MongoDB. This eliminates the need for external storage services like Cloudinary. The upload is limited to 2MB per image to keep database size manageable.
- HTTP-only cookie authentication (no localStorage)
- Password hashing with bcrypt
- JWT token verification
- Protected routes middleware
- Role-based access control
- CORS configuration
- Input validation
MIT