openapi: 3.1.0 info: title: Api version: 0.1.0 description: ESHR Attendance Management System API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication operations - name: users description: User management - name: departments description: Department management - name: attendance description: Attendance management - name: leaves description: Leave management - name: salary description: Salary management - name: holidays description: Holiday management - name: notifications description: Notification management - name: reports description: Reports paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /auth/login: post: operationId: login tags: [auth] summary: Login requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginRequest" responses: "200": description: Login successful content: application/json: schema: $ref: "#/components/schemas/LoginResponse" "401": description: Invalid credentials content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/logout: post: operationId: logout tags: [auth] summary: Logout responses: "200": description: Logged out content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get current user responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/User" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /users: get: operationId: getUsers tags: [users] summary: Get all users (Admin/HR) responses: "200": description: List of users content: application/json: schema: type: array items: $ref: "#/components/schemas/User" post: operationId: createUser tags: [users] summary: Create user (Admin/HR) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateUserRequest" responses: "201": description: User created content: application/json: schema: $ref: "#/components/schemas/User" /users/{id}: get: operationId: getUser tags: [users] summary: Get user by ID parameters: - name: id in: path required: true schema: type: integer responses: "200": description: User found content: application/json: schema: $ref: "#/components/schemas/User" put: operationId: updateUser tags: [users] summary: Update user parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateUserRequest" responses: "200": description: User updated content: application/json: schema: $ref: "#/components/schemas/User" delete: operationId: deleteUser tags: [users] summary: Delete user (Admin) parameters: - name: id in: path required: true schema: type: integer responses: "200": description: User deleted content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /departments: get: operationId: getDepartments tags: [departments] summary: Get all departments responses: "200": description: List of departments content: application/json: schema: type: array items: $ref: "#/components/schemas/Department" post: operationId: createDepartment tags: [departments] summary: Create department requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateDepartmentRequest" responses: "201": description: Department created content: application/json: schema: $ref: "#/components/schemas/Department" /departments/{id}: put: operationId: updateDepartment tags: [departments] summary: Update department parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateDepartmentRequest" responses: "200": description: Department updated content: application/json: schema: $ref: "#/components/schemas/Department" delete: operationId: deleteDepartment tags: [departments] summary: Delete department parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Department deleted content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /attendance/punch: post: operationId: punchAttendance tags: [attendance] summary: Punch in or out requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PunchRequest" responses: "200": description: Punch recorded content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" /attendance/today: get: operationId: getTodayAttendance tags: [attendance] summary: Get today's attendance for current user responses: "200": description: Today's attendance content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" /attendance/history: get: operationId: getAttendanceHistory tags: [attendance] summary: Get attendance history parameters: - name: userId in: query schema: type: integer - name: month in: query schema: type: integer - name: year in: query schema: type: integer responses: "200": description: Attendance history content: application/json: schema: type: array items: $ref: "#/components/schemas/AttendanceRecord" /attendance/{id}: put: operationId: updateAttendance tags: [attendance] summary: Update attendance record (Admin/HR) parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateAttendanceRequest" responses: "200": description: Attendance updated content: application/json: schema: $ref: "#/components/schemas/AttendanceRecord" /leaves: get: operationId: getLeaves tags: [leaves] summary: Get leave requests parameters: - name: userId in: query schema: type: integer - name: status in: query schema: type: string responses: "200": description: Leave requests content: application/json: schema: type: array items: $ref: "#/components/schemas/LeaveRequest" post: operationId: createLeave tags: [leaves] summary: Apply for leave requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateLeaveRequest" responses: "201": description: Leave applied content: application/json: schema: $ref: "#/components/schemas/LeaveRequest" /leaves/{id}/approve: put: operationId: approveLeave tags: [leaves] summary: Approve leave (Admin/HR) parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Leave approved content: application/json: schema: $ref: "#/components/schemas/LeaveRequest" /leaves/{id}/reject: put: operationId: rejectLeave tags: [leaves] summary: Reject leave (Admin/HR) parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/RejectLeaveRequest" responses: "200": description: Leave rejected content: application/json: schema: $ref: "#/components/schemas/LeaveRequest" /leaves/balance: get: operationId: getLeaveBalance tags: [leaves] summary: Get leave balance for current user responses: "200": description: Leave balance content: application/json: schema: $ref: "#/components/schemas/LeaveBalance" /salary: get: operationId: getSalaryRecords tags: [salary] summary: Get salary records parameters: - name: userId in: query schema: type: integer - name: month in: query schema: type: integer - name: year in: query schema: type: integer responses: "200": description: Salary records content: application/json: schema: type: array items: $ref: "#/components/schemas/SalaryRecord" /salary/calculate: post: operationId: calculateSalary tags: [salary] summary: Calculate salary for a user/month requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CalculateSalaryRequest" responses: "200": description: Salary calculated content: application/json: schema: $ref: "#/components/schemas/SalaryRecord" /salary/payslip/{id}: get: operationId: getPayslip tags: [salary] summary: Get payslip details parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Payslip content: application/json: schema: $ref: "#/components/schemas/Payslip" /holidays: get: operationId: getHolidays tags: [holidays] summary: Get holidays parameters: - name: year in: query schema: type: integer responses: "200": description: Holidays content: application/json: schema: type: array items: $ref: "#/components/schemas/Holiday" post: operationId: createHoliday tags: [holidays] summary: Create holiday (Admin/HR) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateHolidayRequest" responses: "201": description: Holiday created content: application/json: schema: $ref: "#/components/schemas/Holiday" /holidays/{id}: delete: operationId: deleteHoliday tags: [holidays] summary: Delete holiday (Admin/HR) parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Holiday deleted content: application/json: schema: $ref: "#/components/schemas/MessageResponse" /notifications: get: operationId: getNotifications tags: [notifications] summary: Get notifications for current user responses: "200": description: Notifications content: application/json: schema: type: array items: $ref: "#/components/schemas/Notification" /notifications/{id}/read: put: operationId: markNotificationRead tags: [notifications] summary: Mark notification as read parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Notification marked as read content: application/json: schema: $ref: "#/components/schemas/Notification" /reports/monthly: get: operationId: getMonthlyReport tags: [reports] summary: Get monthly attendance and salary report parameters: - name: userId in: query schema: type: integer - name: month in: query required: true schema: type: integer - name: year in: query required: true schema: type: integer responses: "200": description: Monthly report content: application/json: schema: $ref: "#/components/schemas/MonthlyReport" /reports/company: get: operationId: getCompanyReport tags: [reports] summary: Get company-wide report (Admin/HR) parameters: - name: month in: query required: true schema: type: integer - name: year in: query required: true schema: type: integer responses: "200": description: Company report content: application/json: schema: $ref: "#/components/schemas/CompanyReport" /activity-logs: get: operationId: getActivityLogs tags: [reports] summary: Get activity logs (Admin/HR) parameters: - name: userId in: query schema: type: integer - name: limit in: query schema: type: integer responses: "200": description: Activity logs content: application/json: schema: type: array items: $ref: "#/components/schemas/ActivityLog" components: schemas: HealthStatus: type: object properties: status: type: string required: [status] ErrorResponse: type: object properties: error: type: string required: [error] MessageResponse: type: object properties: message: type: string required: [message] LoginRequest: type: object properties: email: type: string password: type: string required: [email, password] LoginResponse: type: object properties: user: $ref: "#/components/schemas/User" message: type: string required: [user, message] User: type: object properties: id: type: integer email: type: string firstName: type: string lastName: type: string role: type: string enum: [admin, hr, employee] employeeId: type: string departmentId: type: integer departmentName: type: string designation: type: string phone: type: string monthlySalary: type: number joiningDate: type: string isActive: type: boolean createdAt: type: string required: [id, email, firstName, lastName, role, isActive] CreateUserRequest: type: object properties: email: type: string password: type: string firstName: type: string lastName: type: string role: type: string enum: [admin, hr, employee] employeeId: type: string departmentId: type: integer designation: type: string phone: type: string monthlySalary: type: number joiningDate: type: string required: [email, password, firstName, lastName, role] UpdateUserRequest: type: object properties: email: type: string firstName: type: string lastName: type: string role: type: string enum: [admin, hr, employee] departmentId: type: integer designation: type: string phone: type: string monthlySalary: type: number isActive: type: boolean password: type: string Department: type: object properties: id: type: integer name: type: string description: type: string managerId: type: integer managerName: type: string employeeCount: type: integer required: [id, name] CreateDepartmentRequest: type: object properties: name: type: string description: type: string managerId: type: integer required: [name] PunchRequest: type: object properties: type: type: string enum: [in, out] latitude: type: number longitude: type: number selfieUrl: type: string note: type: string required: [type] AttendanceRecord: type: object properties: id: type: integer userId: type: integer date: type: string punchIn: type: string punchOut: type: string status: type: string enum: [present, absent, late, half-day, holiday, leave] workingHours: type: number otHours: type: number isLate: type: boolean lateMinutes: type: integer note: type: string latitude: type: number longitude: type: number required: [id, userId, date, status] UpdateAttendanceRequest: type: object properties: punchIn: type: string punchOut: type: string status: type: string enum: [present, absent, late, half-day, holiday, leave] note: type: string LeaveRequest: type: object properties: id: type: integer userId: type: integer userName: type: string leaveType: type: string enum: [casual, sick, paid, unpaid] startDate: type: string endDate: type: string days: type: integer reason: type: string status: type: string enum: [pending, approved, rejected] approvedBy: type: integer approverName: type: string rejectionReason: type: string appliedAt: type: string required: [id, userId, leaveType, startDate, endDate, days, status] CreateLeaveRequest: type: object properties: leaveType: type: string enum: [casual, sick, paid, unpaid] startDate: type: string endDate: type: string reason: type: string required: [leaveType, startDate, endDate] RejectLeaveRequest: type: object properties: reason: type: string LeaveBalance: type: object properties: userId: type: integer year: type: integer casualLeave: type: integer sickLeave: type: integer paidLeave: type: integer casualUsed: type: integer sickUsed: type: integer paidUsed: type: integer casualRemaining: type: integer sickRemaining: type: integer paidRemaining: type: integer required: [userId, year] SalaryRecord: type: object properties: id: type: integer userId: type: integer userName: type: string month: type: integer year: type: integer monthlySalary: type: number totalWorkingDays: type: integer presentDays: type: integer absentDays: type: integer leaveDays: type: integer otHours: type: number otAmount: type: number perDaySalary: type: number perHourSalary: type: number earnedSalary: type: number deductions: type: number finalSalary: type: number status: type: string enum: [pending, generated, paid] generatedAt: type: string required: [id, userId, month, year, finalSalary, status] CalculateSalaryRequest: type: object properties: userId: type: integer month: type: integer year: type: integer required: [userId, month, year] Payslip: type: object properties: salary: $ref: "#/components/schemas/SalaryRecord" employee: $ref: "#/components/schemas/User" attendance: type: array items: $ref: "#/components/schemas/AttendanceRecord" company: type: object properties: name: type: string address: type: string required: [name] required: [salary, employee, company] Holiday: type: object properties: id: type: integer name: type: string date: type: string type: type: string enum: [national, regional, company] description: type: string required: [id, name, date, type] CreateHolidayRequest: type: object properties: name: type: string date: type: string type: type: string enum: [national, regional, company] description: type: string required: [name, date, type] Notification: type: object properties: id: type: integer userId: type: integer title: type: string message: type: string type: type: string enum: [info, success, warning, error] isRead: type: boolean createdAt: type: string required: [id, userId, title, message, type, isRead] MonthlyReport: type: object properties: userId: type: integer userName: type: string month: type: integer year: type: integer totalWorkingDays: type: integer presentDays: type: integer absentDays: type: integer lateDays: type: integer halfDays: type: integer leaveDays: type: integer totalOtHours: type: number attendance: type: array items: $ref: "#/components/schemas/AttendanceRecord" salary: $ref: "#/components/schemas/SalaryRecord" required: [userId, month, year] CompanyReport: type: object properties: month: type: integer year: type: integer totalEmployees: type: integer presentToday: type: integer absentToday: type: integer lateToday: type: integer onLeaveToday: type: integer totalSalaryBudget: type: number departmentStats: type: array items: type: object properties: departmentId: type: integer departmentName: type: string employeeCount: type: integer presentCount: type: integer absentCount: type: integer required: [departmentId, departmentName, employeeCount] required: [month, year, totalEmployees] ActivityLog: type: object properties: id: type: integer userId: type: integer userName: type: string action: type: string entity: type: string entityId: type: integer details: type: string ipAddress: type: string createdAt: type: string required: [id, userId, action, entity]