Enterprise-grade Loan Processing System built with Clean Architecture, Domain-Driven Design (DDD), and .NET 10.
SmartLend is a compliance-ready financial engine designed to automate loan risk assessment. It moves beyond simple CRUD to demonstrate how Deterministic Logic and Generative AI can work together in a secure banking environment.
The system enforces strict financial rules using C# (safe), while leveraging Google Gemini 2.5 Flash to generate empathetic, human-readable explanations for customers (smart).
The solution follows strict Clean Architecture principles to ensure that Business Logic is isolated from Technical Details.
- 🟡 Domain (The Core): Contains the Enterprise Business Rules.
- Rich Domain Model: Logic is encapsulated in
LoanApplication.Evaluate(), ensuring a loan can never exist in an invalid state. - Pure: Zero dependencies on external libraries.
- Rich Domain Model: Logic is encapsulated in
- 🔴 Application (The Orchestrator): Contains the Use Cases.
- Orchestrates the flow:
DTO -> Domain Logic -> Database -> AI Advisor.
- Orchestrates the flow:
- 🔵 Infrastructure (The Plugins): Contains the external tools.
- Persistence Strategy: Implements the Repository Pattern with Dual Support (In-Memory & SQL Server).
- AI Service: Google Gemini 2.5 Flash implementation via
HttpClient.
- 🟢 API (The Entry Point): The REST API/Swagger UI.
- Wires everything together using Dependency Injection.
I integrated Google Gemini 2.5 Flash into the Infrastructure layer to act as a "Financial Advisor."
- Workflow: When a loan is rejected by the C# math engine, the AI analyzes the user's data (Salary, Credit Score) and generates a polite, personalized financial tip.
- Safety: The AI never makes the approval decision. It only explains it. This prevents "AI Hallucinations" from approving risky loans.
To demonstrate architectural flexibility, I implemented two database providers in the Infrastructure layer:
InMemoryLoanRepository: Optimized for rapid development, unit testing, and demos (Currently Active).SqlServerLoanRepository: Production-ready implementation using Entity Framework Core.- Note: The application is currently configured to run in In-Memory Mode for ease of review (no local SQL setup required). To switch to SQL, simply uncomment the line in
Program.cs.
Every decision is immutable. The system records a timestamped (UTC) Audit Log for every action.
- Example Log:
[AUDIT] Action: Rejected | Time: 12/05/2025 | AI Advice: "Debt-to-Income ratio too high..."
- Framework: .NET 10 (Preview)
- Architecture: Clean Architecture / Onion Architecture
- AI Model: Google Gemini 2.5 Flash
- Database: In-Memory (Active) / SQL Server (Implemented)
- Testing: xUnit
- Documentation: Swagger / OpenAPI
- .NET 10.0 SDK installed.
- (Optional) A Google Gemini API Key. Note: If no key is provided, the system gracefully degrades to "Offline Mode" and still processes loans.
-
Clone the repository:
git clone [https://github.com/TaGoat/SmartLend.git](https://github.com/TaGoat/SmartLend.git) cd SmartLend -
Run the API:
dotnet run --project SmartLend.Api
-
Test with Swagger: Open your browser to the URL shown in the terminal (e.g.,
http://localhost:5xxx/swagger).- POST /api/loans: Submit a loan request.
- Check Console: Watch the VS Code terminal to see the AI Advice and Audit Logs printed in real-time.
Core business logic is covered by Unit Tests in the SmartLend.Domain.Tests project.
- Run Tests:
dotnet test - Coverage: Verifies that the "Debt-to-Income" and "Credit Score" rules trigger the correct Rejection status.
Built by [Tareq AL-Suraihi]