bank-management-spring-boot

Bank Management System - Full Documentation

1. Overview

This document provides system documentation for the Bank Management System. Originally a simple monolithic web application, it has been architected into a multi-container system with a separate frontend landing page and a Spring Boot backend, orchestrated by Docker and served through an Nginx reverse proxy.

The application simulates core banking functionalities including user management (Manager, Staff, Customer), account management, loan/FD applications, and grievance filing.

2. Features

2.1 Core Features

2.2 Manager Features (ROLE_MANAGER)

2.3 Staff Features (ROLE_STAFF)

2.4 Customer Features (ROLE_CUSTOMER)

3. Architecture

The application was initially developed as a pure Spring Boot monolith. To gain experience with modern DevOps practices, Nginx, and a decoupled frontend, the architecture was evolved into a multi-container system.

The system is orchestrated by Docker Compose and consists of three main services:

3.1 Nginx Reverse Proxy (nginx service):

*   Acts as the single entry point for all web traffic.
*   Listens on ports 80 and 443.
*   Serves the static landing page for the root path (`/`).
*   Routes all other requests starting with `/login`, `/dashboard`, `/manager`, `/staff`, `/customer`, etc., to the Spring Boot backend service.
*   Handles SSL/TLS termination, providing HTTPS for the entire application.

3.2 Frontend (frontend service):

*   A static website built using **Vite + Tailwind CSS**.
*   This container runs an Nginx server configured to serve the compiled `dist` folder generated by the Vite build process.
*   Contains a "Login" button that links to the `/login` path, which is handled by the backend.

3.3 Backend (backend service):

The application follows principles of Clean Code Architecture, promoting separation of concerns and maintainability. The main layers are:

3.3.1 Presentation Layer (controller, templates)

3.3.2 Application Layer (service, service.impl, dto, mapper)

3.3.3 Domain Layer (model, exception)

3.3.4 Persistence Layer (repository, util)

3.3.5 Security Layer (security)

Production Deployment Architecture:

4. Technology Stack

5. Project Structure

The project structure has evolved to support the multi-container setup:

bank-management/
├── pom.xml # Maven build configuration
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/bankmanagement/
│ │ │ ├── BankManagementApplication.java # Main application class
│ │ │ ├── controller/ # Spring MVC Controllers (Presentation Layer)
│ │ │ ├── dto/ # Data Transfer Objects
│ │ │ ├── exception/ # Custom Exceptions & Global Handler
│ │ │ ├── mapper/ # DTO <-> Entity Mappers
│ │ │ ├── model/ # Domain Entities & Enums
│ │ │ ├── repository/ # Data Access Interfaces
│ │ │ ├── security/ # Spring Security Configuration
│ │ │ ├── service/ # Business Logic Interfaces
│ │ │ │ └── impl/ # Business Logic Implementations
│ │ │ └── util/ # Utility classes (e.g., AccountNumberGenerator)
│ │ └── resources/
│ │ ├── application.properties # Spring Boot configuration (DB, server, etc.)
│ │ ├── data.sql # Initial data seeding (Manager user)
│ │ ├── static/ # Static web resources (CSS, JS, images)
│ │ │ └── css/style.css
│ │ └── templates/ # Thymeleaf view templates (.html)
│ │ ├── layout.html # Main layout template
│ │ ├── login.html # Login page
│ │ ├── error.html # Generic error page
│ │ ├── dashboard-.html # Role-specific dashboards
│ │ ├── manager/ # Manager-specific views
│ │ ├── staff/ # Staff-specific views
│ │ └── customer/ # Customer-specific views
│ └── test/ # Unit and integration tests
├── frontend/ # Contains the Vite + Tailwind CSS landing page
├── nginx/ # Configuration for the reverse proxy
│ └── nginx.conf
├── Dockerfile # Instructions to build Docker image
├── Dockerfile.frontend # Instructions to build Docker image
└── docker-compose-db.yml # Running PostgreSQL locally with Docker Compose
└── docker-compose.prod.yml # Docker Compose for production
└── env.example # Template for environment variables

6. Database Schema

The database schema is derived from the JPA entity definitions in the model package. Key entities include:

Key Enums: Role, AccountStatus, AccountType, RequestStatus, TransactionType.

7. Security Implementation

8. Setup and Running Locally

Prerequisites:

Steps:

  1. Clone the Repository:

    git clone https://github.com/frhanjav/bank-management-spring-boot.git
    cd bank-management-spring-boot
    
  2. Update data.sql:
    • Open src/main/resources/data.sql.
    • IMPORTANT: Replace the placeholder bcrypt hash for the manager user with a hash generated for your desired password. You can use online tools or a simple Java program with BCryptPasswordEncoder.
  3. Build the Application:

    ./mvnw clean package
    
  4. Create .env File: The application is configured to read database credentials from an environment file. Copy the example file:

    cp env.example .env
    
  5. Configure Credentials: Open the newly created .env file and fill in the connection details for your PostgreSQL database:

    # .env file
    DB_HOST=<your_database_host_ip>
    DB_PORT=<your_database_port>
    DB_NAME=<your_database_name>
    DB_USERNAME=<your_database_username>
    DB_PASSWORD=<your_database_password>
    
  6. Run the Docker Container: Execute the docker run command, which pulls the image from GitHub Container Registry and injects the environment variables from your .env file.

     docker compose -f docker-compose-db.yml up -d
    
  7. Run the Application:

    ./mvnw spring-boot:run
    # OR run the JAR directly:
    # java -jar target/bank-management-0.0.1-SNAPSHOT.jar
    
  8. Access: Open your web browser and navigate to http://localhost:8080. You will be redirected to the login page (http://localhost:8080/login).

  9. Login: Use the manager credentials (username: manager, password: the one you hashed and put in data.sql).

9. Key Workflows Summary


This documentation provides a snapshot of the system. Refer to the source code for the most up-to-date implementation details.