Skip to content

lakshay1341/CarCatalog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— CarCatalog - Vehicle Rental Management System

Java Spring Boot MySQL JWT Swagger

A comprehensive vehicle catalog and rental management system with secure RESTful API

Overview β€’ Features β€’ Architecture β€’ Installation β€’ API Reference β€’ Security β€’ Documentation β€’ Contributing

πŸ“‹ Overview

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.

✨ Key Features

πŸš— 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

🌟 Advanced Features

πŸ’³ 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

πŸ—„οΈ Architecture

Technology Stack

  • 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

Project Structure

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

πŸ“₯ Installation

Prerequisites

  • Java 17 or higher
  • Maven 3.6+
  • MySQL 8.0+

Quick Start Guide

  1. Clone the repository
git clone https://github.com/yourusername/CarCatalog.git
cd CarCatalog
  1. Configure the database
CREATE DATABASE carCatalogDb;
  1. 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
  1. Build and run the application
mvn clean install
mvn spring-boot:run
  1. Access the application

πŸ”₯ API Reference

API Structure

The API is organized into logical controller groups that handle different aspects of the rental system:

  1. Authentication & User Management: User registration, login, and account management
  2. Customer Management: Both individual and corporate customer operations
  3. Vehicle Management: Cars, brands, colors, maintenance, and crash records
  4. Rental Management: Booking operations and city-based location management
  5. Additional Services: Extra services that can be added to rentals
  6. Payment & Invoicing: Payment processing and invoice generation

Controller Overview

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

Key API Endpoints

πŸ” Authentication & Users

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

πŸ‘€ Customer Management

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

πŸš— Vehicle Management

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

🎟️ Rental Operations

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

🧩 Additional Services

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

πŸ’³ Payment & Invoicing

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

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...

πŸ“– Documentation

API Documentation

The API is documented using Swagger OpenAPI 3.0, providing interactive documentation for all endpoints.

Response Format

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"
}

πŸ’» Contributing

Contributions are welcome! Here's how you can contribute:

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

⭐ Star this repository if you find it helpful!

CarCatalog - Built with ❀️ using Spring Boot and Java

About

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.

Resources

Stars

Watchers

Forks

Contributors

Languages