This Spring application provides a RESTful API for managing bank accounts, including creating accounts, depositing money, transferring funds between accounts, and checking account balances.
These instructions will help you get the project up and running on your local machine for development and testing purposes, whether you're using Linux or Windows.
- Java JDK 17 or later
- Maven 3.2+ (if not using the Maven Wrapper)
-
Clone the repository:
git clone https://github.com/Christian-G-J/bankaccountapi.git
-
Build the project:
- Using Maven:
mvn clean install
- Or using the Maven Wrapper:
- For Linux:
./mvnw clean install
- For Windows:
mvnw.cmd clean install
- For Linux:
- Using Maven:
-
Run the application:
- Using Maven:
mvn spring-boot:run
- Or using the Maven Wrapper:
- For Linux:
./mvnw spring-boot:run
- For Windows:
mvnw.cmd spring-boot:run
- For Linux:
- Using Maven:
The application should now be running and accessible at http://localhost:8080
.
Additionally, you can access the database console at http://localhost:8080/h2
.
Upon startup, the application will automatically populate the in-memory H2 database with a set of predefined bank accounts for immediate use and testing.
The following endpoints are available:
- Method: POST
- Endpoint:
/accounts
- Description: Creates a new bank account.
- Payload Example:
{ "accountNumber": "123456", "firstName": "John", "lastName": "Doe", "balance": "1000.00" }
- cURL Example:
curl -X POST http://localhost:8080/accounts \ -H 'Content-Type: application/json' \ -d '{ "accountNumber": "123456", "firstName": "John", "lastName": "Doe", "balance": "1000.00" }'
- Method: PUT
- Endpoint:
/accounts/{accountNumber}/deposit
- Description: Deposits money into an account.
- Parameters:
amount
- cURL Example:
curl -X PUT 'http://localhost:8080/accounts/123456/deposit?amount=500'
- Method: PUT
- Endpoint:
/accounts/{sourceAccountNumber}/transfer
- Description: Transfers money from one account to another.
- Parameters:
destinationAccountNumber
,amount
- cURL Example:
curl -X PUT 'http://localhost:8080/accounts/123456/transfer?destinationAccountNumber=654321&amount=200'
- Method: GET
- Endpoint:
/accounts/{accountNumber}/balance
- Description: Retrieves the balance of a specific account.
- cURL Example:
curl -X GET http://localhost:8080/accounts/123456/balance
To run the automated tests for this system:
- Using Maven:
mvn test
- Or using the Maven Wrapper:
- For Linux:
./mvnw test
- For Windows:
mvnw.cmd test
- For Linux: