BunkMate is a RESTful Spring Boot-based backend application that helps students track their class attendance, calculate attendance percentages, and find out how many classes they need to attend or can afford to skip — all while staying above the required attendance threshold (default: 75%).
- ✅ JWT-based Authentication
- 📚 Subject-wise Attendance Management
- 📈 Intelligent Attendance Suggestions
- 🌐 REST API ready for frontend integration
- 🐘 PostgreSQL Database Support
📦 UI Repository: BunkMate-UI
- Register via
POST /student - Login via
POST /student/login - Receive a JWT token
- Use the token in this header format:
Authorization: Bearer <your_access_token>
⚠️ In production, consider using refresh tokens.
| Field | Type | Description |
|---|---|---|
| id | Long | Unique ID |
| name | String | Username |
| password | String | Hashed password |
| subjects | Array<Subject> | List of subject records |
| Field | Type | Description |
|---|---|---|
| id | Long | Unique subject ID |
| name | String | Subject name |
| attendedClasses | Integer | Number of attended classes |
| missedClasses | Integer | Number of missed classes |
| requiredPercentage | Integer | Required attendance percentage (default 75%) |
| currentAttendancePercentage | Double | Current attendance (calculated) |
| classesNeededToReachRequirement | Integer | Classes required to hit required percentage (calculated) |
| classesCanBeMissed | Integer | Classes that can be missed while staying above requirement |
POST /student
{
"name": "kartikeya",
"password": "password123"
}- 201 CREATED
- 409 CONFLICT (username exists)
- POST /student/login
{
"name": "kartikeya",
"password": "password123"
}- 200 OK → Returns accessToken
- 401 UNAUTHORIZED (invalid credentials)
Requires
Authorization: Bearer <token>
POST /student/{studentName}/subject
{
"subjectName": "Analytical Geometry",
"attendedClasses": 1,
"missedClasses": 0
}DELETE /student/{studentName}/subject/{subjectName}
Deletes a subject from a student’s profile.
PUT /student/{studentName}/subject/{subjectName}/{type}/{change}
type:attendedormissedchange:incordec
Example:
PUT /student/kartikeya/subject/DSA/attended/inc{
"id": 102,
"name": "DSA",
"attendedClasses": 2,
"missedClasses": 0,
"requiredPercentage": 75,
"currentAttendancePercentage": 100.0,
"classesNeededToReachRequirement": 0,
"classesCanBeMissed": 0
}| Status | Meaning | Description |
|---|---|---|
| 200 | OK | Successful operation |
| 201 | Created | Student created successfully |
| 401 | Unauthorized | Missing or invalid token |
| 404 | Not Found | Student or subject not found |
| 409 | Conflict | Username already taken |
| 500 | Server Error | Unexpected server error |
If you’ve attended 10 and missed 5 classes:
- Attendance =
10 / (10 + 5) = 66.67% - System tells you how many more to attend to reach 75%.
git clone https://github.com/your-username/bunkmate-backend.git
cd bunkmate-backendCopy the provided application.properties.template to application.properties:
cp src/main/resources/application.properties.template src/main/resources/application.propertiesand edit the following:
spring.application.name=BunkMate
# Database Configuration
spring.datasource.username=${DB_USERNAME:postgres}
spring.datasource.password=${DB_PASSWORD:password}
spring.datasource.url=${DB_URL:jdbc:postgresql://localhost:5432/BunkMate}
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
# JWT Configuration
jwt.secret.key=${JWT_SECRET:default-jwt-secret-key}
# Spring Security Configuration
spring.security.user.name=${ADMIN_USERNAME:admin}
spring.security.user.password=${ADMIN_PASSWORD:admin123}./mvnw spring-boot:runKartikeya Aryam
GitHub: F0RREALTHO