Skip to content

harshraj277/Bank_Application_Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bank_Application

🏦 Banking Register System

A full-stack banking management REST API built with Spring Boot and plain JavaScript frontend.
Supports account creation, balance management, deposits, withdrawals, transfers, and transaction history with PDF export.


πŸ“ Project Structure

register2/
β”œβ”€β”€ src/
β”‚   └── main/
β”‚       β”œβ”€β”€ java/com/example/register2/
β”‚       β”‚   β”œβ”€β”€ controller/
β”‚       β”‚   β”‚   └── RegisterController.java       ← REST API endpoints
β”‚       β”‚   β”œβ”€β”€ model/
β”‚       β”‚   β”‚   β”œβ”€β”€ RegisterModel.java             ← User account entity
β”‚       β”‚   β”‚   └── TransactionModel.java          ← Transaction entity
β”‚       β”‚   β”œβ”€β”€ repository/
β”‚       β”‚   β”‚   β”œβ”€β”€ RegisterRepository.java        ← JPA repository for accounts
β”‚       β”‚   β”‚   └── TransactionRepository.java     ← JPA repository for transactions
β”‚       β”‚   └── service/
β”‚       β”‚       β”œβ”€β”€ RegisterService.java           ← Business logic (account ops)
β”‚       β”‚       └── TransactionService.java        ← Transaction logic + PDF export
β”‚       └── resources/
β”‚           β”œβ”€β”€ static/
β”‚           β”‚   β”œβ”€β”€ register.html                  ← Create account UI
β”‚           β”‚   β”œβ”€β”€ register.js                    ← Register form handler
β”‚           β”‚   β”œβ”€β”€ register.css                   ← Shared styles
β”‚           β”‚   β”œβ”€β”€ get.js                         ← Fetch account handler
β”‚           β”‚   β”œβ”€β”€ update.js                      ← Update account handler
β”‚           β”‚   └── delete.js                      ← Delete account handler
β”‚           └── application.properties             ← DB and server config
└── pom.xml

βš™οΈ Prerequisites

Tool Version Download
Java 17+ https://adoptium.net
Maven 3.8+ https://maven.apache.org
MySQL 8.0+ https://dev.mysql.com/downloads

πŸ—„οΈ Database Setup

Run the following SQL to create the required tables:

CREATE DATABASE banking_db;
USE banking_db;

CREATE TABLE user_account (
    ID                BIGINT AUTO_INCREMENT PRIMARY KEY,
    FULL_NAME         VARCHAR(100),
    DATE_OF_BIRTH     DATE,
    PERMANENT_ADDRESS VARCHAR(255),
    CURRENT_ADDRESS   VARCHAR(255),
    PHONE_NUMBER      VARCHAR(20),
    EMAIL             VARCHAR(100),
    ACCOUNT_TYPE      VARCHAR(50),
    USER_ID           VARCHAR(50),
    ACCOUNT_NUMBER    VARCHAR(50) UNIQUE,
    BALANCE           DOUBLE,
    STATUS            VARCHAR(20),
    BRANCH_NAME       VARCHAR(100),
    IFSC_CODE         VARCHAR(20),
    GENDER            VARCHAR(10),
    IS_MARRIED        BOOLEAN,
    PASSWORD          VARCHAR(100),
    PIN               INT
);

CREATE TABLE transactions (
    TRANSACTION_ID          BIGINT AUTO_INCREMENT PRIMARY KEY,
    USER_ID                 VARCHAR(50),
    ACCOUNT_NUMBER          VARCHAR(50),
    TRANSACTION_TYPE        VARCHAR(50),
    TRANSACTION_DESCRIPTION VARCHAR(255),
    AMOUNT                  DOUBLE,
    TOTAL_AMOUNT            DOUBLE,
    TRANSACTION_DATE        DATETIME
);

πŸ”§ Configuration

Edit src/main/resources/application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/banking_db
spring.datasource.username=your_mysql_username
spring.datasource.password=your_mysql_password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true

server.port=8080

πŸš€ Getting Started

# 1. Clone the project
git clone <your-repo-url>
cd register2

# 2. Configure DB credentials in application.properties

# 3. Run the app
./mvnw spring-boot:run

# 4. Open in browser
http://localhost:8080

πŸ”Œ API Reference

Base URL: http://localhost:8080/api/v1/register

Account Endpoints

Method Endpoint Description
POST /create Create a new bank account
GET /getAccount Get account details
PUT /update Update a specific account field
DELETE /delete Delete an account
GET /balance Get current balance

Transaction Endpoints

Method Endpoint Description
GET /deposit Deposit money into account
GET /withdraw Withdraw money from account
POST /transfer Transfer money between accounts
GET /transactionHistory Get all transactions for a user
GET /transactionHistory/pdf Download transaction history as PDF

πŸ“‹ API Examples

Create Account

POST /api/v1/register/create
Content-Type: application/json

{
  "fullName": "John Doe",
  "dateOfBirth": "1995-06-15",
  "permanentAddress": "123 Main St, Mumbai",
  "currentAddress": "456 Park Ave, Pune",
  "phoneNumber": "9876543210",
  "email": "john@example.com",
  "accountType": "SAVINGS",
  "accountNumber": "ACC123456",
  "balance": 5000.00,
  "status": "ACTIVE",
  "branchName": "Pune Main Branch",
  "ifscCode": "BANK0001234",
  "gender": "MALE",
  "isMarried": false,
  "password": "securepass123",
  "pin": 1234
}

Get Account

GET /api/v1/register/getAccount?accountNumber=ACC123456&password=securepass123

Update Account Field

PUT /api/v1/register/update?accountNumber=ACC123456&field=EMAIL&newValue=newemail@example.com

Allowed fields for update: FULL_NAME, DATE_OF_BIRTH, PERMANENT_ADDRESS, CURRENT_ADDRESS, PHONE_NUMBER, EMAIL, ACCOUNT_TYPE, BALANCE, STATUS, BRANCH_NAME, IFSC_CODE, GENDER, IS_MARRIED, PASSWORD, PIN

Delete Account

DELETE /api/v1/register/delete?accountNumber=ACC123456

Check Balance

GET /api/v1/register/balance?accountNumber=ACC123456&password=securepass123

Deposit

GET /api/v1/register/deposit?userId=USR001&accountNumber=ACC123456&password=securepass123&balance=1000

Withdraw

GET /api/v1/register/withdraw?userId=USR001&accountNumber=ACC123456&password=securepass123&balance=500

Transfer

POST /api/v1/register/transfer?fromUserId=USR001&fromAccount=ACC123456&fromPassword=securepass123&toAccount=ACC789012&toUserId=USR002&amount=2000

Transaction History

GET /api/v1/register/transactionHistory?UserId=USR001

Download Transaction PDF

GET /api/v1/register/transactionHistory/pdf?userId=USR001

πŸ—‚οΈ Database Tables

user_account

Column Type Description
ID BIGINT Auto-generated primary key
FULL_NAME VARCHAR Customer full name
DATE_OF_BIRTH DATE Date of birth
PERMANENT_ADDRESS VARCHAR Permanent address
CURRENT_ADDRESS VARCHAR Current address
PHONE_NUMBER VARCHAR Mobile number
EMAIL VARCHAR Email address
ACCOUNT_TYPE VARCHAR SAVINGS / CURRENT
USER_ID VARCHAR Auto-generated 6-char random ID
ACCOUNT_NUMBER VARCHAR Unique account number
BALANCE DOUBLE Current balance
STATUS VARCHAR ACTIVE / INACTIVE
BRANCH_NAME VARCHAR Bank branch name
IFSC_CODE VARCHAR Branch IFSC code
GENDER VARCHAR MALE / FEMALE / OTHER
IS_MARRIED BOOLEAN Marital status
PASSWORD VARCHAR Account password
PIN INT 4-digit transaction PIN

transactions

Column Type Description
TRANSACTION_ID BIGINT Auto-generated primary key
USER_ID VARCHAR Owner user ID
ACCOUNT_NUMBER VARCHAR Account number
TRANSACTION_TYPE VARCHAR DEPOSIT / WITHDRAWAL / TRANSFER
TRANSACTION_DESCRIPTION VARCHAR Transaction details
AMOUNT DOUBLE Transaction amount
TOTAL_AMOUNT DOUBLE Balance after transaction
TRANSACTION_DATE DATETIME Timestamp of transaction

πŸ”’ Security Notes

⚠️ This project stores passwords in plain text. Before deploying to production, implement:

  • Password hashing with BCrypt via spring-security-crypto
  • JWT-based authentication and session management
  • HTTPS enforcement
  • Rate limiting on login, transfer, and withdrawal endpoints
  • Bean validation with @Valid and @NotBlank on all request bodies

❌ Common Errors & Fixes

Error Cause Fix
Connection refused MySQL not running Start MySQL service
Access denied for user Wrong DB credentials Check application.properties
Table doesn't exist Tables not created Run the SQL setup script above
Account not found Wrong account number or password Double-check credentials
Insufficient funds Balance less than withdrawal amount Check balance first
CORS error Frontend on wrong port @CrossOrigin is set to localhost:4200 β€” update if needed
Transfer failed Recipient account not found Verify the destination account number exists

πŸ“¦ Maven Dependencies

Add these to your pom.xml:

<!-- Spring Boot Web -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Spring Data JPA -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!-- MySQL Driver -->
<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <scope>runtime</scope>
</dependency>

<!-- PDF Generation (OpenPDF) -->
<dependency>
    <groupId>com.github.librepdf</groupId>
    <artifactId>openpdf</artifactId>
    <version>1.3.30</version>
</dependency>

πŸ“„ License

MIT β€” free to use and modify.

About

🏦 Banking REST API built with Spring Boot & MySQL. Supports account management, deposits, withdrawals, transfers, and transaction history with PDF export.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors