Skip to content

maandel/hotel_booking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

102 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏨 Hotel Booking Management System

A comprehensive, full-featured hotel booking and management system built with Django. This application provides both a customer-facing booking interface and a powerful administrative panel for hotel management.

Django Python Status

πŸ“‹ Table of Contents

✨ Features

🎯 Core Functionality

Customer-Facing Features

  • 🏠 Hotel Showcase: Beautiful, responsive hotel presentation with image galleries
  • πŸ” Room Search & Filtering: Advanced search with date range, guest count, and room type filters
  • πŸ“… Real-time Availability: Live room availability checking with conflict prevention
  • πŸ’³ Secure Booking: Complete booking workflow with payment integration
  • πŸ“± Mobile-First Design: Fully responsive design optimized for all devices
  • πŸ“§ Contact System: Integrated contact forms with email notifications
  • 🎨 Modern UI/UX: Clean, professional interface with smooth animations

Administrative Features

  • πŸ“Š Comprehensive Dashboard: Real-time analytics and booking insights
  • 🏨 Hotel Management: Multi-hotel support with detailed property management
  • πŸ›οΈ Room Management: Complete room inventory with types, amenities, and pricing
  • πŸ“‹ Booking Management: Full booking lifecycle management with status tracking
  • πŸ‘₯ Guest Management: Customer database with booking history
  • πŸ’° Financial Tracking: Revenue analytics and payment monitoring
  • πŸ” User Management: Role-based access control with custom permissions
  • πŸ“ˆ Reporting: Detailed reports and analytics

πŸ›‘οΈ Advanced Features

Security & Authentication

  • πŸ”’ Role-Based Access Control (RBAC): Granular permission system
  • πŸ‘€ User Profile Management: Extended user profiles with avatars
  • πŸ” Secure Authentication: Django's built-in authentication with custom enhancements
  • πŸ›‘οΈ CSRF Protection: Complete protection against cross-site request forgery
  • πŸ”‘ Permission Management: Custom permission system for fine-grained control

Data Management

  • πŸ—‘οΈ Soft Delete System: Data preservation with soft delete functionality
  • πŸ“ Audit Trail: Complete tracking of data changes and user actions
  • πŸ’Ύ Data Validation: Comprehensive validation at model and form levels
  • πŸ”„ Data Integrity: Foreign key constraints and business rule enforcement

Integration & APIs

  • πŸ’³ Paystack Integration: Secure payment processing with Paystack
  • πŸ“§ Email System: SMTP integration for notifications and confirmations
  • 🌐 RESTful APIs: AJAX endpoints for dynamic functionality
  • πŸ“± Responsive Design: Bootstrap-based responsive framework

πŸ—οΈ System Architecture

Application Structure

hotel_booking/
β”œβ”€β”€ myhotel/                    # Main Django project
β”‚   β”œβ”€β”€ hotel/                  # Customer-facing application
β”‚   β”‚   β”œβ”€β”€ models.py          # Core business models
β”‚   β”‚   β”œβ”€β”€ views.py           # Customer views and booking logic
β”‚   β”‚   β”œβ”€β”€ forms.py           # Customer forms and validation
β”‚   β”‚   β”œβ”€β”€ templates/         # Customer-facing templates
β”‚   β”‚   β”œβ”€β”€ static/            # CSS, JS, images for customer site
β”‚   β”‚   β”œβ”€β”€ booking.py         # Booking business logic
β”‚   β”‚   β”œβ”€β”€ room_availability.py # Availability checking system
β”‚   β”‚   └── context_processors.py # Template context processors
β”‚   β”‚
β”‚   β”œβ”€β”€ admin_panel/           # Administrative application
β”‚   β”‚   β”œβ”€β”€ views/             # Admin views (modular structure)
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.py   # Dashboard and analytics
β”‚   β”‚   β”‚   β”œβ”€β”€ booking_views.py # Booking management
β”‚   β”‚   β”‚   β”œβ”€β”€ room_views.py  # Room management
β”‚   β”‚   β”‚   β”œβ”€β”€ guest_views.py # Guest management
β”‚   β”‚   β”‚   β”œβ”€β”€ hotel_views.py # Hotel management
β”‚   β”‚   β”‚   β”œβ”€β”€ user_manager_views.py # User management
β”‚   β”‚   β”‚   └── permission_views.py # Permission management
β”‚   β”‚   β”œβ”€β”€ templates/         # Admin panel templates
β”‚   β”‚   β”œβ”€β”€ static/            # Admin panel assets
β”‚   β”‚   └── forms.py           # Admin forms
β”‚   β”‚
β”‚   β”œβ”€β”€ myhotel/               # Project settings
β”‚   β”‚   β”œβ”€β”€ settings.py        # Django configuration
β”‚   β”‚   β”œβ”€β”€ urls.py            # URL routing
β”‚   β”‚   └── wsgi.py            # WSGI configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ media/                 # User-uploaded files
β”‚   β”œβ”€β”€ manage.py              # Django management script
β”‚   └── db.sqlite3             # SQLite database
β”‚
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ .env                       # Environment variables
β”œβ”€β”€ .gitignore                # Git ignore rules
└── README.md                 # This file

Technology Stack

  • Backend: Django 5.2.4 (Python web framework)
  • Database: SQLite (development) / PostgreSQL (production ready)
  • Frontend: HTML5, CSS3, JavaScript (ES6+)
  • UI Framework: Bootstrap 5.3.0 with custom styling
  • Icons: Font Awesome 6.0.0
  • Fonts: Google Fonts (Playfair Display, Inter)
  • Payment: Paystack API integration
  • Email: SMTP with Django's email framework

πŸš€ Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)
  • Git

Step-by-Step Installation

  1. Clone the Repository

    git clone <repository-url>
    cd hotel_booking
  2. Create Virtual Environment

    python -m venv .venv
    
    # On Windows
    .venv\Scripts\activate
    
    # On macOS/Linux
    source .venv/bin/activate
  3. Install Dependencies

    pip install -r requirements.txt
  4. Environment Configuration Create a .env file in the myhotel/ directory:

    SECRET_KEY=your-secret-key-here
    PAYSTACK_SECRET_KEY=your-paystack-secret-key
    PAYSTACK_PUBLIC_KEY=your-paystack-public-key
    EMAIL_HOST=your-smtp-host
    EMAIL_PORT=587
    EMAIL_HOST_USER=your-email@example.com
    EMAIL_HOST_PASSWORD=your-email-password
    DEFAULT_FROM_EMAIL=your-email@example.com
  5. Database Setup

    cd myhotel
    python manage.py makemigrations
    python manage.py migrate
  6. Create Superuser

    python manage.py createsuperuser
  7. Collect Static Files

    python manage.py collectstatic
  8. Run Development Server

    python manage.py runserver
  9. Access the Application

βš™οΈ Configuration

Environment Variables

Variable Description Required
SECRET_KEY Django secret key for cryptographic signing Yes
PAYSTACK_SECRET_KEY Paystack secret key for payment processing Yes
PAYSTACK_PUBLIC_KEY Paystack public key for frontend integration Yes
EMAIL_HOST SMTP server hostname Yes
EMAIL_PORT SMTP server port Yes
EMAIL_HOST_USER SMTP username Yes
EMAIL_HOST_PASSWORD SMTP password Yes
DEFAULT_FROM_EMAIL Default sender email address Yes

Database Configuration

The application uses SQLite by default for development. For production, configure PostgreSQL:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'hotel_booking_db',
        'USER': 'your_db_user',
        'PASSWORD': 'your_db_password',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

πŸ“– Usage

Customer Workflow

  1. Browse Hotels: View hotel information, amenities, and room types
  2. Search Availability: Use the booking form to check room availability
  3. Select Rooms: Choose from available room types with detailed information
  4. Make Booking: Complete the booking form with guest details
  5. Payment: Secure payment processing through Paystack
  6. Confirmation: Receive booking confirmation and receipt

Administrator Workflow

  1. Dashboard Access: Login to the admin panel for overview analytics
  2. Hotel Setup: Configure hotel information, amenities, and room types
  3. Room Management: Add rooms, set pricing, and manage availability
  4. Booking Management: View, edit, and manage customer bookings
  5. Guest Management: Access customer database and booking history
  6. User Management: Create staff accounts with appropriate permissions
  7. Reports: Generate and view various business reports

πŸ”Œ API Documentation

Availability Check API

Endpoint: /hotel/admin/api/check-room-availability/ Method: POST Purpose: Check room availability for specific dates

Request Body:

{
    "checkin": "2024-01-15",
    "checkout": "2024-01-20",
    "room_type": 1,
    "guests": 2
}

Response:

{
    "available": true,
    "available_rooms": 3,
    "total_price": 500.00,
    "nights": 5
}

Contact Form API

Endpoint: /hotel/contact/submit/ Method: POST Purpose: Submit contact form

Request Body:

{
    "name": "John Doe",
    "email": "john@example.com",
    "subject": "Inquiry",
    "message": "Hello, I have a question..."
}

πŸ› οΈ Admin Panel

Dashboard Features

  • πŸ“Š Booking Analytics: Real-time booking statistics and trends
  • πŸ’° Revenue Tracking: Financial performance metrics
  • πŸ“ˆ Occupancy Rates: Room utilization analytics
  • 🎯 Quick Actions: Fast access to common administrative tasks

Management Modules

🏨 Hotel Management

  • Hotel information and branding
  • Contact details and descriptions
  • Logo and image management
  • Amenity configuration

πŸ›οΈ Room Management

  • Room type creation and editing
  • Pricing and capacity management
  • Amenity assignment
  • Image gallery management
  • Individual room tracking

πŸ“‹ Booking Management

  • Booking status tracking (Pending, Confirmed, Cancelled)
  • Payment status monitoring
  • Guest information management
  • Special request handling
  • Booking modification and cancellation

πŸ‘₯ User Management

  • Staff account creation
  • Role and permission assignment
  • User profile management
  • Activity monitoring

πŸ” Permission System

  • Custom permission creation
  • Role-based access control
  • Granular permission assignment
  • Permission auditing

πŸ—„οΈ Database Schema

Core Models

Hotel

  • Basic hotel information
  • Contact details
  • Branding assets

RoomType

  • Room categories and descriptions
  • Pricing and capacity
  • Amenity relationships
  • Image management

Room

  • Individual room instances
  • Room number tracking
  • Availability status
  • Hotel association

Booking

  • Reservation details
  • Guest information
  • Payment tracking
  • Status management

Guest

  • Customer information
  • Contact details
  • Booking history

Security Models

Permission

  • Custom permission definitions
  • Content type associations
  • Permission type categorization

Role

  • Permission groupings
  • Role descriptions
  • Active status tracking

UserRole

  • User-role assignments
  • Assignment tracking
  • Audit trail

πŸ’³ Payment Integration

Paystack Integration

  • Secure Processing: PCI-compliant payment handling
  • Multiple Payment Methods: Card payments, bank transfers
  • Transaction Tracking: Complete payment audit trail
  • Webhook Support: Real-time payment status updates
  • Refund Management: Automated refund processing

Payment Workflow

  1. Customer completes booking form
  2. Payment amount calculated automatically
  3. Secure redirect to Paystack payment page
  4. Payment processing and verification
  5. Booking confirmation and receipt generation
  6. Email notifications sent to customer and admin

πŸ›‘οΈ Security Features

Authentication & Authorization

  • Django Authentication: Built-in user authentication system
  • Custom Permissions: Granular access control
  • Role-Based Access: Hierarchical permission system
  • Session Management: Secure session handling
  • Password Validation: Strong password requirements

Data Protection

  • CSRF Protection: Cross-site request forgery prevention
  • SQL Injection Prevention: Parameterized queries
  • XSS Protection: Output escaping and sanitization
  • Soft Delete: Data preservation and recovery
  • Audit Logging: Complete action tracking

Infrastructure Security

  • Environment Variables: Sensitive data protection
  • HTTPS Ready: SSL/TLS configuration support
  • Security Headers: Comprehensive security headers
  • Input Validation: Server-side validation for all inputs

πŸ“± Mobile Responsiveness

Design Features

  • Mobile-First Approach: Optimized for mobile devices
  • Responsive Grid: Bootstrap-based responsive layout
  • Touch-Friendly: Large touch targets and intuitive navigation
  • Fast Loading: Optimized images and minimal JavaScript
  • Cross-Browser: Compatible with all modern browsers

Mobile-Specific Enhancements

  • Hamburger Menu: Collapsible navigation for mobile
  • Touch Gestures: Swipe and touch interactions
  • Optimized Forms: Mobile-friendly form layouts
  • Image Optimization: Responsive images with proper sizing
  • Performance: Minimal load times on mobile networks

πŸ§ͺ Testing

Running Tests

# Run all tests
python manage.py test

# Run specific app tests
python manage.py test hotel
python manage.py test admin_panel

# Run with coverage
coverage run --source='.' manage.py test
coverage report

Test Coverage

  • Model validation tests
  • View functionality tests
  • Form validation tests
  • API endpoint tests
  • Authentication tests
  • Permission system tests

πŸš€ Deployment

Production Checklist

  • Set DEBUG = False
  • Configure production database
  • Set up static file serving
  • Configure email backend
  • Set up SSL/HTTPS
  • Configure allowed hosts
  • Set up monitoring and logging
  • Configure backup strategy

Deployment Options

  • Traditional Hosting: Apache/Nginx + Gunicorn
  • Cloud Platforms: AWS, Google Cloud, Azure
  • Platform as a Service: Heroku, PythonAnywhere
  • Containerization: Docker deployment ready

🀝 Contributing

We welcome contributions to improve the Hotel Booking Management System!

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Write comprehensive tests for new features
  • Update documentation for any changes
  • Ensure backward compatibility
  • Add appropriate error handling

Code Style

  • Use meaningful variable and function names
  • Add docstrings to all functions and classes
  • Follow Django best practices
  • Maintain consistent indentation (4 spaces)

πŸ“ž Support

For support, questions, or feature requests:

  • Documentation: Check this README and inline code documentation
  • Issues: Open an issue on the GitHub repository
  • Email: Contact the development team
  • Community: Join our developer community discussions

πŸ™ Acknowledgments

  • Django framework and community
  • Bootstrap for responsive design
  • Font Awesome for icons
  • Paystack for payment processing
  • All contributors and testers

Built with ❀️ using Django

This project demonstrates modern web development practices with Django, including responsive design, secure payment processing, comprehensive admin functionality, and production-ready architecture.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors