Skip to content

YOUHAD08/e-bank-backend-springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’³ E-BANK Backend Application

A robust and modular backend banking system built with Spring Boot, Spring Data JPA, and MariaDB/MySQL.

This backend powers core banking features such as customer management, bank account operations (debit, credit, transfer), and full transaction history. The application is structured with clean architectural separation (DTOs, services, mappers, exception handling) and JWT-based security.

⚠️ This repository contains the backend only. The Angular frontend is implemented in this repository.


πŸš€ Features

βœ… Customer Management

  • Create, update, retrieve, and delete customers.
  • Search customers by keyword or exact name.

βœ… Bank Account Management

  • Supports Current Accounts (with overdraft) and Saving Accounts (with interest rate).
  • Create, update, delete, and retrieve bank accounts.
  • Retrieve accounts by customer.

βœ… Account Operations

  • Debit, credit, and transfer between accounts.
  • Track full transaction history with pagination and summaries.

βœ… Advanced History API

  • Structured account history using AccountHistoryDTO.
  • Access latest operation summaries.

βœ… Security & Authentication

-JWT-based authentication with role-based access control (USER and ADMIN scopes). Password encryption using BCrypt.

βœ… Exception Handling

Handles common banking errors:

  • CustomerNotFoundException
  • BankAccountNotFoundException
  • InsufficientBalanceException

βœ… API Documentation

Interactive Swagger UI at:

http://localhost:8085/swagger-ui/index.html


πŸ“‚ Project Structure

Backend Project Structure

  • Entities: Customer, BankAccount, CurrentAccount, SavingAccount, AccountOperation
  • DTOs: Transfer objects for API communication
  • Repositories: Spring Data JPA Repositories
  • Services: Business logic with interfaces and implementations
  • Controllers: REST API endpoints secured by JWT scopes
  • Mappers: Entity ↔ DTO transformation
  • Exceptions: Custom exceptions for domain errors
  • Security: JWT generation and validation, password encoding

🧩 MySQL Database Structure

This backend currently uses a relational MySQL database to persist customer, account, and transaction data.

MySQL Database Schema

πŸ”— Relationships

  • 1️⃣ Customer ⇨ N BankAccounts
  • 1️⃣ BankAccount ⇨ N AccountOperations

πŸ› οΈ Technologies Used

Technology Version
Java 21
Spring Boot 3.5.3
Spring Data JPA Included
MySQL 8+
Lombok 1.18.34
Swagger / OpenAPI 2.5.0
Maven Build Tool
H2 (optional) For testing
JWT (Nimbus JOSE) included
BCrypt Password Encoding

πŸ’» Getting Started

Prerequisites

  • Java 21+
  • Maven
  • MySQL running (DB name: E-BANK)
  • (Optional) phpMyAdmin or MySQL client

βš™οΈ Setup & Run

  1. Clone this repository:
    git clone https://github.com/YOUHAD08/e-bank-backend-springboot.git
    cd e-bank-backend-springboot
    
    
  2. Configure database in src/main/resources/application.properties:
    spring.datasource.url=jdbc:mysql://localhost:3306/E-BANK?createDatabaseIfNotExist=true
    spring.datasource.username=root
    spring.datasource.password=
    
  3. Build & Run
     mvn clean install
     mvn spring-boot:run
    
  4. Access the APIs:

πŸ“„ API Overview

Customer API (/auth)

  • POST /auth/login β€” Login with username and password, returns JWT token.
  • POST /auth/signup β€” Register a new customer (role USER by default).
  • GET /auth/profile β€” Get current authenticated user details.

Customer API (/customer, /customers)

  • GET /customers β€” List all customers.
  • GET /customer/{id} β€” Get customer by ID.
  • GET /customers/search?keyword= β€” Search customers by keyword.
  • GET /customer/search?name= β€” Search customer by exact name.
  • POST /customer β€” Create customer (ADMIN only).
  • PUT /customer/{id} β€” Update customer (ADMIN only).
  • DELETE /customer/{id} β€” Delete customer (ADMIN only)

Bank Account API (/account, /accounts, /currentAccount, /savingAccount)

  • GET /account/{accountId}β€” Get bank account by ID.
  • GET /accounts β€” List all accounts.
  • GET /accounts/{customerId} β€” List all accounts of a customer.
  • POST /currentAccount/{customerId} β€” Create current account (ADMIN only).
  • POST /savingAccount/{customerId} β€” Create saving account (ADMIN only).
  • PUT /currentAccount/{accountId} β€” Update current account (ADMIN only).
  • PUT /savingAccount/{accountId} β€” Update saving account (ADMIN only).
  • DELETE /account/{accountId} β€” Delete account (ADMIN only).

Account Operations API (/account/{accountId}/operations)

  • GET /account/{accountId}/operations β€” List all operations for an account.
  • GET /account/{accountId}/pageOperations?page=&size= β€” Paginated operations list.
  • POST /account/{accountId}/debit?amount=&description= β€” Debit an account.
  • POST /account/{accountId}/credit?amount=&description= β€” Credit an account (ADMIN only).
  • POST /account/{accountId}/transfer?toAccountId=&amount= β€” Transfer money (ADMIN only).
  • GET /operations β€” List all account operations.

πŸ“š Exception Handling

  • CustomerNotFoundException - Thrown when a customer is not found.
  • BankAccountNotFoundException - Thrown when a bank account is not found.
  • InsufficientBalanceException - Thrown when an account has insufficient funds for a debit or transfer.

πŸ§ͺ Database Initialization

On startup, the application seeds the database with:

  • 10 customers with realistic names, cities, and emails.
  • 3 to 5 random accounts per customer (mix of current and saving).
  • 10 to 20 random debit and credit operations per account.

🀝 Contribution

Contributions are welcome! Feel free to open issues or pull requests so we grow together.


πŸ–₯️ Next Steps: Agentic AI & Future Database Migration

This project currently implements the backend RESTful API using Spring Boot and a relational MySQL database.

πŸ”œ Upcoming Plans

πŸ› οΈ Frontend (Done):

The frontend is currently under development using Angular and is structured to provide a clean and interactive UI for:

  • Customer and account management
  • Performing debit/credit/transfer operations
  • Viewing paginated account operation history
  • ... and more features to come

πŸ€– Agentic AI Integration (In Progress):

In future development, I plan to build an agentic AI component to work alongside this backend. While the full scope is yet to be defined, potential features might include:

  • Intelligent customer support and chatbot integration
  • Automated transaction analysis and fraud detection
  • Personalized financial advice and account management
  • Dynamic task automation within the banking system

This agentic AI will aim to enhance user experience, improve operational efficiency, and provide smart automation capabilities.

πŸ” Future Migration to MongoDB:

Although this version uses MySQL, a future version of this backend will be migrated to MongoDB to take advantage of:

  • Flexible document-based schema
  • Easier scalability
  • Faster iterations in development

Stay tuned for the agentic AI enhancements, and the MongoDB-backed backend!


Developed by Youhad
Β© 2025

About

Spring Boot backend for E-Banking with JWT security, customer/account management, transactions, and MySQL. Clean, scalable, and ready for AI and NoSQL upgrades.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages