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