A comprehensive vehicle catalog and rental management system with secure RESTful API
Overview β’ Features β’ Architecture β’ Installation β’ API Reference β’ Security β’ Documentation β’ Contributing
CarCatalog is a robust Spring Boot application designed to provide a complete solution for vehicle catalog and rental management. The system allows users to browse available vehicles, make reservations, manage bookings, and process payments through a secure RESTful API.
The application supports both individual and corporate customers, with different workflows for each. It includes features for tracking vehicle maintenance, crash history, and city-based operations. The system also handles additional services that can be added to rentals, such as GPS or child seats.
| π Vehicle Management | ποΈ Reservation System | π Security |
|---|---|---|
| β’ Browse & search vehicles β’ Filter by brand, color, etc. β’ Vehicle maintenance tracking β’ Crash history management β’ Kilometer tracking |
β’ Booking management β’ Date-based availability β’ City-based pickup/return β’ Different pricing for different cities β’ Individual & corporate customers |
β’ JWT authentication β’ Role-based access control β’ Admin-specific endpoints β’ Secure password storage β’ Token-based authorization |
| π³ Payment Processing | π§Ύ Invoicing | π« Additional Services |
|---|---|---|
| β’ Multiple payment processors (Ziraat Bank, Akbank) β’ Credit card storage option β’ Secure transaction handling |
β’ Automatic invoice generation β’ Detailed price breakdown β’ Unique invoice numbers β’ Rental history tracking |
β’ Add-on services for rentals β’ Priced per day β’ Can be added during or after booking β’ Included in invoice calculations |
- Backend: Java 17, Spring Boot 3.x, Spring Data JPA
- Database: MySQL 8.0
- Security: Spring Security, JWT Authentication
- API Documentation: Swagger OpenAPI 3.0
- Utilities: Lombok, ModelMapper
- Testing: JUnit 5
The project follows a layered architecture with clear separation of concerns:
- API Layer: Controllers handling HTTP requests
- Business Layer: Services implementing business logic
- Data Access Layer: Repositories for database operations
- Entity Layer: Domain models representing database tables
- DTO Layer: Data Transfer Objects for API responses
- Request Models: Objects for handling API requests
- Core Utilities: Common functionality and helpers
- Java 17 or higher
- Maven 3.6+
- MySQL 8.0+
- Clone the repository
git clone https://github.com/yourusername/CarCatalog.git
cd CarCatalog- Configure the database
CREATE DATABASE carCatalogDb;- Configure application properties
Update src/main/resources/application.properties with your database credentials:
spring.datasource.url=jdbc:mysql://localhost:3306/carCatalogDb
spring.datasource.username=your_username
spring.datasource.password=your_password- Build and run the application
mvn clean install
mvn spring-boot:run- Access the application
- API: http://localhost:8080
- Swagger UI: http://localhost:8080/swagger-ui.html
The API is organized into logical controller groups that handle different aspects of the rental system:
- Authentication & User Management: User registration, login, and account management
- Customer Management: Both individual and corporate customer operations
- Vehicle Management: Cars, brands, colors, maintenance, and crash records
- Rental Management: Booking operations and city-based location management
- Additional Services: Extra services that can be added to rentals
- Payment & Invoicing: Payment processing and invoice generation
| Controller | Base Path | Purpose | Key Endpoints |
|---|---|---|---|
| AuthController | /api/auth |
Authentication | Login, Registration |
| UsersController | /api/users |
User management | Get users, User details |
| CustomersController | /api/customers |
Base customer operations | List customers, Customer details |
| IndividualCustomersController | /api/individualCustomers |
Person customers | CRUD for individual customers |
| CorporateCustomersController | /api/corporateCustomers |
Business customers | CRUD for corporate customers |
| CarsController | /api/cars |
Car inventory | CRUD for cars |
| BrandsController | /api/brands |
Car brands | CRUD for brands |
| ColorsController | /api/colors |
Car colors | CRUD for colors |
| CarMaintenancesController | /api/carMaintenances |
Maintenance tracking | CRUD for maintenance records |
| CarCrashesController | /api/carCrashes |
Accident history | CRUD for crash records |
| RentalCarsController | /api/rentalCars |
Rental operations | Create/manage rentals, Return cars |
| CitiesController | /api/cities |
Location management | CRUD for pickup/return cities |
| AdditionalsController | /api/additionals |
Extra service types | CRUD for additional service types |
| OrderedAdditionalsController | /api/orderedAdditionals |
Rental extras | Manage extras for specific rentals |
| PaymentsController | /api/payments |
Payment processing | Process payments for different scenarios |
| CreditCardsController | /api/creditCards |
Payment methods | Manage saved credit cards |
| InvoicesController | /api/invoices |
Invoice management | Generate/retrieve invoices |
| Method | Endpoint | Description | Access |
|---|---|---|---|
POST |
/api/auth/login |
Get JWT token | Public |
POST |
/api/auth/signup |
Register new user | Public |
GET |
/api/users/getAll |
Get all users | Admin |
GET |
/api/users/getById |
Get user by ID | Authenticated |
| Method | Endpoint | Description | Access |
|---|---|---|---|
GET |
/api/customers/getAll |
Get all customers | Authenticated |
GET |
/api/individualCustomers/getAll |
Get all individual customers | Authenticated |
POST |
/api/individualCustomers/add |
Add individual customer | Authenticated |
GET |
/api/corporateCustomers/getAll |
Get all corporate customers | Authenticated |
POST |
/api/corporateCustomers/add |
Add corporate customer | Authenticated |
| Method | Endpoint | Description | Access |
|---|---|---|---|
GET |
/api/cars/getAll |
Get all cars | Public |
GET |
/api/cars/getByCarId |
Get car by ID | Public |
POST |
/api/cars/add |
Add car | Admin |
GET |
/api/brands/getAll |
Get all brands | Public |
GET |
/api/colors/getAll |
Get all colors | Public |
GET |
/api/carMaintenances/getAll |
Get all maintenance records | Authenticated |
GET |
/api/carCrashes/getAll |
Get all crash records | Authenticated |
| Method | Endpoint | Description | Access |
|---|---|---|---|
GET |
/api/rentalCars/getAll |
Get all rentals | Admin |
GET |
/api/rentalCars/getById |
Get rental by ID | Authenticated |
POST |
/api/rentalCars/add |
Create rental | Authenticated |
PUT |
/api/rentalCars/update |
Update rental | Authenticated |
PUT |
/api/rentalCars/receiveTheCar |
Mark car as returned | Authenticated |
GET |
/api/cities/getAll |
Get all cities | Public |
| Method | Endpoint | Description | Access |
|---|---|---|---|
GET |
/api/additionals/getAll |
Get all additional service types | Public |
GET |
/api/orderedAdditionals/getAll |
Get all ordered additionals | Admin |
GET |
/api/orderedAdditionals/getByOrderedAdditional_RentalCarId |
Get additionals for a rental | Authenticated |
| Method | Endpoint | Description | Access |
|---|---|---|---|
GET |
/api/payments/getAll |
Get all payments | Admin |
POST |
/api/payments/makePaymentForIndividualRentAdd |
Process payment for individual | Authenticated |
POST |
/api/payments/makePaymentForCorporateRentAdd |
Process payment for corporate | Authenticated |
POST |
/api/payments/makePaymentForOrderedAdditionalAdd |
Pay for additional services | Authenticated |
GET |
/api/invoices/getAll |
Get all invoices | Admin |
GET |
/api/invoices/getAllByCustomer_CustomerId |
Get customer invoice history | Authenticated |
GET |
/api/creditCards/getByCustomerId |
Get customer's saved cards | Authenticated |
| Security Features | Authentication Flow |
|---|---|
| β’ JWT Authentication: Secure token-based authentication β’ Password Encryption: BCrypt encoding β’ Role-Based Access Control: User/admin permissions β’ Method-Level Security: Endpoint protection with @PreAuthorize β’ Stateless Sessions: No server-side session state |
1. User registers or logs in with credentials 2. Server validates credentials and returns a JWT token 3. Client includes JWT in Authorization header 4. Server validates token and grants access based on roles Example Header: Authorization: Bearer eyJhbGciOiJIUzUxMiJ9... |
The API is documented using Swagger OpenAPI 3.0, providing interactive documentation for all endpoints.
- Swagger UI: http://localhost:8080/swagger-ui.html
- API Docs: http://localhost:8080/v3/api-docs
All API responses follow a consistent format using wrapper classes:
{
"success": true,
"message": "Data listed successfully",
"data": {"Response data here"}
}Error responses include error details and maintain the same structure:
{
"success": false,
"message": "Error message here"
}Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add some amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
β Star this repository if you find it helpful!
CarCatalog - Built with β€οΈ using Spring Boot and Java