Backend-first loan amortization and repayment forecasting API built with Java 26, Spring Boot 4, PostgreSQL, Flyway, and OpenAPI.
This project is designed as a portfolio-grade finance backend that demonstrates how to build a production-style loan calculation engine with clean architecture, persistent scenarios, export support, and realistic repayment modelling. It is intentionally API-first, so Swagger UI is the primary interface instead of an Angular frontend.
Recruiters and engineering teams often see simple CRUD demos. This repository aims to show stronger backend engineering skills through:
- deterministic financial calculations with
BigDecimal - explicit domain modelling for loan schedules and rate changes
- clean package boundaries across
api,application,domain,infrastructure, andconfig - Flyway-managed schema evolution
- meaningful automated tests across domain logic and Spring MVC integration
- export workflows that make the project demo-friendly without building a UI
- create and persist loan projections
- generate full amortization schedules
- support monthly, weekly, and biweekly repayment frequencies
- model one-time extra payments
- model recurring extra payments
- apply variable interest-rate adjustments over time
- support multiple repricing strategies, including capped payment increases
- compare multiple loan scenarios against a baseline
- export persisted projections as CSV or PDF
- explore and test the API through Swagger UI
- How much interest will I pay on a 60-month personal loan?
- What happens if I make a lump-sum payment after month 12?
- How much faster does the loan close if I pay an extra amount every two weeks?
- What happens when the rate changes but payment growth is capped?
- Which of two repayment strategies produces the lower total cost?
- Java 26
- Spring Boot 4.1
- Spring Data JPA
- PostgreSQL
- Flyway
- springdoc OpenAPI / Swagger UI
- PDFBox
- JUnit 5
- Mockito
- Testcontainers
- Docker Compose
The main engineering value lives in the calculation and orchestration layers rather than the controller layer.
apiREST controllers, request DTOs, response DTOs, and export optionsapplicationuse-case orchestration, persistence coordination, export generationdomainamortization logic, repayment frequency rules, extra-payment behaviour, repricing strategiesinfrastructureJPA entities and repositoriesconfigOpenAPI and application configuration
- Start PostgreSQL:
docker compose up -d- Start the application:
mvn spring-boot:run- Open Swagger UI:
http://localhost:8080/swagger-ui.html
Default local settings are defined in src/main/resources/application.yml.
Environment variables you can override:
DB_URLDB_USERNAMEDB_PASSWORD
POST /api/v1/loan-projectionsGET /api/v1/loan-projections/{projectionId}GET /api/v1/loan-projections/{projectionId}/scheduleGET /api/v1/loan-projections/{projectionId}/export?format=CSVGET /api/v1/loan-projections/{projectionId}/export?format=PDFPOST /api/v1/loan-projections/compare
{
"customerName": "Portfolio Demo",
"principal": 250000.00,
"annualInterestRate": 11.75,
"termMonths": 60,
"repaymentFrequency": "MONTHLY",
"startDate": "2026-07-01",
"originationFee": 1200.00,
"monthlyServiceFee": 69.00,
"extraPayments": [
{
"paymentDate": "2027-07-01",
"amount": 15000.00
}
],
"recurringExtraPayments": [
{
"startDate": "2026-10-01",
"endDate": "2027-10-01",
"amount": 500.00,
"recurrenceFrequency": "MONTHLY"
}
],
"interestRateAdjustments": [
{
"effectiveDate": "2028-01-01",
"annualInterestRate": 13.25,
"strategy": "RECALCULATE_PAYMENT_WITH_CAP",
"paymentChangeCapPercent": 8.00
}
]
}- Create a projection with
POST /api/v1/loan-projections - Inspect the summary and payoff date
- Open the stored schedule with
GET /api/v1/loan-projections/{projectionId}/schedule - Export the result as CSV or PDF
- Compare alternative repayment scenarios with
POST /api/v1/loan-projections/compare
Run the required checks with:
mvn clean verify
mvn testNotes:
- the default test profile uses H2 in PostgreSQL compatibility mode for fast feedback
- Swagger endpoints are disabled in tests to keep the test runtime quieter and closer to focused application behaviour
- a PostgreSQL-backed migration validation test is included for stronger schema confidence when Docker is available
- authentication and role-based access control
- versioned projection history
- event publication for downstream ledger systems
- repayment holiday support
- richer PDF formatting for customer-style statements
- eventual Angular dashboard in a separate UI repository
MIT