This project includes a SpringBoot application for handling financial transactions 💸 .
Update: Currency exchange is now performed to the transferred amount (if necessary) by fetching the latest exchange rates from "https://freecurrencyapi.com/"! 💱
Powered by Swagger. Visit "http://localhost:8080/api/swagger-ui/index.html" to explore endpoints and try-out the app! 😊
The Account entity represents a bank account with the following properties:
Field | Description |
---|---|
account_id | Unique identifier of the account |
balance | Decimal number representing the account balance |
currency | Currency of the account (e.g., "GBP") |
createdAt | Date and time when the account was created |
The Transaction entity represents a financial transaction between two accounts and includes the following properties:
Field | Description |
---|---|
transaction_id | Unique identifier of the transaction |
source_account_id | ID of the account sending the funds |
target_account_id | ID of the account receiving the funds |
amount | Amount being transferred |
currency | Currency of the transaction |
The TransactionRequest entity provides idempotent behavior for POST transfer requests.
Field | Description |
---|---|
transactionRequest_id | Unique identifier of the TransactionRequest |
transaction_id | ID of the successful Transaction |
errorMessage | Error message |
requestStatus | Status of the TransactionRequest |
jsonBody | String representation of the jsonBody of the request |
- TransactionController
Container classes, read-only purposes.
Business Logic for executing a request for a financial transaction.
Business logic for performing a financial transactions between two accounts.
Business logic for performing currency exchange.
- TransactionRequest
- Transaction
- Account
JPA repository for each entity.
- Custom exceptions
- GlobalAPIExceptionHandler returns the appropriate HTTP status for each custom exception.
At the moment, integration tests for services are provided. More to come, as the app progresses! Note: Integration tests use H2 embedded db.
- AC 1: Happy path
- AC 2: Insufficient balance
- AC 3: Transfer in the same account
- AC 4: Source/target account does not exist
The app and (Postgres) db are now dockerized! ❤️ Let the magic happen by executing the following commands:
First-time setup:
docker compose up db --build
docker compose up app --build
Note: allow database setup to complete before starting the app container.
Subsequent runs:
docker compose up