Skip to content

Transactional REST API prototype. Focuses on concurrent account operations, ACID compliance fundamentals, and secure data handling.

Notifications You must be signed in to change notification settings

Kitty-Hivens/Bank-API-Spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bank API Service

About the Project

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.

Technology Stack

  • 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)

Key Features

  • 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 transactions table.

Database Structure

Hibernate automatically generates the following schema based on Entities:

  1. users: Stores information about users.
  2. accounts: Stores information about the accounts linked to users. Each account has a balance and one of three currencies (USD, EUR, UAH).
  3. transactions: Log of all financial transactions (DEPOSIT, TRANSFER, CONVERSION).
  4. exchange_rates: Table for storing exchange rates against UAH. (For example, USD_rateToUah = 39.50).

API Endpoints

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)

Installation and Run

  1. Clone the repository:
git clone https://github.com/Kitty-Hivens/Bank-API-Spring.git
cd Bank-API-Spring
  1. 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 the bank_db database and all necessary tables.
  1. Run the application:
./gradlew bootRun

Or run BankApplication.java from your IDE.

  1. Testing:
  • The service will be accessible at http://localhost:8080.
  • On first run, the DataInitializer class will create test exchange rates and two users with a full set of accounts (UAH, USD, EUR) to demonstrate the API.

About

Transactional REST API prototype. Focuses on concurrent account operations, ACID compliance fundamentals, and secure data handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages