Skip to content

adLahiru/SkyNest_Hotels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

97 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏨 SkyNest Hotels - Hotel Management System

Version License Node TypeScript React

A comprehensive hotel management system built with Node.js, TypeScript, Express, React, and MySQL. This system provides complete functionality for managing hotel operations including bookings, rooms, branches, staff, services, payments, and reporting.


πŸ“‹ Table of Contents


✨ Features

πŸ” Authentication & Authorization

  • JWT-based authentication with access and refresh tokens
  • Role-based access control (Admin, Manager, Receptionist, Housekeeping, Guest)
  • Secure password hashing with bcrypt
  • Session management with automatic token refresh

🏒 Branch Management

  • Multi-branch hotel support
  • Branch-specific operations and reporting
  • Branch details with contact information and photos

πŸšͺ Room Management

  • Room type categorization with pricing
  • Room status tracking (available, occupied, maintenance, cleaning)
  • Floor-wise room organization
  • Real-time availability checking

πŸ“… Booking System

  • Complete booking workflow (pending β†’ confirmed β†’ checked-in β†’ checked-out)
  • Booking modification and cancellation
  • Guest information management
  • Date validation and double-booking prevention
  • Check-in/check-out processing

πŸ›ŽοΈ Service Management

  • Service catalogue with branch-specific pricing
  • Service addition to bookings
  • Service usage tracking
  • Photo uploads for services

πŸ’° Payment Processing

  • Flexible payment handling (full/partial payments)
  • Multiple payment methods (cash, credit card, debit card, bank transfer)
  • Payment transaction history
  • Automatic bill calculation with taxes and discounts
  • Outstanding balance tracking

πŸ‘₯ User Management

  • Staff management (managers, receptionists, housekeepers)
  • Guest registration and profiles
  • User status control (active/inactive)
  • Salary and employment tracking for staff

πŸ“Š Reporting & Analytics

  • Room occupancy reports
  • Revenue analysis (daily, monthly)
  • Service usage statistics
  • Guest billing summaries
  • Top services by branch

πŸ“§ Contact Management

  • Guest inquiry system
  • Message status tracking (pending/read)
  • Inquiry type categorization

πŸ”’ Security Features

  • Input validation and sanitization
  • SQL injection prevention (parameterized queries)
  • XSS protection
  • CORS configuration
  • Secure session management

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js v18+
  • Language: TypeScript 5.9.2
  • Framework: Express 5.1.0
  • Database: MySQL 8.0 / MariaDB 10.11
  • Authentication: JWT (jsonwebtoken)
  • Password Hashing: bcryptjs
  • Logging: Winston 3.18.3
  • File Upload: Multer
  • Database Migrations: db-migrate
  • Package Manager: pnpm

Frontend

  • Framework: React 18.3.1
  • Routing: React Router DOM
  • HTTP Client: Axios
  • Icons: Lucide React
  • Styling: CSS3
  • Package Manager: npm

Database

  • RDBMS: MySQL 8.0+ / MariaDB 10.11+
  • Connection Pooling: mysql2
  • Triggers & Stored Procedures: Advanced SQL features
  • Transactions: ACID compliance

πŸ“ Project Structure

SkyNest_Hotels/
β”œβ”€β”€ backend/                    # Backend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/            # Configuration files
β”‚   β”‚   β”‚   └── db.ts          # Database connection
β”‚   β”‚   β”œβ”€β”€ controllers/       # Route controllers
β”‚   β”‚   β”œβ”€β”€ middleware/        # Express middleware
β”‚   β”‚   β”œβ”€β”€ routes/            # API routes
β”‚   β”‚   β”œβ”€β”€ types/             # TypeScript type definitions
β”‚   β”‚   β”œβ”€β”€ utils/             # Utility functions & logger
β”‚   β”‚   └── index.ts           # Application entry point
β”‚   β”œβ”€β”€ migrations/            # Database migration files
β”‚   β”œβ”€β”€ logs/                  # Application logs
β”‚   β”œβ”€β”€ config/                # Environment configurations
β”‚   β”‚   β”œβ”€β”€ .env.development   # Development environment
β”‚   β”‚   └── .env.test          # Test environment
β”‚   β”œβ”€β”€ database.json          # Migration configuration
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── README.md
β”‚
β”œβ”€β”€ frontend/                   # Frontend application
β”‚   β”œβ”€β”€ public/                # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ services/          # API service layer
β”‚   β”‚   β”œβ”€β”€ styles/            # CSS stylesheets
β”‚   β”‚   β”œβ”€β”€ utils/             # Utility functions & logger
β”‚   β”‚   β”œβ”€β”€ config/            # Configuration
β”‚   β”‚   β”œβ”€β”€ App.js             # Main app component
β”‚   β”‚   └── index.js           # React entry point
β”‚   β”œβ”€β”€ package.json
β”‚   └── README.md
β”‚
β”œβ”€β”€ docs/                       # Documentation
β”‚   β”œβ”€β”€ DEPLOYMENT_CHECKLIST.md
β”‚   β”œβ”€β”€ MIGRATION_FIXES.md
β”‚   └── BOOKING_MANAGEMENT_*.md
β”‚
└── README.md                   # This file

πŸ“¦ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js v18.0.0 or higher
  • npm v9.0.0 or higher
  • pnpm v8.0.0 or higher (for backend)
  • MySQL 8.0+ or MariaDB 10.11+
  • Git

πŸš€ Installation

1. Clone the Repository

git clone https://github.com/adLahiru/SkyNest_Hotels.git
cd SkyNest_Hotels

2. Backend Setup

cd backend

# Install dependencies
pnpm install

# Copy environment file
cp config/.env.development config/.env

# Update database credentials in config/.env
# Then run migrations
pnpm migrate:dev

# Build TypeScript
pnpm build

3. Frontend Setup

cd frontend

# Install dependencies
npm install

# Create environment file
cat > .env << EOF
REACT_APP_API_URL=http://localhost:8084/api
REACT_APP_ENV=development
EOF

# Build production version (optional)
npm run build

βš™οΈ Configuration

Backend Configuration (backend/config/.env)

# Database Configuration
DB_HOST=localhost
DB_PORT=3306
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=SkyNest_Hotels

# Server Configuration
PORT=8084
NODE_ENV=development

# JWT Configuration
JWT_SECRET=your-super-secure-jwt-secret-min-32-characters
JWT_REFRESH_SECRET=your-super-secure-refresh-secret-min-32-characters
JWT_EXPIRES_IN=1h
JWT_REFRESH_EXPIRES_IN=7d

# CORS Configuration
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001

Frontend Configuration (frontend/.env)

REACT_APP_API_URL=http://localhost:8084/api
REACT_APP_ENV=development

πŸƒ Running the Application

Development Mode

Backend:

cd backend
pnpm dev
# Server runs on http://localhost:8084

Frontend:

cd frontend
npm start
# Application runs on http://localhost:3000

Production Mode

Backend:

cd backend
pnpm build
pnpm start

Frontend:

cd frontend
npm run build
# Serve the build folder with a static server

πŸ“š API Documentation

Base URL

http://localhost:8084/api

Main Endpoints

Authentication

  • POST /api/auth/login - User login
  • POST /api/auth/refresh - Refresh access token
  • POST /api/auth/logout - User logout
  • POST /api/auth/register - Guest registration

Users

  • GET /api/users - Get all users (Admin)
  • GET /api/users/:id - Get user by ID
  • POST /api/users - Create user (Admin)
  • PUT /api/users/:id - Update user
  • DELETE /api/users/:id - Delete user (Admin)
  • GET /api/users/profile - Get current user profile
  • PUT /api/users/profile - Update profile

Branches

  • GET /api/branches - Get all branches
  • GET /api/branches/:id - Get branch by ID
  • POST /api/branches - Create branch (Admin)
  • PUT /api/branches/:id - Update branch (Admin)
  • DELETE /api/branches/:id - Delete branch (Admin)

Room Types

  • GET /api/room-types - Get all room types
  • GET /api/room-types/:id - Get room type by ID
  • POST /api/room-types - Create room type (Admin/Manager)
  • PUT /api/room-types/:id - Update room type
  • DELETE /api/room-types/:id - Delete room type

Rooms

  • GET /api/rooms - Get all rooms
  • GET /api/rooms/:id - Get room by ID
  • POST /api/rooms - Create room (Admin/Manager)
  • PUT /api/rooms/:id - Update room
  • DELETE /api/rooms/:id - Delete room
  • PATCH /api/rooms/:id/status - Update room status

Bookings

  • GET /api/bookings - Get all bookings
  • GET /api/bookings/:id - Get booking by ID
  • POST /api/bookings - Create booking
  • PUT /api/bookings/:id - Update booking
  • DELETE /api/bookings/:id - Cancel booking
  • PATCH /api/bookings/:id/checkin - Check-in
  • PATCH /api/bookings/:id/checkout - Check-out
  • POST /api/bookings/:id/services - Add service to booking
  • GET /api/bookings/:id/services - Get booking services
  • POST /api/bookings/:id/payments - Process payment
  • GET /api/bookings/:id/payment-details - Get payment details
  • GET /api/bookings/available-rooms - Get available rooms

Services

  • GET /api/services - Get all services
  • GET /api/services/:id - Get service by ID
  • POST /api/services - Create service (Admin/Manager)
  • PUT /api/services/:id - Update service
  • DELETE /api/services/:id - Delete service

Dashboard

  • GET /api/dashboard/admin - Admin dashboard statistics
  • GET /api/dashboard/housekeeping - Housekeeping statistics

Reports

  • GET /api/reports/room-occupancy - Room occupancy report
  • GET /api/reports/guest-billing - Guest billing report
  • GET /api/reports/service-usage - Service usage report
  • GET /api/reports/monthly-revenue - Monthly revenue report
  • GET /api/reports/top-services - Top services report

Contact

  • POST /api/contact - Submit contact form
  • GET /api/contact - Get all messages (Admin)
  • PUT /api/contact/:id/status - Update message status
  • DELETE /api/contact/:id - Delete message

πŸ—„οΈ Database Schema

Core Tables

  • users - User accounts (staff and guests)
  • staff - Staff-specific information
  • hotel_branches - Hotel branch information
  • room_types - Room categories and pricing
  • rooms - Individual room records
  • booking - Booking records
  • payments - Payment information
  • payment_transactions - Payment transaction history
  • service_catalogue - Available services
  • service_usage - Service usage records
  • tax_policies - Tax configuration
  • discounts - Discount policies
  • contact_messages - Customer inquiries
  • user_sessions - Active user sessions
  • refresh_tokens - JWT refresh tokens
  • audit_log - System audit trail

Database Features

  • Foreign key constraints
  • Triggers for automatic status updates
  • Stored procedures for complex calculations
  • Indexes for performance optimization
  • Transaction support

🚒 Deployment

Quick Deployment Checklist

  1. Configure Production Environment

    • Update .env.production with production database credentials
    • Set strong JWT secrets
    • Configure CORS for production domain
  2. Build Applications

    # Backend
    cd backend && pnpm build
    
    # Frontend
    cd frontend && npm run build
  3. Run Database Migrations

    cd backend
    pnpm migrate:prod
  4. Deploy

    • Backend: Use PM2, Docker, or your preferred Node.js hosting
    • Frontend: Deploy build folder to static hosting (Nginx, Vercel, Netlify)
    • Database: Use managed MySQL service or self-hosted

For detailed deployment instructions, see docs/DEPLOYMENT_CHECKLIST.md


πŸ‘₯ User Roles & Permissions

Role Permissions
Admin Full system access, manage all branches, users, and settings
Manager Branch-specific management, staff, rooms, bookings, reports
Receptionist Check-in/out, bookings, guest management for assigned branch
Housekeeping View assigned rooms, update room status
Guest View own bookings, update profile, make new bookings

πŸ”§ Development

Available Scripts

Backend:

pnpm dev          # Start development server with nodemon
pnpm build        # Build TypeScript to JavaScript
pnpm start        # Start production server
pnpm migrate:dev  # Run database migrations (development)
pnpm migrate:prod # Run database migrations (production)

Frontend:

npm start         # Start development server
npm run build     # Create production build
npm run lint      # Run ESLint

Code Quality

  • TypeScript for type safety
  • ESLint for code linting
  • Winston for structured logging
  • Comprehensive error handling

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Lahiru


πŸ™ Acknowledgments

  • Built with ❀️ for efficient hotel management
  • Inspired by modern hotel management needs
  • Special thanks to all contributors

πŸ“ž Support

For support, please:

  1. Check the documentation
  2. Open an issue on GitHub
  3. Contact the development team

Made with ❀️ by SkyNest Hotels Development Team

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors