A robust, secure banking backend API built with Spring Boot 3.2.4 and Java 21, featuring comprehensive banking operations, JWT authentication, and email integration.
- JWT-based authentication with refresh token support
- Role-based authorization (Customer/Admin)
- Password strength validation
- OTP verification for account activation
- Secure password hashing with BCrypt
- Account creation and management
- Money deposit and withdrawal
- Fund transfers between accounts
- Balance inquiries and transaction history
- Transaction limits management
- Real-time balance updates
- Email notifications with HTML templates
- OTP generation and verification
- Welcome emails for new customers
- Password reset notifications
- Global exception handling
- Input validation
- Transaction logging
- Account suspension capabilities
- Secure API endpoints
- Java 21 - Latest LTS version
- Spring Boot 3.2.4 - Main framework
- Spring Security 6.2.4 - Authentication & authorization
- Spring Data JPA - Data persistence
- Hibernate - ORM framework
- MySQL 8.0 - Production database
- H2 - In-memory database for testing
- JWT (jjwt) 0.12.5 - Token management
- BCrypt - Password hashing
- Spring Boot Mail - Email service
- Thymeleaf - HTML email templates
- Maven 3.10.1 - Build tool
- Docker & Docker Compose - Containerization
- JUnit 5 - Testing framework
- Java 21 JDK
- Maven 3.10.1+
- MySQL 8.0 (or Docker)
- Git
-
Clone the repository
git clone https://github.com/devhnry/online-banking-backend.git cd online-banking-backend -
Set up environment variables (Depending on 'dev or qa' environment)
# Database Configuration export DATABASE_NAME=your_db_name export DATABASE_USERNAME=your_db_username export DATABASE_PASSWORD=your_db_password # Email Configuration (Gmail SMTP) export EMAIL_HOST=smtp.gmail.com export EMAIL_PASSWORD=your_app_password export [email protected] export EMAIL_PORT=587
-
Database Setup
CREATE DATABASE onlinebanking; CREATE USER 'banking_user'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON onlinebanking.* TO 'banking_user'@'localhost';
# Install dependencies
mvn clean install
# Run the application
mvn spring-boot:run- API Base URL:
http://localhost:6000 - H2 Console (Development):
http://localhost:6000/h2-console - Health Check:
GET http://localhost:6000/actuator/health
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /auth/onboard |
Register new customer | β |
| POST | /auth/send-otp |
Send OTP for verification | β |
| POST | /auth/onboard/verify-otp |
Verify OTP and activate account | β |
| POST | /auth/login |
Customer login | β |
| POST | /auth/refresh-token |
Refresh access token | β |
| POST | /auth/login |
Customer login | β |
| POST | /auth/refresh-token |
Refresh access token | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/v1/account/get-details |
Get customer details | β |
| GET | /api/v1/account/view-balance |
Check account balance | β |
| POST | /api/v1/account/make-deposit |
Deposit money | β |
| POST | /api/v1/account/withdraw |
Withdraw money | β |
| POST | /api/v1/account/make-transfer |
Transfer funds | β |
| POST | /api/v1/account/get-transfer-summary |
Get transfer summary | β |
| GET | /api/v1/account/details |
Get account holder name | β |
| GET | /api/v1/account/view-bank-statement |
View transaction history | β |
| PUT | /api/v1/account/change-password |
Change password | β |
| PATCH | /api/v1/account/update-profile |
Update profile information | β |
| PUT | /api/v1/account/update-transaction-limit |
Update transaction limit | β |
β οΈ Note: The following endpoints exist in the codebase but are not fully implemented:
| Method | Endpoint | Description | Status |
|---|---|---|---|
| PUT | /api/v1/admin/suspend/{id} |
Suspend user account | π§ Returns empty response |
| GET | /api/v1/account/send-otp |
Generate OTP | π§ Returns empty response |
| PUT | /api/v1/account/forgot-password |
Reset password | π§ Returns empty response |
Kora Virtual Account endpoints (
/api/v1/kora/**) are commented out and not active.
The application uses H2 in-memory database for testing with automatic schema generation.
src/
βββ main/
β βββ java/org/henry/bankingsystem/
β β βββ config/ # Security & application configuration
β β βββ controller/ # REST API endpoints
β β βββ dto/ # Data Transfer Objects
β β βββ entity/ # JPA entities
β β βββ enums/ # Enumerations
β β βββ exceptions/ # Custom exceptions & handlers
β β βββ repository/ # Data access layer
β β βββ service/ # Business logic
β β βββ utils/ # Utility classes
β βββ resources/
β βββ templates/ # Email templates
β βββ application*.yml # Configuration files
βββ test/ # Test files
- dev: Development environment with local MySQL
- qa: Testing environment with cloud database
server:
port: 6000
spring:
profiles:
active: dev
datasource:
url: jdbc:mysql://localhost:3306/${DATABASE_NAME}
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}- Access token expiry: 24 hours
- Refresh token for seamless authentication
- Stateless session management
- BCrypt hashing with strength 12
- Password strength validation (uppercase, numbers, special characters)
- 4-digit PIN for transactions
- All endpoints except auth require valid JWT
- Role-based access control
- Request/response logging for audit
Henry
- LinkedIn: https://www.linkedin.com/in/henry-taiwo-b60198313/
- X: https://x.com/h3nry0x
- Email: [email protected]
For support, email me at [email protected] or create an issue in this repository.