A simple project based on Java 8, Spring Boot and JUnit.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
What things you need to run the project
Java Development Kit (JDK 8 or newer)
Maven
Docker (if you want to run the application using the Docker image)
Clone the repository
git clone https://github.com/rezaep/loan-payback-planner
Use Maven build tool to compile and build the project.
mvn clean compile
To run unit tests use the following command.
mvn test
To run integration tests use the following command.
mvn verify
To run end-to-end (e2e) tests run following command.
mvn verify
To run all tests together run following command.
mvn test verify
To run the application using Java, run following command.
java -jar target/loan-planner-1.0.0.jar
To run the application using Spring boot maven-plugin, run following command.
mvn spring-boot:run
To run the application using Docker, run following command.
docker run image:tag (e.g. rezaep/loan-payback-planner:latest)
To generate payback plan using a REST client (e.g. cURL) send a POST request to the following URL.
URL: http://localhost:8080/loan/plan/generate
Body:
{
"loanAmount": "5000.00",
"interestRate": "5.00",
"duration": 24,
"startDate": "2018-01-01T00:00:01Z"
}
cURL request:
curl -X POST \
http://localhost:8080/loan/plan/generate \
-H 'Content-Type: application/json' \
-d '{"loanAmount":"5000.00","interestRate":"5.00","duration":24,"startDate":"2020-01-01T00:00:01Z"}'
wget request:
wget --quiet \
--method POST \
--header 'Content-Type: application/json' \
--body-data '{"loanAmount":"5000.00","interestRate":"5.00","duration":24,"startDate":"2020-01-01T00:00:01Z"}' \
--output-document \
- http://localhost:8080/loan/plan/generate
sample JSON response:
[
{
"date": "2020-01-01T00:00:01Z",
"initialOutstandingPrincipal": 5000.00,
"borrowerPaymentAmount": 219.36,
"interest": 20.83,
"principal": 198.53,
"remainingOutstandingPrincipal": 4801.47
},
{
"date": "2020-02-01T00:00:01Z",
"initialOutstandingPrincipal": 4801.47,
"borrowerPaymentAmount": 219.36,
"interest": 20.01,
"principal": 199.35,
"remainingOutstandingPrincipal": 4602.12
},
...,
{
"date": "2021-12-01T00:00:01Z",
"initialOutstandingPrincipal": 218.37,
"borrowerPaymentAmount": 219.28,
"interest": 0.91,
"principal": 218.37,
"remainingOutstandingPrincipal": 0.00
}
]
To package the Jar file inside a Docker image use following commands.
mvn clean compile test verify
docker build -t image:tag . (e.g. rezaep/loan-payback-planner:latest)
- Reza Ebrahimpour - Github
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details