Skip to content

Latest commit

ย 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿจ BookingX

Full-Stack Hotel Booking Platform

BookingX is a full-stack hotel booking platform built to provide a complete hotel discovery and reservation experience. Users can search for hotels by location, explore available rooms, securely authenticate, make bookings, manage reservations, and control their account from a centralized profile.

The project is built with a React + Vite frontend and a Django REST Framework backend, backed by PostgreSQL.


โœจ Features

๐Ÿ” Authentication & Security

  • User registration and login
  • JWT-based authentication
  • Automatic access-token refresh
  • Protected frontend routes
  • Secure password change
  • Forgot password functionality
  • Email-based password reset
  • Current-password verification before account deletion
  • Permanent account deletion
  • Login and logout activity tracking
  • Password-change audit logging

๐Ÿจ Hotel Discovery

  • Featured hotels
  • Hotel search by name/location
  • Location autocomplete using Geoapify
  • GPS/location-based hotel search
  • Hotel and room details
  • Hotel images and room images
  • Room filtering by hotel

๐Ÿ“… Booking System

  • Date-range based booking
  • Guest selection
  • Room availability validation
  • Guest-capacity validation
  • Check-in/check-out date validation
  • Prevention of overlapping bookings
  • Transaction-safe booking creation
  • Unique booking references
  • Booking status management
  • Booking cancellation
  • Automatic completion of past confirmed bookings
  • My Bookings section

๐Ÿ‘ค User Profile

  • View profile information
  • Update first name and last name
  • Update profile image
  • Change password
  • View booking history
  • Permanently delete account

๐Ÿ› ๏ธ Administration

Django Admin provides management functionality for:

  • Users
  • Hotels
  • Rooms
  • Bookings
  • Featured hotels
  • User activity logs
  • Password-change logs

๐Ÿงฑ Architecture

BookingX follows a client-server architecture:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚        React Frontend        โ”‚
โ”‚          Vite + JS           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ”‚ REST API
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      Django REST API         โ”‚
โ”‚     Django + DRF + JWT       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         PostgreSQL           โ”‚
โ”‚          Database            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

External Integration:
        โ”‚
        โ””โ”€โ”€ Geoapify
             โ””โ”€โ”€ Location Autocomplete

The frontend is responsible for the user interface and client-side application state, while the Django backend handles authentication, business logic, validation, bookings, and database operations.


๐Ÿ› ๏ธ Tech Stack

Frontend

  • React.js
  • Vite
  • JavaScript
  • React Router
  • Bootstrap 5
  • CSS
  • React DatePicker

Backend

  • Python
  • Django
  • Django REST Framework
  • Simple JWT
  • REST APIs

Database

  • PostgreSQL
  • pgAdmin

External Services

  • Geoapify
  • OpenStreetMap-based location data
  • Email service for password reset

Development Tools

  • Git
  • GitHub
  • VS Code
  • Django Admin

๐Ÿ“‚ Project Structure

BookingX/
โ”‚
โ”œโ”€โ”€ booking-backend/
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ manage.py
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ accounts/
โ”‚   โ”‚   โ”œโ”€โ”€ models.py
โ”‚   โ”‚   โ”œโ”€โ”€ serializers.py
โ”‚   โ”‚   โ”œโ”€โ”€ views.py
โ”‚   โ”‚   โ””โ”€โ”€ urls.py
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ hotels/
โ”‚   โ”‚   โ”œโ”€โ”€ models.py
โ”‚   โ”‚   โ”œโ”€โ”€ serializers.py
โ”‚   โ”‚   โ”œโ”€โ”€ views.py
โ”‚   โ”‚   โ”œโ”€โ”€ urls.py
โ”‚   โ”‚   โ””โ”€โ”€ admin.py
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ”œโ”€โ”€ booking-ui/
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ context/
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ vite.config.js
โ”‚
โ””โ”€โ”€ README.md

๐Ÿš€ Getting Started

Prerequisites

Make sure the following are installed:

  • Python 3.12+
  • Node.js
  • npm
  • PostgreSQL
  • Git

1. Clone the Repository

git clone https://github.com/adithyanhp/BookingX.git

cd BookingX

โš™๏ธ Backend Setup

2. Navigate to the Backend

cd booking-backend

3. Create a Virtual Environment

Windows

python -m venv venv

Activate it:

venv\Scripts\activate

Linux / macOS

python3 -m venv venv
source venv/bin/activate

4. Install Dependencies

pip install -r requirements.txt

5. Configure Environment Variables

Create a .env file inside the backend directory.

Example:

SECRET_KEY=your-django-secret-key

DEBUG=True

DB_NAME=bookingx
DB_USER=postgres
DB_PASSWORD=your-postgresql-password
DB_HOST=localhost
DB_PORT=5432

FRONTEND_URL=http://localhost:5173

EMAIL_HOST_USER=your-email@example.com
EMAIL_HOST_PASSWORD=your-email-password

Important: Never commit your .env file or secret credentials to GitHub.


6. Create the PostgreSQL Database

Create a PostgreSQL database for BookingX.

For example:

CREATE DATABASE bookingx;

Then make sure the database credentials in your .env file match your PostgreSQL configuration.


7. Run Migrations

python manage.py makemigrations
python manage.py migrate

8. Create a Django Admin Account

python manage.py createsuperuser

Follow the prompts to create your admin account.


9. Start the Backend Server

python manage.py runserver

The backend will normally be available at:

http://127.0.0.1:8000/

๐ŸŽจ Frontend Setup

Open another terminal.

10. Navigate to the Frontend

From the project root:

cd booking-ui

11. Install Dependencies

npm install

12. Configure Frontend Environment Variables

Create:

.env

inside booking-ui.

Example:

VITE_API_BASE_URL=http://127.0.0.1:8000/api
VITE_GEOAPIFY_API_KEY=your-geoapify-api-key

Important: Do not commit API keys or other secrets to GitHub.


13. Start the Frontend

npm run dev

The frontend will normally be available at:

http://localhost:5173/

๐Ÿ”‘ Authentication Flow

BookingX uses JWT authentication.

User
 โ”‚
 โ”œโ”€โ”€ Register
 โ”‚
 โ–ผ
Login
 โ”‚
 โ”œโ”€โ”€ Access Token
 โ””โ”€โ”€ Refresh Token
       โ”‚
       โ–ผ
Protected API Requests
       โ”‚
       โ–ผ
Access Token Expired?
       โ”‚
       โ”œโ”€โ”€ No โ†’ Continue
       โ”‚
       โ””โ”€โ”€ Yes
             โ”‚
             โ–ผ
        Refresh Token
             โ”‚
             โ–ผ
        New Access Token

The frontend centralizes authenticated API requests and automatically attempts to refresh expired access tokens.


๐Ÿ“ Location Search

BookingX uses Geoapify to provide location autocomplete.

The location system works independently from the hotel database:

User enters location
        โ”‚
        โ–ผ
Geoapify Autocomplete
        โ”‚
        โ–ผ
User selects location
        โ”‚
        โ”œโ”€โ”€ Latitude
        โ””โ”€โ”€ Longitude
                โ”‚
                โ–ผ
        BookingX Django API
                โ”‚
                โ–ผ
       Hotel search by distance

This allows users to search using real-world locations instead of being limited to predefined database entries.


๐Ÿจ Booking Flow

The main booking workflow is:

Search Location
      โ”‚
      โ–ผ
Search Hotels
      โ”‚
      โ–ผ
Select Hotel
      โ”‚
      โ–ผ
Select Room
      โ”‚
      โ–ผ
Choose Dates & Guests
      โ”‚
      โ–ผ
Validate Availability
      โ”‚
      โ–ผ
Create Booking
      โ”‚
      โ–ผ
Booking Confirmation
      โ”‚
      โ–ผ
My Bookings

The backend performs server-side validation before creating a booking.


๐Ÿ”’ Booking Integrity

BookingX does not rely only on frontend validation.

The backend validates:

  • Check-in date
  • Check-out date
  • Guest capacity
  • Room status
  • Room availability
  • Existing overlapping bookings

Booking creation uses database transactions and row-level locking to reduce the possibility of conflicting bookings when multiple requests target the same room.


๐Ÿ“Š Booking Lifecycle

Bookings can move through different states:

Pending
   โ”‚
   โ–ผ
Confirmed
   โ”‚
   โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Cancelled
   โ”‚
   โ–ผ
Completed

Past confirmed bookings can automatically transition to the completed state.


๐Ÿ”‘ Password Reset Flow

BookingX includes a complete password recovery workflow.

Login
  โ”‚
  โ–ผ
Forgot Password
  โ”‚
  โ–ผ
Enter Email
  โ”‚
  โ–ผ
Password Reset Email
  โ”‚
  โ–ผ
Reset Link
  โ”‚
  โ–ผ
Reset Password Page
  โ”‚
  โ–ผ
New Password
  โ”‚
  โ–ผ
Password Updated

Reset links contain a secure user identifier and token generated by Django's password-reset mechanisms.


๐Ÿ‘ค Account Management

Users can manage their account through the Profile section.

Available functionality includes:

  • Profile information
  • Profile image
  • Edit profile
  • Change password
  • My bookings
  • Permanent account deletion

Account deletion requires current-password verification before the account is permanently removed.


๐Ÿ“ Activity & Security Logging

BookingX includes auditing functionality for security-sensitive operations.

User Activity

The system records:

  • Login
  • Logout
  • Timestamp
  • IP address
  • User agent

Password Changes

Password changes are recorded with information about whether the change was initiated by:

  • The user
  • An administrator

This provides administrators with better visibility into account security events.


๐Ÿ›ก๏ธ Security Considerations

The project follows several security practices:

  • JWT-based authentication
  • Protected API endpoints
  • Protected frontend routes
  • Password hashing through Django
  • Current-password verification for account deletion
  • Server-side booking validation
  • Transaction-safe booking creation
  • Environment variables for secrets
  • Token refresh handling
  • Separation between frontend and backend responsibilities

๐Ÿงช Testing the Application

After starting both servers:

Frontend

http://localhost:5173

Backend

http://127.0.0.1:8000

Django Admin

http://127.0.0.1:8000/admin/

Recommended testing flow:

  1. Register a new user.
  2. Log in.
  3. Search for a location.
  4. Select a hotel.
  5. Select a room.
  6. Choose dates and guests.
  7. Create a booking.
  8. Check the booking under My Bookings.
  9. Test booking cancellation.
  10. Test profile editing.
  11. Test password change.
  12. Test forgot-password and reset-password.
  13. Test account deletion.
  14. Verify records through Django Admin.

๐ŸŽฏ Project Goals

BookingX was developed to provide practical experience with building a complete full-stack application rather than only implementing isolated frontend pages or backend APIs.

The project focuses on:

  • Full-stack architecture
  • REST API development
  • Database-driven applications
  • Authentication and authorization
  • Booking business logic
  • Transaction management
  • API integration
  • Location-based search
  • Account security
  • Administrative management
  • Responsive user interfaces

๐Ÿ”ฎ Future Improvements

Potential future improvements include:

  • Online payment integration
  • Hotel reviews and ratings
  • Hotel amenities and advanced filtering
  • Wishlist/favorites
  • Booking invoices
  • Email booking confirmations
  • Improved hotel recommendation system
  • Advanced admin dashboard
  • Analytics and booking reports
  • Deployment with production infrastructure
  • Automated backend and frontend tests
  • Docker-based development and deployment
  • CI/CD pipeline

๐Ÿ“ธ Screenshots

Screenshots can be added here to showcase the application.

Example:

## Screenshots

### Home Page

![BookingX Home Page](screenshots/home.png)

### Hotel Search

![Hotel Search](screenshots/hotel-search.png)

### Booking

![Booking Page](screenshots/booking.png)

### My Bookings

![My Bookings](screenshots/my-bookings.png)

### Profile

![Profile](screenshots/profile.png)

๐Ÿ“š What I Learned

Building BookingX provided hands-on experience with the complete lifecycle of a modern full-stack web application.

Key areas of learning include:

  • Designing RESTful APIs with Django REST Framework
  • Building reusable React components
  • Managing authentication using JWT
  • Handling access-token expiration and refresh
  • Designing relational database models
  • Implementing real-world booking validation
  • Preventing overlapping reservations
  • Using database transactions for critical operations
  • Integrating third-party APIs
  • Implementing secure password recovery
  • Building administrative tools with Django Admin
  • Managing user activity and security logs
  • Structuring a frontend/backend application for maintainability

๐Ÿ‘จโ€๐Ÿ’ป Author

Adithyan H P

Full-Stack Python Developer | React | Django | PostgreSQL

GitHub: @adithyanhp


โญ Support

If you find this project useful or interesting, consider giving the repository a โญ on GitHub.


๐Ÿ“„ License

This project is currently intended for educational and portfolio purposes.

About

BookingX is a Platform where u can Book Hotels,Travel Package, Cab and Flights

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages