Spring Boot sample app for banking with three entities that are located in postgreSQL database. This app contains the following routes:
- Create a new bank account for a customer, with an initial deposit amount. A single customer may have multiple bank accounts.
- Transfer amounts between any two accounts, including those owned by different customers.
- Retrieve balances for a given account.
- Retrieve transfer history for a given account
- And additionaly, create customer route, for testing purposes!
You can also run it in dev, prod and test environment. When the application is started in test environment, integration tests that use h2 memory database are run.
Once you start the application, the customer table will consist of the following lines:
[
{
"id": 1,
"name": "Arisha Barron"
},
{
"id": 2,
"name": "Branden Gibson"
},
{
"id": 3,
"name": "Rhonda Church"
},
{
"id": 4,
"name": "Georgina Hazel"
}
]
- Installed java 17 on your machine.
- Installed PostgresSQL on your machine and created database with name “bankDB” on port “5432” with credentials:
- username: "postgres"
- password: "postgres"
- Clone the project and build it with the Gradle build tool in order to create a jar file (usually in the build directory).
- Open cmd as administrator
- Type:
java -jar /path/to/jar/file.jar
You can also run it from intellij idea if you have it installed on your local machine with a "Run" button press!
- Type in cmd:
java -jar -Dspring.profiles.active=dev /path/to/jar/file.jar
- Type in cmd:
java -jar -Dspring.profiles.active=prod /path/to/jar/file.jar
Type in cmd:
java -jar -Dspring.profiles.active=test /path/to/jar/file.jar
The REST API to the app is described below.
POST /customer
Request body:
{
"name": "string"
}
Response body:
{
"id": 0
}
POST /bank-account
Request body:
{
"name": "string",
"customerId": 0,
"balance": 0
}
Response body:
{
"id": 0
}
GET /bank-account/bankAccountId/balance
Parameter:
bankAccountId
Response body:
{
"balance": 0
}
POST /transaction
Request body:
{
"fromAccountId": 0,
"toAccountId": 0,
"amount": 0
}
Response body:
{
"id": 0
}
GET /transaction/bankAccountId/history
Parameter:
bankAccountId
Response body:
{
"list": [
{
"id": 0,
"fromAccountId": 0,
"fromAccountName": "string",
"toAccountId": 0,
"toAccountName": "string",
"amount": 0
}
]
}