A robust backend system that safely and concurrently processes multiple loan applications with automated system approval delays, agent-manager hierarchies, and mock notifications. Built with Spring Boot 3 and MySQL.
This system demonstrates enterprise-level backend development skills by implementing:
- Multithreaded processing with 25-second delay simulation
- Automated decision-making based on customizable business rules
- Agent-manager hierarchy with automatic assignment workflow
- Mock notification system for push and SMS alerts
- Thread-safe concurrent processing using ReentrantLock
- Real-time monitoring and analytics
- Backend: Spring Boot 3.5.5
- Language: Java 17
- Database: MySQL 8.0
- ORM: Hibernate/JPA
- Build Tool: Maven
- Architecture: Layered (Controller β Service β Repository β Entity)
- Java 17 or higher
- MySQL 8.0 or higher
- Maven 3.6 or higher
- IDE (IntelliJ IDEA, Eclipse, or VS Code)
CREATE DATABASE loan_origination_db;
Update src/main/resources/application.yml
:
spring:
datasource:
url: jdbc:mysql://localhost:3306/loan_origination_db
username: root
password: password
INSERT INTO agents (agent_name, email, phone, is_available, manager_id, created_at) VALUES
('Rajesh Kumar Sharma', 'rajesh.sharma@bank.com', '9876543210', true, null, NOW()),
('Priya Gupta', 'priya.gupta@bank.com', '9876543211', true, 1, NOW()),
('Amit Patel', 'amit.patel@bank.com', '9876543212', true, 1, NOW()),
('Sunita Verma', 'sunita.verma@bank.com', '9876543213', true, 2, NOW());
mvn spring-boot:run
Application URL: http://localhost:8080
Endpoint | Method | Description |
---|---|---|
/api/v1/loans |
POST | Submit new loan application |
/api/v1/loans/status-count |
GET | Get real-time status counts |
/api/v1/loans |
GET | Get loans by status (paginated) |
/api/v1/customers/top |
GET | Get top 3 customers with most approved loans |
/api/v1/agents/{agentId}/loans/{loanId}/decision |
PUT | Agent makes approve/reject decision |
POST http://localhost:8080/api/v1/loans
Content-Type: application/json
{
"loanId": "LOAN001",
"customerName": "Ramesh Kumar Singh",
"customerPhone": "9123456789",
"loanAmount": 250000,
"loanType": "PERSONAL"
}
GET http://localhost:8080/api/v1/loans/status-count
Response:
{
"applied": 0,
"approvedBySystem": 9,
"rejectedBySystem": 16,
"underReview": 16,
"approvedByAgent": 0,
"rejectedByAgent": 0
}
PUT http://localhost:8080/api/v1/agents/1/loans/LOAN001/decision
Content-Type: application/json
{
"decision": "APPROVE"
}
-
Application Submission β Status:
APPLIED
-
Background Processing (25-second delay) β Business rules applied:
- Auto-approve: Personal loans β€ βΉ50,000 β
APPROVED_BY_SYSTEM
- Auto-reject: Any loan > βΉ50,00,000 β
REJECTED_BY_SYSTEM
- Manual review: Other cases β
UNDER_REVIEW
- Auto-approve: Personal loans β€ βΉ50,000 β
-
Agent Assignment β Available agent assigned automatically
-
Notifications β Push to agent, SMS to customer
-
Agent Decision β
APPROVED_BY_AGENT
orREJECTED_BY_AGENT
Condition | Action | Result Status |
---|---|---|
Personal loan β€ βΉ50,000 | Auto-approve | APPROVED_BY_SYSTEM |
Any loan > βΉ50,00,000 | Auto-reject | REJECTED_BY_SYSTEM |
Other amounts | Random decision | 30% approve, 30% reject, 40% review |
Import LOS-API-Collection.json
for comprehensive testing of all endpoints.
// Auto-approve scenario
{
"loanId": "AUTO_APPROVE_001",
"customerName": "Test User 1",
"customerPhone": "9999999991",
"loanAmount": 45000,
"loanType": "PERSONAL"
}
// Manual review scenario
{
"loanId": "MANUAL_REVIEW_001",
"customerName": "Test User 2",
"customerPhone": "9999999992",
"loanAmount": 250000,
"loanType": "BUSINESS"
}
// Auto-reject scenario
{
"loanId": "AUTO_REJECT_001",
"customerName": "Test User 3",
"customerPhone": "9999999993",
"loanAmount": 6000000,
"loanType": "BUSINESS"
}
src/
βββ main/
β βββ java/com/example/LOS/
β β βββ entity/
β β β βββ LoanApplication.java
β β β βββ Agent.java
β β βββ repository/
β β β βββ LoanApplicationRepository.java
β β β βββ AgentRepository.java
β β βββ service/
β β β βββ LoanApplicationService.java
β β β βββ LoanProcessingService.java
β β β βββ ScheduledLoanProcessor.java
β β β βββ impl/
β β β β βββ LoanApplicationServiceImpl.java
β β β βββ notification/
β β β βββ NotificationService.java
β β β βββ MockNotificationService.java
β β βββ controller/
β β β βββ LoanApplicationController.java
β β β βββ AgentController.java
β β βββ dto/
β β β βββ LoanApplicationRequest.java
β β β βββ LoanApplicationResponse.java
β β β βββ AgentDecisionRequest.java
β β β βββ StatusCountResponse.java
β β β βββ TopCustomerResponse.java
β β βββ enums/
β β β βββ ApplicationStatus.java
β β β βββ LoanType.java
β β βββ config/
β β β βββ ThreadPoolConfig.java
β β βββ exception/
β β β βββ GlobalExceptionHandler.java
β β β βββ ResourceNotFoundException.java
β β β βββ InvalidStatusTransitionException.java
β β βββ LoanOriginationSystemApplication.java
β βββ resources/
β βββ application.yml
β βββ data.sql
βββ test/
βββ java/com/example/LOS/
βββ service/
β βββ LoanApplicationServiceTest.java
βββ controller/
βββ LoanApplicationControllerTest.java
- β Multithreaded Processing: Background jobs with thread pool
- β Thread Safety: ReentrantLock prevents race conditions
- β Automated Decision Making: Business rule engine
- β Agent Workflow: Hierarchical assignment and notifications
- β Mock Services: Push and SMS notification simulation
- β Real-time Analytics: Status monitoring and top customers
- β Pagination Support: Efficient data retrieval
- β Input Validation: Comprehensive request validation
- β Error Handling: Global exception management
- β Clean Architecture: Layered design with separation of concerns
- Core threads: 3
- Max threads: 10
- Queue capacity: 50
- Processing interval: Every 5 seconds
- Simulation delay: 25 seconds per loan
- Indexed columns:
application_status
,customer_name
- Connection pooling: HikariCP
- Transaction management: Spring @Transactional
- Concurrent Processing: Multiple loans processed simultaneously
- Database Indexing: Optimized query performance
- Async Operations: Non-blocking background processing
- Memory Efficient: Pagination for large datasets
- Connection Pooling: Efficient database resource usage
Requirement | Status | Implementation |
---|---|---|
Submit Loan Application | β | POST /api/v1/loans with validation |
Multithreaded Processing | β | Background jobs with 25-second delay |
Agent Assignment & Review | β | Automatic assignment with hierarchy |
Mock Notifications | β | Push and SMS services |
Status Monitoring | β | Real-time counts endpoint |
Top Customers API | β | Analytics with approved loan counts |
Pagination Support | β | GET /api/v1/loans with paging |
Thread Safety | β | ReentrantLock implementation |
Clean Architecture | β | Layered design pattern |
Database Design | β | Normalized schema with indexes |
Built with Spring Boot 3.5.5 & Java 17
This project demonstrates enterprise-grade loan processing capabilities with concurrent handling, automated workflows, and comprehensive monitoring suitable for production banking systems.