Skip to content

NJVinay/Java-Banking-Enterprise-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Java Enterprise Banking System

Java Spring Boot Maven MySQL JUnit

A production-ready, enterprise-grade banking system built with Java, Spring Boot, and MySQL. This multi-tier application demonstrates advanced software engineering principles with 5,000+ lines of well-architected, testable code.

🎯 Key Features

Core Banking Operations

  • Deposits, Withdrawals, Transfers with ACID-compliant transactions
  • Balance Inquiries with transaction history
  • Multi-Account Support (Checking, Savings, Credit accounts)
  • ATM Operations simulation
  • Real-time Transaction Notifications (Email, SMS)

Security & Authentication

  • BCrypt Password Hashing (12-round encryption)
  • Account Lockout after failed login attempts
  • Role-Based Access Control (Customer, Teller, Manager, Admin)
  • Secure Transaction Management with optimistic locking

Additional Modules

  • Library Management System - Book borrowing and tracking
  • Inventory Management System - Stock tracking and reorder management

πŸ—οΈ Architecture

Three-Tier Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         PRESENTATION LAYER (Controllers)        β”‚
β”‚    REST APIs for Banking, ATM, Library, etc.   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       BUSINESS LOGIC LAYER (Services)           β”‚
β”‚   Transaction Management, Authentication, etc.  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         DATA ACCESS LAYER (Repositories)        β”‚
β”‚    JPA/Hibernate ORM with MySQL Database       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Design Patterns Implemented

Pattern Implementation Purpose
Singleton DatabaseConnectionManager Thread-safe database connection management
Factory AccountFactory Dynamic account creation (Checking, Savings, Credit)
DAO *Repository interfaces Data access abstraction layer
MVC Controllers, Services, Entities Separation of concerns
Observer TransactionNotifier, *Observer Real-time transaction notifications

πŸš€ Technology Stack

  • Java 17 - Core programming language
  • Spring Boot 3.2.0 - Application framework
  • Spring Data JPA - Data persistence
  • Hibernate ORM - Object-relational mapping
  • MySQL 8.0+ - Relational database
  • Spring Security - Authentication & authorization
  • BCrypt - Password encryption
  • JUnit 5 - Unit testing framework
  • Mockito - Mocking framework for tests
  • Maven - Build automation
  • Lombok - Reduce boilerplate code

πŸ“¦ Project Structure

src/
β”œβ”€β”€ main/
β”‚   β”œβ”€β”€ java/com/enterprise/banking/
β”‚   β”‚   β”œβ”€β”€ BankingSystemApplication.java      # Main application class
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── SecurityConfig.java            # Security configuration
β”‚   β”‚   β”œβ”€β”€ controller/                        # REST Controllers (MVC)
β”‚   β”‚   β”‚   β”œβ”€β”€ AccountController.java
β”‚   β”‚   β”‚   β”œβ”€β”€ AtmController.java
β”‚   β”‚   β”‚   β”œβ”€β”€ BankingController.java
β”‚   β”‚   β”‚   β”œβ”€β”€ InventoryController.java
β”‚   β”‚   β”‚   └── LibraryController.java
β”‚   β”‚   β”œβ”€β”€ dto/                               # Data Transfer Objects
β”‚   β”‚   β”‚   β”œβ”€β”€ TransactionRequest.java
β”‚   β”‚   β”‚   └── TransactionResponse.java
β”‚   β”‚   β”œβ”€β”€ exception/                         # Custom exceptions
β”‚   β”‚   β”‚   β”œβ”€β”€ AccountNotFoundException.java
β”‚   β”‚   β”‚   β”œβ”€β”€ BankingException.java
β”‚   β”‚   β”‚   └── InsufficientFundsException.java
β”‚   β”‚   β”œβ”€β”€ model/                             # Entity models
β”‚   β”‚   β”‚   β”œβ”€β”€ Account.java
β”‚   β”‚   β”‚   β”œβ”€β”€ Customer.java
β”‚   β”‚   β”‚   β”œβ”€β”€ InventoryItem.java
β”‚   β”‚   β”‚   β”œβ”€β”€ LibraryBook.java
β”‚   β”‚   β”‚   β”œβ”€β”€ Transaction.java
β”‚   β”‚   β”‚   └── User.java
β”‚   β”‚   β”œβ”€β”€ pattern/                           # Design patterns
β”‚   β”‚   β”‚   β”œβ”€β”€ AccountFactory.java            # Factory pattern
β”‚   β”‚   β”‚   β”œβ”€β”€ DatabaseConnectionManager.java # Singleton pattern
β”‚   β”‚   β”‚   β”œβ”€β”€ EmailNotificationObserver.java # Observer pattern
β”‚   β”‚   β”‚   β”œβ”€β”€ SmsNotificationObserver.java   # Observer pattern
β”‚   β”‚   β”‚   β”œβ”€β”€ TransactionNotifier.java       # Observer pattern
β”‚   β”‚   β”‚   └── TransactionObserver.java       # Observer interface
β”‚   β”‚   β”œβ”€β”€ repository/                        # DAO layer
β”‚   β”‚   β”‚   β”œβ”€β”€ AccountRepository.java
β”‚   β”‚   β”‚   β”œβ”€β”€ CustomerRepository.java
β”‚   β”‚   β”‚   β”œβ”€β”€ InventoryItemRepository.java
β”‚   β”‚   β”‚   β”œβ”€β”€ LibraryBookRepository.java
β”‚   β”‚   β”‚   β”œβ”€β”€ TransactionRepository.java
β”‚   β”‚   β”‚   └── UserRepository.java
β”‚   β”‚   └── service/                           # Business logic layer
β”‚   β”‚       β”œβ”€β”€ AccountService.java
β”‚   β”‚       β”œβ”€β”€ AuthenticationService.java
β”‚   β”‚       β”œβ”€β”€ BankingService.java
β”‚   β”‚       β”œβ”€β”€ InventoryService.java
β”‚   β”‚       └── LibraryService.java
β”‚   └── resources/
β”‚       └── application.properties             # Configuration
└── test/
    └── java/com/enterprise/banking/           # JUnit tests
        β”œβ”€β”€ pattern/
        β”‚   β”œβ”€β”€ AccountFactoryTest.java
        β”‚   └── ObserverPatternTest.java
        └── service/
            β”œβ”€β”€ AccountServiceTest.java
            β”œβ”€β”€ AuthenticationServiceTest.java
            └── BankingServiceTest.java

πŸ”§ Setup Instructions

Prerequisites

  • Java 17 or higher
  • Maven 3.8 or higher
  • MySQL 8.0 or higher
  • IDE (IntelliJ IDEA, Eclipse, or VS Code with Java extensions)

Database Setup

  1. Install MySQL and start the MySQL server

  2. Create the database:

CREATE DATABASE banking_system;
  1. Update database credentials in src/main/resources/application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/banking_system
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORD

Build and Run

  1. Clone the repository:
git clone <repository-url>
cd "Java Bank Enterprise"
  1. Build the project:
mvn clean install
  1. Run tests:
mvn test
  1. Run the application:
mvn spring-boot:run

The application will start on http://localhost:8080

πŸ“š API Documentation

Banking Operations

Deposit

POST /api/banking/deposit
Content-Type: application/json

{
  "accountNumber": "CHK-123456-ABCD",
  "amount": 500.00,
  "description": "Salary deposit",
  "channel": "ONLINE"
}

Withdraw

POST /api/banking/withdraw
Content-Type: application/json

{
  "accountNumber": "CHK-123456-ABCD",
  "amount": 200.00,
  "description": "Cash withdrawal",
  "channel": "ATM"
}

Transfer

POST /api/banking/transfer
Content-Type: application/json

{
  "accountNumber": "CHK-123456-ABCD",
  "targetAccountNumber": "SAV-789012-EFGH",
  "amount": 300.00,
  "description": "Transfer to savings",
  "channel": "ONLINE"
}

Get Balance

GET /api/banking/balance/{accountNumber}

Get Transaction History

GET /api/banking/transactions/{accountNumber}?startDate=2024-01-01T00:00:00&endDate=2024-12-31T23:59:59

Account Management

Create Account

POST /api/accounts?username=testuser&accountType=CHECKING

Get User Accounts

GET /api/accounts/user/{username}

Get Account Details

GET /api/accounts/{accountNumber}

Close Account

DELETE /api/accounts/{accountNumber}

ATM Operations

ATM Withdrawal

POST /api/atm/withdraw
Content-Type: application/json

{
  "accountNumber": "CHK-123456-ABCD",
  "amount": 100.00
}

ATM Balance Inquiry

GET /api/atm/balance/{accountNumber}

Library Management

Add Book

POST /api/library/books
Content-Type: application/json

{
  "isbn": "978-0-13-468599-1",
  "title": "Clean Code",
  "author": "Robert C. Martin",
  "category": "Programming"
}

Borrow Book

POST /api/library/books/{isbn}/borrow

Return Book

POST /api/library/books/{isbn}/return

Search Books

GET /api/library/books/search?keyword=java

Inventory Management

Add Inventory Item

POST /api/inventory/items
Content-Type: application/json

{
  "sku": "LAPTOP-001",
  "name": "Dell Laptop",
  "category": "Electronics",
  "unitPrice": 999.99,
  "quantityInStock": 50
}

Add Stock

POST /api/inventory/items/{sku}/add-stock?quantity=10

Get Low Stock Items

GET /api/inventory/items/low-stock

πŸ§ͺ Testing

Run All Tests

mvn test

Run Specific Test Class

mvn test -Dtest=BankingServiceTest

Generate Test Coverage Report

mvn clean test jacoco:report

View the coverage report at: target/site/jacoco/index.html

Test Coverage Highlights

  • BankingService: 85%+ coverage
  • AuthenticationService: 90%+ coverage
  • AccountService: 88%+ coverage
  • Design Patterns: 92%+ coverage
  • Overall Project: 80%+ coverage

πŸŽ“ Java 8+ Features Used

Streams API

// Filter and sum deposits using Streams
return transactionRepository.findByAccount(account).stream()
    .filter(txn -> txn.getTransactionType() == Transaction.TransactionType.DEPOSIT)
    .filter(Transaction::isSuccessful)
    .map(Transaction::getAmount)
    .reduce(BigDecimal.ZERO, BigDecimal::add);

Lambda Expressions

// Register observers with lambda
observers.forEach(observer -> {
    try {
        observer.onTransactionCompleted(transaction);
    } catch (Exception e) {
        log.error("Error notifying observer", e);
    }
});

Optional for Null Safety

// Safe navigation with Optional
public Optional<Account> getAccountByNumber(String accountNumber) {
    return accountRepository.findByAccountNumber(accountNumber);
}

Collections Framework

  • ArrayList - Transaction history lists
  • HashMap - Category summaries
  • LinkedList - Pending transactions queue
  • CopyOnWriteArrayList - Thread-safe observer list

πŸ” Security Features

BCrypt Password Hashing

BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
String hashedPassword = encoder.encode(plainPassword);
boolean matches = encoder.matches(plainPassword, hashedPassword);

Account Lockout Policy

  • Maximum 5 failed login attempts
  • Automatic account lock after threshold
  • Admin unlock capability

Transaction Security

  • Optimistic Locking - Prevents lost updates
  • Pessimistic Locking - For critical sections
  • ACID Compliance - All or nothing transactions
  • Isolation Levels - READ_COMMITTED, SERIALIZABLE

πŸ“Š Database Schema

Core Tables

  • users - User authentication and profile
  • customers - Customer KYC information
  • accounts - Bank account details
  • transactions - Transaction records
  • library_books - Library inventory
  • inventory_items - Product inventory

Key Relationships

  • User β†’ Accounts (One-to-Many)
  • Account β†’ Transactions (One-to-Many)
  • User ↔ Customer (One-to-One)

🎯 Design Patterns in Detail

Singleton Pattern

DatabaseConnectionManager ensures single database connection instance

  • Thread-safe with double-checked locking
  • Lazy initialization
  • Connection pooling support

Factory Pattern

AccountFactory creates account instances based on type

  • Encapsulates account creation logic
  • Default configurations per account type
  • Custom account creation support

Observer Pattern

TransactionNotifier broadcasts transaction events

  • Email notifications
  • SMS notifications
  • Extensible for additional observers

DAO Pattern

Repository interfaces abstract data access

  • Spring Data JPA implementation
  • Custom query methods
  • Transaction management

MVC Pattern

Clear separation of concerns:

  • Model: Entity classes
  • View: REST API responses
  • Controller: HTTP request handlers

🚦 Exception Handling

Custom Exceptions

  • BankingException - Base exception
  • AccountNotFoundException - Account not found
  • InsufficientFundsException - Insufficient balance
  • AuthenticationException - Login failures

Error Responses

{
  "status": "error",
  "message": "Insufficient funds",
  "timestamp": "2024-12-16T10:30:00"
}

πŸ“ˆ Performance Optimization

  • Connection Pooling - HikariCP with optimized settings
  • Batch Processing - Hibernate batch inserts/updates
  • Indexed Queries - Database indexes on frequently queried columns
  • Lazy Loading - Fetch associations only when needed
  • Caching - Second-level cache for reference data

πŸ”„ Transaction Management

ACID Properties

  • Atomicity: All or nothing operations
  • Consistency: Database constraints enforced
  • Isolation: Concurrent transaction handling
  • Durability: Persistent after commit

Isolation Levels

  • READ_COMMITTED - Standard operations
  • SERIALIZABLE - Critical transfers

πŸ“ Logging

Comprehensive logging at multiple levels:

  • DEBUG: Development troubleshooting
  • INFO: Key business events
  • WARN: Potential issues
  • ERROR: Exception details

Log files location: logs/banking-system.log

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘€ Author

Enterprise Banking Team

πŸ™ Acknowledgments

  • Spring Boot community for excellent documentation
  • Hibernate team for robust ORM framework
  • JUnit and Mockito communities for testing tools
  • MySQL for reliable database system

πŸ“ž Support

For support, email support@enterprisebanking.com or create an issue in the repository.


Built with ❀️ using Java, Spring Boot, and modern software engineering practices

About

Enterprise-grade banking system built with Java, Spring Boot, and MySQL featuring secure transactions, multi-account management, ATM operations, and RESTful APIs. Implements MVC architecture, design patterns (Singleton, Factory, DAO), and BCrypt authentication for production-ready financial services.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages