A desktop application for managing car rentals, built with Java Swing and MySQL.
It follows a modular MVC-inspired architecture with migrations, DAOs, domain models, and a Swing GUI.
- About
- Features
- Tech Stack
- Project Architecture
- Design Patterns
- Project Components
- Prerequisites
- Installation
- Configuration
- Database Setup
- Running the Application
- Screenshots
- Team Members
- License
The Car Rental Management System (CRMS) is a comprehensive desktop application designed to simplify the car rental process for businesses. It provides a complete solution for managing customers, vehicles, bookings, payments, and maintenance all within a single interface.
This application is built using Java Swing for the GUI and MySQL for data persistence, following an MVC (Model-View-Controller) architecture pattern. It's designed with modularity and extensibility in mind, making it easy to maintain and extend.
-
User Authentication
- โ Customer and Admin login and registration
- ๐ Secure password hashing with jBCrypt
- ๐ง Email verification system
-
Customer Management
- ๐ค Customer registration with license information
- ๐ Customer profile management
- ๐ Customer search and filtering
-
Car Management
- ๐ Complete car inventory system (CRUD operations)
- ๐ท๏ธ Car categorization and brand management
- ๐ Car availability tracking
- ๐ผ๏ธ Car image upload and display
-
Booking System
- ๐ Advanced booking with date validation
- ๐ณ Payment processing
- ๐งพ Invoice generation
- ๐ Rental history tracking
-
Maintenance & Reviews
- ๐ง Vehicle maintenance logging
- ๐ฐ Maintenance cost tracking
- โญ Customer review and rating system
-
Admin Features
- ๐ Dashboard with key metrics
- ๐ฅ User management
- ๐ต Payment oversight
- ๐ Discount management
- Language: Java SE
- GUI Framework: Java Swing with FlatLaf for modern UI
- Database: MySQL
- JDBC Connector: MySQL Connector/J 9.1.0
- Additional Libraries:
- jBCrypt for password hashing
- FlatLaf for modern UI
- PDFBox for PDF generation
- JavaMail for email functionality
- JDatePicker for date selection
- MigLayout for flexible GUI layouts
The Car Rental Management System follows the Model-View-Controller (MVC) architectural pattern, structured as follows:
๐ src/
โฃ ๐ models/ # Domain models representing business entities
โฃ ๐ dao/ # Data Access Objects for database operations
โฃ ๐ controllers/ # Controllers to handle business logic
โฃ ๐ views/ # UI components and screens
โฃ ๐ utils/ # Utility classes and helpers
โฃ ๐ migrations/ # Database setup and migrations
โฃ ๐ services/ # Business services (e.g., OTP service)
โฃ ๐ resources/ # Configuration files
โฃ ๐ assets/ # Images and other static resources
โ ๐ fonts/ # Custom fonts for the application
This architecture provides:
- Separation of concerns: Each component has a clear responsibility
- Maintainability: Changes to one layer don't affect other layers
- Testability: Components can be tested in isolation
- Flexibility: Easy to extend or modify functionality
Models represent the business entities and encapsulate the data structure. Key models include:
-
Car: Represents a vehicle available for rental
- Attributes: ID, model, category, mileage, availability, price, etc.
- Related models:
CarBrand,CarModel,Category
-
Customer: Represents a registered user
- Attributes: ID, username, password hash, email, license number, etc.
- Authentication and profile details
-
Booking: Represents a car reservation
- Attributes: ID, car ID, customer ID, dates, status, etc.
- Links customers to cars for a specific period
-
Payment: Handles financial transactions
- Attributes: ID, booking ID, amount, status, date, method
- Tracks all financial aspects of rentals
-
RentalHistory: Records past rentals
- Attributes: ID, booking ID, return date, condition notes, etc.
- Maintains a history of all completed rentals
-
Maintenance: Tracks vehicle upkeep
- Attributes: ID, car ID, date, description, cost, etc.
- Records all maintenance activities for each vehicle
-
Review: Customer feedback about rentals
- Attributes: ID, booking ID, rating, comments, date
- Allows customers to rate their rental experience
The Data Access Object (DAO) layer provides an abstraction between the database and the application. Each DAO class:
- Handles CRUD operations (Create, Read, Update, Delete)
- Manages SQL queries and database connections
- Maps database records to model objects
Key DAO classes:
-
CarDAO: Manages car data in the database
- Methods:
insertCar(),getCarById(),updateCar(),deleteCar(), etc. - Handles car-specific database operations
- Methods:
-
CustomerDAO: Manages customer accounts
- Methods:
registerCustomer(),getCustomerByUsername(),verifyCustomer(), etc. - Handles customer authentication and profile management
- Methods:
-
BookingDAO: Manages rental bookings
- Methods:
createBooking(),getBookingsByCustomer(),updateBookingStatus(), etc. - Handles reservation-related database operations
- Methods:
All DAO classes follow a similar pattern, providing a consistent interface for database operations while encapsulating SQL complexity.
Controllers act as intermediaries between the Views and the Models/DAOs. They:
- Validate user input before processing
- Implement business logic
- Call appropriate DAO methods
- Return results to the Views
Key controllers:
-
CarController: Manages car-related operations
- Methods:
addCar(),updateCar(),deleteCar(),getCarById(), etc. - Validates car data before database operations
- Methods:
-
BookingController: Handles rental bookings
- Methods:
createBooking(),cancelBooking(),getActiveBookings(), etc. - Manages the booking workflow and status transitions
- Methods:
-
LoginController: Handles user authentication
- Methods:
loginCustomer(),loginAdmin(),verifyCredentials() - Securely authenticates users and manages sessions
- Methods:
Views are the user interface components built with Java Swing. The application uses FlatLaf for a modern look and feel. Key views include:
-
LoginView: User authentication screen
- Components: Username/password fields, login button
- Functionality: Authenticate users, reset password
-
AdminDashboard: Main admin interface
- Components: Navigation menu, summary statistics
- Functionality: Access to all admin functions
-
AvailableCarsView: Displays cars for rental
- Components: Car listing table, filters, booking button
- Functionality: Browse and select cars for rental
-
BookingView: Booking creation interface
- Components: Date pickers, customer details, payment options
- Functionality: Complete the booking process
-
ManageCarView: Car management interface
- Components: Car listing, add/edit/delete buttons
- Functionality: CRUD operations for car inventory
Each view is designed to be responsive and user-friendly, with consistent styling and navigation.
Utility classes provide common functionality used across the application:
-
MySQLConnection: Database connection management (Singleton)
- Methods:
getInstance(),getConnection() - Maintains a single connection to the MySQL database
- Methods:
-
EmailUtil: Email notification services
- Methods:
sendVerificationEmail(),sendPasswordReset() - Handles all email communications
- Methods:
-
HashUtil: Password security
- Methods:
hashPassword(),verifyPassword() - Uses jBCrypt for secure password handling
- Methods:
-
ValidationUtil: Input validation
- Methods:
isValidEmail(),isValidPhone(), etc. - Ensures data integrity before processing
- Methods:
-
AppColors: UI color constants
- Defines color scheme for consistent UI appearance
The migration system automates database setup and schema changes:
- DBMigration: Database setup and schema management
- Methods:
migrate(),applyMigration() - Creates all required tables and initial data
- Methods:
- Java Development Kit (JDK) 8 or higher
- MySQL Server 5.7 or higher
- MySQL Connector/J 9.1.0
- (Optional) An IDE such as Eclipse, IntelliJ IDEA, or NetBeans
-
Clone the repository
git clone https://github.com/kareem-diaa/Car-Rental-Management-System-CRMS-.git cd Car_Rental -
Configure database connection
- Edit
src/resources/DBPropFile.propertieswith your MySQL credentials - Ensure MySQL server is running
- Edit
-
Add required libraries
- All required JAR files are in the
lib/directory - Add these to your build path if not already included
- All required JAR files are in the
-
Compile the project
- Use your IDE's build functionality or compile manually
Edit the src/resources/DBPropFile.properties file:
MYSQL_DB_URL=jdbc:mysql://localhost:3306/car_rental
USER=your_username
PASSWORD=your_passwordEdit the src/resources/smtp.properties file:
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_AUTH=true
SMTP_STARTTLS=true
SMTP_USERNAME=your_email@gmail.com
SMTP_PASSWORD=your_app_passwordTo initialize the database:
-
Create a MySQL database
CREATE DATABASE car_rental;
-
Run migrations
- Uncomment the migration code in
Main.java - Run the application once to create all tables
- Re-comment the migration code for subsequent runs
- Uncomment the migration code in
The migration system will automatically create all required tables, indexes, and relationships.
-
Compile and run the Main class
javac -cp "lib/*" -d bin src/car_rental/Main.java java -cp "bin;lib/*" car_rental.Main
-
Login
- Use the default admin credentials (check admin_passwords.txt)
- Or register a new customer account
-
Navigate the interface
- Use the menu options to access different features
- Admin users have access to management features
- Customers can browse cars, make bookings, and view their history
- Abram Mina
- Ahmed Mohamed
- Kareem Diaa
- Zeyad Mahmoud
For inquiries or collaboration, feel free to reach out via GitHub Issues or Discussions.
- SU TECH Assistant Professors, Teaching Assistants, and Mentors
- Java & Swing Documentation
- MySQL Community Edition
- GitHub Community
- Open-source contributors
