This project is a Student Leave Management System built using the MERN stack. It allows students to request leaves and administrators to manage these requests.
- Student Registration and Authentication
- Submit Leave Requests
- Admin Approval/Denial of Leave Requests
- View Leave Request Status
- MongoDB
- Express.js
- React.js
- Node.js
Ensure you have the following installed:
- Node.js
- MongoDB
-
Clone the repository
git clone https://github.com/your-repo/student-leave-management.git cd student-leave-management
-
Install server dependencies
cd server npm install
-
Install client dependencies
cd ../client npm install
-
Create a
.env
file in the server directory and add the following environment variablesMONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret
-
Start the development servers
- For server:
cd server npm run dev
- For client:
cd ../client npm start
- For server:
Once the servers are running, you can access the application at http://localhost:3000
.
-
Register a Student
- URL:
POST /api/auth/register
- Body:
{ "name": "Student Name", "email": "student@example.com", "password": "password" }
- URL:
-
Login
- URL:
POST /api/auth/login
- Body:
{ "email": "student@example.com", "password": "password" }
- URL:
-
Submit a Leave Request
- URL:
POST /api/leaves
- Headers:
Authorization: Bearer <token>
- Body:
{ "fromDate": "2023-06-01", "toDate": "2023-06-05", "reason": "Personal reasons" }
- URL:
-
Get All Leave Requests (Admin)
- URL:
GET /api/leaves
- Headers:
Authorization: Bearer <token>
- URL:
-
Get Student Leave Requests
- URL:
GET /api/leaves/student
- Headers:
Authorization: Bearer <token>
- URL:
-
Approve/Reject a Leave Request (Admin)
- URL:
PATCH /api/leaves/:id
- Headers:
Authorization: Bearer <token>
- Body:
{ "status": "approved" }
- URL:
-
Set up Postman Environment
- Create a new environment in Postman.
- Add a variable
baseUrl
with the valuehttp://localhost:5000/api
.
-
Register a New Student
- Method:
POST
- URL:
{{baseUrl}}/auth/register
- Body:
{ "name": "John Doe", "email": "john.doe@example.com", "password": "password123" }
- Send the request and ensure you get a 201 status code with the registered student data.
- Method:
-
Login
- Method:
POST
- URL:
{{baseUrl}}/auth/login
- Body:
{ "email": "john.doe@example.com", "password": "password123" }
- Send the request and store the
token
from the response.
- Method:
-
Submit a Leave Request
- Method:
POST
- URL:
{{baseUrl}}/leaves
- Headers:
Authorization: Bearer <token>
- Body:
{ "fromDate": "2023-06-01", "toDate": "2023-06-05", "reason": "Family event" }
- Send the request and ensure you get a 201 status code with the leave request data.
- Method:
-
Get Student Leave Requests
- Method:
GET
- URL:
{{baseUrl}}/leaves/student
- Headers:
Authorization: Bearer <token>
- Send the request and ensure you get a 200 status code with the list of leave requests.
- Method:
-
Approve a Leave Request (Admin)
- Method:
PATCH
- URL:
{{baseUrl}}/leaves/{leaveId}
- Headers:
Authorization: Bearer <token>
- Body:
{ "status": "approved" }
- Send the request and ensure you get a 200 status code with the updated leave request.
- Method: