The College Appointment System is a web application that enables students to book appointments with professors based on their availability. The system is built using Go (Golang) as the backend language, MongoDB as the database, and JWT (JSON Web Token) for secure authentication.
- Project Overview
- Features
- Technologies Used
- Setup Instructions
- Endpoints
- Authentication
- Testing
- Contributing
- License
The College Appointment System simplifies the process of scheduling appointments between students and professors. Professors can set their availability, while students can view and book available slots. The system ensures secure access and proper role-based permissions using JWT-based authentication.
- User Registration and Login:
- Students and professors can register and log in to the system.
- Set Availability:
- Professors can set their available time slots.
- Book Appointments:
- Students can book appointments with professors based on their availability.
- View Appointments:
- Students can view their booked appointments.
- Cancel Appointments:
- Students can cancel their appointments.
- Role-Based Access Control:
- Separate access levels for
student
andprofessor
roles.
- Separate access levels for
- Backend: Go (Golang)
- Database: MongoDB
- Authentication: JWT (JSON Web Token)
- API Framework: Gorilla Mux
- Utilities:
golang.org/x/crypto
for password hashinggh.seave.top/golang-jwt/jwt/v5
for JWT generation and validation
- Build Tool: Makefile
- Testing: Postman
-
Go:
- Install Go from https://golang.org/dl/.
- Ensure
go version
returns a compatible version (e.g.,1.20+
).
-
MongoDB:
- Install MongoDB locally or use a cloud-hosted instance like MongoDB Atlas.
- Update the connection string in
.env
.
-
Postman:
- Install Postman for API testing: https://www.postman.com/downloads/.
-
Make:
- Install
make
for running build and test commands.
- Install
-
Clone the Repository:
git clone https://github.com/Beeram12/college-appointment-system.git cd college-appointment-system
-
Install Dependencies: Make sure you have
go mod
initialized and install the required dependencies:make deps
This will execute
go mod tidy
, downloading and organizing all dependencies specified in thego.mod
file. -
Configure Environment Variables: Create a
.env
file in the root directory and add the following configurations:MONGO_URI=mongodb://localhost:27017 MONGO_DB="Your DB name" JWT_SECRET=your_secret_key PORT=8000
- Replace
mongodb://localhost:27017
with your MongoDB connection string (e.g., for MongoDB Atlas). - Replace your
_jwt_secret_key_
here with a strong secret key for signing JWT tokens. - Ensure the
.env
file is added to.gitignore
to prevent sensitive information from being committed:
- Replace
-
Run the Application: Start the server using the following command:
make run
The application will run at
http://localhost:8000
.
Method | Endpoint | Description | Request Body |
---|---|---|---|
POST | /auth/register |
Register a user | { "username": "user1", "password": "password123", "role": "student" } |
POST | /auth/login |
Login to get a JWT token | { "username": "user1", "password": "password123" } |
Method | Endpoint | Description | Request Body |
---|---|---|---|
POST | /professor/availability |
Set available time slots | { "time_slot": "09:00 AM"} |
GET | /professor/appointments |
View all appointments | None |
Method | Endpoint | Description | Request Body |
---|---|---|---|
GET | /appointments/{professor_id} |
View available slots | None |
POST | /appointments/book |
Book an appointment | { "professor_id": "67a62b8f1dae6c55fdddf2d9", "time_slot": "09:00 AM" } |
DELETE | /appointments/cancel/{appointment_id} |
Cancel a booked appointment | None |
GET | /student/appointments |
View booked appointments | None |
- The system uses JWT(JSON Web Token) for secure authentication.
- Users must include their token in the
Authorization
header for protected endpoints:Authorization: Bearer <your_token>
- Use Postman to test all endpoints individually.
- Include the JWT token in headers for authenticated routes.