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.
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.
- 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.
- User registration and login.
- Hotel search and booking.
- AI-based recommendations.
- Admin/manager hotel management.
- Data-driven improvements and analytics.
This document covers system background, design, implementation, user manual, and future work, providing a holistic view of the StayMate platform.
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.
- NestJS Documentation
- Flask Documentation
- Transformers
- MongoDB
- Research on recommender systems and user personalization
- Backend: NestJS (Node.js, TypeScript)
- AI Service: Python (Flask, PyTorch, Transformers)
- Database: MongoDB
- Other: Docker, Vercel, AWS S3, Pandas, Scikit-learn
Agile methodology with modular design for scalability and rapid iteration. Each module (auth, hotels, bookings, recommendations, AI) is independently testable and deployable.
- 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
- 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
- User submits booking/preferences → API → AI Service → Recommendations
- Admin/Manager actions → API → Database
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
- 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.
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"
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.
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
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.
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
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.
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
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.
(Not included in this repo; API-first design for easy integration with any frontend such as React, Angular, or mobile apps.)
- 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.
- 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.
- Modern PC/server, 4GB+ RAM (8GB+ recommended for AI service with GPU support).
- Sufficient disk space for MongoDB and model files.
- Node.js (v18+), Python 3.8+, MongoDB, pip, yarn/npm
- (Optional) CUDA-enabled GPU for faster AI inference
- Register/login via
/auth/registerand/auth/login - Search and book hotels via
/hotelsand/bookings - View recommendations via
/recommendations/:userId - View booking history
- Add/update/delete hotels via
/hotelsendpoints - View all bookings via
/bookingsendpoints - Manage users (admin only)
- Register via
/auth/register(Nest API) - Login via
/auth/login(Nest API) - JWT token required for protected endpoints (pass in
Authorization: Bearer <token>header)
- 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
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.
- No frontend included (API only)
- AI recommendations depend on data quality and volume
- Payment gateway integration not included
- 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)
git clone <repo-url>
cd staymatecd "Nest API"
yarn install
yarn start:devcd "../AI service"
pip install -r requirements.txt
python app.py- Configure MongoDB URI and JWT secret in Nest API (via
.envor config service). - (Optional) Set
HUGGINGFACE_TOKENfor AI service for model downloads.
/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
/initialize(POST) - Initialize hotel embeddings (send hotels data)/recommend(POST) - Get recommendations (send user_id and bookings)
- MongoDB collections for users, hotels, and bookings are auto-created on first use.
- Sample data can be generated using scripts in
AI service/services/.
- User: Can search, book, and view recommendations
- Manager: Can manage hotels they own
- Admin: Full access to all hotels, bookings, and users
- 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
This project is licensed under the MIT License.