A robust RESTful API built with Node.js, Express, and MongoDB for managing dentist appointments. This backend provides advanced authentication, role-based access control, and scalable data management.
- Advanced Authentication: JWT-based security with HTTP-only cookie support.
- RBAC (Role-Based Access Control): Custom middleware to manage
UserandAdminpermissions. - MVC Architecture: Structured codebase for high maintainability across Controllers, Models, and Routes.
- Advanced Querying: Built-in support for filtering, sorting, selecting fields, and pagination on API endpoints.
- Data Integrity: Comprehensive Mongoose schemas with strict validation and cascade deletes.
- Security: Password hashing with BcryptJS and protection against common vulnerabilities.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (via Mongoose ODM)
- Security: JSON Web Tokens (JWT), BcryptJS, Cookie-parser
- Environment: Dotenv
- Deployment: Optimized for Vercel
├── config/ # Database & Environment configuration
├── controllers/ # Business logic for Auth, Dentists, Bookings, and Users
├── middleware/ # Custom Auth and Error handling middleware
├── models/ # Mongoose schemas (User, Dentist, Booking)
├── routes/ # API route definitions
└── server.js # Entry point of the application
POST /api/v1/auth/register- Register a new userPOST /api/v1/auth/login- Login and receive JWT in cookieGET /api/v1/auth/logout- Clear authentication cookieGET /api/v1/auth/me- Get current logged-in user profilePUT /api/v1/auth/update-me- Update profile detailsPUT /api/v1/auth/change-password- Update password
GET /api/v1/dentists- Get all dentists (Supports filtering, sorting, pagination)GET /api/v1/dentists/:id- Get single dentist detailsPOST /api/v1/dentists- Add new dentist (Admin only)PUT /api/v1/dentists/:id- Update dentist info (Admin only)DELETE /api/v1/dentists/:id- Delete dentist (Admin only)
GET /api/v1/bookings- Get all bookings (Admin sees all, User sees own)GET /api/v1/bookings/:id- Get specific bookingPOST /api/v1/dentists/:dentistId/bookings- Create a new bookingPUT /api/v1/bookings/:id- Update bookingDELETE /api/v1/bookings/:id- Cancel booking
-
Clone the repository
git clone https://github.com/Brightpmk/dentist-backend cd dentist-backend -
Install dependencies
npm install
-
Configure Environment Variables Create a
config/config.envfile and add the following:PORT=5000 NODE_ENV=development MONGO_URI=your_mongodb_atlas_uri JWT_SECRET=your_jwt_secret JWT_EXPIRE=30d JWT_COOKIE_EXPIRE=30
-
Run the application
# Development mode npm run dev # Production mode npm start
This project is licensed under the ISC License.