A comprehensive REST API for managing student attendance in educational institutions. This system allows teachers to track student participation across different subjects, groups, and time sessions.
- 🔐 Authentication & Authorization: JWT-based authentication for teachers
- 👥 Teacher Management: Complete CRUD operations for teacher accounts
- 📚 Student Management: Full student lifecycle management
- 🏫 Group Management: Organize students into groups/classes
- 📖 Subject Management: Manage subjects and assign teachers
- ⏰ Timeslot Management: Schedule classes with time sessions (0-9)
- ✅ Attendance Tracking: Mark attendance with PRESENT/LATE/ABSENT status
- 📊 Statistics: Generate attendance reports and statistics
- Backend: Kotlin 2.0.21 + Spring Boot 3.4.0
- Runtime: Java 21 LTS (OpenJDK 21.0.7)
- Database: SQLite with Hibernate/JPA
- Security: Spring Security + JWT
- Build Tool: Gradle 8.5
- Build Tool: Gradle 8.5
- Java Version: 17
src/main/kotlin/com/attendance/
├── controller/ # REST API endpoints
├── service/ # Business logic layer
├── repository/ # Data access layer
├── entity/ # JPA entities
├── dto/ # Data transfer objects
├── config/ # Configuration classes
└── util/ # Utility classes
- Teachers: User accounts for authentication and subject assignment
- Students: Student information and enrollment
- Groups: Class/group organization
- Subjects: Course subjects with teacher assignment
- Timeslots: Scheduled class sessions
- Attendance: Daily attendance records with status tracking
POST /login- Teacher loginPOST /register- Teacher registrationPOST /forgot-password- Password recovery
GET /- List all teachersGET /{id}- Get teacher by IDPOST /- Create new teacherPUT /{id}- Update teacherDELETE /{id}- Delete teacher
GET /- List all studentsGET /{id}- Get student by IDPOST /- Create new studentPUT /{id}- Update studentDELETE /{id}- Delete student
GET /- List all groupsGET /{id}- Get group by IDGET /{id}/students- Get students in groupPOST /- Create new groupPOST /add-students- Add students to groupPUT /{id}- Update groupDELETE /{id}- Delete group
GET /- List all subjectsGET /{id}- Get subject by IDGET /teacher/{teacherId}- Get subjects by teacherPOST /- Create new subjectPUT /{id}- Update subjectDELETE /{id}- Delete subject
GET /- List all timeslotsGET /{id}- Get timeslot by IDGET /group/{groupId}- Get timeslots by groupGET /group/{groupId}/subject/{subjectId}- Get timeslots by group and subjectPOST /- Create new timeslotsDELETE /{id}- Delete timeslot
POST /mark- Mark student attendanceGET /group/{groupId}/subject/{subjectId}- Get attendance for class sessionGET /student/{studentId}- Get student's attendance historyGET /subject/{subjectId}- Get attendance for subjectGET /stats/student/{studentId}/subject/{subjectId}- Get attendance statistics
- Java 17 or higher
- Gradle 8.5 or higher
-
Clone the repository
git clone <repository-url> cd KotlinBackendApi
-
Build the project
./gradlew build
-
Run the application
./gradlew bootRun
The API will be available at http://localhost:8080/api
- SQLite database file (
attendance.db) will be created automatically - Database schema is generated using Hibernate DDL auto-update
# Register a new teacher
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "teacher1",
"email": "teacher1@school.com",
"password": "password123",
"confirmPassword": "password123",
"fullName": "John Doe"
}'
# Login
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"usernameOrEmail": "teacher1",
"password": "password123"
}'curl -X POST http://localhost:8080/api/students \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-jwt-token>" \
-d '{
"name": "Alice Smith",
"studentId": "STU001",
"email": "alice@student.com"
}'curl -X POST http://localhost:8080/api/attendance/mark \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-jwt-token>" \
-d '{
"studentId": 1,
"subjectId": 1,
"date": "2024-01-15",
"session": 0,
"status": "PRESENT"
}'Sessions are numbered 0-9 representing different time periods:
- Session 0: 8:30 AM - 9:50 AM
- Session 1: 10:00 AM - 11:20 AM
- Session 2: 11:30 AM - 12:50 PM
- Session 3: 1:00 PM - 2:20 PM
- Session 4: 2:30 PM - 3:50 PM
- Session 5: 4:00 PM - 5:20 PM
- Session 6: 5:30 PM - 6:50 PM
- Session 7: 7:00 PM - 8:20 PM
- Session 8: 8:30 PM - 9:50 PM
- Session 9: 10:00 PM - 11:20 PM
Key configuration properties in application.properties:
# Server
server.port=8080
server.servlet.context-path=/api
# Database
spring.datasource.url=jdbc:sqlite:attendance.db
spring.jpa.hibernate.ddl-auto=update
# JWT
app.jwt.secret=MySecretKey
app.jwt.expiration=86400000- All endpoints return a consistent
ApiResponse<T>wrapper - Attendance can be updated multiple times for the same session
- Students can be assigned to multiple groups
- Teachers can be assigned to multiple subjects
- Full CORS support for frontend integration
This project is developed for educational purposes.