A console-based Car Rental System built with Python using Object-Oriented Programming (OOP) principles. It goes beyond a simple fleet tracker with real customer accounts, unique per-booking IDs (so a car can have multiple future bookings), genuine date-overlap prevention, and multi-charge billing (discount, GST, fuel, insurance) — all backed by JSON persistence and a modular package structure.
-
Admin Panel:
- Secure Admin Login (SHA-256 password hashing)
- View Cars Fleet
- Add New Car
- Update Car Details
- Remove Car (blocked if the car has active bookings)
- View Booking History
- View Advanced Sales Report
-
Customer System:
- Customer Registration & Login (SHA-256 password hashing, unique usernames)
- View Cars Fleet
- Search Car (by Car ID, Category, or Brand)
- Rent Car — with past-date rejection and real date-overlap prevention against the car's other bookings
- View My Booking (scoped to the logged-in customer only)
- Update Booking (change dates, re-checked for overlaps)
- Cancel Booking
- Calculate Bill (Subtotal, Discount, GST, Fuel & Insurance breakdown)
- Advanced Payment Checkout (generates an itemized receipt covering all of a customer's active bookings)
- Return Car (by Booking ID — frees the car only once its last active booking is returned)
-
Data & Billing Features:
- Persistent JSON storage for Cars, Users, Active Bookings, and Booking History
- Unique, sequential Booking IDs (
B-101,B-102, ...) — a single car can now have multiple bookings for different, non-overlapping date ranges - Real date-overlap checking (
is_date_overlapping()) so the same car can never be double-booked for conflicting dates - Tiered discounts (5% above Rs. 15,000, 10% above Rs. 25,000), GST (5%), Fuel Charges (5%), Insurance Charges (2%) — computed through a single shared
compute_totals()method - Auto-generated, sequential receipt numbers (
receipt_1001.txt) - Input validation and exception handling, including corrupt-JSON recovery
- Python 3 (Object-Oriented Programming)
- JSON Module (Data persistence)
- hashlib (SHA-256 password hashing)
- Datetime Module (Date validation, overlap checking, timestamps)
- OS Module (Directory management and file IO)
Car-Rental-System/
│
├── data/
│ ├── cars.json # Persistent car fleet (gitignored)
│ ├── users.json # Persistent customer/admin accounts (gitignored)
│ ├── car_booking.json # Persistent active bookings (gitignored)
│ └── car_booking_history.json # Persistent booking/sales history (gitignored)
│
├── customer_receipts/ # Auto-generated, sequential receipts (gitignored)
│
├── src/ # Source code package
│ ├── __init__.py
│ ├── models.py # Car, User classes
│ ├── manager.py # CarRentalManager class — persistence, auth, booking, billing logic
│ └── UI.py # CarRentalUI class — menus, display formatting
│
├── .gitignore # Excludes __pycache__, data, and customer_receipts
├── main.py # Application entry point
└── README.md
Note:
data/*.jsonfiles are created automatically on first run. The car fleet is seeded with 25 sample vehicles across Sedan/Hatchback/SUV/Luxury/Van categories, and a default Admin account (admin/12345) is created. All are excluded from the repository via.gitignore.
Clone the repository
git clone https://github.com/osaid400/Car-Rental-System.gitMove into the project folder
cd Car-Rental-SystemRun the project
python main.py============================= MAIN MENU ==============================
1. Customer Portal
2. Admin Portal
0. Exit System
======================================================================
================== CUSTOMER PORTAL ==================
1. Login
2. Sign Up
0. Back to Main Menu
=====================================================
Enter choice: 2
==================== CUSTOMER SIGN UP ====================
Choose username: osaid
Choose password: pass1234
Registration successful! You can now log in.
Enter choice: 1
Enter username: osaid
Enter password: pass1234
Welcome back, osaid!
=========================================================================================================
Car ID Brand Model Category Status Price Per Day
=========================================================================================================
101 Toyota Corolla Sedan Available Rs. 8,000.00
102 Honda Civic Sedan Available Rs. 9,500.00
105 Kia Sportage SUV Available Rs. 15,000.00
111 Audi A4 Luxury Available Rs. 35,000.00
=========================================================================================================
Enter the Car ID to book: 105
Enter Pickup Date (DD-MM-YYYY): 20-08-2026
Enter Return Date (DD-MM-YYYY): 25-08-2026
✅ Car successfully booked! Your Booking ID is B-101
========================================================================================================================
Car ID Car Model Car Category Price Per Day Days Subtotal
========================================================================================================================
105 Sportage SUV Rs. 15,000.00 5 Rs. 75,000.00
========================================================================================================================
Enter the Car ID to book: 105
Enter Pickup Date (DD-MM-YYYY): 22-08-2026
Enter Return Date (DD-MM-YYYY): 24-08-2026
❌ Car is already booked for these dates! Choose different dates or another car.
======================================================= MY BOOKINGS ====================================================
Car ID Car Model Car Category Price Per Day Days Subtotal
========================================================================================================================
105 Sportage SUV Rs. 15,000.00 5 Rs. 75,000.00
========================================================================================================================
Subtotal: Rs. 75,000.00
Discount (10%): -Rs. 7,500.00
After Discount: Rs. 67,500.00
GST (5%): +Rs. 3,375.00
Fuel Charges (5%): +Rs. 3,375.00
Insurance (2%): +Rs. 1,350.00
========================================================================================================================
GRAND TOTAL: Rs. 75,600.00
========================================================================================================================
Enter customer full name: Osaid
Enter phone number: 03001234567
==================== PAYMENT METHOD ====================
1. Cash
2. Card
3. Mobile Payment
Enter choice (1-3): 2
Proceed to checkout? (y/n): y
=====================================================================================
CAR RENTAL - RECEIPT
=====================================================================================
Receipt No : 1001
Customer Name : Osaid
Username : osaid
Phone : 03001234567
Date & Time : 13-08-2026 18:20:11
Payment Method : Card
-------------------------------------------------------------------------------------
ID Car Model Days Price Subtotal
-------------------------------------------------------------------------------------
105 Sportage 5 Rs. 15,000.00 Rs. 75,000.00
-------------------------------------------------------------------------------------
Subtotal: Rs. 75,000.00
Discount (10%): -Rs. 7,500.00
After Discount: Rs. 67,500.00
GST (5%): + Rs. 3,375.00
Fuel Charges: + Rs. 3,375.00
Insurance: + Rs. 1,350.00
=====================================================================================
GRAND TOTAL: Rs. 75,600.00
=====================================================================================
Receipt saved to: customer_receipts/receipt_1001.txt
===================== RETURN CAR =====================
Enter Booking ID to return: B-101
Booking B-101 returned successfully! Car status updated.
Enter Car ID: 126
Enter Brand: Tesla
Enter Model: Model 3
Enter Category: Luxury
Enter Price per Day: 40000
Car added successfully!
- Object-Oriented Programming (OOP): Class design and encapsulation (
Car,User,CarRentalManager), withto_dict()/from_dict()serialization that handles multiple possible key formats. - CRUD Operations: Complete management of the car fleet and customer bookings.
- JSON Data Serialization: Managing persistent state across four files (cars, users, active bookings, booking history), with corrupt-file recovery.
- Authentication: SHA-256 password hashing for both customer and admin accounts, with registration validation (unique usernames, non-empty passwords).
- Interval/Overlap Logic: Real date-range overlap detection (
max(start1, start2) <= min(end1, end2)) so a car can be safely booked multiple times for different, non-conflicting periods — replacing the earlier one-booking-per-car limitation. - Financial Logic: Tiered discounts, GST, fuel charges, and insurance calculations via a shared
compute_totals()method, used identically for bill preview and checkout. - Date Handling: Pickup/return date validation using the
datetimemodule (rejecting past dates and invalid ranges). - Defensive Input Handling: Input validation (no negative prices, valid IDs) and exception handling across all CLI menus.
- Modules & Packages: Code organized into a
src/package (models.py,manager.py,UI.py), separating data, business logic, and presentation, withmain.pyas the entry point outside the package.
- Every booking gets its own sequential ID (
B-101,B-102, ...) instead of being tracked only by Car ID. - This means the same car can have several bookings on the books at once, as long as their date ranges don't overlap — a genuine improvement over the earlier version, where a car could only ever have one active booking, period.
- Before confirming a new booking (or updating an existing one's dates),
is_date_overlapping()checks it against every other booking for that same car, rejecting the request if the ranges conflict.
- Customers register with a username and password (hashed with SHA-256) and log in before they can book.
- Every booking, view, update, cancellation, and checkout is scoped to
self.current_user.username— so one customer can never see or modify another customer's bookings, unlike the account-less flow in earlier projects.
- Move default admin credentials out of source code
- Regex-based phone number validation
- Discount & promo coupon codes
- SQLite Database Migration
- GUI Version (Tkinter) / Web API (Flask/FastAPI)
This project helped me practice and solidify key software engineering concepts:
- Real customer authentication: Moving from an account-less, name-only flow to hashed-password registration and login, with all booking operations properly scoped to the logged-in user.
- Solving the "one booking per car" limitation properly: Introducing unique Booking IDs and real interval-overlap checking, rather than just tracking a single Available/Booked status per car.
- Financial Calculations: Building accurate multi-step billing logic (subtotal → discount → GST → fuel → insurance) shared across both preview and checkout flows to avoid code duplication.
- Defensive Programming: Applying
try-excepthandling to protect against invalid input and corrupt data files. - Modular project structure: Splitting a single-file project into a
models/manager/UI/mainpackage, closing out a full first pass across all 15 console projects.
Muhammad Abdullah Farooq
GitHub: https://github.com/osaid400