# saanvi2005/ai-powered-loan-automation-system architecture

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

- Interactive diagram: https://gitdiagram.com/saanvi2005/ai-powered-loan-automation-system
- Repository: https://github.com/saanvi2005/ai-powered-loan-automation-system

## Overview

NexusBank is a loan application system: a customer chats with an assistant to provide application details, receives an underwriting decision, and—if eligible—uploads identity and salary documents for verification. The frontend also tracks progress and presents an approval-style completion state; the README describes final approval, while the sampled frontend simulates it locally. Edges reflect visible calls and documented frontend behavior; unsampled subsystems are not inferred.

Main entry points: [`backend/api/sales_routes.py`](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/sales_routes.py) (Sales message API), [`backend/main.py`](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/main.py) (App and static serving), [`frontend/index.html`](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/index.html) (Application UI), [`frontend/script.js`](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/script.js) (Chat and status)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer interface"]
  node_application_ui["Application UI<br/>[index.html]"]
  node_chat_ui["Chat and status<br/>[script.js]"]
  node_document_ui["Document upload<br/>[script.js]"]
end

subgraph group_api["FastAPI routes"]
  node_sales_api["Sales message API<br/>[sales_routes.py]"]
  node_underwriter_api["Underwriting API"]
  node_document_api["Document verification API<br/>[document_router.py]"]
  node_app_entry["App and static serving<br/>[main.py]"]
end

subgraph group_agents["Loan processing"]
  node_sales_agent["Information collection<br/>[sales_agent.py]"]
  node_underwriter["Eligibility analysis<br/>[underwriter.py]"]
  node_document_verifier["OCR verification<br/>[doc_verify.py]"]
end

subgraph group_state["Models and session state"]
  node_session_memory["Session memory<br/>[memory.py]"]
  node_local_llm["Local LLM wrapper<br/>[ollama_model.py]"]
end

node_customer(("Applicant"))

node_customer -->|"provides application details"| node_application_ui
node_application_ui -->|"opens chat"| node_chat_ui
node_chat_ui -->|"posts messages"| node_sales_api
node_sales_api -->|"reads and updates"| node_session_memory
node_sales_api -->|"requests response"| node_sales_agent
node_sales_api -->|"submits collected data"| node_underwriter
node_sales_agent -->|"invokes model"| node_local_llm
node_underwriter -->|"invokes model"| node_local_llm
node_chat_ui -.->|"posts analysis"| node_underwriter_api
node_underwriter_api -->|"runs analysis"| node_underwriter
node_customer -->|"uploads documents"| node_document_ui
node_document_ui -->|"posts files"| node_document_api
node_document_api -->|"verifies document"| node_document_verifier
node_application_ui -->|"shows progress and outcomes"| node_chat_ui
node_app_entry -->|"registers route"| node_sales_api
node_app_entry -->|"registers route"| node_underwriter_api
node_app_entry -->|"registers route"| node_document_api
node_app_entry -->|"serves frontend"| node_application_ui

click node_application_ui "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/index.html"
click node_chat_ui "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/script.js"
click node_document_ui "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/script.js"
click node_sales_api "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/sales_routes.py"
click node_underwriter_api "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/underwriter_router.py"
click node_document_api "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/document_router.py"
click node_sales_agent "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/agents/sales_agent.py"
click node_underwriter "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/agents/underwriter.py"
click node_document_verifier "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/agents/doc_verify.py"
click node_session_memory "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/memory.py"
click node_local_llm "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/models/ollama_model.py"
click node_app_entry "https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/main.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_application_ui,node_chat_ui,node_document_ui toneBlue
class node_sales_api,node_underwriter_api,node_document_api,node_app_entry toneAmber
class node_sales_agent,node_underwriter,node_document_verifier toneMint
class node_session_memory,node_local_llm toneRose
class node_customer toneIndigo
```

## Components

### Customer interface

- [Application UI](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/index.html): `frontend/index.html`
- [Chat and status](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/script.js): `frontend/script.js`
- [Document upload](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/frontend/script.js): `frontend/script.js`

### FastAPI routes

- [Sales message API](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/sales_routes.py): `backend/api/sales_routes.py`
- [Underwriting API](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/underwriter_router.py): `backend/api/underwriter_router.py`
- [Document verification API](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/api/document_router.py): `backend/api/document_router.py`
- [App and static serving](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/main.py): `backend/main.py`

### Loan processing

- [Information collection](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/agents/sales_agent.py): `backend/agents/sales_agent.py`
- [Eligibility analysis](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/agents/underwriter.py): `backend/agents/underwriter.py`
- [OCR verification](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/agents/doc_verify.py): `backend/agents/doc_verify.py`

### Models and session state

- [Session memory](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/memory.py): `backend/memory.py`
- [Local LLM wrapper](https://github.com/saanvi2005/ai-powered-loan-automation-system/blob/main/backend/models/ollama_model.py): `backend/models/ollama_model.py`

### Other components

- **Applicant**

## Connections

- Applicant → Application UI: provides application details (evidence: `README.md`)
- Application UI → Chat and status: opens chat (evidence: `frontend/script.js`)
- Chat and status → Sales message API: posts messages (evidence: `frontend/script.js`)
- Sales message API → Session memory: reads and updates (evidence: `backend/api/sales_routes.py`)
- Sales message API → Information collection: requests response (evidence: `backend/api/sales_routes.py`)
- Sales message API → Eligibility analysis: submits collected data (evidence: `backend/api/sales_routes.py`)
- Information collection → Local LLM wrapper: invokes model (evidence: `backend/agents/sales_agent.py`)
- Eligibility analysis → Local LLM wrapper: invokes model (evidence: `backend/agents/underwriter.py`)
- Chat and status → Underwriting API: posts analysis
- Underwriting API → Eligibility analysis: runs analysis (evidence: `backend/api/underwriter_router.py`)
- Applicant → Document upload: uploads documents (evidence: `README.md`)
- Document upload → Document verification API: posts files (evidence: `frontend/script.js`)
- Document verification API → OCR verification: verifies document (evidence: `backend/api/document_router.py`)
- Application UI → Chat and status: shows progress and outcomes (evidence: `frontend/script.js`)
- App and static serving → Sales message API: registers route (evidence: `backend/main.py`)
- App and static serving → Underwriting API: registers route (evidence: `backend/main.py`)
- App and static serving → Document verification API: registers route (evidence: `backend/main.py`)
- App and static serving → Application UI: serves frontend (evidence: `backend/main.py`)
