Skip to content

KPorus/staymate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

StayMate Project

Abstract

StayMate is a comprehensive hotel booking and recommendation platform. It features a robust backend built with NestJS and an AI-powered recommendation service using Python and machine learning. The system allows users to register, book hotels, and receive personalized hotel recommendations based on their preferences and booking history. The modular architecture supports scalability, security, and easy integration with various frontends.

Chapter 1: Introduction

1.1 Problem Specification/Statement

Finding the right hotel that matches user preferences and budget is challenging. StayMate aims to simplify this by providing a seamless booking experience and AI-driven recommendations, addressing the gap in personalized hotel search and management.

1.2 Objectives

  • Enable users to search, book, and manage hotel reservations.
  • Provide personalized hotel recommendations using AI.
  • Support admin and manager roles for hotel management.
  • Ensure secure authentication and authorization.
  • Offer scalable and maintainable architecture.

1.3 Flow of the Project

  1. User registration and login.
  2. Hotel search and booking.
  3. AI-based recommendations.
  4. Admin/manager hotel management.
  5. Data-driven improvements and analytics.

1.4 Organization Of Project Report

This document covers system background, design, implementation, user manual, and future work, providing a holistic view of the StayMate platform.


Chapter 2: Background

2.1 Existing System Analysis

Traditional hotel booking platforms often lack personalized recommendations and seamless management for different user roles. StayMate addresses these limitations by integrating AI and role-based access control.

2.2 Supporting Literatures


Chapter 3: System Analysis & Design

3.1 Technology & Tools

  • Backend: NestJS (Node.js, TypeScript)
  • AI Service: Python (Flask, PyTorch, Transformers)
  • Database: MongoDB
  • Other: Docker, Vercel, AWS S3, Pandas, Scikit-learn

3.2 Model & Diagram

3.2.1 Model (SDLC/Agile/Waterfall/OOM)

Agile methodology with modular design for scalability and rapid iteration. Each module (auth, hotels, bookings, recommendations, AI) is independently testable and deployable.

3.2.2 Use Case Diagram

  • User: Register, login, search hotels, book hotels, view recommendations
  • Admin: Manage hotels, view all bookings, manage users
  • Manager: Add/update/delete hotels, manage bookings
  • AI Service: Generate personalized recommendations

3.2.3 Context Level Diagram

  • Users interact with the NestJS API for all operations
  • NestJS API communicates with MongoDB and the AI service
  • AI service processes user and hotel data to return recommendations

3.2.4 Data Flow Diagram

  • User submits booking/preferences → API → AI Service → Recommendations
  • Admin/Manager actions → API → Database

3.2.5 Database Schema

Hotels

  • name, location, description, price_per_night, rating, amenities, available_rooms, hotel_type, userId, image_url

Booking

  • userId, hotelId, check_in_date, check_out_date, total_price, booked_rooms, status, paymentStatus, paymentType, confirmationToken

Users

  • username, email, password, role, bookingId, created_at

3.2.6 Algorithms/Flowchart

  • AI Recommendation: Uses sentence-transformer embeddings and cosine similarity to match user preferences with hotel features.
  • Booking Management: Ensures room availability, handles payment status, and manages booking lifecycle.
  • Authentication: JWT-based, with role-based guards for access control.

Database Schema Design

Below is the Entity-Relationship (ER) diagram for the StayMate platform:

erDiagram
    USERS {
        string _id PK
        string username
        string email
        string password
        enum role
        ObjectId bookingId FK
        date created_at
    }
    HOTELS {
        ObjectId _id PK
        string name
        GeoJSON location
        string description
        number price_per_night
        number rating
        string[] amenities
        number available_rooms
        string hotel_type
        ObjectId userId FK
        string image_url
    }
    BOOKINGS {
        ObjectId _id PK
        ObjectId userId FK
        ObjectId hotelId FK
        date check_in_date
        date check_out_date
        number total_price
        number booked_rooms
        enum status
        enum paymentStatus
        enum paymentType
        string confirmationToken
    }
    USERS ||--o{ BOOKINGS : "makes"
    HOTELS ||--o{ BOOKINGS : "has"
    USERS ||--o{ HOTELS : "manages"
Loading

Explanation:

  • USERS can make multiple BOOKINGS (one-to-many).
  • HOTELS can have multiple BOOKINGS (one-to-many).
  • USERS (with manager/admin role) can manage multiple HOTELS (one-to-many).
  • Each BOOKING references a single USER and a single HOTEL.

Use Case Diagram

Below is the Use Case Diagram for the StayMate platform:

flowchart TD
  User((User))
  Manager((Manager))
  Admin((Admin))
  AIService((AI Service))

  User -- Register/Login --> RL[Register/Login]
  User -- Search Hotels --> SH[Search Hotels]
  User -- Book Hotel --> BH[Book Hotel]
  User -- View Recommendations --> VR[View Recommendations]
  User -- View Booking History --> VBH[View Booking History]
  Manager -- Add/Update/Delete Hotels --> AUDH[Add/Update/Delete Hotels]
  Manager -- View Managed Bookings --> VMB[View Managed Bookings]
  Admin -- Manage Users --> MU[Manage Users]
  Admin -- View All Bookings --> VAB[View All Bookings]
  Admin -- Manage All Hotels --> MAH[Manage All Hotels]
  BH -- include --> VR
  VR -- include --> AIService
Loading

Explanation:

  • User can register/login, search hotels, book hotels, view recommendations, and view booking history.
  • Manager can add/update/delete hotels and view bookings they manage.
  • Admin can manage users, view all bookings, and manage all hotels.
  • AI Service is included in the recommendation process.

DFD Level 0 (Context Diagram)

Below is the Data Flow Diagram (Level 0) for the StayMate platform:

flowchart TD
  A[User] -->|Register/Login| B[NestJS API]
  A -->|Search Hotels| B
  A -->|Book Hotel| B
  A -->|View Recommendations| B
  B -->|Authenticate/Authorize| C[Database]
  B -->|Hotel/Booking Data| C
  B -->|Request Recommendations| D[AI Service]
  D -->|Return Recommendations| B
  B -->|Return Data| A
Loading

Explanation:

  • The user interacts with the NestJS API for all operations.
  • The API handles authentication, data management, and communicates with the database and AI service.
  • The AI service processes recommendation requests and returns results to the API, which then responds to the user.

System Architecture Design

Below is the System Architecture Diagram for the StayMate platform:

flowchart TD
  subgraph UserSide [User Side]
    U1(User)
    U2(Admin/Manager)
  end
  subgraph Backend [NestJS API]
    Auth[Auth Module]
    Hotels[Hotels Module]
    Bookings[Bookings Module]
    Recommendations[Recommendations Module]
    S3[S3 Service]
    Email[Email Service]
  end
  subgraph AIService [AI Recommendation Service]
    Model[Model Loader]
    RecEndpoint[Recommendation Endpoint]
  end
  subgraph DB [MongoDB]
    Users[Users Collection]
    HotelsDB[Hotels Collection]
    BookingsDB[Bookings Collection]
  end

  U1 -- REST API --> Backend
  U2 -- REST API --> Backend
  Backend -- CRUD/Query --> DB
  Backend -- File Uploads --> S3
  Backend -- Email Notifications --> Email
  Backend -- Recommendation Request --> AIService
  AIService -- Recommendations --> Backend
  Backend -- API Response --> U1
  Backend -- API Response --> U2
Loading

Explanation:

  • Users (including Admins/Managers) interact with the system via REST API endpoints exposed by the NestJS backend.
  • The NestJS API is modular, handling authentication, hotel management, bookings, recommendations, file uploads (S3), and email notifications.
  • The backend communicates with MongoDB for persistent data storage.
  • For recommendations, the backend sends requests to the AI Recommendation Service (Flask/Python), which loads models and returns results.
  • All responses are routed back to the users through the backend API.

Chapter 4: Implementation

4.1 Interface Design/Front-End

(Not included in this repo; API-first design for easy integration with any frontend such as React, Angular, or mobile apps.)

4.2 Back-End

  • NestJS API: Handles authentication, hotel management, bookings, and recommendations. Modular structure for maintainability.
  • AI Service: Flask app for hotel recommendations using ML models. Embeds hotel and user preferences, computes similarity, and returns top matches.

4.3 Modules

  • Auth: User registration, login, JWT-based authentication, role management (User, Manager, Admin).
  • Hotels: CRUD operations, nearby search, admin/manager controls, image upload (S3 integration).
  • Bookings: Create/view bookings, cron for unconfirmed bookings, user booking history.
  • Recommendations: Fetch personalized hotel recommendations from the AI service.
  • Database: MongoDB schemas for users, hotels, and bookings.
  • Email Service: (If enabled) Sends booking confirmations and notifications.

Chapter 5: User Manual

5.1 System Requirement

5.1.1 Hardware Requirement

  • Modern PC/server, 4GB+ RAM (8GB+ recommended for AI service with GPU support).
  • Sufficient disk space for MongoDB and model files.

5.1.2 Software Requirement

  • Node.js (v18+), Python 3.8+, MongoDB, pip, yarn/npm
  • (Optional) CUDA-enabled GPU for faster AI inference

5.2 User Interfaces

5.2.1 Panel A: User

  • Register/login via /auth/register and /auth/login
  • Search and book hotels via /hotels and /bookings
  • View recommendations via /recommendations/:userId
  • View booking history

5.2.2 Panel B: Admin/Manager

  • Add/update/delete hotels via /hotels endpoints
  • View all bookings via /bookings endpoints
  • Manage users (admin only)

5.2.3 Login Credentials

  • Register via /auth/register (Nest API)
  • Login via /auth/login (Nest API)
  • JWT token required for protected endpoints (pass in Authorization: Bearer <token> header)

5.2.4 Example API Usage

  • Register: POST /auth/register { username, email, pass, role }
  • Login: POST /auth/login { email, pass }
  • Create Hotel: POST /hotels/create (Manager/Admin only)
  • Book Hotel: POST /bookings/create (User only)
  • Get Recommendations: GET /recommendations/:userId

Chapter 6: Conclusion

6.1 Conclusion

StayMate provides a scalable, modular hotel booking and recommendation platform with modern backend and AI technologies. Its architecture supports future enhancements and easy integration with various frontends.

6.2 Limitation

  • No frontend included (API only)
  • AI recommendations depend on data quality and volume
  • Payment gateway integration not included

6.3 Future Works

  • Add frontend (web/mobile)
  • Enhance AI with more user data and advanced models
  • Integrate payment gateways
  • Add analytics and reporting modules
  • Expand to other domains (e.g., travel packages)

References


Setup Instructions

1. Clone the repository

git clone <repo-url>
cd staymate

2. Install and Run NestJS API

cd "Nest API"
yarn install
yarn start:dev

3. Install and Run AI Service

cd "../AI service"
pip install -r requirements.txt
python app.py

4. Environment Variables

  • Configure MongoDB URI and JWT secret in Nest API (via .env or config service).
  • (Optional) Set HUGGINGFACE_TOKEN for AI service for model downloads.

5. API Endpoints

Nest API

  • /auth/register - Register new user
  • /auth/login - Login and receive JWT
  • /hotels - List/search hotels
  • /hotels/create - Add hotel (Manager/Admin)
  • /hotels/:id - Get hotel details
  • /bookings/create - Book a hotel
  • /bookings/user/:id - Get user bookings
  • /recommendations/:userId - Get recommendations for user

AI Service

  • /initialize (POST) - Initialize hotel embeddings (send hotels data)
  • /recommend (POST) - Get recommendations (send user_id and bookings)

6. Database Initialization

  • MongoDB collections for users, hotels, and bookings are auto-created on first use.
  • Sample data can be generated using scripts in AI service/services/.

7. User Roles

  • User: Can search, book, and view recommendations
  • Manager: Can manage hotels they own
  • Admin: Full access to all hotels, bookings, and users

8. System Architecture

  • NestJS API: Handles business logic, authentication, and data management
  • AI Service: Provides recommendations via REST API
  • MongoDB: Stores all persistent data
  • S3 (optional): Stores hotel images

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published