A full-featured RESTful banking API built with Spring Boot, featuring user management, account operations, transactions, transfers, and loan processing.
- User Management — Registration, authentication, profile updates
- Account Operations — Create accounts, check balances, deposit, withdraw
- Fund Transfers — Transfer money between accounts with validation
- Transaction History — Track all account activity
- Loan Processing — Apply for loans, track repayments, manage loan status
- Security — Spring Security with role-based access control
| Layer | Technology |
|---|---|
| Framework | Spring Boot 3.4.3 |
| Language | Java 21 |
| Database | MySQL 8.0 |
| ORM | Spring Data JPA / Hibernate |
| Security | Spring Security |
| Build | Maven |
| Cloud | AWS RDS (Production) |
- Java 21 — Download
- Docker — Download (for local MySQL database)
- Maven — Included via
./mvnwwrapper (no install needed)
git clone https://github.com/olael94/banking-api.git
cd banking-apicp .env.example .envThe default .env is pre-configured for Docker MySQL — no changes needed for local development.
docker-compose up -dThis starts a MySQL 8.0 container with the database ready to use.
./mvnw spring-boot:runThe API is now running at: http://localhost:8080
Test it:
curl http://localhost:8080/api/usersIf you prefer to use AWS RDS:
- Edit your
.envfile - Comment out Option 1 (Docker)
- Uncomment Option 2 (AWS RDS) and fill in your credentials
# Option 1: Docker MySQL — COMMENT THESE OUT
# SPRING_DATASOURCE_URL=jdbc:mysql://localhost:3306/banking_application
# SPRING_DATASOURCE_USERNAME=banking_user
# SPRING_DATASOURCE_PASSWORD=banking_password
# Option 2: AWS RDS — UNCOMMENT AND FILL IN
SPRING_DATASOURCE_URL=jdbc:mysql://your-rds-endpoint:3306/banking_application
SPRING_DATASOURCE_USERNAME=admin
SPRING_DATASOURCE_PASSWORD=your-passwordSee docs/aws-setup.md for detailed AWS RDS setup instructions.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/users/register |
Register new user |
| GET | /api/users/{id} |
Get user details |
| PUT | /api/users/{id} |
Update user |
| DELETE | /api/users/{id} |
Delete user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/accounts |
Create account |
| GET | /api/accounts/{id} |
Get account details |
| POST | /api/accounts/{id}/deposit |
Deposit funds |
| POST | /api/accounts/{id}/withdraw |
Withdraw funds |
| POST | /api/accounts/transfer |
Transfer between accounts |
| DELETE | /api/accounts/{id} |
Close account |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/transactions/{accountId} |
Get transaction history |
| POST | /api/transactions |
Create transaction |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/transfers |
Initiate transfer |
| GET | /api/transfers/{id} |
Get transfer details |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/loans/apply |
Apply for loan |
| GET | /api/loans/{id} |
Get loan details |
| POST | /api/loans/{id}/repay |
Make loan payment |
banking-api/
│
├── src/main/java/edu/ensign/cs460/banking_api/
│ ├── controller/ # REST API endpoints
│ ├── service/ # Business logic interfaces
│ │ └── impl/ # Service implementations
│ ├── repository/ # Data access layer (JPA)
│ ├── models/ # JPA entities
│ ├── dto/ # Data transfer objects
│ ├── exception/ # Custom exceptions & global handler
│ ├── config/ # Security & app configuration
│ └── security/ # Authentication components
│
├── src/main/resources/
│ └── application.properties
│
├── src/test/ # Unit & integration tests
├── sql/ # Database schema scripts
├── docs/ # Documentation
│ └── aws-setup.md # AWS RDS setup guide
│
├── .env.example # Environment variables template
├── docker-compose.yml # Local MySQL database
├── pom.xml # Maven dependencies
└── README.md
┌─────────────────────────────────────────────────────────────────┐
│ Client │
└─────────────────────────────┬───────────────────────────────────┘
│ HTTP
▼
┌─────────────────────────────────────────────────────────────────┐
│ Controllers │
│ REST endpoints for Users, Accounts, Loans, etc. │
├─────────────────────────────────────────────────────────────────┤
│ Services │
│ Business logic & validation │
├─────────────────────────────────────────────────────────────────┤
│ Repositories │
│ JPA Data Access Layer │
├─────────────────────────────────────────────────────────────────┤
│ MySQL Database │
│ (Docker for local / AWS RDS for production) │
└─────────────────────────────────────────────────────────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ USER │ │ ACCOUNT │ │ TRANSACTION │
├──────────────┤ ├──────────────┤ ├──────────────┤
│ user_id (PK) │───┐ │ account_id │───┐ │ transaction_id│
│ username │ │ │ user_id (FK) │ │ │ account_id(FK)│
│ password │ └──►│ account_num │ └──►│ type │
│ email │ │ account_type │ │ amount │
│ full_name │ │ balance │ │ date │
│ dob │ │ status │ │ status │
│ reg_date │ └──────────────┘ └──────────────┘
└──────────────┘
│
│ ┌──────────────┐ ┌──────────────┐
│ │ TRANSFER │ │ LOAN │
│ ├──────────────┤ ├──────────────┤
│ │ transfer_id │ │ loan_id │
│ │ from_acct(FK)│ │ user_id (FK) │
│ │ to_acct (FK) │ │ loan_type │
│ │ amount │ │ amount │
│ │ date │ │ interest_rate│
└─────────────►│ status │ │ status │
└──────────────┘ └──────────────┘
Environment variables are loaded automatically from .env via spring-dotenv.
| Variable | Description | Default |
|---|---|---|
SPRING_DATASOURCE_URL |
JDBC connection URL | jdbc:mysql://localhost:3306/banking_application |
SPRING_DATASOURCE_USERNAME |
Database username | banking_user |
SPRING_DATASOURCE_PASSWORD |
Database password | banking_password |
SERVER_PORT |
Application port | 8080 |
SPRING_JPA_HIBERNATE_DDL_AUTO |
Schema generation | update |
# Start MySQL database
docker-compose up -d
# Stop MySQL database (keeps data)
docker-compose down
# Stop MySQL and delete all data
docker-compose down -v
# Run the application
./mvnw spring-boot:run
# Run tests
./mvnw test
# Build JAR file
./mvnw clean package
# Run JAR file
java -jar target/banking-api-0.0.1-SNAPSHOT.jarMake sure MySQL is running:
docker-compose psIf it's not running:
docker-compose up -dCheck your .env file has the correct credentials matching docker-compose.yml:
- Username:
banking_user - Password:
banking_password
Stop any existing MySQL service:
# macOS
brew services stop mysql
# Linux
sudo systemctl stop mysql
# Or change the port in docker-compose.yml
ports:
- "3307:3306" # Use port 3307 insteadChange the port in your .env file:
SERVER_PORT=8081# Run all tests
./mvnw test
# Run a specific test class
./mvnw test -Dtest=UserServiceImplTest
# Run with coverage report
./mvnw test jacoco:reportThis project is licensed under the MIT License — see the LICENSE file for details.