Loan Application Evaluator
A runnable Spring Boot 4 project that shows how a real loan-evaluation backend is structured — from REST API to JPA persistence and Mockito unit tests.
What You'll Find Here
| Note | Description |
|---|---|
| Project Overview | What the project does, tech stack, and how to run it locally. |
| Domain Model | Entities, DTOs (Records), and the five enums that drive business rules. |
| API Contract | The single REST endpoint, request/response shapes, and Bean Validation rules. |
| Service & Business Logic | Risk classification, interest-rate formula, EMI calculation, and the two-tier eligibility check. |
| Persistence Layer | JPA @Embeddable value objects, @ElementCollection for rejection reasons, and H2 schema. |
| Exception Handling | @RestControllerAdvice catching validation failures and mapping them to structured JSON errors. |
| Testing Strategy | Mockito-based unit tests with @Nested grouping by concern. |
Learning Path
Work through the notes in this order for the clearest mental model:
- Project Overview — run the app first; get a feel for what it does.
- Domain Model — understand the data before the logic.
- API Contract — see what input the API accepts and what it returns.
- Service & Business Logic — the core: risk, rate, EMI, eligibility.
- Persistence Layer — how the domain objects map to H2 tables.
- Exception Handling — how invalid requests are turned into useful error responses.
- Testing Strategy — how unit tests verify each business rule in isolation.
Source Code
The full source lives at projects/loan-application-evaluator/ in the repository root.
projects/loan-application-evaluator/
├── src/main/java/com/dileephegde/loanapplicationevaluator/
│ ├── LoanApplicationEvaluator.java ← @SpringBootApplication entry point
│ ├── controller/
│ │ └── LoanApplicationController.java ← POST /applications
│ ├── service/
│ │ └── LoanApplicationService.java ← all business logic
│ ├── entity/
│ │ ├── LoanApplication.java ← aggregate root (@Entity)
│ │ ├── Applicant.java ← @Embeddable value object
│ │ ├── Loan.java ← @Embeddable value object
│ │ ├── Offer.java ← @Embeddable value object
│ │ └── enums/
│ │ ├── ApplicationStatus.java
│ │ ├── EmploymentType.java
│ │ ├── LoanPurpose.java
│ │ ├── RejectionReason.java
│ │ └── RiskBand.java
│ ├── dto/
│ │ ├── LoanApplicationRequest.java ← record (input)
│ │ ├── LoanApplicationResponse.java ← record (output)
│ │ ├── ApplicantDTO.java ← record with @Valid annotations
│ │ ├── LoanDTO.java ← record with @Valid annotations
│ │ └── OfferDTO.java ← record (read-only output)
│ ├── repository/
│ │ └── ILoanApplicationRepository.java ← JpaRepository
│ └── exception/
│ ├── GlobalExceptionHandler.java ← @RestControllerAdvice
│ └── ErrorResponse.java ← record
└── src/test/java/…/service/
└── LoanApplicationServiceTest.java ← @Nested Mockito tests
Related Domains
- Spring Boot — auto-configuration, starters,
@SpringBootApplication. - Spring Data — JPA repositories,
@Embeddable,@ElementCollection. - Testing — JUnit 5 and Mockito patterns used in this project.
- Web — REST controller patterns,
@RestControllerAdvice.