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.
ROLE_MANAGER
)data.sql
.ROLE_STAFF
)ROLE_CUSTOMER
)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:
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.
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.
backend
service):The application follows principles of Clean Code Architecture, promoting separation of concerns and maintainability. The main layers are:
controller
, templates
)@Controller
).*.html
) for rendering dynamic HTML views.service
, service.impl
, dto
, mapper
)AccountService
, UserService
, etc.).AccountServiceImpl
, etc.) which orchestrate calls to repositories and enforce business rules.AccountMapper
, etc.) to convert between Entities and DTOs.model
, exception
)User
, Account
, Customer
, Loan
, etc.ResourceNotFoundException
, InsufficientBalanceException
, etc.).repository
, util
)AccountRepository
) using Spring Data conventions.AccountNumberGenerator
may reside here.security
)SecurityConfig
– defines HTTP security rules.UserDetailsServiceImpl
– loads user-specific data for authentication.CustomAccessDeniedHandler
– handles unauthorized access attempts.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
The database schema is derived from the JPA entity definitions in the model
package. Key entities include:
users
(User.java
): Stores login credentials (username
, password
), role
(Enum: MANAGER, STAFF, CUSTOMER), and enabled
status.managers
(Manager.java
): Manager-specific details, linked one-to-one with users
.staff
(Staff.java
): Staff-specific details, linked one-to-one with users
.customers
(Customer.java
): Customer profile information (name
, email
, phone
, address
, panNumber
, active
status), linked one-to-one with users
.accounts
(Account.java
): Bank account details (accountNumber
, balance
, status
[Enum: PENDING_APPROVAL, ACTIVE, etc.], accountType
[Enum: SAVINGS, CURRENT]), linked many-to-one with customers
and optionally managers
(approver).transactions
(Transaction.java
): Records deposits/withdrawals (transactionType
[Enum], amount
, timestamp
, description
), linked many-to-one with accounts
and optionally staff
(performer). Note: Table name is transactions
due to SQL keyword conflict.loans
(Loan.java
): Loan application details (loanAmount
, interestRate
, termMonths
, status
[Enum: PENDING, APPROVED, REJECTED, etc.]), linked many-to-one with customers
and optionally managers
(approver).fixed_deposits
(FixedDeposit.java
): FD details (principalAmount
, interestRate
, termMonths
, maturityDate
, status
), linked many-to-one with customers
and optionally managers
(approver).grievances
(Grievance.java
): Customer grievance details (subject
, description
, status
, submittedDate
, resolvedDate
), linked many-to-one with customers
and optionally users
(handler).Key Enums: Role
, AccountStatus
, AccountType
, RequestStatus
, TransactionType
.
SecurityConfig.java
).
UserDetailsServiceImpl
to load user data from the users
table.BCryptPasswordEncoder
for secure password hashing (jBCrypt recommended if not using Spring Security)./login
./login
.SecurityConfig.java
using http.authorizeHttpRequests()
and role checks (.hasRole("MANAGER")
, etc.)..anyRequest().authenticated()
ensures all other paths require login.@PreAuthorize
(requires @EnableMethodSecurity
).CustomAccessDeniedHandler
intercepts 403 Forbidden errors.csrf(AbstractHttpConfigurer::disable)
) for simplicity. Enable and configure properly for production.Prerequisites:
Steps:
Clone the Repository:
git clone https://github.com/frhanjav/bank-management-spring-boot.git
cd bank-management-spring-boot
data.sql
:
src/main/resources/data.sql
.manager
user with a hash generated for your desired password. You can use online tools or a simple Java program with BCryptPasswordEncoder
.Build the Application:
./mvnw clean package
Create .env
File: The application is configured to read database credentials from an environment file. Copy the example file:
cp env.example .env
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>
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
Run the Application:
./mvnw spring-boot:run
# OR run the JAR directly:
# java -jar target/bank-management-0.0.1-SNAPSHOT.jar
Access: Open your web browser and navigate to http://localhost:8080
. You will be redirected to the login page (http://localhost:8080/login
).
username: manager
, password: the one you hashed and put in data.sql
).data.sql
.This documentation provides a snapshot of the system. Refer to the source code for the most up-to-date implementation details.