How dahirali3823/applicant-service works
Purpose and runtime
Credit Risk Assessment System is a Java 17 Spring Boot REST backend that manages applicants, computes configurable credit-risk scores, and returns approve/deny loan decisions. The application starts from src/main/java/com/example/Application.java; HTTP APIs run in the Spring Boot process.
API boundary
Controllers expose JSON endpoints and separate transport concerns from domain services:
• Applicant CRUD: src/main/java/com/example/applicant_service/ApplicantController.java
• Credit-score calculation and explanation: src/main/java/com/example/scoring_service/ScoringController.java
• Loan evaluation: src/main/java/com/example/loan_service/LoanController.java
• Liveness-style status endpoints: src/main/java/com/example/health/HealthController.java
Applicant lifecycle and persistence
Applicant is the central input record for all risk assessment, carrying applicant financial and employment/residency data. ApplicantService owns create/read/update/partial-update/delete behavior and uses the repository boundary for storage:
• src/main/java/com/example/applicant_service/Applicant.java
• src/main/java/com/example/applicant_service/ApplicantService.java
• src/main/java/com/example/applicant_service/ApplicantRepository.java
PostgreSQL is the intended persistence service; connection and application settings are in src/main/resources/application.yml.
Scoring stage
ScoringService receives an applicant identifier, obtains applicant data through the application’s domain layer, and calculates a numeric credit score from applicant attributes and scoring weights. It also produces a human-readable breakdown for the explanation endpoint. CreditScore is the score-domain result/value model.
• src/main/java/com/example/scoring_service/ScoringService.java
• src/main/java/com/example/scoring_service/CreditScore.java
• src/main/java/com/example/scoring_service/ScoringController.java
Loan-decision stage
LoanDecisionService is the downstream policy layer: it evaluates an applicant using score-related and applicant data, then emits a LoanDecision containing the approval/denial outcome. The loan controller is therefore an orchestration-facing API, not a separate persistence subsystem.
• src/main/java/com/example/loan_service/LoanDecisionService.java
• src/main/java/com/example/loan_service/LoanDecision.java
• src/main/java/com/example/loan_service/LoanController.java
Primary control flow
1. Client creates or updates an applicant through /api/applicants; the controller delegates to ApplicantService, which persists through ApplicantRepository.
2. A scoring request identifies an applicant; ScoringService loads its current data and returns either score data or explanatory output.
3. A loan request identifies an applicant; LoanDecisionService applies decision policy based on applicant/scoring results and returns LoanDecision.
4. Health endpoints provide lightweight availability checks independent of the business workflows.
Deployment and infrastructure
Maven builds the Spring Boot artifact using pom.xml. The repository supports containerized execution through Dockerfile and docker-compose.yml; Compose is the likely boundary for the application and PostgreSQL containers. Runtime configuration remains externalized in src/main/resources/application.yml.
Main entry points: Application.java Spring Boot Application · ApplicantService.java Applicant Service · LoanDecisionService.java Loan Decision Service · ScoringService.java Scoring Service
Components 17
HTTP API
- Applicant Controller · Applicant CRUD endpoints.
src/main/java/com/example/applicant_service/ApplicantController.java - Scoring Controller · Score and explanation endpoints.
src/main/java/com/example/scoring_service/ScoringController.java - Loan Controller · Loan evaluation endpoint.
src/main/java/com/example/loan_service/LoanController.java - Health Controller · Lightweight availability endpoints.
src/main/java/com/example/health/HealthController.java
Risk Domain
- Applicant Service · Owns applicant lifecycle operations.
src/main/java/com/example/applicant_service/ApplicantService.java - Applicant · Financial and employment input for assessment.
src/main/java/com/example/applicant_service/Applicant.java - Scoring Service · Calculates scores and explanatory breakdowns.
src/main/java/com/example/scoring_service/ScoringService.java - Credit Score · Numeric scoring result.
src/main/java/com/example/scoring_service/CreditScore.java - Loan Decision Service · Applies approval or denial policy.
src/main/java/com/example/loan_service/LoanDecisionService.java - Loan Decision · Approval or denial outcome.
src/main/java/com/example/loan_service/LoanDecision.java
Persistence
- Applicant Repository · Storage boundary for applicants.
src/main/java/com/example/applicant_service/ApplicantRepository.java - PostgreSQL · Intended applicant persistence store.
Build & Runtime
- Spring Boot Application · Starts the REST backend.
src/main/java/com/example/Application.java - Application Configuration · Externalized database and application settings.
src/main/resources/application.yml - Maven Build · Builds the Spring Boot artifact.
pom.xml - Container Deployment · Defines application and PostgreSQL containers.
docker-compose.yml - Application Image
Dockerfile
Connections 20
- Spring Boot Application → Applicant Controller: serves
- Spring Boot Application → Scoring Controller: serves
- Spring Boot Application → Loan Controller: serves
- Spring Boot Application → Health Controller: serves
- Applicant Controller → Applicant Service: CRUD requests
- Applicant Service → Applicant: manages
- Applicant Service → Applicant Repository: persists via
- Applicant Repository → PostgreSQL: stores
- Scoring Controller → Scoring Service: score requests
- Scoring Service → Applicant Service: loads applicant
- Scoring Service → Credit Score: produces
- Loan Controller → Loan Decision Service: evaluation requests
- Loan Decision Service → Applicant Service: uses applicant data
- Loan Decision Service → Scoring Service: uses score
- Loan Decision Service → Loan Decision: produces
- Application Configuration → Spring Boot Application: configures
- Maven Build → Application Image: packages
- Application Image → Container Deployment: runs in
- Container Deployment → Spring Boot Application: deploys
- Container Deployment → PostgreSQL: provisions