This project implements backend APIs for a college appointment system that allows students to book appointments with professors. The system includes authentication for users, availability management for professors, appointment scheduling for students, and cancellation functionality. An end-to-end (E2E) automated test validates the key user flow, ensuring the APIs function as expected.
- Node.js: JavaScript runtime for building scalable backend services.
- Express.js: Framework for creating robust APIs.
- MongoDB: Database to store users, availability, and appointment details.
- Mongoose: Object Data Modeling (ODM) library for MongoDB.
- Jest: Framework for automated testing.
- Supertest: Library for testing HTTP APIs.
- User Authentication: Students and professors can securely log in to access the system.
- Availability Management: Professors can specify their available time slots for appointments.
- Appointment Booking: Students can view professors' available slots and book appointments.
- Appointment Cancellation: Professors can cancel existing appointments.
- Automated E2E Testing: Validates the full user flow described in the requirements.
Follow these steps to set up the project on your local machine.
Ensure you have the following installed:
- Node.js (v16+ recommended)
- MongoDB (local or cloud-based)
- Postman for manual API testing
-
Clone the repository:
git clone https://github.com/your-repository-link.git cd college-appointment-system -
Install dependencies:
npm install
-
Configure environment variables by creating a
.envfile in the project root with the following content:PORT=5000 MONGO_URI=mongodb://localhost:27017/college_appointments JWT_SECRET=your_jwt_secret
-
Start the server:
npm start
-
The API will be available at
http://localhost:3000.
To run the automated E2E tests:
npm test{
"_id": "ObjectId",
"name": "string",
"email": "string",
"password": "string",
"role": "string" // "student" or "professor"
}{
"_id": "ObjectId",
"professorId": "ObjectId",
"availableSlots": ["Object"]
}{
"_id": "ObjectId",
"studentId": "ObjectId",
"professorId": "ObjectId",
"timeSlot": "string", // Appointment time slot
"status": "string" // "booked" or "cancelled"
}-
Student Login
- Method:
POST - Endpoint:
/api/student/login - Body:
{ "email": "student@example.com", "password": "password123" }
- Method:
-
Teacher Login
- Method:
POST - Endpoint:
/api/teacher/login - Body:
{ "email": "teacher@example.com", "password": "password123" }
- Method:
-
Set Availability
- Method:
POST - Endpoint:
/api/teacher/add-available-slots - Body:
{ "email": "teacher@example.com", "slotDate": "19/12/2024", "slotTime": "1:00PM - 3:00PM" }
- Method:
-
View Availability
- Method:
GET - Endpoint:
/api/student/my-appointments - Body:
{ "teacherEmail": "teacher@example.com" }
- Method:
-
Book Appointment
- Method:
POST - Endpoint:
/api/appointments - Body:
{ "studentId": "676438ac6b3e22727b57d479", "teacherId": "6765a5d179df7dca0830ead3", "slotDate": "19/12/2024", "slotTime": "1:00PM - 3:00PM" }
- Method:
-
Cancel Appointment
- Method:
POST - Endpoint:
/api/teacher/cancel-appointment - Body:
{ "appointmentId": "6765a76579df7dca0830eae4", "teacherId": "6765a5d179df7dca0830ead3" }
- Method:
-
View Appointments
- Method:
GET - Endpoint:
/api/student/my-appointments?studentId=676438ac6b3e22727b57d479
- Method:
The automated test case validates the following flow:
- A student logs in.
- A professor logs in and specifies available slots.
- The student views available slots and books an appointment.
- Another student logs in and books a different slot.
- The professor cancels the first appointment.
- The first student verifies their updated appointment status.
Run the test suite using:
npm test- Code Explanation and Automated Test Case: https://drive.google.com/file/d/10PbEGjlWOJ9lMWQwbqqBeubdC5kPZXsG/view?usp=sharing
- Manual API Testing: https://drive.google.com/file/d/10myq9RtjCyc96pQmv9WIcul8rU1MQTYY/view?usp=sharing
May Pyone
- GitHub: https://github.com/MayPyone
- Email: maypyone015@gmail.com
This project is licensed under the MIT License.