Bank API Service is a RESTful API service emulating a core banking system. It provides endpoints for managing users, accounts, processing transactions, currency conversion, and retrieving balance summary information.
The project is built on the Spring Boot stack and uses MariaDB as the database, with Hibernate (JPA) for the ORM.
- Java 17
- Spring Boot 3.x
- Spring Web (RESTful API)
- Spring Data JPA (Hibernate)
- Spring Validation
- MariaDB (Database)
- Lombok (Boilerplate code reduction)
- Gradle (KTS) (Build System)
- Account Management: Create accounts in three currencies (USD, EUR, UAH).
- Account Top-up: Deposit funds to any account.
- Funds Transfer: Transfer funds between any two accounts with automatic conversion if the currencies are different.
- Currency Conversion: Transfer funds between accounts of the same user with explicit conversion.
- Balance Aggregation: Get the user's total balance in UAH equivalent, calculated at current exchange rates.
- Transaction Logging: All transactions (top-ups, transfers, conversions) are recorded in the
transactionstable.
Hibernate automatically generates the following schema based on Entities:
users: Stores information about users.accounts: Stores information about the accounts linked to users. Each account has a balance and one of three currencies (USD,EUR,UAH).transactions: Log of all financial transactions (DEPOSIT, TRANSFER, CONVERSION).exchange_rates: Table for storing exchange rates against UAH. (For example,USD_rateToUah = 39.50).
All endpoints are available at the base path /api/v1/bank.
| Method | URL | Description | Request body (JSON) |
|---|---|---|---|
POST |
/deposit |
Account replenishment. | {"accountNumber": "...", "amount": ...} |
POST |
/transfer |
Transfer funds between any two accounts. | {"fromAccountNumber": "...", "toAccountNumber": "...", "amount": ...} |
POST |
/users/{userId}/convert |
Convert currencies between accounts of the same user. | {"fromAccountNumber": "...", "toAccountNumber": "...", "amount": ...} |
GET |
/users/{userId}/total-balance |
Get the user's total balance in UAH. | (None) |
- Clone the repository:
git clone https://github.com/Kitty-Hivens/Bank-API-Spring.git
cd Bank-API-Spring- Configure the database:
- Make sure you have MariaDB installed and running. * Open
src/main/resources/application.properties. - Change the following parameters to reflect your MariaDB settings:
spring.datasource.url=jdbc:mariadb://localhost:3306/bank_db?createDatabaseIfNotExist=true
spring.datasource.username=your_username
spring.datasource.password=your_password- On first run (
spring.jpa.hibernate.ddl-auto=update), Hibernate will automatically create thebank_dbdatabase and all necessary tables.
- Run the application:
./gradlew bootRunOr run BankApplication.java from your IDE.
- Testing:
- The service will be accessible at
http://localhost:8080. - On first run, the
DataInitializerclass will create test exchange rates and two users with a full set of accounts (UAH, USD, EUR) to demonstrate the API.