Skip to content

An API that simulates a Decent Online Banking System, allows all CRUD operations performed by a user on ATM or Mobile App. This project is still in progress.

Notifications You must be signed in to change notification settings

devhnry/Online-Banking-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 Online Banking System Backend

A robust, secure banking backend API built with Spring Boot 3.2.4 and Java 21, featuring comprehensive banking operations, JWT authentication, and email integration.

🌟 Features

πŸ” Authentication & Security

  • JWT-based authentication with refresh token support
  • Role-based authorization (Customer/Admin)
  • Password strength validation
  • OTP verification for account activation
  • Secure password hashing with BCrypt

πŸ’° Core Banking Operations

  • Account creation and management
  • Money deposit and withdrawal
  • Fund transfers between accounts
  • Balance inquiries and transaction history
  • Transaction limits management
  • Real-time balance updates

πŸ“§ Communication (Enable or Disable in property file)

  • Email notifications with HTML templates
  • OTP generation and verification
  • Welcome emails for new customers
  • Password reset notifications

πŸ›‘οΈ Security Features

  • Global exception handling
  • Input validation
  • Transaction logging
  • Account suspension capabilities
  • Secure API endpoints

πŸ› οΈ Tech Stack

Backend Framework

  • Java 21 - Latest LTS version
  • Spring Boot 3.2.4 - Main framework
  • Spring Security 6.2.4 - Authentication & authorization
  • Spring Data JPA - Data persistence
  • Hibernate - ORM framework

Database

  • MySQL 8.0 - Production database
  • H2 - In-memory database for testing

Security & Authentication

  • JWT (jjwt) 0.12.5 - Token management
  • BCrypt - Password hashing

Email & Templates

  • Spring Boot Mail - Email service
  • Thymeleaf - HTML email templates

Build & Deployment

  • Maven 3.10.1 - Build tool
  • Docker & Docker Compose - Containerization
  • JUnit 5 - Testing framework

πŸš€ Getting Started

Prerequisites

  • Java 21 JDK
  • Maven 3.10.1+
  • MySQL 8.0 (or Docker)
  • Git

Environment Setup

  1. Clone the repository

    git clone https://github.com/devhnry/online-banking-backend.git
    cd online-banking-backend
  2. Set up environment variables (Depending on 'dev or qa' environment)

    # Database Configuration
    export DATABASE_NAME=your_db_name
    export DATABASE_USERNAME=your_db_username
    export DATABASE_PASSWORD=your_db_password
    
    # Email Configuration (Gmail SMTP)
    export EMAIL_HOST=smtp.gmail.com
    export EMAIL_PASSWORD=your_app_password
    export [email protected]
    export EMAIL_PORT=587
  3. Database Setup

    CREATE DATABASE onlinebanking;
    CREATE USER 'banking_user'@'localhost' IDENTIFIED BY 'your_password';
    GRANT ALL PRIVILEGES ON onlinebanking.* TO 'banking_user'@'localhost';

Running the Application

Local Development

# Install dependencies
mvn clean install

# Run the application
mvn spring-boot:run

Accessing the Application

  • API Base URL: http://localhost:6000
  • H2 Console (Development): http://localhost:6000/h2-console
  • Health Check: GET http://localhost:6000/actuator/health

πŸ“‹ API Documentation

Authentication Endpoints

Method Endpoint Description Auth Required
POST /auth/onboard Register new customer ❌
POST /auth/send-otp Send OTP for verification ❌
POST /auth/onboard/verify-otp Verify OTP and activate account ❌
POST /auth/login Customer login ❌
POST /auth/refresh-token Refresh access token ❌
POST /auth/login Customer login ❌
POST /auth/refresh-token Refresh access token ❌

Account Management

Method Endpoint Description Auth Required
GET /api/v1/account/get-details Get customer details βœ…
GET /api/v1/account/view-balance Check account balance βœ…
POST /api/v1/account/make-deposit Deposit money βœ…
POST /api/v1/account/withdraw Withdraw money βœ…
POST /api/v1/account/make-transfer Transfer funds βœ…
POST /api/v1/account/get-transfer-summary Get transfer summary βœ…
GET /api/v1/account/details Get account holder name βœ…
GET /api/v1/account/view-bank-statement View transaction history βœ…
PUT /api/v1/account/change-password Change password βœ…
PATCH /api/v1/account/update-profile Update profile information βœ…
PUT /api/v1/account/update-transaction-limit Update transaction limit βœ…

Currently Inactive Endpoints

⚠️ Note: The following endpoints exist in the codebase but are not fully implemented:

Method Endpoint Description Status
PUT /api/v1/admin/suspend/{id} Suspend user account 🚧 Returns empty response
GET /api/v1/account/send-otp Generate OTP 🚧 Returns empty response
PUT /api/v1/account/forgot-password Reset password 🚧 Returns empty response

Kora Virtual Account endpoints (/api/v1/kora/**) are commented out and not active.

Test Database

The application uses H2 in-memory database for testing with automatic schema generation.

πŸ“ Project Structure

src/
β”œβ”€β”€ main/
β”‚   β”œβ”€β”€ java/org/henry/bankingsystem/
β”‚   β”‚   β”œβ”€β”€ config/              # Security & application configuration
β”‚   β”‚   β”œβ”€β”€ controller/          # REST API endpoints
β”‚   β”‚   β”œβ”€β”€ dto/                 # Data Transfer Objects
β”‚   β”‚   β”œβ”€β”€ entity/              # JPA entities
β”‚   β”‚   β”œβ”€β”€ enums/               # Enumerations
β”‚   β”‚   β”œβ”€β”€ exceptions/          # Custom exceptions & handlers
β”‚   β”‚   β”œβ”€β”€ repository/          # Data access layer
β”‚   β”‚   β”œβ”€β”€ service/             # Business logic
β”‚   β”‚   └── utils/               # Utility classes
β”‚   └── resources/
β”‚       β”œβ”€β”€ templates/           # Email templates
β”‚       └── application*.yml     # Configuration files
└── test/                        # Test files

πŸ”§ Configuration

Application Profiles

  • dev: Development environment with local MySQL
  • qa: Testing environment with cloud database

Key Configuration Properties

server:
  port: 6000

spring:
  profiles:
    active: dev
  
  datasource:
    url: jdbc:mysql://localhost:3306/${DATABASE_NAME}
    username: ${DATABASE_USERNAME}
    password: ${DATABASE_PASSWORD}

πŸ” Security Implementation

JWT Configuration

  • Access token expiry: 24 hours
  • Refresh token for seamless authentication
  • Stateless session management

Password Security

  • BCrypt hashing with strength 12
  • Password strength validation (uppercase, numbers, special characters)
  • 4-digit PIN for transactions

API Security

  • All endpoints except auth require valid JWT
  • Role-based access control
  • Request/response logging for audit

πŸ‘¨β€πŸ’» Author

Henry


Postman Collection

πŸ“ž Support

For support, email me at [email protected] or create an issue in this repository.

About

An API that simulates a Decent Online Banking System, allows all CRUD operations performed by a user on ATM or Mobile App. This project is still in progress.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published