Skip to content

Enterprise-grade Loan Origination System with multithreaded processing, automated decision-making, agent-manager hierarchy, and mock notifications. Built with Spring Boot 3.5.5 & MySQL.

Notifications You must be signed in to change notification settings

Yugenrane/loan-origination-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Loan Origination System (LOS)

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.

🎯 Overview

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

πŸ› οΈ Technology Stack

  • 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)

πŸ“‹ Prerequisites

  • Java 17 or higher
  • MySQL 8.0 or higher
  • Maven 3.6 or higher
  • IDE (IntelliJ IDEA, Eclipse, or VS Code)

πŸš€ Quick Setup

1. Database Configuration

CREATE DATABASE loan_origination_db;

2. Application Configuration

Update src/main/resources/application.yml:

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/loan_origination_db
    username: root
    password: password

3. Insert Sample Data

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());

4. Run Application

mvn spring-boot:run

Application URL: http://localhost:8080

πŸ“– API Endpoints

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

πŸ§ͺ Sample Usage

Submit Loan Application

POST http://localhost:8080/api/v1/loans
Content-Type: application/json

{
  "loanId": "LOAN001",
  "customerName": "Ramesh Kumar Singh",
  "customerPhone": "9123456789",
  "loanAmount": 250000,
  "loanType": "PERSONAL"
}

Check Status Counts

GET http://localhost:8080/api/v1/loans/status-count

Response:

{
  "applied": 0,
  "approvedBySystem": 9,
  "rejectedBySystem": 16,
  "underReview": 16,
  "approvedByAgent": 0,
  "rejectedByAgent": 0
}

Agent Decision

PUT http://localhost:8080/api/v1/agents/1/loans/LOAN001/decision
Content-Type: application/json

{
  "decision": "APPROVE"
}

πŸ”„ Loan Processing Workflow

  1. Application Submission β†’ Status: APPLIED

  2. 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
  3. Agent Assignment β†’ Available agent assigned automatically

  4. Notifications β†’ Push to agent, SMS to customer

  5. Agent Decision β†’ APPROVED_BY_AGENT or REJECTED_BY_AGENT

πŸ“Š Business Rules

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

πŸ§ͺ Testing

Using Postman Collection

Import LOS-API-Collection.json for comprehensive testing of all endpoints.

Test Data Samples

// 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"
}

πŸ—οΈ Architecture

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

βœ… Features Implemented

  • βœ… 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

πŸ”§ Configuration

Thread Pool Settings

  • Core threads: 3
  • Max threads: 10
  • Queue capacity: 50
  • Processing interval: Every 5 seconds
  • Simulation delay: 25 seconds per loan

Database Optimization

  • Indexed columns: application_status, customer_name
  • Connection pooling: HikariCP
  • Transaction management: Spring @Transactional

πŸ“ˆ Performance Features

  • 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

🎯 Assignment Requirements Fulfilled

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.

About

Enterprise-grade Loan Origination System with multithreaded processing, automated decision-making, agent-manager hierarchy, and mock notifications. Built with Spring Boot 3.5.5 & MySQL.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages