A comprehensive and secure Banking Application REST API built with Spring Boot 3.4.3, providing complete banking operations including user management, account handling, transactions, and net banking capabilities.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- API Endpoints
- Testing with Postman
- Project Structure
- Security
- Contributing
- License
- Contact
- JWT-based Authentication - Secure token-based authentication system
- Spring Security Integration - Role-based access control
- Custom User Details Service - Personalized user authentication
- User registration and login
- Secure password encryption
- User profile management
- Admin user search functionality
- Create and manage bank accounts
- Link users to accounts
- View account details
- Account balance tracking
- Deposit - Add money to accounts
- Withdrawal - Withdraw money from accounts
- Net Banking - Transfer money between accounts
- Balance Inquiry - Check current account balance
- Real-time transaction processing
- View transaction history
- Complete passbook details
- Account-wise transaction records
- Sender and receiver details tracking
- JWT token validation
- Custom exception handling
- Data validation
- SQL injection prevention
- Secure API endpoints
- Search and manage users
- User registration
- System-wide user overview
Backend:
- Java 17
- Spring Boot 3.4.3
- Spring Data JPA
- Spring Security
- Spring Validation
Database:
- PostgreSQL
Security:
- JWT (JSON Web Tokens) - io.jsonwebtoken 0.12.5
- BCrypt Password Encoder
Tools & Libraries:
- Lombok - Reduce boilerplate code
- MapStruct 1.5.5 - Object mapping
- Apache Commons Text 1.10.0
- Apache Commons Collections 4.4
- Maven - Dependency management
Testing:
- Tested extensively with Postman
- All endpoints verified and working
Before running this application, make sure you have:
- Java Development Kit (JDK) 17 or higher
- PostgreSQL 12 or higher
- Maven 3.6+ (or use included Maven wrapper)
- Postman (for API testing)
- Git (for version control)
git clone https://github.com/Krishal-Modi/Banking-Application-Rest-API.git
cd Banking-Application-Rest-API/BankingApplicationCreate a PostgreSQL database:
CREATE DATABASE BankingApplication;Update the database credentials in src/main/resources/application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/BankingApplication
spring.datasource.username=your_username
spring.datasource.password=your_passwordUsing Maven wrapper (recommended):
# Windows
mvnw.cmd clean install
# Linux/Mac
./mvnw clean installOr using Maven:
mvn clean install# Windows
mvnw.cmd spring-boot:run
# Linux/Mac
./mvnw spring-boot:runThe application will start on http://localhost:8086
Key configurations in application.properties:
# Server Port
server.port=8086
# Database Configuration
spring.datasource.url=jdbc:postgresql://localhost:5432/BankingApplication
spring.datasource.username=postgres
spring.datasource.password=root
# JPA Configuration
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=trueJWT secret key and expiration can be configured in JwtUtil.java
POST /user/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}Response: JWT Token
POST /admin/signUp
Content-Type: application/json
{
"name": "John Doe",
"email": "john@example.com",
"password": "secure_password",
"phoneNumber": "1234567890",
"roles": "USER"
}GET /admin/search?search=john
Authorization: Bearer {jwt_token}POST /userAccount/addingAccount
Authorization: Bearer {jwt_token}
Content-Type: application/json
{
"accountNumber": 1234567890,
"accountType": "SAVINGS",
"balance": 1000.00
}GET /userAccount/passbook
Authorization: Bearer {jwt_token}PUT /userAccount/netBanking
Authorization: Bearer {jwt_token}
Content-Type: application/x-www-form-urlencoded
senderAccountNumber=1234567890
receiverAccountNumber=0987654321
amount=500PUT /transaction/deposit
Authorization: Bearer {jwt_token}
Content-Type: application/json
{
"accountNumber": 1234567890,
"amount": 1000.00
}PUT /transaction/withdrawal
Authorization: Bearer {jwt_token}
Content-Type: application/json
{
"accountNumber": 1234567890,
"amount": 500.00
}GET /transaction/currentBalance/{accountNumber}
Authorization: Bearer {jwt_token}This API has been thoroughly tested with Postman to ensure all endpoints work correctly.
-
Download Postman from postman.com
-
Import Collection (Optional - Create your own)
- Create a new collection called "Banking API"
- Add all endpoints mentioned above
-
Setup Environment Variables
- Create variables:
base_url:http://localhost:8086jwt_token: (Will be set after login)
- Create variables:
-
Testing Flow
Step 1: Register a User
POST {{base_url}}/admin/signUpStep 2: Login
POST {{base_url}}/user/loginCopy the JWT token from response
Step 3: Set Authorization
- Add header:
Authorization: Bearer {your_jwt_token}
Step 4: Create Account
POST {{base_url}}/userAccount/addingAccountStep 5: Test Transactions
- Deposit money
- Withdraw money
- Check balance
- Transfer money (net banking)
Step 6: View Passbook
GET {{base_url}}/userAccount/passbook - Add header:
- Use Environment Variables for base URL and tokens
- Enable Auto-Refresh Tokens if tokens expire
- Save Example Responses for documentation
- Use Tests Tab to add assertions
- Create Collection Runner for automated testing
// Save JWT token automatically after login
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
var jsonData = pm.response.text();
pm.environment.set("jwt_token", jsonData);BankingApplication/
βββ src/
β βββ main/
β β βββ java/com/example/BankingApplication/
β β β βββ BankingApplication.java # Main application class
β β β βββ config/
β β β β βββ SpringSecurity.java # Security configuration
β β β βββ controller/ # REST controllers
β β β β βββ AccountController.java
β β β β βββ AdminController.java
β β β β βββ TransactionalController.java
β β β β βββ UserController.java
β β β βββ entity/ # JPA entities
β β β β βββ Account.java
β β β β βββ Passbook.java
β β β β βββ User.java
β β β βββ exceptions/ # Custom exceptions
β β β β βββ DataNotFoundException.java
β β β β βββ DataValidationException.java
β β β β βββ handler/
β β β β βββ GlobalExceptionHandler.java
β β β βββ filter/ # Security filters
β β β β βββ JwtFilter.java
β β β βββ mapper/ # MapStruct mappers
β β β β βββ AccountMapper.java
β β β β βββ PassbookMapper.java
β β β β βββ UserMapper.java
β β β βββ model/ # DTOs
β β β β βββ AccountModel.java
β β β β βββ LoanModel.java
β β β β βββ NetBankingModel.java
β β β β βββ PassbookAccountModel.java
β β β β βββ PassbookModel.java
β β β β βββ ReceiverModel.java
β β β β βββ SenderModel.java
β β β β βββ TransactionalModel.java
β β β β βββ UserAccountModel.java
β β β β βββ UserModel.java
β β β β βββ UserPassbookModel.java
β β β β βββ error/
β β β β βββ ErrorResponse.java
β β β β βββ ErrorType.java
β β β βββ repository/ # JPA repositories
β β β β βββ AccountRepository.java
β β β β βββ PassbookRepository.java
β β β β βββ UserRepository.java
β β β βββ service/ # Business logic
β β β β βββ AccountService.java
β β β β βββ AdminService.java
β β β β βββ CustomUserDetailsService.java
β β β β βββ TransactionalService.java
β β β β βββ UserService.java
β β β βββ utils/ # Utility classes
β β β βββ JwtUtil.java
β β βββ resources/
β β βββ application.properties # Application configuration
β βββ test/ # Test files
βββ mvnw # Maven wrapper (Unix)
βββ mvnw.cmd # Maven wrapper (Windows)
βββ pom.xml # Maven dependencies
- User sends credentials to
/user/login - Server validates credentials
- JWT token is generated and returned
- Client includes token in
Authorizationheader for subsequent requests - Server validates token using
JwtFilter
- Password Encryption: BCrypt encoding for password storage
- JWT Tokens: Stateless authentication
- Request Filtering: JWT validation on protected endpoints
- Custom Exception Handling: Secure error messages
- Input Validation: Bean validation on all inputs
- SQL Injection Prevention: JPA/Hibernate parameterized queries
β
Token-based authentication
β
Password hashing
β
Role-based access control
β
Global exception handling
β
Input validation
β
Secure headers
β
Database connection pooling
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Commit your changes
git commit -m 'Add some AmazingFeature' - Push to the branch
git push origin feature/AmazingFeature
- Open a Pull Request
- Follow Java coding conventions
- Write meaningful commit messages
- Add comments for complex logic
- Update documentation if needed
- Test your changes thoroughly with Postman
This project is licensed under the MIT License - see the LICENSE file for details.
Krishal Modi
- GitHub: @Krishal-Modi
- Project Link: https://github.com/Krishal-Modi/Banking-Application-Rest-API
- Spring Boot Documentation
- PostgreSQL Community
- JWT.io for JWT implementation guidance
- Postman for excellent API testing tools
- Open source community
- Add interest calculation for savings accounts
- Implement loan management system
- Add email notifications for transactions
- Create admin dashboard
- Implement transaction limits
- Add two-factor authentication
- Create mobile app integration
- Add support for multiple currencies
- Implement account statements PDF generation
- Add GraphQL support
βοΈ Star this repo if you find it helpful! βοΈ
Made with β€οΈ by Krishal Modi