Car Dealer API allows the dealer/user to add new cars, and search the inventory based on several parameters and different criterias. The API also allows user to get a particular recommendation based on a pre-defined deal, which is configured in the application.
Below instructions will get you a copy of up and running project on your local machine for development and testing purposes.
- Spring Boot: The Spring Boot Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform.
- Java 8 - Java
- MongoDB - A Document based distributed database. for this project, we are using embedded mongodb, so we don't need to install anything.
- Swagger - Interactive API documentation
- Lombok - Java library that automatically plugs into your editor and build tools
- Maven - Maven 3.6.1
Backend - Spring Boot : Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". Embedded Tomcat provides a quick way to run our applications on any servers without prior setup or installation of any webservers. Sring boot makes it easier to scale up the application vertically on any given cloud platforms.
Database - Mongo DB : MongoDB is a general purpose, document-based, distributed database built for the cloud era. Considering the load on Car dealer application, search feature and complex suggestion based on various parameters would be used most. Keeping this in mind Mongo DB stands out the best as it provides a faster reading capability compared to various databases, and can also handle complex query which can be run directly on a database.
- Java 8, Maven are installed.
- IDE used : Intellij with lombok plugin installed
- Step 1: Checkout the above mentioned application and navigate to root folder.
- Step 2: Use
mvn clean install
to build the application. - Step 3: Use
mvn spring-boot:run
to start the application using default profile.
-
Rest API Documentation is available at :
http://localhost:8080/rhdhv/swagger-ui.html
-
HealthCheck is available at :
http://localhost:8080/rhdhv/healthcheck.html
- To Create Cars, please find below example request : POST
localhost:8080/rhdhv/cars
{
"brand": "Honda",
"fuelConsumption": 10,
"maintenanceCost": 100,
"model": "CR-V",
"price": 11000,
"version": 1,
"yearOfRelease": 2019
}
- To Search for Cars, please find below a sample search request : POST
localhost:8080/rhdhv/cars/search
{
"search": {
"brand": {
"type": "string",
"value": "Honda",
"comparison": "eq"
},
"yearOfRelease": {
"type": "number",
"value": 2020,
"comparison": "eq"
}
},
"sort": {
"field": "fuelConsumption",
"sortType": "desc"
}
}
- To suggest a recommendation, please find below a sample search request : POST
localhost:8080/rhdhv/cars/deal
{
"searchRequest": {
"search": {
"yearOfRelease": {
"type": "number",
"value": 2019,
"comparison": "eq"
}
},
"sort": null
},
"deal": {
"dealType": "lowAnnualMaintenance",
"fuelRate": 10,
"travelDistance": 250
}
}
- Naushad Mohammed