openapi: 3.0.0 info: title: Alamait Property Management System API description: API documentation for the Alamait Property Management System version: 1.0.0 contact: name: Alamait Support email: macdonaldsairos24@gmail.com servers: - url: 'https://alamait-backend.onrender.com/api' description: Development server - url: 'https://alamait-backend.onrender.com/api' description: Production server components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: User: type: object properties: _id: type: string email: type: string firstName: type: string lastName: type: string role: type: string enum: [student, admin, property_manager] phone: type: string applicationCode: type: string isVerified: type: boolean emergencyContact: type: object properties: name: type: string relationship: type: string phone: type: string createdAt: type: string format: date-time lastLogin: type: string format: date-time updatedAt: type: string format: date-time Message: type: object properties: _id: type: string sender: $ref: '#/components/schemas/User' recipient: $ref: '#/components/schemas/User' subject: type: string content: type: string status: type: string enum: [unread, read, archived] createdAt: type: string format: date-time replies: type: array items: $ref: '#/components/schemas/MessageReply' Booking: type: object properties: _id: type: string student: $ref: '#/components/schemas/User' residence: $ref: '#/components/schemas/Residence' room: type: object properties: roomNumber: type: string type: type: string price: type: number startDate: type: string format: date endDate: type: string format: date status: type: string enum: [pending, confirmed, cancelled, completed] paymentStatus: type: string enum: [pending, partial, paid] totalAmount: type: number paidAmount: type: number payments: type: array items: type: object properties: amount: type: number date: type: string format: date-time method: type: string status: type: string transactionId: type: string specialRequests: type: string emergencyContact: type: object properties: name: type: string relationship: type: string phone: type: string documents: type: array items: type: object properties: type: type: string name: type: string url: type: string uploadDate: type: string format: date-time checkInDetails: type: object properties: actualCheckIn: type: string format: date-time checkInNotes: type: string checkOutDetails: type: object properties: actualCheckOut: type: string format: date-time checkOutNotes: type: string roomCondition: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time Maintenance: type: object properties: _id: type: string student: $ref: '#/components/schemas/User' residence: $ref: '#/components/schemas/Residence' room: type: object properties: roomNumber: type: string title: type: string description: type: string priority: type: string enum: [low, medium, high, urgent] status: type: string enum: [pending, in_progress, completed, cancelled] category: type: string enum: [plumbing, electrical, hvac, appliance, structural, cleaning, pest_control, security, furniture, fire_safety, emergency, landscaping, internet_it, accessibility, parking, exterior, communication, general_maintenance, other] images: type: array items: type: object properties: url: type: string caption: type: string assignedTo: $ref: '#/components/schemas/User' comments: type: array items: type: object properties: user: $ref: '#/components/schemas/User' text: type: string createdAt: type: string format: date-time scheduledDate: type: string format: date-time completedDate: type: string format: date-time estimatedCost: type: number actualCost: type: number createdAt: type: string format: date-time updatedAt: type: string format: date-time Event: type: object properties: _id: type: string title: type: string description: type: string residence: $ref: '#/components/schemas/Residence' date: type: string format: date startTime: type: string endTime: type: string location: type: string category: type: string enum: [social, academic, sports, cultural, other] organizer: $ref: '#/components/schemas/User' capacity: type: integer participants: type: array items: type: object properties: student: $ref: '#/components/schemas/User' status: type: string enum: [registered, attended, cancelled] registeredAt: type: string format: date-time status: type: string enum: [upcoming, ongoing, completed, cancelled] image: type: object properties: url: type: string caption: type: string requirements: type: array items: type: string resources: type: array items: type: object properties: name: type: string url: type: string feedback: type: array items: type: object properties: student: $ref: '#/components/schemas/User' rating: type: number minimum: 1 maximum: 5 comment: type: string createdAt: type: string format: date-time createdAt: type: string format: date-time updatedAt: type: string format: date-time Residence: type: object properties: _id: type: string name: type: string description: type: string address: type: object properties: street: type: string city: type: string state: type: string zipCode: type: string country: type: string location: type: object properties: type: type: string enum: [Point] coordinates: type: array items: type: number rooms: type: array items: type: object properties: roomNumber: type: string type: type: string enum: [single, double, studio, apartment] price: type: number status: type: string enum: [available, occupied, maintenance, reserved] features: type: array items: type: string floor: type: number area: type: number amenities: type: array items: type: object properties: name: type: string description: type: string icon: type: string images: type: array items: type: object properties: url: type: string caption: type: string rules: type: array items: type: object properties: title: type: string description: type: string features: type: array items: type: object properties: name: type: string description: type: string icon: type: string manager: type: string status: type: string enum: [active, inactive, maintenance] contactInfo: type: object properties: email: type: string phone: type: string website: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time StudentInput: type: object required: - email - firstName - lastName properties: email: type: string format: email firstName: type: string lastName: type: string phone: type: string status: type: string enum: [active, inactive, pending] emergencyContact: type: object properties: name: type: string relationship: type: string phone: type: string Student: allOf: - $ref: '#/components/schemas/StudentInput' - type: object properties: _id: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time isVerified: type: boolean role: type: string enum: [student] Application: type: object properties: _id: type: string student: $ref: '#/components/schemas/User' residence: $ref: '#/components/schemas/Residence' status: type: string enum: [pending, approved, rejected, waitlisted] paymentStatus: type: string enum: [pending, paid, failed] roomNumber: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time Room: type: object properties: id: type: string name: type: string capacity: type: integer price: type: number occupants: type: array items: type: string applications: type: array items: type: string pendingPayments: type: array items: type: string waitlist: type: array items: type: string PaymentInput: type: object required: - student - payments - date - method properties: student: type: string description: Full name of the student payments: type: array items: type: object required: - type - amount properties: type: type: string enum: [rent, admin, deposit] amount: type: number minimum: 0 date: type: string format: date method: type: string enum: [Bank Transfer, Cash, Online Payment] Payment: type: object properties: id: type: string example: PAY001 student: type: string example: John Doe payments: type: array items: type: object properties: type: type: string enum: [rent, admin, deposit] amount: type: number totalAmount: type: number date: type: string format: date method: type: string enum: [Bank Transfer, Cash, Online Payment] status: type: string enum: [Pending, Confirmed, Failed] MaintenanceRequest: type: object properties: id: type: string title: type: string description: type: string location: type: string category: type: string enum: [plumbing, electrical, hvac, appliance, structural, cleaning, pest_control, security, furniture, fire_safety, emergency, landscaping, internet_it, accessibility, parking, exterior, communication, general_maintenance, other] priority: type: string enum: [low, medium, high] status: type: string enum: [pending, assigned, in-progress, on-hold, completed] student: type: object properties: id: type: string name: type: string residence: type: object properties: id: type: string name: type: string roomNumber: type: string assignedTo: type: object properties: id: type: string name: type: string requestDate: type: string format: date-time scheduledDate: type: string format: date-time estimatedCompletion: type: string format: date-time completedDate: type: string format: date-time updates: type: array items: type: object properties: date: type: string format: date-time message: type: string author: type: object properties: id: type: string name: type: string images: type: array items: type: object properties: url: type: string uploadedAt: type: string format: date-time MaintenanceStats: type: object properties: openRequests: type: integer description: Number of open maintenance requests highPriorityCount: type: integer description: Number of high priority requests inProgressCount: type: integer description: Number of requests in progress completedToday: type: integer description: Number of requests completed today MaintenanceStaff: type: object properties: id: type: string firstName: type: string lastName: type: string email: type: string phone: type: string role: type: string enum: [maintenance_staff] AdminMessage: type: object properties: id: type: string description: Unique identifier for the message sender: type: string description: Name or ID of the sender recipient: type: string description: Name or ID of the recipient (or 'All Students' for broadcast) subject: type: string description: Subject of the message message: type: string description: Content of the message timestamp: type: string format: date-time description: Time when the message was sent read: type: boolean description: Whether the message has been read status: type: string enum: [sent, delivered, read] description: Status of the message required: - id - sender - recipient - message - timestamp AdminProfileUpdate: type: object properties: firstName: type: string description: Admin's first name lastName: type: string description: Admin's last name phone: type: string description: Admin's phone number department: type: string description: Admin's department office: type: string description: Admin's office location AdminPasswordChange: type: object required: - currentPassword - newPassword properties: currentPassword: type: string description: Current password newPassword: type: string description: New password minLength: 8 StudentDashboardProfile: type: object properties: name: type: string example: "John Doe" id: type: string example: "STU2024001" program: type: string example: "Computer Science" year: type: string example: "2nd Year" image: type: string example: "https://example.com/profile.jpg" StudentDashboardCard: type: object properties: payment: type: object properties: amount: type: number example: 800 dueDate: type: string format: date-time room: type: object properties: status: type: string enum: [Active, None] example: "Active" validUntil: type: string format: date maintenance: type: object properties: activeCount: type: integer example: 1 status: type: string example: "In Progress" messages: type: object properties: unreadCount: type: integer example: 3 latestMessageTime: type: string format: date-time StudentDashboardResponse: type: object properties: profile: $ref: '#/components/schemas/StudentDashboardProfile' cards: $ref: '#/components/schemas/StudentDashboardCard' AvailableRoom: type: object properties: id: type: string name: type: string example: "Student Single" capacity: type: integer example: 1 price: type: number example: 800 status: type: string enum: [available, occupied, maintenance] example: "available" features: type: array items: type: string example: ["Study desk", "Built-in wardrobe"] amenities: type: array items: type: string example: ["wifi", "ac", "desk"] image: type: string example: "https://example.com/room.jpg" StudentNotification: type: object properties: id: type: string title: type: string message: type: string createdAt: type: string format: date-time read: type: boolean default: false StudentBookingDetails: type: object properties: currentBooking: type: object properties: id: type: string description: Booking ID roomNumber: type: string description: Room number (e.g., A-101) roomType: type: string description: Type of room (e.g., Student Single) startDate: type: string format: date description: Start date of booking endDate: type: string format: date description: End date of booking monthlyRent: type: number description: Monthly rent amount status: type: string enum: [active, completed, cancelled] description: Current status of booking image: type: string description: URL of room image features: type: array items: type: string description: List of room features bookingHistory: type: array items: type: object properties: id: type: string description: Historical booking ID roomNumber: type: string description: Room number roomType: type: string description: Type of room startDate: type: string format: date description: Start date of historical booking endDate: type: string format: date description: End date of historical booking status: type: string enum: [completed, cancelled] description: Status of historical booking roomOptions: type: array items: type: object properties: id: type: string description: Room ID roomNumber: type: string description: Room number type: type: string description: Type of room price: type: number description: Monthly price features: type: array items: type: string description: List of room features amenities: type: array items: type: string description: List of amenities size: type: string description: Room size floor: type: string description: Floor location image: type: string description: URL of room image roomtype: type: string enum: [upgrade, downgrade] description: Type of room option MessageReply: type: object properties: id: type: string author: type: object properties: id: type: string name: type: string role: type: string content: type: string timestamp: type: string format: date-time ResidenceInput: type: object required: - name - description - address - location - rooms properties: name: type: string description: type: string address: type: string location: type: object properties: type: type: string default: Point coordinates: type: array items: type: number rooms: type: array items: type: object required: - roomNumber - type - price properties: roomNumber: type: string type: type: string enum: [single, double, studio, apartment] price: type: number status: type: string enum: [available, occupied, maintenance] default: available Residence: allOf: - $ref: '#/components/schemas/ResidenceInput' - type: object properties: _id: type: string createdAt: type: string format: date-time updatedAt: type: string format: date-time paths: /auth/register: post: tags: - Authentication summary: Register a new user description: Register a new user with email verification requestBody: required: true content: application/json: schema: type: object required: - email - password - firstName - lastName - phone - applicationCode properties: email: type: string password: type: string firstName: type: string lastName: type: string phone: type: string applicationCode: type: string responses: '201': description: User registered successfully '400': description: Invalid input data '409': description: Email already exists /auth/login: post: tags: - Authentication summary: User login description: Authenticate user and return JWT token requestBody: required: true content: application/json: schema: type: object required: - email - password properties: email: type: string password: type: string responses: '200': description: Login successful content: application/json: schema: type: object properties: token: type: string '401': description: Invalid credentials /auth/verify-email/{token}: get: tags: - Authentication summary: Verify email address parameters: - in: path name: token required: true schema: type: string responses: '200': description: Email verified successfully '400': description: Invalid or expired token /auth/forgot-password: post: tags: - Authentication summary: Request password reset requestBody: required: true content: application/json: schema: type: object required: - email properties: email: type: string responses: '200': description: Password reset email sent '404': description: User not found /monitoring/metrics: get: tags: - Monitoring summary: Get Prometheus metrics security: - BearerAuth: [] responses: '200': description: Prometheus metrics in text format '401': description: Unauthorized '403': description: Forbidden - Admin access required /monitoring/health: get: tags: - Monitoring summary: Get system health status description: Returns detailed system health metrics including memory usage and uptime responses: '200': description: System health information content: application/json: schema: type: object properties: status: type: string timestamp: type: string format: date-time uptime: type: number environment: type: string memory: type: object properties: heapUsed: type: string heapTotal: type: string rss: type: string /student/messages: get: tags: - Student summary: Get student messages security: - BearerAuth: [] responses: '200': description: List of messages content: application/json: schema: type: array items: $ref: '#/components/schemas/Message' /student/bookings: get: tags: - Student summary: Get student bookings security: - BearerAuth: [] responses: '200': description: List of bookings content: application/json: schema: type: array items: $ref: '#/components/schemas/Booking' /student/maintenance: get: tags: - Student summary: Get maintenance requests security: - BearerAuth: [] responses: '200': description: List of maintenance requests content: application/json: schema: type: array items: $ref: '#/components/schemas/Maintenance' post: tags: - Student summary: Create maintenance request security: - BearerAuth: [] requestBody: required: true content: application/json: schema: type: object required: - title - description - priority - category properties: title: type: string description: type: string priority: type: string enum: [low, medium, high, urgent] category: type: string enum: [plumbing, electrical, hvac, appliance, structural, cleaning, pest_control, security, furniture, fire_safety, emergency, landscaping, internet_it, accessibility, parking, exterior, communication, general_maintenance, other] images: type: array items: type: object properties: url: type: string caption: type: string responses: '201': description: Maintenance request created '400': description: Invalid input data /student/dashboard: get: tags: - Student summary: Get student dashboard data security: - BearerAuth: [] responses: '200': description: Dashboard information including notifications, upcoming payments, and recent activities /student/payment-history: get: tags: - Student summary: Get payment history security: - BearerAuth: [] responses: '200': description: List of payment transactions /student/events: get: tags: - Student summary: Get residence events security: - BearerAuth: [] responses: '200': description: List of upcoming and past events /student/profile: get: tags: - Student summary: Get student profile description: Retrieve the authenticated student's profile information security: - BearerAuth: [] responses: 200: description: Student profile retrieved successfully content: application/json: schema: type: object properties: id: type: string firstName: type: string lastName: type: string email: type: string phone: type: string studentId: type: string program: type: string year: type: string emergencyContact: type: object properties: name: type: string relationship: type: string phone: type: string 401: description: Unauthorized - Invalid or missing token 500: description: Server error put: tags: - Student summary: Update student profile description: Update the authenticated student's profile information security: - BearerAuth: [] requestBody: required: true content: application/json: schema: type: object properties: firstName: type: string lastName: type: string phone: type: string emergencyContact: type: object properties: name: type: string relationship: type: string phone: type: string responses: 200: description: Profile updated successfully content: application/json: schema: $ref: '#/components/schemas/Student' 400: description: Invalid request data 401: description: Unauthorized - Invalid or missing token 500: description: Server error /student/profile/password: put: tags: - Student summary: Change student password description: Update the authenticated student's password security: - BearerAuth: [] requestBody: required: true content: application/json: schema: type: object properties: currentPassword: type: string newPassword: type: string responses: 200: description: Password changed successfully 400: description: Invalid password data 401: description: Unauthorized - Invalid or missing token 500: description: Server error /applications/submit: post: tags: - Applications summary: Submit a new application description: Submit a new application for student accommodation requestBody: required: true content: application/json: schema: type: object required: - firstName - lastName - email - phone - preferredRoom - startDate - endDate - residence properties: firstName: type: string lastName: type: string email: type: string phone: type: string preferredRoom: type: string alternateRooms: type: array items: type: string startDate: type: string format: date description: "Desired start date for accommodation" endDate: type: string format: date description: "Desired end date for accommodation" residence: type: string description: "Residence ID where the application is being submitted" responses: '201': description: Application submitted successfully content: application/json: schema: type: object properties: message: type: string application: type: object properties: id: type: string status: type: string applicationDate: type: string format: date-time '400': description: Invalid input '500': description: Server error /applications/status/{email}: get: tags: - Applications summary: Get application status description: Get the status of an application by email parameters: - in: path name: email required: true schema: type: string description: Email address used in the application responses: '200': description: Application status retrieved successfully content: application/json: schema: $ref: '#/components/schemas/Application' '404': description: Application not found '500': description: Server error /admin/applications: get: summary: Get all applications tags: - Applications security: - BearerAuth: [] responses: '200': description: List of all applications content: application/json: schema: type: array items: $ref: '#/components/schemas/Application' '401': description: Unauthorized '403': description: Forbidden - Admin access required /admin/applications/{applicationId}: put: summary: Update application status tags: - Applications security: - BearerAuth: [] parameters: - name: applicationId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: - action - roomNumber - residenceId properties: action: type: string enum: [approve, reject, waitlist] roomNumber: type: string description: Required when action is 'approve' or 'waitlist' residenceId: type: string description: "Required when action is 'approve'" responses: '200': description: Application status updated successfully '400': description: Invalid request parameters '401': description: Unauthorized '403': description: Forbidden - Admin access required '404': description: Application not found /admin/applications/{applicationId}/payment: put: summary: Update application payment status tags: - Applications security: - BearerAuth: [] parameters: - name: applicationId in: path required: true schema: type: string requestBody: required: true content: application/json: schema: type: object required: - paymentStatus properties: paymentStatus: type: string enum: [pending, paid, failed] responses: '200': description: Payment status updated successfully '400': description: Invalid request parameters '401': description: Unauthorized '403': description: Forbidden - Admin access required '404': description: Application not found /admin/residences: post: summary: Add a new residence tags: - Residences security: - BearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ResidenceInput' responses: '201': description: Residence created successfully '400': description: Invalid request parameters '401': description: Unauthorized '403': description: Forbidden - Admin access required get: summary: Get all residences tags: - Residences security: - BearerAuth: [] responses: '200': description: List of all residences content: application/json: schema: type: array items: $ref: '#/components/schemas/Residence' '401': description: Unauthorized '403': description: Forbidden - Admin access required /admin/residences/{id}: get: summary: Get a specific residence tags: - Residences security: - BearerAuth: [] parameters: - name: id in: path required: true schema: type: string responses: '200': description: Residence details content: application/json: schema: $ref: '#/components/schemas/Residence' '401': description: Unauthorized '403': description: Forbidden - Admin access required '404': description: Residence not found put: summary: Update a residence tags: - Residences security: - BearerAuth: [] parameters: - name: id in: path required: true schema: type: string requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ResidenceInput' responses: '200': description: Residence updated successfully '400': description: Invalid request parameters '401': description: Unauthorized '403': description: Forbidden - Admin access required '404': description: Residence not found delete: summary: Delete a residence tags: - Residences security: - BearerAuth: [] parameters: - name: id in: path required: true schema: type: string responses: '200': description: Residence deleted successfully '401': description: Unauthorized '403': description: Forbidden - Admin access required '404': description: Residence not found /public/residences/st-kilda: get: summary: Get St Kilda residence details tags: - Public description: Public endpoint to get details about St Kilda Student House responses: '200': description: St Kilda residence details retrieved successfully content: application/json: schema: type: object properties: success: type: boolean data: $ref: '#/components/schemas/Residence' '404': description: St Kilda residence not found '500': description: Server error /public/residences/belvedere: get: summary: Get Belvedere residence details tags: - Public description: Public endpoint to get details about Belvedere Student House responses: '200': description: Belvedere residence details retrieved successfully content: application/json: schema: type: object properties: success: type: boolean data: $ref: '#/components/schemas/Residence' '404': description: Belvedere residence not found '500': description: Server error /public/residences/name/{name}: get: summary: Get residence by name tags: - Public description: Public endpoint to get details about a specific residence by name parameters: - name: name in: path required: true schema: type: string description: Name of the residence responses: '200': description: Residence details retrieved successfully content: application/json: schema: $ref: '#/components/schemas/Residence' '404': description: Residence not found '500': description: Server error /api/monitoring/health: get: tags: - Monitoring summary: Get system health status description: Returns detailed system health information including memory usage, uptime, and metrics responses: 200: description: Successful health check content: application/json: schema: type: object properties: status: type: string example: "ok" timestamp: type: string format: date-time uptime: type: number description: System uptime in seconds environment: type: string example: "development" memory: type: object properties: heapUsed: type: string example: "50MB" heapTotal: type: string example: "100MB" rss: type: string example: "150MB" metrics: type: array items: type: object description: Prometheus metrics /api/monitoring/metrics: get: tags: - Monitoring summary: Get Prometheus metrics description: Returns Prometheus-formatted metrics for system monitoring security: - BearerAuth: [] responses: 200: description: Prometheus metrics content: text/plain: schema: type: string 401: description: Unauthorized 403: description: Forbidden - Admin access required /api/monitoring/performance: get: tags: - Monitoring summary: Check system performance description: Returns performance metrics focusing on response times and SLA compliance security: - BearerAuth: [] responses: 200: description: Performance metrics content: application/json: schema: type: object properties: totalRequests: type: integer example: 100 slowRequests: type: integer example: 2 performanceMeetsSLA: type: boolean example: true 401: description: Unauthorized 403: description: Forbidden - Admin access required /api/admin/backup/create: post: tags: - Backup Management summary: Create new backup description: Triggers creation of a new database backup security: - BearerAuth: [] responses: 200: description: Backup created successfully content: application/json: schema: type: object properties: message: type: string example: "Backup created successfully" path: type: string example: "/backups/backup-2024-02-25.tar.gz" 401: description: Unauthorized 403: description: Forbidden - Admin access required 500: description: Backup creation failed /api/admin/backup/list: get: tags: - Backup Management summary: List available backups description: Returns list of all available backups with metadata security: - BearerAuth: [] responses: 200: description: List of backups content: application/json: schema: type: array items: type: object properties: filename: type: string example: "backup-2024-02-25.tar.gz" size: type: integer example: 1048576 created: type: string format: date-time 401: description: Unauthorized 403: description: Forbidden - Admin access required /api/admin/backup/restore/{filename}: post: tags: - Backup Management summary: Restore from backup description: Restores database from specified backup file security: - BearerAuth: [] parameters: - in: path name: filename required: true schema: type: string description: Name of backup file to restore from responses: 200: description: Backup restored successfully content: application/json: schema: type: object properties: message: type: string example: "Backup restored successfully" 401: description: Unauthorized 403: description: Forbidden - Admin access required 500: description: Backup restoration failed /api/admin/backup/{filename}: delete: tags: - Backup Management summary: Delete backup description: Deletes specified backup file security: - BearerAuth: [] parameters: - in: path name: filename required: true schema: type: string description: Name of backup file to delete responses: 200: description: Backup deleted successfully content: application/json: schema: type: object properties: message: type: string example: "Backup deleted successfully" 401: description: Unauthorized 403: description: Forbidden - Admin access required 500: description: Failed to delete backup /api/admin/backup/upload: post: tags: - Backup Management summary: Upload a new lease template description: Upload a new lease template for a specific residence consumes: - multipart/form-data parameters: - name: residenceId in: formData type: string required: true description: The ID of the residence for which the template is being uploaded. - name: leaseTemplate in: formData responses: 200: description: Lease template uploaded successfully 400: description: Invalid request parameters 401: description: Unauthorized 500: description: Server error tags: - name: Monitoring description: System monitoring and performance tracking endpoints - name: Backup Management description: Database backup and restore management endpoints