How ria-1705/loanflow-backend works
Purpose and runtime
Loanflow is a Java/Spring Boot backend for managing customers, loans, loan documents, users/roles, credit checks, and loan-state workflow. The application starts at src/main/java/com/ria/loanflow/LoanflowApplication.java; Maven build/dependency configuration is in pom.xml. HTTP REST controllers are the primary entry points.
API and application boundary
Controllers accept request DTOs, delegate to service interfaces/implementations, and return response DTOs. Principal resource APIs cover authentication, customers, loans, documents, users, dashboard summaries, and health:
• src/main/java/com/ria/loanflow/controller/AuthController.java
• src/main/java/com/ria/loanflow/controller/LoanController.java
• src/main/java/com/ria/loanflow/controller/CustomerController.java
DTOs and mappers isolate the HTTP contract from persistence entities, notably src/main/java/com/ria/loanflow/dtos/req/LoanRequest.java, src/main/java/com/ria/loanflow/dtos/res/LoanResponse.java, and src/main/java/com/ria/loanflow/mapper/LoanMapper.java.
Identity, access, and session flow
Security is Spring Security with JWT authentication. SecurityConfig configures the security boundary; the JWT filter establishes an authenticated principal for protected requests. Authentication services issue/manage tokens, including persisted refresh tokens. Roles are modeled and seeded at startup.
• src/main/java/com/ria/loanflow/config/SecurityConfig.java
• src/main/java/com/ria/loanflow/security/jwt/JwtAuthenticationFilter.java
• src/main/java/com/ria/loanflow/service/impl/AuthServiceImpl.java
Core loan domain and persistence
The central model is Loan, associated with Customer, uploaded LoanDocument records, users/roles, and refresh-token records. Spring Data repositories form the persistence boundary; application.properties supplies runtime database and application configuration.
• src/main/java/com/ria/loanflow/entity/Loan.java
• src/main/java/com/ria/loanflow/entity/Customer.java
• src/main/java/com/ria/loanflow/repository/LoanRepository.java
Primary flow: a loan request is mapped into the domain, persisted through LoanService, and exposed as a response. Loan and customer statuses/types are explicit enums, allowing business behavior to be state-driven rather than inferred from fields.
Workflow and state history
Loan processing is separated into a workflow subsystem. Workflow events and validation govern legal transitions; each status change can be retained as LoanStatusHistory. This creates a clear boundary between ordinary loan CRUD and controlled approval/rejection/state progression.
• src/main/java/com/ria/loanflow/service/impl/WorkflowServiceImpl.java
• src/main/java/com/ria/loanflow/workflow/validator/LoanWorkflowValidator.java
• src/main/java/com/ria/loanflow/workflow/history/LoanStatusHistory.java
InvalidLoanStateException and the global exception handler standardize invalid-transition and business-error API behavior.
Credit, documents, and external I/O
Credit evaluation is abstracted behind CreditService and CreditBureauClient; ExperianAdapter is the concrete external-bureau adapter. This keeps loan decisioning insulated from a particular credit provider.
• src/main/java/com/ria/loanflow/service/impl/CreditServiceImpl.java
• src/main/java/com/ria/loanflow/integration/CreditBureauClient.java
• src/main/java/com/ria/loanflow/integration/ExperianAdapter.java
Document handling uses LoanDocumentService behind a StorageService abstraction, currently implemented by local filesystem storage rather than cloud object storage.
• src/main/java/com/ria/loanflow/service/impl/LoanDocumentServiceImpl.java
• src/main/java/com/ria/loanflow/service/impl/LocalStorageService.java
Audit and operational views
Cross-cutting auditing is implemented with an @Audit annotation and AOP aspect, then stored as audit-log entities and exposed through its own controller. This decouples audit capture from individual business services. Dashboard services aggregate domain information for operational summaries.
• src/main/java/com/ria/loanflow/audit/aspect/AuditAspect.java
• src/main/java/com/ria/loanflow/audit/entity/AuditLog.java
• src/main/java/com/ria/loanflow/service/impl/DashboardServiceImpl.java
Main entry points: LoanController.java REST Controllers · LoanRepository.java Spring Data Repositories · WorkflowServiceImpl.java Workflow Service · JwtAuthenticationFilter.java JWT Filter
Components 20
HTTP API
- REST Controllers · Auth, loan, customer, document, user, dashboard, and health APIs.
src/main/java/com/ria/loanflow/controller/LoanController.java - Loan DTOs & Mapper · Separates loan HTTP contracts from domain entities.
src/main/java/com/ria/loanflow/mapper/LoanMapper.java
Security & Identity
- Security Config
src/main/java/com/ria/loanflow/config/SecurityConfig.java - JWT Filter · Establishes the principal on protected requests.
src/main/java/com/ria/loanflow/security/jwt/JwtAuthenticationFilter.java - Auth Service · Issues and manages JWT and persisted refresh tokens.
src/main/java/com/ria/loanflow/service/impl/AuthServiceImpl.java - Users, Roles & Tokens
Loan Domain
- Loan Service · Coordinates loan CRUD and domain operations.
- Loan & Customer Model · Status and type enums make domain behavior state-driven.
src/main/java/com/ria/loanflow/entity/Loan.java - Spring Data Repositories
src/main/java/com/ria/loanflow/repository/LoanRepository.java - Application Database · Stores domain, identity, history, and audit records.
Workflow & Integrations
- Workflow Service · Separates controlled loan progression from ordinary CRUD.
src/main/java/com/ria/loanflow/service/impl/WorkflowServiceImpl.java - Workflow Validator · Validates legal loan state transitions.
src/main/java/com/ria/loanflow/workflow/validator/LoanWorkflowValidator.java - Loan Status History · Retains each loan status change.
src/main/java/com/ria/loanflow/workflow/history/LoanStatusHistory.java - Credit Service
src/main/java/com/ria/loanflow/service/impl/CreditServiceImpl.java - Credit Bureau Adapter · CreditBureauClient abstraction implemented by Experian.
src/main/java/com/ria/loanflow/integration/ExperianAdapter.java - Document & Local Storage · Loan documents are stored through the local storage implementation.
src/main/java/com/ria/loanflow/service/impl/LoanDocumentServiceImpl.java
Audit & Operations
- Audit Aspect · Captures annotated business activity into audit logs.
src/main/java/com/ria/loanflow/audit/aspect/AuditAspect.java - Audit Logs
src/main/java/com/ria/loanflow/audit/entity/AuditLog.java - Dashboard Service · Builds operational summaries from domain data.
src/main/java/com/ria/loanflow/service/impl/DashboardServiceImpl.java
Other components
- Spring Boot App
src/main/java/com/ria/loanflow/LoanflowApplication.java
Connections 25
- Spring Boot App → Security Config: boots
- Spring Boot App → REST Controllers: serves
- REST Controllers → JWT Filter: protected requests
- Security Config → JWT Filter: installs
- REST Controllers → Auth Service: auth API
- JWT Filter → Auth Service: validates token
- Auth Service → Users, Roles & Tokens: manages
- REST Controllers → Loan DTOs & Mapper: accepts and returns
- Loan DTOs & Mapper → Loan Service: maps requests
- REST Controllers → Loan Service: loan API
- Loan Service → Loan & Customer Model: operates on
- Loan Service → Spring Data Repositories: persists through
- Spring Data Repositories → Application Database: reads and writes
- Loan Service → Workflow Service: state changes
- Workflow Service → Workflow Validator: validates
- Workflow Service → Loan Status History: records transition
- Loan Status History → Spring Data Repositories: persists
- Loan Service → Credit Service: requests evaluation
- Credit Service → Credit Bureau Adapter: calls
- REST Controllers → Document & Local Storage: document API
- Document & Local Storage → Loan & Customer Model: associates documents
- REST Controllers → Dashboard Service: dashboard API
- Dashboard Service → Spring Data Repositories: aggregates
- Audit Aspect → Audit Logs: writes
- Audit Logs → Spring Data Repositories: persists