Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏨 LuxeStay - Premium Hotel Management System

LuxeStay Logo

Version License Node MySQL Express

A complete, production-ready Hotel Management System with luxury UI and full-stack functionality

Features β€’ Installation β€’ Documentation β€’ Demo β€’ Support


πŸ“‹ Table of Contents


🌟 Overview

LuxeStay is a comprehensive, enterprise-grade Hotel Management System designed for luxury hotels and hospitality businesses. Built with modern web technologies, it provides a complete solution for managing rooms, bookings, customers, billing, and analytics with a beautiful, intuitive interface.

Why LuxeStay?

  • ✨ Luxury Design - Premium 5-star hotel aesthetic with glassmorphism effects
  • πŸš€ Production Ready - Complete backend with authentication, validation, and security
  • πŸ“± Fully Responsive - Works seamlessly on desktop, tablet, and mobile devices
  • πŸ”’ Enterprise Security - JWT authentication, role-based access, encrypted passwords
  • πŸ“Š Advanced Analytics - Real-time reporting and data visualization
  • 🎯 Easy to Deploy - Simple setup process with comprehensive documentation

✨ Features

🎨 Premium User Interface

  • Luxury Design Language

    • Modern glassmorphism effects
    • Gradient backgrounds and smooth transitions
    • Professional color scheme (Gold, Navy, White)
    • Custom animations and micro-interactions
  • Responsive Design

    • Mobile-first approach
    • Tablet and desktop optimized
    • Flexible grid layouts
    • Touch-friendly controls
  • Accessibility

    • WCAG 2.1 compliant
    • Keyboard navigation
    • Screen reader support
    • High contrast modes

πŸ” Authentication & Authorization

  • Multi-Method Login

    • Email/Password authentication
    • Google OAuth 2.0 integration
    • Remember me functionality
    • Secure password reset
  • Role-Based Access Control

    • Admin: Full system access
    • Receptionist: Front desk operations
    • Staff: Limited operational access
    • Manager: Reports and analytics
  • Security Features

    • JWT token-based sessions
    • Password encryption (bcrypt)
    • Secure HTTP-only cookies
    • CSRF protection
    • Rate limiting on auth endpoints

🏨 Core Hotel Management

Room Management

  • Add, edit, and delete rooms
  • Multiple room types (Deluxe, Suite, Standard, etc.)
  • Room status tracking (Available, Occupied, Maintenance)
  • Pricing management
  • Amenities configuration
  • Photo gallery per room
  • Room availability calendar

Customer Management

  • Comprehensive customer database
  • Customer profiles with history
  • Contact information management
  • Booking history tracking
  • Customer preferences
  • Loyalty program integration
  • Document storage (ID, passport)

Booking System

  • Intelligent booking engine
  • Real-time availability checking
  • Booking conflict prevention
  • Multiple booking types (Online, Walk-in, Phone)
  • Reservation modifications
  • Cancellation handling
  • Group booking support
  • Special requests management

Billing & Invoicing

  • Automated invoice generation
  • Tax calculations (GST/VAT)
  • Multiple payment methods
  • Payment tracking
  • Refund processing
  • Discount and coupon management
  • PDF invoice export
  • Email invoice delivery

Reports & Analytics

  • Revenue reports (Daily, Weekly, Monthly, Yearly)
  • Occupancy rate analytics
  • Customer demographics
  • Booking source analysis
  • Room performance metrics
  • Staff performance reports
  • Export to CSV/PDF/Excel
  • Custom date range filtering

πŸ“Š Dashboard Features

  • Real-time statistics
  • Interactive charts (Chart.js)
  • Quick action buttons
  • Recent activity feed
  • Upcoming bookings overview
  • Revenue trends
  • Occupancy visualization
  • Alert notifications

πŸ› οΈ Tech Stack

Frontend Technologies

Technology Version Purpose
HTML5 Latest Semantic markup
CSS3 Latest Styling and animations
JavaScript ES6+ Client-side logic
Bootstrap 5.3+ Responsive framework
Font Awesome 6.0+ Icon library
Chart.js 4.0+ Data visualization

Backend Technologies

Technology Version Purpose
Node.js 16+ JavaScript runtime
Express.js 4.18+ Web framework
MySQL 8.0+ Database
JWT Latest Authentication
bcrypt Latest Password hashing
Passport.js Latest OAuth integration

Development Tools

  • Version Control: Git
  • Package Manager: npm/yarn
  • API Testing: Postman/Thunder Client
  • Database Tool: MySQL Workbench
  • Code Editor: VS Code (recommended)

πŸ“ Project Structure

HOTEL-MANAGEMENT/
β”‚
β”œβ”€β”€ πŸ“‚ backend/
β”‚   β”œβ”€β”€ πŸ“‚ config/
β”‚   β”‚   └── database.js              # MySQL connection pool configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js        # Authentication logic (signup, login, verify)
β”‚   β”‚   β”œβ”€β”€ roomController.js        # Room CRUD operations
β”‚   β”‚   β”œβ”€β”€ customerController.js    # Customer management
β”‚   β”‚   β”œβ”€β”€ bookingController.js     # Booking operations
β”‚   β”‚   β”œβ”€β”€ paymentController.js     # Payment processing
β”‚   β”‚   └── reportController.js      # Analytics and reports
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ middleware/
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js        # JWT verification
β”‚   β”‚   β”œβ”€β”€ roleMiddleware.js        # Role-based authorization
β”‚   β”‚   β”œβ”€β”€ validationMiddleware.js  # Input validation
β”‚   β”‚   └── errorMiddleware.js       # Error handling
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js            # /api/auth endpoints
β”‚   β”‚   β”œβ”€β”€ roomRoutes.js            # /api/rooms endpoints
β”‚   β”‚   β”œβ”€β”€ customerRoutes.js        # /api/customers endpoints
β”‚   β”‚   β”œβ”€β”€ bookingRoutes.js         # /api/bookings endpoints
β”‚   β”‚   β”œβ”€β”€ paymentRoutes.js         # /api/payments endpoints
β”‚   β”‚   └── reportRoutes.js          # /api/reports endpoints
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ utils/
β”‚   β”‚   β”œβ”€β”€ emailService.js          # Email notifications
β”‚   β”‚   β”œβ”€β”€ pdfGenerator.js          # Invoice PDF generation
β”‚   β”‚   β”œβ”€β”€ validators.js            # Custom validators
β”‚   β”‚   └── helpers.js               # Utility functions
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ models/                    # Database models (optional ORM)
β”‚   β”‚
β”‚   β”œβ”€β”€ .env                         # Environment variables (not in repo)
β”‚   β”œβ”€β”€ .env.example                 # Environment template
β”‚   β”œβ”€β”€ package.json                 # Node dependencies
β”‚   β”œβ”€β”€ package-lock.json            # Dependency lock file
β”‚   └── server.js                    # Express server entry point
β”‚
β”œβ”€β”€ πŸ“‚ frontend/
β”‚   β”œβ”€β”€ πŸ“‚ css/
β”‚   β”‚   β”œβ”€β”€ style.css                # Landing page styles
β”‚   β”‚   β”œβ”€β”€ auth.css                 # Authentication pages styles
β”‚   β”‚   β”œβ”€β”€ dashboard.css            # Dashboard layout styles
β”‚   β”‚   └── components.css           # Reusable component styles
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ js/
β”‚   β”‚   β”œβ”€β”€ main.js                  # Landing page functionality
β”‚   β”‚   β”œβ”€β”€ animations.js            # Advanced animations
β”‚   β”‚   β”œβ”€β”€ signup.js                # Signup page logic
β”‚   β”‚   β”œβ”€β”€ login.js                 # Login page logic
β”‚   β”‚   β”œβ”€β”€ dashboard.js             # Dashboard functionality
β”‚   β”‚   β”œβ”€β”€ api.js                   # API service layer
β”‚   β”‚   └── utils.js                 # Utility functions
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ images/
β”‚   β”‚   β”œβ”€β”€ byui.jpeg                # Hotel images
β”‚   β”‚   β”œβ”€β”€ r3.jpg                   # Room photos
β”‚   β”‚   β”œβ”€β”€ ro1.webp                 # WebP optimized images
β”‚   β”‚   β”œβ”€β”€ ro2.webp
β”‚   β”‚   β”œβ”€β”€ ro3.webp
β”‚   β”‚   β”œβ”€β”€ ro4.webp
β”‚   β”‚   β”œβ”€β”€ ro5.webp
β”‚   β”‚   β”œβ”€β”€ ro6.webp
β”‚   β”‚   └── ro7.webp
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ pages/
β”‚   β”‚   β”œβ”€β”€ login.html               # User login page
β”‚   β”‚   β”œβ”€β”€ signup.html              # User registration page
β”‚   β”‚   β”œβ”€β”€ dashboard.html           # Main dashboard
β”‚   β”‚   β”œβ”€β”€ rooms.html               # Room management
β”‚   β”‚   β”œβ”€β”€ customers.html           # Customer management
β”‚   β”‚   β”œβ”€β”€ bookings.html            # Booking management
β”‚   β”‚   β”œβ”€β”€ billing.html             # Billing & invoices
β”‚   β”‚   β”œβ”€β”€ reports.html             # Reports & analytics
β”‚   β”‚   └── profile.html             # User profile settings
β”‚   β”‚
β”‚   └── index.html                   # Landing page
β”‚
β”œβ”€β”€ πŸ“‚ database/
β”‚   β”œβ”€β”€ database.sql                 # Complete database schema
β”‚   β”œβ”€β”€ seeders.sql                  # Sample data for testing
β”‚   └── migrations/                  # Database version control
β”‚
β”œβ”€β”€ πŸ“‚ docs/
β”‚   β”œβ”€β”€ API.md                       # API documentation
β”‚   β”œβ”€β”€ SETUP.md                     # Detailed setup guide
β”‚   β”œβ”€β”€ CONTRIBUTING.md              # Contribution guidelines
β”‚   └── CHANGELOG.md                 # Version history
β”‚
β”œβ”€β”€ .gitignore                       # Git ignore rules
β”œβ”€β”€ README.md                        # This file
β”œβ”€β”€ LICENSE                          # MIT License
└── QUICKSTART.md                    # Quick start guide

πŸš€ Installation & Setup

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v16.0.0 or higher) - Download
  • MySQL (v8.0 or higher) - Download
  • Git (optional) - Download
  • Code Editor - VS Code recommended

Quick Start (5 Minutes)

# 1. Clone or download the repository
git clone https://github.com/yourusername/luxestay.git
cd luxestay

# 2. Import database
mysql -u root -p < database.sql

# 3. Setup backend
cd backend
npm install
cp .env.example .env
# Edit .env with your settings
npm start

# 4. Setup frontend (new terminal)
cd frontend
npx http-server -p 3000

# 5. Open browser
# Visit: http://localhost:3000

Detailed Installation Steps

Step 1: Database Setup

  1. Start MySQL Server

    # Windows
    net start MySQL80
    
    # macOS (Homebrew)
    brew services start mysql
    
    # Linux
    sudo systemctl start mysql
    # or
    sudo service mysql start
  2. Create Database

    # Method 1: Command Line
    mysql -u root -p < database.sql
    
    # Method 2: MySQL Workbench
    # - Open MySQL Workbench
    # - Connect to your MySQL server
    # - File β†’ Run SQL Script
    # - Select database.sql
    # - Click Execute
  3. Verify Database Creation

    mysql -u root -p
    
    USE luxestay_hotel;
    SHOW TABLES;
    
    -- You should see:
    -- users, roles, rooms, room_types, customers, 
    -- bookings, payments, invoices, etc.
  4. Create Default Admin User (Optional)

    -- The database.sql already includes default users
    -- Admin credentials:
    -- Email: admin@luxestay.com
    -- Password: Admin@123

Step 2: Backend Configuration

  1. Navigate to Backend Directory

    cd backend
  2. Install Dependencies

    npm install
    
    # This installs:
    # - express
    # - mysql2
    # - jsonwebtoken
    # - bcryptjs
    # - cors
    # - dotenv
    # - helmet
    # - express-rate-limit
    # - passport
    # - passport-google-oauth20
  3. Configure Environment Variables

    # Copy example environment file
    cp .env.example .env
    
    # Edit with your preferred editor
    nano .env
    # or
    code .env
  4. Update .env File

    # Server Configuration
    PORT=5000
    NODE_ENV=development
    FRONTEND_URL=http://localhost:3000
    
    # Database Configuration
    DB_HOST=localhost
    DB_PORT=3306
    DB_USER=root
    DB_PASSWORD=your_mysql_root_password
    DB_NAME=luxestay_hotel
    
    # JWT Configuration
    JWT_SECRET=your_super_secret_key_min_32_characters_long_for_security
    JWT_EXPIRE=7d
    JWT_COOKIE_EXPIRE=7
    
    # Google OAuth (Optional - for social login)
    GOOGLE_CLIENT_ID=your_google_client_id_here
    GOOGLE_CLIENT_SECRET=your_google_client_secret_here
    GOOGLE_CALLBACK_URL=http://localhost:5000/api/auth/google/callback
    
    # Email Configuration (Optional - for notifications)
    SMTP_HOST=smtp.gmail.com
    SMTP_PORT=587
    SMTP_USER=your_email@gmail.com
    SMTP_PASS=your_app_specific_password
    
    # File Upload Configuration
    MAX_FILE_SIZE=5242880
    UPLOAD_PATH=./uploads
  5. Start Backend Server

    # Production mode
    npm start
    
    # Development mode (with auto-reload)
    npm run dev

    Expected Output:

    ╔═══════════════════════════════════════════════╗
    β•‘                                               β•‘
    β•‘   🏨 LuxeStay Hotel Management System         β•‘
    β•‘                                               β•‘
    β•‘   Server Status: RUNNING                      β•‘
    β•‘   Port: 5000                                  β•‘
    β•‘   Environment: development                    β•‘
    β•‘   Database: Connected βœ“                       β•‘
    β•‘   API URL: http://localhost:5000              β•‘
    β•‘                                               β•‘
    β•‘   Health Check: http://localhost:5000/health  β•‘
    β•‘   API Docs: http://localhost:5000/api-docs    β•‘
    β•‘                                               β•‘
    β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
    
    [2024-02-02 10:30:45] INFO: Database connected successfully
    [2024-02-02 10:30:45] INFO: Server initialized
    

Step 3: Frontend Setup

  1. Open New Terminal Tab/Window

  2. Navigate to Frontend Directory

    cd frontend
  3. Serve Frontend Files

    Option A: Using Node.js http-server (Recommended)

    # Install globally (one time)
    npm install -g http-server
    
    # Serve the frontend
    http-server -p 3000 -c-1
    
    # Options:
    # -p 3000: Port number
    # -c-1: Disable caching

    Option B: Using Python

    # Python 3
    python -m http.server 3000
    
    # Python 2
    python -m SimpleHTTPServer 3000

    Option C: Using PHP

    php -S localhost:3000

    Option D: Using VS Code Live Server

    • Install "Live Server" extension in VS Code
    • Right-click index.html
    • Select "Open with Live Server"
    • Server will start on port 5500 by default
  4. Access the Application

    Open your browser and navigate to:

    http://localhost:3000
    

Step 4: Verify Installation

  1. Test Backend API

    # Health check
    curl http://localhost:5000/health
    
    # Should return:
    # {"status":"success","message":"Server is running"}
  2. Test Frontend

    • Landing page should load with animations
    • Navigation should work smoothly
    • Images should display correctly
  3. Test Authentication

    # Login endpoint test
    curl -X POST http://localhost:5000/api/auth/login \
      -H "Content-Type: application/json" \
      -d '{"email":"admin@luxestay.com","password":"Admin@123"}'
    
    # Should return JWT token

βš™οΈ Configuration

Environment Variables Explained

Variable Description Default Required
PORT Backend server port 5000 Yes
NODE_ENV Environment (development/production) development Yes
FRONTEND_URL Frontend URL for CORS http://localhost:3000 Yes
DB_HOST MySQL host address localhost Yes
DB_PORT MySQL port 3306 No
DB_USER Database username root Yes
DB_PASSWORD Database password - Yes
DB_NAME Database name luxestay_hotel Yes
JWT_SECRET Secret key for JWT tokens - Yes
JWT_EXPIRE Token expiration time 7d No
GOOGLE_CLIENT_ID Google OAuth client ID - No
GOOGLE_CLIENT_SECRET Google OAuth secret - No

Database Configuration

The config/database.js file manages the MySQL connection pool:

const pool = mysql.createPool({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  waitForConnections: true,
  connectionLimit: 10,
  queueLimit: 0
});

CORS Configuration

CORS is configured in server.js to allow frontend-backend communication:

app.use(cors({
  origin: process.env.FRONTEND_URL,
  credentials: true
}));

πŸ“š API Documentation

Base URL

http://localhost:5000/api

Authentication

Most endpoints require a JWT token in the Authorization header:

Authorization: Bearer <your-jwt-token>

Endpoints Overview

Authentication Endpoints

POST /api/auth/signup

Register a new user account.

Request Body:

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "SecurePass123!",
  "phone": "+1234567890",
  "role": "admin"
}

Response (201 Created):

{
  "success": true,
  "message": "User registered successfully",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com",
    "role": "admin"
  }
}
POST /api/auth/login

Authenticate user and receive JWT token.

Request Body:

{
  "email": "admin@luxestay.com",
  "password": "Admin@123"
}

Response (200 OK):

{
  "success": true,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "name": "Admin User",
    "email": "admin@luxestay.com",
    "role": "admin"
  }
}
GET /api/auth/verify

Verify JWT token validity.

Headers:

Authorization: Bearer <token>

Response (200 OK):

{
  "success": true,
  "valid": true,
  "user": {
    "id": 1,
    "email": "admin@luxestay.com",
    "role": "admin"
  }
}
GET /api/auth/me

Get current user details.

Headers:

Authorization: Bearer <token>

Response (200 OK):

{
  "success": true,
  "user": {
    "id": 1,
    "name": "Admin User",
    "email": "admin@luxestay.com",
    "phone": "+1234567890",
    "role": "admin",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Room Management Endpoints

GET /api/rooms

Get all rooms with filters.

Query Parameters:

  • type: Room type filter (deluxe, suite, standard)
  • status: Status filter (available, occupied, maintenance)
  • minPrice: Minimum price filter
  • maxPrice: Maximum price filter

Response (200 OK):

{
  "success": true,
  "count": 25,
  "rooms": [
    {
      "id": 1,
      "room_number": "101",
      "type": "Deluxe",
      "status": "available",
      "price": 150.00,
      "capacity": 2,
      "description": "Luxury room with ocean view",
      "amenities": ["WiFi", "TV", "Mini Bar", "Balcony"]
    }
  ]
}
POST /api/rooms

Create a new room (Admin only).

Request Body:

{
  "room_number": "305",
  "type_id": 1,
  "floor": 3,
  "price": 200.00,
  "capacity": 3,
  "description": "Premium suite with city view",
  "status": "available"
}
PUT /api/rooms/:id

Update room details.

DELETE /api/rooms/:id

Delete a room (Admin only).

Customer Management Endpoints

GET /api/customers

Get all customers.

POST /api/customers

Add new customer.

Request Body:

{
  "first_name": "Jane",
  "last_name": "Smith",
  "email": "jane@example.com",
  "phone": "+1234567890",
  "id_type": "passport",
  "id_number": "AB123456",
  "address": "123 Main St, City, Country"
}
GET /api/customers/:id

Get customer by ID.

PUT /api/customers/:id

Update customer details.

Booking Management Endpoints

GET /api/bookings

Get all bookings.

POST /api/bookings

Create new booking.

Request Body:

{
  "customer_id": 5,
  "room_id": 12,
  "check_in": "2024-03-01",
  "check_out": "2024-03-05",
  "adults": 2,
  "children": 1,
  "special_requests": "Late check-in required"
}
GET /api/bookings/:id

Get booking details.

PUT /api/bookings/:id

Update booking.

DELETE /api/bookings/:id

Cancel booking.

Payment Endpoints

GET /api/payments

Get all payments.

POST /api/payments

Process payment.

Request Body:

{
  "booking_id": 123,
  "amount": 750.00,
  "payment_method": "credit_card",
  "transaction_id": "TXN123456789"
}

Report Endpoints

GET /api/reports/revenue

Get revenue report.

Query Parameters:

  • startDate: Start date (YYYY-MM-DD)
  • endDate: End date (YYYY-MM-DD)
  • groupBy: Grouping (day, week, month, year)
GET /api/reports/occupancy

Get occupancy report.

GET /api/reports/customers

Get customer analytics.

Error Responses

All error responses follow this format:

{
  "success": false,
  "error": "Error message here",
  "statusCode": 400
}

Common Status Codes:

  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 500 - Server Error

πŸ—„οΈ Database Schema

Tables Overview

users

Stores user accounts and authentication information.

CREATE TABLE users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(100) NOT NULL,
  email VARCHAR(100) UNIQUE NOT NULL,
  password VARCHAR(255) NOT NULL,
  phone VARCHAR(20),
  role_id INT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (role_id) REFERENCES roles(id)
);

roles

User role definitions.

CREATE TABLE roles (
  id INT PRIMARY KEY AUTO_INCREMENT,
  role_name VARCHAR(50) UNIQUE NOT NULL,
  description TEXT
);

room_types

Room category definitions.

CREATE TABLE room_types (
  id INT PRIMARY KEY AUTO_INCREMENT,
  type_name VARCHAR(50) NOT NULL,
  description TEXT,
  base_price DECIMAL(10,2),
  max_occupancy INT
);

rooms

Room inventory.

CREATE TABLE rooms (
  id INT PRIMARY KEY AUTO_INCREMENT,
  room_number VARCHAR(10) UNIQUE NOT NULL,
  type_id INT,
  floor INT,
  price DECIMAL(10,2) NOT NULL,
  status ENUM('available','occupied','maintenance') DEFAULT 'available',
  description TEXT,
  FOREIGN KEY (type_id) REFERENCES room_types(id)
);

customers

Customer information.

CREATE TABLE customers (
  id INT PRIMARY KEY AUTO_INCREMENT,
  first_name VARCHAR(50) NOT NULL,
  last_name VARCHAR(50) NOT NULL,
  email VARCHAR(100),
  phone VARCHAR(20) NOT NULL,
  id_type VARCHAR(20),
  id_number VARCHAR(50),
  address TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

bookings

Reservation records.

CREATE TABLE bookings (
  id INT PRIMARY KEY AUTO_INCREMENT,
  customer_id INT NOT NULL,
  room_id INT NOT NULL,
  check_in DATE NOT NULL,
  check_out DATE NOT NULL,
  adults INT DEFAULT 1,
  children INT DEFAULT 0,
  total_amount DECIMAL(10,2),
  status ENUM('confirmed','checked_in','checked_out','cancelled') DEFAULT 'confirmed',
  special_requests TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (customer_id) REFERENCES customers(id),
  FOREIGN KEY (room_id) REFERENCES rooms(id)
);

payments

Payment transactions.

CREATE TABLE payments (
  id INT PRIMARY KEY AUTO_INCREMENT,
  booking_id INT NOT NULL,
  amount DECIMAL(10,2) NOT NULL,
  payment_method VARCHAR(50),
  transaction_id VARCHAR(100),
  payment_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  status ENUM('pending','completed','failed','refunded') DEFAULT 'pending',
  FOREIGN KEY (booking_id) REFERENCES bookings(id)
);

Database Relationships

users (1) ─── (Many) bookings
roles (1) ─── (Many) users
room_types (1) ─── (Many) rooms
rooms (1) ─── (Many) bookings
customers (1) ─── (Many) bookings
bookings (1) ─── (Many) payments
bookings (1) ─── (1) invoices

Sample Queries

Get available rooms for date range:

SELECT r.* FROM rooms r
WHERE r.status = 'available'
AND r.id NOT IN (
  SELECT room_id FROM bookings
  WHERE status != 'cancelled'
  AND check_in < '2024-03-10'
  AND check_out > '2024-03-05'
);

Get revenue for current month:

SELECT SUM(amount) as total_revenue
FROM payments
WHERE MONTH(payment_date) = MONTH(CURRENT_DATE())
AND YEAR(payment_date) = YEAR(CURRENT_DATE())
AND status = 'completed';

🎨 UI/UX Pages

Landing Page (index.html)

Purpose: Marketing and first impression

Sections:

  • Hero section with parallax effect
  • Feature showcase with icons
  • Room gallery with hover effects
  • Statistics counter animation
  • Testimonials slider
  • Call-to-action buttons
  • Premium footer

Key Features:

  • Smooth scroll navigation
  • Lazy loading images
  • AOS (Animate On Scroll) effects
  • Responsive hamburger menu

Authentication Pages

Signup Page (pages/signup.html)

  • Multi-step form
  • Role selection
  • Password strength meter
  • Email validation
  • Terms & conditions checkbox
  • Google OAuth button

Login Page (pages/login.html)

  • Email/password fields
  • Remember me checkbox
  • Forgot password link
  • Google OAuth integration
  • Link to signup page

Dashboard Pages

Main Dashboard (pages/dashboard.html)

  • Statistics cards (Occupancy, Revenue, Bookings, Customers)
  • Quick action buttons
  • Revenue chart (Chart.js)
  • Recent bookings table
  • Upcoming check-ins/check-outs
  • Notifications panel

Rooms Page (pages/rooms.html)

  • Room grid/list view toggle
  • Filter by type, status, price
  • Sort options
  • Add/Edit room modal
  • Room details view
  • Bulk actions

Customers Page (pages/customers.html)

  • Customer table with search
  • Filter by date, status
  • Add customer form
  • Customer profile view
  • Booking history
  • Export to CSV

Bookings Page (pages/bookings.html)

  • Calendar view
  • List view with filters
  • Create booking wizard
  • Booking timeline
  • Status management
  • Check-in/Check-out actions

Billing Page (pages/billing.html)

  • Invoice list
  • Create invoice
  • Payment recording
  • Tax calculation
  • PDF generation
  • Email invoice

Reports Page (pages/reports.html)

  • Date range selector
  • Revenue charts
  • Occupancy graphs
  • Customer analytics
  • Export options
  • Print reports

Profile Page (pages/profile.html)

  • User information
  • Password change
  • Notification settings
  • Theme preferences
  • Activity log

πŸ”’ Security Features

Implemented Security Measures

  1. Authentication Security

    • JWT with secure signing algorithm (HS256)
    • HTTP-only cookies for token storage
    • Token expiration and refresh
    • Password complexity requirements
  2. Password Security

    • bcrypt hashing (10 salt rounds)
    • Minimum 8 characters
    • Must include uppercase, lowercase, number, special char
    • Password history to prevent reuse
  3. Input Validation

    • Server-side validation for all inputs
    • SQL injection prevention (parameterized queries)
    • XSS protection (input sanitization)
    • CSRF token validation
  4. HTTP Security Headers (via Helmet.js)

    helmet.contentSecurityPolicy()
    helmet.dnsPrefetchControl()
    helmet.frameguard()
    helmet.hidePoweredBy()
    helmet.hsts()
    helmet.ieNoOpen()
    helmet.noSniff()
    helmet.xssFilter()
  5. Rate Limiting

    • Login: 5 attempts per 15 minutes
    • API calls: 100 per 15 minutes per IP
    • Signup: 3 accounts per hour per IP
  6. Database Security

    • Prepared statements (prevent SQL injection)
    • Principle of least privilege
    • Connection pooling with limits
    • Encrypted database connections (SSL)
  7. Session Management

    • Secure session cookies
    • Session timeout (7 days default)
    • Logout on all devices option
    • Active session monitoring

Security Best Practices

  • Never commit .env file
  • Regularly update dependencies
  • Use HTTPS in production
  • Implement proper logging
  • Regular security audits
  • Backup database regularly

πŸ’» Development

Local Development Setup

  1. Install Development Dependencies

    cd backend
    npm install --save-dev nodemon
  2. Run in Development Mode

    npm run dev
  3. Enable Debug Logging

    DEBUG=* npm run dev

Code Style Guide

JavaScript:

  • Use ES6+ features
  • 2 spaces for indentation
  • Semicolons required
  • camelCase for variables
  • PascalCase for classes

CSS:

  • BEM methodology
  • Mobile-first approach
  • Use CSS variables
  • Comment complex selectors

File Naming:

  • kebab-case for files
  • camelCase for JavaScript
  • PascalCase for components

Adding New Features

Backend Feature

  1. Create controller in controllers/
  2. Define routes in routes/
  3. Add middleware if needed
  4. Update API documentation

Frontend Feature

  1. Create HTML page in pages/
  2. Add styles in css/
  3. Write JavaScript in js/
  4. Update navigation

Database Migrations

-- Example migration file: 001_add_loyalty_points.sql
ALTER TABLE customers
ADD COLUMN loyalty_points INT DEFAULT 0;

-- Run migration
mysql -u root -p luxestay_hotel < migrations/001_add_loyalty_points.sql

πŸ§ͺ Testing

Manual Testing

Test Authentication:

# Signup
curl -X POST http://localhost:5000/api/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"name":"Test User","email":"test@test.com","password":"Test@123","role":"admin"}'

# Login
curl -X POST http://localhost:5000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"test@test.com","password":"Test@123"}'

Test Protected Routes:

# Get rooms (requires token)
curl http://localhost:5000/api/rooms \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

Testing Checklist

  • User registration works
  • Login authentication successful
  • JWT token validation
  • Room CRUD operations
  • Booking creation and management
  • Payment processing
  • Report generation
  • Responsive design on mobile
  • Cross-browser compatibility
  • Performance optimization

πŸš€ Deployment

Backend Deployment

Option 1: Heroku

# Install Heroku CLI
# Login to Heroku
heroku login

# Create app
heroku create luxestay-api

# Set environment variables
heroku config:set NODE_ENV=production
heroku config:set DB_HOST=your-db-host
heroku config:set DB_USER=your-db-user
heroku config:set DB_PASSWORD=your-db-password
heroku config:set JWT_SECRET=your-jwt-secret

# Deploy
git push heroku main

# View logs
heroku logs --tail

Option 2: DigitalOcean

# SSH into droplet
ssh root@your-server-ip

# Install Node.js
curl -sL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs

# Install PM2
npm install -g pm2

# Clone repository
git clone your-repo-url
cd luxestay/backend

# Install dependencies
npm install --production

# Start with PM2
pm2 start server.js --name luxestay-api
pm2 startup
pm2 save

# Configure Nginx
nano /etc/nginx/sites-available/luxestay

Nginx Configuration:

server {
    listen 80;
    server_name api.yourdomain.com;
    
    location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Frontend Deployment

Option 1: Netlify

# Install Netlify CLI
npm install -g netlify-cli

# Deploy
cd frontend
netlify deploy --prod

Option 2: Vercel

# Install Vercel CLI
npm install -g vercel

# Deploy
cd frontend
vercel --prod

Option 3: GitHub Pages

# Update API URL in JavaScript files
# Push to GitHub
git add .
git commit -m "Deploy to GitHub Pages"
git push origin main

# Enable GitHub Pages in repository settings

Database Deployment

Managed MySQL Services:

  1. AWS RDS

    • Create MySQL instance
    • Configure security groups
    • Enable automated backups
    • Set retention period
  2. Google Cloud SQL

    • Create MySQL instance
    • Configure authorized networks
    • Enable automatic backups
    • Set maintenance window
  3. DigitalOcean Managed Database

    • Create database cluster
    • Configure firewall rules
    • Enable automatic backups
    • Monitor performance

SSL Certificate (Let's Encrypt)

# Install Certbot
apt-get install certbot python3-certbot-nginx

# Obtain certificate
certbot --nginx -d yourdomain.com -d www.yourdomain.com

# Auto-renewal
certbot renew --dry-run

πŸ”§ Troubleshooting

Common Issues and Solutions

1. Database Connection Error

Error:

Error: connect ECONNREFUSED 127.0.0.1:3306

Solutions:

  • Check if MySQL is running: sudo service mysql status
  • Verify credentials in .env file
  • Ensure database exists: SHOW DATABASES;
  • Check MySQL port: SHOW VARIABLES LIKE 'port';

2. Port Already in Use

Error:

Error: listen EADDRINUSE: address already in use :::5000

Solutions:

macOS/Linux:

# Find process using port
lsof -i :5000

# Kill process
kill -9 <PID>

Windows:

# Find process
netstat -ano | findstr :5000

# Kill process
taskkill /PID <PID> /F

3. JWT Token Invalid

Error:

{"success":false,"error":"Invalid token"}

Solutions:

  • Check JWT_SECRET in .env
  • Verify token format: Bearer <token>
  • Check token expiration
  • Clear browser cookies

4. CORS Policy Error

Error:

Access to fetch at 'http://localhost:5000' blocked by CORS policy

Solutions:

  • Verify FRONTEND_URL in .env
  • Check CORS configuration in server.js
  • Ensure credentials: true is set
  • Clear browser cache

5. Module Not Found

Error:

Error: Cannot find module 'express'

Solutions:

# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install

# Or install specific package
npm install express

6. MySQL Password Error

Error:

ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'

Solutions:

-- Reset MySQL password
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
FLUSH PRIVILEGES;

7. Frontend API Not Connecting

Checklist:

  • Backend server is running
  • API_URL is correct in JavaScript files
  • Network tab shows request
  • Check browser console for errors
  • Verify authentication token

8. Images Not Loading

Solutions:

  • Check image paths are correct
  • Verify images exist in /images folder
  • Check file permissions
  • Inspect browser Network tab

Debug Mode

Enable detailed logging:

// In server.js
if (process.env.NODE_ENV === 'development') {
  app.use((req, res, next) => {
    console.log(`${req.method} ${req.path}`);
    console.log('Headers:', req.headers);
    console.log('Body:', req.body);
    next();
  });
}

🀝 Contributing

We welcome contributions to LuxeStay! Here's how you can help:

How to Contribute

  1. Fork the Repository

    # Click "Fork" on GitHub
  2. Clone Your Fork

    git clone https://github.com/your-username/luxestay.git
    cd luxestay
  3. Create Feature Branch

    git checkout -b feature/amazing-feature
  4. Make Changes

    • Write clean, documented code
    • Follow existing code style
    • Add tests if applicable
  5. Commit Changes

    git add .
    git commit -m "Add amazing feature"
  6. Push to Branch

    git push origin feature/amazing-feature
  7. Open Pull Request

    • Go to GitHub
    • Click "New Pull Request"
    • Describe your changes

Contribution Guidelines

  • Follow code style guide
  • Write meaningful commit messages
  • Update documentation
  • Test your changes
  • Be respectful and constructive

Areas Needing Help

  • Additional payment gateway integrations
  • Email notification templates
  • Mobile app (React Native)
  • Advanced analytics dashboard
  • Multi-language support
  • Accessibility improvements

πŸ“„ License

MIT License

Copyright (c) 2024 LuxeStay

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


🌟 Acknowledgments

  • Bootstrap - Responsive framework
  • Font Awesome - Icon library
  • Unsplash - Stock images
  • Google Fonts - Typography
  • Chart.js - Data visualization
  • Node.js Community - Backend ecosystem
  • MySQL Community - Database support

πŸ“ž Support

Get Help

Stay Updated


πŸ—ΊοΈ Roadmap

Version 1.1.0 (Q2 2024)

  • Complete all dashboard pages
  • Add room availability calendar
  • Implement email notifications
  • Add PDF report generation
  • Mobile responsive improvements

Version 1.2.0 (Q3 2024)

  • Multi-property support
  • Advanced reporting with charts
  • SMS integration
  • Stripe payment integration
  • Housekeeping module

Version 2.0.0 (Q4 2024)

  • React Native mobile app
  • Restaurant/POS integration
  • Staff scheduling module
  • Inventory management
  • Customer loyalty program

πŸ“Š Project Statistics

  • Total Files: 50+
  • Lines of Code: 10,000+
  • Languages: JavaScript, HTML, CSS, SQL
  • Dependencies: 15+ npm packages
  • Database Tables: 12
  • API Endpoints: 40+

✨ Features Coming Soon

  • Real-time notifications
  • Advanced analytics
  • Mobile app
  • Multi-language support
  • Dark mode
  • API documentation (Swagger)
  • Docker containerization
  • Automated testing

Built with ❀️ for modern hospitality management

⬆ Back to Top


Version 1.0.0 | Released January 2024

Β© 2024 LuxeStay. All rights reserved.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages