This is a simple REST API for managing car lease contracts. It is written in Java using Spring Boot and Spring Data JPA and uses mysql as the database.
It uses Flyway for database migrations including the initial schema creation and data seeding.
- Java 11
- Docker
- Gradle
- MySQL
Vehicle
- a car that can be leasedContract
- a lease contract for a vehicleCustomer
- a customer who can lease a vehicle
The REST endpoints are exposed by Spring Data REST. The following endpoints are available:
GET /vehicles
- list all vehiclesGET /vehicles/{id}
- get a vehicle by idPOST /vehicles
- create a new vehiclePUT /vehicles/{id}
- update a vehiclePATCH /vehicles/{id}
- partially update a vehicleDELETE /vehicles/{id}
- delete a vehicleGET /contracts
- list all contractsGET /contracts/{id}
- get a contract by idPOST /contracts
- create a new contractPUT /contracts/{id}
- update a contractPATCH /contracts/{id}
- partially update a contractDELETE /contracts/{id}
- delete a contractGET /customers
- list all customersGET /customers/{id}
- get a customer by idPOST /customers
- create a new customerPUT /customers/{id}
- update a customerPATCH /customers/{id}
- partially update a customerDELETE /customers/{id}
- delete a customer
The tests can be run using the following command:
./gradlew test
The application can be built using the following command:
./gradlew build
The docker image can be built using the following command:
./gradlew bootBuildImage
The application can be run using the following command:
./gradlew bootRun
The application can be run in a containerized environment using the following command:
docker-compose up
In order to run the application in a containerized environment, the following environment variables need to be set:
MYSQL_ROOT_PASSWORD
- the root password for the mysql databaseMYSQL_PASSWORD
- the password for the database
In order to create environment variables, create a .env
file in the root directory of the project and add the following lines:
MYSQL_ROOT_PASSWORD=secret
MYSQL_PASSWORD=secret