This is a RESTful API built with Node.js and Express.js that allows users to register, log in, and book appointments. It includes role-based access and JWT authentication. Postman is used for automated end-to-end (E2E) testing.
- User Registration and Login (JWT-based)
- Appointment booking and availability management
- Middleware for authentication and authorization
- MongoDB for database storage
- Postman tests for full user flow validation
APPOINTMENT_SYSTEM/
│
├── middleware/ # Auth middleware
│ ├── authmiddleware.js
│ └── protect.js
│
├── models/ # Mongoose models
│ ├── appointment.js
│ ├── availability.js
│ └── user.js
│
├── routes/ # Express route handlers
│ ├── appointment.js
│ ├── auth.js
│ └── availability.js
│
├── index.js # Entry point
├── package.json
├── README.md
├── .env # Environment variables (include your own)
├── appointment-api.postman_collection.json
├── appointment-env.postman_environment.json
-
Clone the repo or unzip the folder
-
Install dependencies
npm install -
Configure environment variables
Create a.envfile in the root directory:PORT=5000 MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret -
Run the server
node index.jsYour API should be running on
http://localhost:5000(or any other port you like
- Register and login endpoints return a JWT token.
- Use the token in the
Authorizationheader as:Authorization: Bearer <token>
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | ❌ |
| POST | /api/auth/login |
Login user | ❌ |
| GET | /api/appointments |
View all appointments | ✅ |
| POST | /api/appointments |
Book an appointment | ✅ |
| GET | /api/availability |
View availability | ✅ |
| POST | /api/availability |
Set availability | ✅ |
- Open Postman.
- Import the following files:
appointment-api.postman_collection.jsonappointment-env.postman_environment.json(optional)
- Go to Collection Runner.
- Select environment (if used) and click Run.
- You’ll see all test cases pass/fail.
- Node.js
- Express.js
- MongoDB & Mongoose
- JWT for authentication
- Postman for API testing
This project is for educational/demo purposes only.