The Car Management System is a RESTful application designed to manage cars and their details, offering features like adding, updating, deleting, searching, pagination, and sorting. The system ensures data integrity through validations and provides a user-friendly interface for developers via APIs.
- Use tools like Postman to interact with the Car Management System by sending requests and viewing responses in a user-friendly interface.
- For command-line testing, cURL or similar tools can be used to simulate API requests.
- Ensure the API endpoints are correctly configured to match the deployment URL:
https://car-management-system-production.up.railway.app. - All API endpoints are mapped under the base path
api/cars.
For example:
https://car-management-system-production.up.railway.app/api/cars/getAllCars.
- URL:
https://car-management-system-production.up.railway.app/api/cars/getAllCars - Method:
GET - Description: Fetches a list of all cars in the database.
- Response: Returns a list of cars as
CarDTOobjects.
- URL:
https://car-management-system-production.up.railway.app/api/cars/addCars - Method:
POST - Description: Adds a list of cars to the database.
- Request Body:
[ { "carName": "Tesla Model S", "carModel": "Model S", "carColor": "White", "carPrice": 75000, "carYear": 2022, "carFuelType": "Electric" } ] - Response: Returns the added cars as
CarDTOobjects. - Validations:
carName: Cannot be blank.carModel: Cannot be blank.carColor: Cannot be blank.carPrice: Must be a positive number.carYear: Must be a valid 4-digit year and not exceed the current year.carFuelType: Must be one of the following:- Petrol
- Diesel
- Electric
- Hybrid
- CNG
- LPG
- petrol
- diesel
- electric
- hybrid
- cng
- lpg
- URL:
https://car-management-system-production.up.railway.app/api/cars/updateCarById/{id} - Method:
PUT - Description: Updates the details of a car with the given ID.
- Request Parameters:
id: The ID of the car to be updated.
- Request Body:
{ "id":41, "carName": "Tesla Model X", "carModel": "Model X", "carColor": "Black", "carPrice": 85000, "carYear": 2023, "carFuelType": "Electric" } - Response: Updated car details as a
CarDTOobject.
- URL:
https://car-management-system-production.up.railway.app/api/cars/deleteCarById/{id} - Method:
DELETE - Description: Deletes a car with the given ID from the database.
- Request Parameters:
id: The ID of the car to be deleted.
- Response: Returns the details of the deleted car as a
CarDTOobject.
- URL:
https://car-management-system-production.up.railway.app/api/cars/search - Method:
GET - Description: Searches for cars based on the provided criteria.
- Request Parameters (Optional):
name: Name of the car.model: Model of the car.year: Year of manufacture.color: Color of the car.fuelType: Fuel type of the car.
- Response: Returns a list of cars matching the criteria.
- URL:
https://car-management-system-production.up.railway.app/api/cars/pagination - Method:
GET - Description: Fetches cars with pagination.
- Request Parameters:
page(default: 0): Page number (starts from 0).size(default: 10): Number of records per page.
- Response: Returns a paginated list of cars.
- URL:
https://car-management-system-production.up.railway.app/api/cars/sorting - Method:
GET - Description: Fetches cars sorted by a specified field.
- Request Parameters:
sortBy(default:carName): Field to sort by.order(default:asc): Sorting order. (ascordesc)
- Response: Returns a sorted list of cars.
- URL:
https://car-management-system-production.up.railway.app/api/cars/pagination-sorting - Method:
GET - Description: Fetches cars with both pagination and sorting.
- Request Parameters:
page(default: 0): Page number.size(default: 10): Number of records per page.sortBy(default:carName): Field to sort by.order(default:asc): Sorting order. (ascordesc)
- Response: Returns a paginated and sorted list of cars.
carName: Cannot be blank.carModel: Cannot be blank.carColor: Cannot be blank.carPrice: Must be a positive number.carYear: Must be a valid year and not exceed the current year.carFuelType: Must be one of the following:- Petrol
- Diesel
- Electric
- Hybrid
- CNG
- LPG
- Spring Boot: For building the RESTful APIs.
- Hibernate/JPA: For database interactions.
- ModelMapper: For object mapping between entities and DTOs.
- Jakarta Validation: For input validations.
- Maven: For dependency management.
- Mysql: For database management.
To run the Car Management System locally, follow these steps:
-
Clone the Repository: Clone the project from your version control system (e.g., GitHub) to your local machine.
git clone https://your-repository-link.git
-
Navigate to the Project Directory: Open your terminal/command prompt and navigate to the project directory.
-
Modify
application.properties: Update theapplication.propertiesfile with your local configuration settings (e.g., database URL, credentials):Example configuration for
application.properties:spring.datasource.url=jdbc:mysql://localhost:3306/car_management spring.datasource.username=root spring.datasource.password=your_password spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.format_sql=true
-
Build the Project: Use Maven to build the project.
mvn clean install
-
Run the Project: After building, you can run the application with the following command:
mvn spring-boot:run
-
Test the API Endpoints with Postman: Use Postman to test the API endpoints. The URLs will be the same as the ones mentioned earlier, but replace the deployment link with
http://localhost:8080if you are running it locally.Example:
- URL:
http://localhost:8080/api/cars/getAllCars - Method:
GET
Postman will allow you to interact with the REST API by sending requests and viewing responses in a user-friendly way.
- URL:



