openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: Semester Attendance Tracker API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: semesters description: Semester management - name: subjects description: Subject management - name: class-slots description: Weekly timetable slots - name: attendance description: Attendance records paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" # ─── SEMESTERS ──────────────────────────────────────────────────────────── /semesters: get: operationId: listSemesters tags: [semesters] summary: List all semesters responses: "200": description: List of semesters content: application/json: schema: type: array items: $ref: "#/components/schemas/Semester" post: operationId: createSemester tags: [semesters] summary: Create a new semester requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SemesterInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Semester" /semesters/{id}: get: operationId: getSemester tags: [semesters] summary: Get a semester by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Semester content: application/json: schema: $ref: "#/components/schemas/Semester" "404": description: Not found patch: operationId: updateSemester tags: [semesters] summary: Update a semester parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SemesterUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Semester" "404": description: Not found delete: operationId: deleteSemester tags: [semesters] summary: Delete a semester parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /semesters/{id}/progress: get: operationId: getSemesterProgress tags: [semesters] summary: Get semester progress and remaining class counts per subject parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Semester progress content: application/json: schema: $ref: "#/components/schemas/SemesterProgress" "404": description: Not found # ─── SUBJECTS ───────────────────────────────────────────────────────────── /subjects: get: operationId: listSubjects tags: [subjects] summary: List all subjects parameters: - name: semesterId in: query required: false schema: type: integer responses: "200": description: List of subjects content: application/json: schema: type: array items: $ref: "#/components/schemas/Subject" post: operationId: createSubject tags: [subjects] summary: Create a new subject requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubjectInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Subject" /subjects/{id}: get: operationId: getSubject tags: [subjects] summary: Get a subject by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Subject content: application/json: schema: $ref: "#/components/schemas/Subject" "404": description: Not found patch: operationId: updateSubject tags: [subjects] summary: Update a subject parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/SubjectUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/Subject" "404": description: Not found delete: operationId: deleteSubject tags: [subjects] summary: Delete a subject parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /subjects/{id}/history: get: operationId: getSubjectHistory tags: [subjects] summary: Complete attendance history for a subject parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Attendance history content: application/json: schema: $ref: "#/components/schemas/SubjectHistory" "404": description: Not found # ─── CLASS SLOTS ────────────────────────────────────────────────────────── /class-slots: get: operationId: listClassSlots tags: [class-slots] summary: List all class slots (weekly timetable entries) parameters: - name: subjectId in: query required: false schema: type: integer - name: dayOfWeek in: query required: false schema: type: integer responses: "200": description: List of class slots content: application/json: schema: type: array items: $ref: "#/components/schemas/ClassSlot" post: operationId: createClassSlot tags: [class-slots] summary: Create a new class slot requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ClassSlotInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/ClassSlot" /class-slots/{id}: get: operationId: getClassSlot tags: [class-slots] summary: Get a class slot by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Class slot content: application/json: schema: $ref: "#/components/schemas/ClassSlot" "404": description: Not found patch: operationId: updateClassSlot tags: [class-slots] summary: Update a class slot parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ClassSlotUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/ClassSlot" "404": description: Not found delete: operationId: deleteClassSlot tags: [class-slots] summary: Delete a class slot parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found # ─── ATTENDANCE ─────────────────────────────────────────────────────────── /attendance: get: operationId: listAttendance tags: [attendance] summary: List attendance records parameters: - name: date in: query required: false schema: type: string - name: classSlotId in: query required: false schema: type: integer - name: subjectId in: query required: false schema: type: integer responses: "200": description: List of attendance records content: application/json: schema: type: array items: $ref: "#/components/schemas/AttendanceRecord" post: operationId: markAttendance tags: [attendance] summary: Mark or create an attendance record requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AttendanceInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" /attendance/{id}: patch: operationId: updateAttendance tags: [attendance] summary: Update an attendance record parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AttendanceUpdate" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" "404": description: Not found delete: operationId: deleteAttendance tags: [attendance] summary: Delete an attendance record parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found /attendance/today: get: operationId: getTodayClasses tags: [attendance] summary: Get today's scheduled classes with their attendance status parameters: - name: semesterId in: query required: false schema: type: integer responses: "200": description: Today's classes content: application/json: schema: type: array items: $ref: "#/components/schemas/TodayClass" /attendance/stats: get: operationId: getAttendanceStats tags: [attendance] summary: Get overall and per-subject attendance statistics parameters: - name: semesterId in: query required: false schema: type: integer responses: "200": description: Attendance statistics content: application/json: schema: $ref: "#/components/schemas/AttendanceStats" /attendance/trends: get: operationId: getAttendanceTrends tags: [attendance] summary: Weekly and monthly attendance trend data parameters: - name: semesterId in: query required: false schema: type: integer - name: groupBy in: query required: false schema: type: string enum: [week, month] responses: "200": description: Trend data content: application/json: schema: type: array items: $ref: "#/components/schemas/AttendanceTrend" components: schemas: HealthStatus: type: object properties: status: type: string required: - status # ── Semester ──────────────────────────────────────────────────────────── Semester: type: object required: [id, name, startDate, endDate, totalWeeks, isActive, createdAt] properties: id: { type: integer } name: { type: string } startDate: { type: string, description: "YYYY-MM-DD" } endDate: { type: string, description: "YYYY-MM-DD" } totalWeeks: { type: integer } isActive: { type: boolean } createdAt: { type: string } SemesterInput: type: object required: [name, startDate, endDate, totalWeeks] properties: name: { type: string, minLength: 1 } startDate: { type: string } endDate: { type: string } totalWeeks: { type: integer, minimum: 1 } isActive: { type: boolean } SemesterUpdate: type: object properties: name: { type: string, minLength: 1 } startDate: { type: string } endDate: { type: string } totalWeeks: { type: integer, minimum: 1 } isActive: { type: boolean } SemesterProgress: type: object required: [semesterId, totalWeeks, currentWeek, remainingWeeks, subjectProgress] properties: semesterId: { type: integer } totalWeeks: { type: integer } currentWeek: { type: integer } remainingWeeks: { type: integer } subjectProgress: type: array items: $ref: "#/components/schemas/SubjectProgress" SubjectProgress: type: object required: [subjectId, subjectName, totalRemainingClasses, classesByDay] properties: subjectId: { type: integer } subjectName: { type: string } totalRemainingClasses: { type: integer } classesByDay: type: array items: type: object required: [dayOfWeek, dayName, count] properties: dayOfWeek: { type: integer } dayName: { type: string } count: { type: integer } # ── Subject ───────────────────────────────────────────────────────────── Subject: type: object required: [id, semesterId, name, lecturer, color, createdAt] properties: id: { type: integer } semesterId: { type: integer } name: { type: string } lecturer: { type: string } classroom: { type: ["string", "null"] } color: { type: string } createdAt: { type: string } SubjectInput: type: object required: [semesterId, name, lecturer] properties: semesterId: { type: integer } name: { type: string, minLength: 1 } lecturer: { type: string, minLength: 1 } classroom: { type: string } color: { type: string } SubjectUpdate: type: object properties: name: { type: string, minLength: 1 } lecturer: { type: string, minLength: 1 } classroom: { type: ["string", "null"] } color: { type: string } SubjectHistory: type: object required: [subject, records] properties: subject: $ref: "#/components/schemas/Subject" records: type: array items: $ref: "#/components/schemas/AttendanceRecord" # ── ClassSlot ─────────────────────────────────────────────────────────── ClassSlot: type: object required: [id, subjectId, dayOfWeek, startTime, endTime, createdAt] properties: id: { type: integer } subjectId: { type: integer } dayOfWeek: { type: integer, minimum: 0, maximum: 6, description: "0=Sunday, 1=Monday, ..., 6=Saturday" } startTime: { type: string, description: "HH:MM" } endTime: { type: string, description: "HH:MM" } createdAt: { type: string } ClassSlotInput: type: object required: [subjectId, dayOfWeek, startTime, endTime] properties: subjectId: { type: integer } dayOfWeek: { type: integer, minimum: 0, maximum: 6 } startTime: { type: string } endTime: { type: string } ClassSlotUpdate: type: object properties: dayOfWeek: { type: integer, minimum: 0, maximum: 6 } startTime: { type: string } endTime: { type: string } # ── Attendance ────────────────────────────────────────────────────────── AttendanceRecord: type: object required: [id, classSlotId, date, status, createdAt] properties: id: { type: integer } classSlotId: { type: integer } date: { type: string, description: "YYYY-MM-DD" } status: { type: string, enum: [present, absent, late, cancelled] } createdAt: { type: string } AttendanceInput: type: object required: [classSlotId, date, status] properties: classSlotId: { type: integer } date: { type: string } status: { type: string, enum: [present, absent, late, cancelled] } AttendanceUpdate: type: object required: [status] properties: status: { type: string, enum: [present, absent, late, cancelled] } TodayClass: type: object required: [classSlotId, subjectId, subjectName, subjectColor, lecturer, classroom, startTime, endTime, attendanceStatus] properties: classSlotId: { type: integer } subjectId: { type: integer } subjectName: { type: string } subjectColor: { type: string } lecturer: { type: string } classroom: { type: ["string", "null"] } startTime: { type: string } endTime: { type: string } attendanceId: { type: ["integer", "null"] } attendanceStatus: { type: ["string", "null"], enum: [present, absent, late, cancelled, null] } # ── Stats ──────────────────────────────────────────────────────────────── AttendanceStats: type: object required: [overall, bySubject] properties: overall: $ref: "#/components/schemas/OverallStats" bySubject: type: array items: $ref: "#/components/schemas/SubjectStats" OverallStats: type: object required: [totalClasses, attended, absent, late, cancelled, percentage] properties: totalClasses: { type: integer } attended: { type: integer } absent: { type: integer } late: { type: integer } cancelled: { type: integer } percentage: { type: number } SubjectStats: type: object required: [subjectId, subjectName, subjectColor, totalClasses, attended, absent, late, cancelled, percentage, canStillMiss, mustAttendConsecutively, status] properties: subjectId: { type: integer } subjectName: { type: string } subjectColor: { type: string } totalClasses: { type: integer } attended: { type: integer } absent: { type: integer } late: { type: integer } cancelled: { type: integer } percentage: { type: number } canStillMiss: { type: integer } mustAttendConsecutively: { type: integer } status: { type: string, enum: [excellent, safe, warning] } AttendanceTrend: type: object required: [period, label, totalClasses, attended, percentage] properties: period: { type: string } label: { type: string } totalClasses: { type: integer } attended: { type: integer } percentage: { type: number }