This is a simple bank ledger system that utilizes the event sourcing pattern to record all banking transactions as immutable events.
- Each event captures relevant information such as transaction type, amount, timestamp, and account identifier.
- The system allows users to perform basic banking operations such as depositing funds, withdrawing funds, and checking balances.
- The ledger maintains a complete and immutable record of all transactions, enabling auditability and reconstruction of account balances at any point in time.
The service accepts two types of transactions:
-
Loads: Add money to a user (credit)
-
Authorizations: Conditionally remove money from a user (debit)
-
Clone the repository:
git clone "https://github.com/Jason-Wuuuu/Bank-Ledger-System.git" cd "Bank-Ledger-System"
-
Build the project:
mvn clean install
-
Run the application:
mvn spring-boot:run
The API will be accessible via http://localhost:8080
.
-
To perform a ping test:
curl -X GET http://localhost:8080/ping
Successful Response :
{ "serverTime": "string" }
Failed Response :
{ "message": "string", "code": "string" }
-
To perform a load transaction:
curl -X PUT http://localhost:8080/load -H "Content-Type: application/json" -d '[request body]'
Example request body :
{ "messageId": "50e70c62-e480-49fc-bc1b-e991ac672173", "userId": "8786e2f9-d472-46a8-958f-d659880e723d", "transactionAmount": { "amount": "100.23", "currency": "USD", "debitOrCredit": "CREDIT" } }
Make sure to wrap JSON data string (request body) in single quotes if using cURL
Successful Response :
{ "userId": "string", "messageId": "string", "balance": { "amount": "string", "currency": "string", "debitOrCredit": "string" } }
Failed Response :
{ "message": "string", "code": "string" }
-
To perform an authorization:
curl -X PUT http://localhost:8080/authorization -H "Content-Type: application/json" -d '[request body]'
Example request body :
{ "messageId": "50e70c62-e480-49fc-bc1b-e991ac672173", "userId": "8786e2f9-d472-46a8-958f-d659880e723d", "transactionAmount": { "amount": "9000", "currency": "USD", "debitOrCredit": "DEBIT" } }
Make sure to wrap JSON data string (request body) in single quotes if using cURL
Successful Response :
{ "userId": "string", "messageId": "string", "balance": { "amount": "string", "currency": "string", "debitOrCredit": "string" }, "responseCode": "string" }
Failed Response :
{ "message": "string", "code": "string" }