# dheekshanaveen/agentic_lending_systems architecture

> Architecture diagram of the GitHub repository dheekshanaveen/agentic_lending_systems, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dheekshanaveen/agentic_lending_systems
- Repository: https://github.com/dheekshanaveen/agentic_lending_systems

## Overview

This repository implements a lending application backend with document-based KYC and income verification. The visible request paths accept uploaded documents, invoke verification agents, and return parsed fields and verification outcomes; the agents also query application data and, in the sampled implementations, persist verification records. Scoring, fraud, explanation, and status modules indicate additional product capabilities, but their implementations and wiring were not shown. The README is empty, and the workflow file excerpt is empty, so those areas are represented without inferred connections.

Main entry points: [`backend/agents/income_agent.py`](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/income_agent.py) (Income verification), [`backend/agents/pan_agent.py`](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/pan_agent.py) (PAN OCR and match), [`backend/routers/ocr.py`](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/ocr.py) (OCR upload API), [`backend/database.py`](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/database.py) (Database session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Application data"]
  node_intake_api["Application intake<br/>[intake.py]"]
  node_request_schema["Request validation<br/>[request_schemas.py]"]
  node_application_record["Application record<br/>[db_models.py]"]
end

subgraph group_kyc["Identity verification"]
  node_ocr_upload["OCR upload API<br/>[ocr.py]"]
  node_aadhaar_agent["Aadhaar OCR<br/>[aadhar_agent.py]"]
  node_pan_agent["PAN OCR and match<br/>[pan_agent.py]"]
  node_kyc_records["KYC records<br/>[db_models.py]"]
end

subgraph group_income["Income verification"]
  node_income_upload["Income upload API<br/>[income.py]"]
  node_income_agent["Income verification<br/>[income_agent.py]"]
  node_salary_slip["Salary slip record<br/>[db_models.py]"]
  node_bank_statement["Bank statement record<br/>[db_models.py]"]
  node_income_result["Income result record<br/>[db_models.py]"]
end

subgraph group_persistence["Persistence and decisions"]
  node_db_session["Database session<br/>[database.py]"]
  node_lending_store[("SQLite lending store<br/>[lending.db]")]
  node_scoring_api["Scoring endpoint<br/>[scoring.py]"]
  node_fraud_api["Fraud endpoint<br/>[fraud.py]"]
  node_explain_api["Explanation endpoint<br/>[explain.py]"]
  node_status_api["Status endpoint<br/>[status.py]"]
end

node_applicant(("Applicant"))

node_applicant -.->|"submits application"| node_intake_api
node_applicant -->|"uploads documents"| node_ocr_upload
node_applicant -->|"uploads statements"| node_income_upload
node_ocr_upload -->|"runs when supplied"| node_aadhaar_agent
node_ocr_upload -->|"runs when supplied"| node_pan_agent
node_pan_agent -->|"queries session"| node_db_session
node_pan_agent -->|"reads application"| node_application_record
node_pan_agent -->|"saves KYC snapshot"| node_kyc_records
node_income_upload -->|"invokes verification"| node_income_agent
node_income_agent -->|"opens session"| node_db_session
node_income_agent -->|"reads application"| node_application_record
node_income_agent -->|"saves parsed slips"| node_salary_slip
node_income_agent -->|"saves parsed statements"| node_bank_statement
node_income_agent -->|"saves verification"| node_income_result
node_db_session -->|"targets SQLite file"| node_lending_store

click node_intake_api "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/intake.py"
click node_request_schema "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/schemas/request_schemas.py"
click node_application_record "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py"
click node_ocr_upload "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/ocr.py"
click node_aadhaar_agent "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/aadhar_agent.py"
click node_pan_agent "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/pan_agent.py"
click node_kyc_records "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py"
click node_income_upload "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/income.py"
click node_income_agent "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/income_agent.py"
click node_salary_slip "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py"
click node_bank_statement "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py"
click node_income_result "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py"
click node_db_session "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/database.py"
click node_lending_store "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/lending.db"
click node_scoring_api "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/scoring.py"
click node_fraud_api "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/fraud.py"
click node_explain_api "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/explain.py"
click node_status_api "https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/status.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_intake_api,node_request_schema,node_application_record toneBlue
class node_ocr_upload,node_aadhaar_agent,node_pan_agent,node_kyc_records toneAmber
class node_income_upload,node_income_agent,node_salary_slip,node_bank_statement,node_income_result toneMint
class node_db_session,node_lending_store,node_scoring_api,node_fraud_api,node_explain_api,node_status_api toneRose
class node_applicant toneIndigo
```

## Components

### Application data

- [Application intake](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/intake.py): `backend/routers/intake.py`
- [Request validation](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/schemas/request_schemas.py): `backend/schemas/request_schemas.py`
- [Application record](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py): `backend/models/db_models.py`

### Identity verification

- [OCR upload API](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/ocr.py): `backend/routers/ocr.py`
- [Aadhaar OCR](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/aadhar_agent.py): `backend/agents/aadhar_agent.py`
- [PAN OCR and match](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/pan_agent.py): `backend/agents/pan_agent.py`
- [KYC records](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py): `backend/models/db_models.py`

### Income verification

- [Income upload API](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/income.py): `backend/routers/income.py`
- [Income verification](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/agents/income_agent.py): `backend/agents/income_agent.py`
- [Salary slip record](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py): `backend/models/db_models.py`
- [Bank statement record](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py): `backend/models/db_models.py`
- [Income result record](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/models/db_models.py): `backend/models/db_models.py`

### Persistence and decisions

- [Database session](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/database.py): `backend/database.py`
- [SQLite lending store](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/lending.db): `lending.db`
- [Scoring endpoint](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/scoring.py): `backend/routers/scoring.py`
- [Fraud endpoint](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/fraud.py): `backend/routers/fraud.py`
- [Explanation endpoint](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/explain.py): `backend/routers/explain.py`
- [Status endpoint](https://github.com/dheekshanaveen/agentic_lending_systems/blob/main/backend/routers/status.py): `backend/routers/status.py`

### Other components

- **Applicant**

## Connections

- Applicant → Application intake: submits application
- Applicant → OCR upload API: uploads documents (evidence: `backend/routers/ocr.py`)
- Applicant → Income upload API: uploads statements (evidence: `backend/routers/income.py`)
- OCR upload API → Aadhaar OCR: runs when supplied (evidence: `backend/routers/ocr.py`)
- OCR upload API → PAN OCR and match: runs when supplied (evidence: `backend/routers/ocr.py`)
- PAN OCR and match → Database session: queries session (evidence: `backend/agents/pan_agent.py`)
- PAN OCR and match → Application record: reads application (evidence: `backend/agents/pan_agent.py`)
- PAN OCR and match → KYC records: saves KYC snapshot (evidence: `backend/agents/pan_agent.py`)
- Income upload API → Income verification: invokes verification (evidence: `backend/routers/income.py`)
- Income verification → Database session: opens session (evidence: `backend/agents/income_agent.py`)
- Income verification → Application record: reads application (evidence: `backend/agents/income_agent.py`)
- Income verification → Salary slip record: saves parsed slips (evidence: `backend/agents/income_agent.py`)
- Income verification → Bank statement record: saves parsed statements (evidence: `backend/agents/income_agent.py`)
- Income verification → Income result record: saves verification (evidence: `backend/agents/income_agent.py`)
- Database session → SQLite lending store: targets SQLite file (evidence: `backend/database.py`)
