openapi: 3.1.0 info: title: Api version: 0.1.0 description: Smart Hostel Allocation & Management System API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: auth description: Authentication - name: students description: Student operations - name: hostels description: Hostel operations - name: rooms description: Room operations - name: allotments description: Allotment operations - name: complaints description: Complaint operations - name: payments description: Fee payment operations - name: reports description: Report/analytics operations 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 as admin or student 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: Unauthorized 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/SuccessResponse" /auth/me: get: operationId: getMe tags: [auth] summary: Get current user session responses: "200": description: Current user content: application/json: schema: $ref: "#/components/schemas/LoginResponse" "401": description: Not authenticated content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /auth/change-password: patch: operationId: changePassword tags: [auth] summary: Change password (students only) security: - sessionAuth: [] requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ChangePasswordRequest" responses: "200": description: Password changed successfully content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "401": description: Unauthorized content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /students: get: operationId: listStudents tags: [students] summary: List all students responses: "200": description: List of students content: application/json: schema: type: array items: $ref: "#/components/schemas/Student" post: operationId: createStudent tags: [students] summary: Create a student requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateStudentRequest" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Student" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /students/{studentId}: get: operationId: getStudent tags: [students] summary: Get a student by ID parameters: - name: studentId in: path required: true schema: type: string responses: "200": description: Student content: application/json: schema: $ref: "#/components/schemas/StudentDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" put: operationId: updateStudent tags: [students] summary: Update a student's information parameters: - name: studentId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateStudentRequest" responses: "200": description: Student updated content: application/json: schema: $ref: "#/components/schemas/Student" "400": description: Validation error content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Student not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: operationId: deleteStudent tags: [students] summary: Delete a student parameters: - name: studentId in: path required: true schema: type: string responses: "200": description: Student deleted content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" "400": description: Validation error (e.g., student has active allotment) content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: Student not found content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /students/{studentId}/phones: get: operationId: listStudentPhones tags: [students] summary: List student phone numbers parameters: - name: studentId in: path required: true schema: type: string responses: "200": description: Phone numbers content: application/json: schema: type: array items: $ref: "#/components/schemas/StudentPhone" post: operationId: addStudentPhone tags: [students] summary: Add a phone number to a student parameters: - name: studentId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/AddPhoneRequest" responses: "201": description: Phone added content: application/json: schema: $ref: "#/components/schemas/StudentPhone" /hostels: get: operationId: listHostels tags: [hostels] summary: List all hostels responses: "200": description: List of hostels content: application/json: schema: type: array items: $ref: "#/components/schemas/Hostel" post: operationId: createHostel tags: [hostels] summary: Create a hostel requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateHostelRequest" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Hostel" /hostels/{hostelId}: put: operationId: updateHostel tags: [hostels] summary: Update a hostel's information parameters: - name: hostelId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateHostelRequest" responses: "200": description: Hostel updated content: application/json: schema: $ref: "#/components/schemas/Hostel" delete: operationId: deleteHostel tags: [hostels] summary: Delete a hostel parameters: - name: hostelId in: path required: true schema: type: string responses: "200": description: Hostel deleted content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" /hostels/{hostelId}/rooms: get: operationId: listRooms tags: [rooms] summary: List rooms in a hostel parameters: - name: hostelId in: path required: true schema: type: string responses: "200": description: List of rooms content: application/json: schema: type: array items: $ref: "#/components/schemas/Room" post: operationId: createRoom tags: [rooms] summary: Create a room in a hostel parameters: - name: hostelId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateRoomRequest" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/Room" /hostels/{hostelId}/rooms/{roomNumber}: put: operationId: updateRoom tags: [rooms] summary: Update a room's information parameters: - name: hostelId in: path required: true schema: type: string - name: roomNumber in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateRoomRequest" responses: "200": description: Room updated content: application/json: schema: $ref: "#/components/schemas/Room" delete: operationId: deleteRoom tags: [rooms] summary: Delete a room from a hostel parameters: - name: hostelId in: path required: true schema: type: string - name: roomNumber in: path required: true schema: type: string responses: "200": description: Room deleted content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" /rooms: get: operationId: listAllRooms tags: [rooms] summary: List all rooms with availability responses: "200": description: All rooms content: application/json: schema: type: array items: $ref: "#/components/schemas/RoomWithAvailability" /allotments: get: operationId: listAllotments tags: [allotments] summary: List allotments with optional filters parameters: - name: status in: query schema: type: string enum: [Active, Completed] - name: hostelId in: query schema: type: string - name: studentId in: query schema: type: string responses: "200": description: List of allotments content: application/json: schema: type: array items: $ref: "#/components/schemas/AllotmentDetail" post: operationId: createAllotment tags: [allotments] summary: Allocate a room to a student requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateAllotmentRequest" responses: "201": description: Allotment created content: application/json: schema: $ref: "#/components/schemas/AllotmentDetail" "400": description: Validation error (already allocated, room full, gender mismatch) content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /allotments/{allotmentId}: parameters: - name: allotmentId in: path required: true schema: type: string delete: operationId: deleteAllotment tags: [allotments] summary: Delete an allotment record responses: "200": description: Deleted content: application/json: schema: $ref: "#/components/schemas/SuccessResponse" patch: operationId: updateAllotment tags: [allotments] summary: Update allotment status (complete/vacate) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateAllotmentRequest" responses: "200": description: Success content: application/json: schema: $ref: "#/components/schemas/AllotmentDetail" /complaints: get: operationId: listComplaints tags: [complaints] summary: List complaints parameters: - name: studentId in: query schema: type: string - name: status in: query schema: type: string enum: [Pending, Resolved] - name: sortBy in: query schema: type: string enum: [date, status] responses: "200": description: List of complaints content: application/json: schema: type: array items: $ref: "#/components/schemas/ComplaintDetail" post: operationId: createComplaint tags: [complaints] summary: Submit a complaint requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateComplaintRequest" responses: "201": description: Complaint created content: application/json: schema: $ref: "#/components/schemas/ComplaintDetail" /complaints/{complaintId}: patch: operationId: updateComplaint tags: [complaints] summary: Update complaint status parameters: - name: complaintId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateComplaintRequest" responses: "200": description: Updated content: application/json: schema: $ref: "#/components/schemas/ComplaintDetail" /payments: get: operationId: listPayments tags: [payments] summary: List payments parameters: - name: studentId in: query schema: type: string - name: status in: query schema: type: string enum: [Paid, Pending] - name: sortBy in: query schema: type: string enum: [date, amount] responses: "200": description: List of payments content: application/json: schema: type: array items: $ref: "#/components/schemas/PaymentDetail" post: operationId: createPayment tags: [payments] summary: Create a fee payment record requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePaymentRequest" responses: "201": description: Payment record created content: application/json: schema: $ref: "#/components/schemas/PaymentDetail" /payments/{paymentId}/pay: post: operationId: makePayment tags: [payments] summary: Pay a pending fee parameters: - name: paymentId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/MakePaymentRequest" responses: "200": description: Payment successful content: application/json: schema: $ref: "#/components/schemas/PaymentDetail" "400": description: Validation error (amount exceeds due) content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /reports/occupancy: get: operationId: getOccupancyReport tags: [reports] summary: Hostel occupancy report responses: "200": description: Occupancy report content: application/json: schema: type: array items: $ref: "#/components/schemas/OccupancyReport" /reports/unallocated-students: get: operationId: getUnallocatedStudents tags: [reports] summary: Students without active allotment responses: "200": description: Unallocated students content: application/json: schema: type: array items: $ref: "#/components/schemas/Student" /reports/revenue: get: operationId: getRevenueReport tags: [reports] summary: Total revenue collected and pending payments responses: "200": description: Revenue summary content: application/json: schema: $ref: "#/components/schemas/RevenueReport" components: schemas: HealthStatus: type: object properties: status: type: string required: [status] ErrorResponse: type: object properties: error: type: string message: type: string required: [error, message] SuccessResponse: type: object properties: success: type: boolean required: [success] LoginRequest: type: object properties: role: type: string enum: [admin, student] studentId: type: string description: Required for student role password: type: string description: Required for admin and student roles username: type: string description: Required for admin role required: [role, password] LoginResponse: type: object properties: role: type: string enum: [admin, student] studentId: type: string studentName: type: string required: [role] Student: type: object properties: studentId: type: string name: type: string gender: type: string enum: [Male, Female] department: type: string yearOfStudy: type: integer email: type: string required: [studentId, name, gender, department, yearOfStudy, email] StudentDetail: allOf: - $ref: "#/components/schemas/Student" - type: object properties: activeAllotment: $ref: "#/components/schemas/AllotmentDetail" phones: type: array items: type: string StudentPhone: type: object properties: studentId: type: string phoneNumber: type: string required: [studentId, phoneNumber] AddPhoneRequest: type: object properties: phoneNumber: type: string required: [phoneNumber] CreateStudentRequest: type: object properties: studentId: type: string name: type: string gender: type: string enum: [Male, Female] department: type: string yearOfStudy: type: integer email: type: string password: type: string required: [studentId, name, gender, department, yearOfStudy, email, password] UpdateStudentRequest: type: object properties: name: type: string gender: type: string enum: [Male, Female] department: type: string yearOfStudy: type: integer email: type: string required: [name, gender, department, yearOfStudy, email] ChangePasswordRequest: type: object properties: currentPassword: type: string newPassword: type: string required: [currentPassword, newPassword] Hostel: type: object properties: hostelId: type: string hostelName: type: string type: type: string enum: [Boys, Girls] totalRooms: type: integer wardenName: type: string required: [hostelId, hostelName, type, totalRooms, wardenName] UpdateHostelRequest: type: object properties: hostelName: type: string type: type: string enum: [Boys, Girls] totalRooms: type: integer wardenName: type: string required: [hostelName, type, totalRooms, wardenName] Room: type: object properties: hostelId: type: string roomNumber: type: string capacity: type: integer roomType: type: string floorNo: type: integer required: [hostelId, roomNumber, capacity, roomType, floorNo] RoomWithAvailability: allOf: - $ref: "#/components/schemas/Room" - type: object properties: hostelName: type: string hostelType: type: string currentOccupancy: type: integer availableSlots: type: integer UpdateRoomRequest: type: object properties: capacity: type: integer roomType: type: string floorNo: type: integer required: [capacity, roomType, floorNo] AllotmentDetail: type: object properties: allotmentId: type: string studentId: type: string studentName: type: string hostelId: type: string hostelName: type: string roomNumber: type: string roomType: type: string allocationDate: type: string format: date vacatingDate: type: string format: date status: type: string enum: [Active, Completed] required: [allotmentId, studentId, hostelId, roomNumber, allocationDate, status] CreateAllotmentRequest: type: object properties: studentId: type: string hostelId: type: string roomNumber: type: string allocationDate: type: string format: date vacatingDate: type: string format: date required: [studentId, hostelId, roomNumber, allocationDate] UpdateAllotmentRequest: type: object properties: status: type: string enum: [Completed] vacatingDate: type: string format: date required: [status] ComplaintDetail: type: object properties: complaintId: type: string studentId: type: string studentName: type: string complaintDate: type: string format: date description: type: string status: type: string enum: [Pending, Resolved] required: [complaintId, studentId, complaintDate, description, status] CreateComplaintRequest: type: object properties: studentId: type: string description: type: string required: [studentId, description] UpdateComplaintRequest: type: object properties: status: type: string enum: [Pending, Resolved] required: [status] PaymentDetail: type: object properties: paymentId: type: string studentId: type: string studentName: type: string amount: type: number dueDate: type: string format: date paymentDate: type: string format: date status: type: string enum: [Paid, Pending] required: [paymentId, studentId, amount, dueDate, status] CreatePaymentRequest: type: object properties: studentId: type: string amount: type: number dueDate: type: string format: date required: [studentId, amount, dueDate] MakePaymentRequest: type: object properties: amountPaid: type: number required: [amountPaid] OccupancyReport: type: object properties: hostelId: type: string hostelName: type: string type: type: string totalCapacity: type: integer currentOccupancy: type: integer occupancyPercentage: type: number required: [hostelId, hostelName, type, totalCapacity, currentOccupancy, occupancyPercentage] RevenueReport: type: object properties: totalRevenue: type: number totalPending: type: number paidCount: type: integer pendingCount: type: integer pendingPayments: type: array items: $ref: "#/components/schemas/PaymentDetail" required: [totalRevenue, totalPending, paidCount, pendingCount, pendingPayments]