# dharanitharan27/the-loan-eligibility-engine architecture

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

- Interactive diagram: https://gitdiagram.com/dharanitharan27/the-loan-eligibility-engine
- Repository: https://github.com/dharanitharan27/the-loan-eligibility-engine

## Overview

The Loan Eligibility Engine takes borrower CSVs through upload and batch ingestion, discovers loan products, ranks eligible offers, generates borrower-specific advice, and sends notifications. The graph includes the dashboard/API surface, the documented n8n workflows, and the Python pipeline’s substantive stages and persistence layer. Several runtime files, including the API and ingestion worker, were not excerpted; their placement and links rely on README statements, so uncertain implementation-level connections are omitted.

Main entry points: [`backend/run_pipeline.py`](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/run_pipeline.py) (CLI pipeline runner), [`backend/database.py`](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/database.py) (Loan engine database), [`backend/ingest_lambda.py`](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/ingest_lambda.py) (CSV stream worker), [`backend/matcher.py`](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/matcher.py) (Eligibility matcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Borrower Dashboard"]
  node_frontend["Web dashboard<br/>[app.js]"]
  node_api["FastAPI service<br/>[app.py]"]
  node_pipeline["CLI pipeline runner<br/>[run_pipeline.py]"]
end

subgraph group_ingestion["Upload and Ingestion"]
  node_presign["Upload URL handler<br/>[presign_lambda.py]"]
  node_s3[("S3 upload bucket")]
  node_ingest["CSV stream worker<br/>[ingest_lambda.py]"]
end

subgraph group_decision["Discovery and Matching"]
  node_discovery["Product discovery<br/>[crawler.py]"]
  node_workflow_a["n8n discovery"]
  node_matching["Eligibility matcher<br/>[matcher.py]"]
  node_workflow_b["n8n matching"]
  node_advisor["AI advice<br/>[llm_advisor.py]"]
end

subgraph group_delivery["Persistence and Delivery"]
  node_db[("Loan engine database<br/>[database.py]")]
  node_email["Email notification service<br/>[email_service.py]"]
  node_workflow_c["n8n notifications"]
  node_ses["AWS SES"]
end

node_borrower(("Borrower / operator"))
node_gemini["Gemini API"]

node_borrower -->|"uses"| node_frontend
node_frontend -->|"calls API"| node_api
node_frontend -->|"uploads CSV"| node_s3
node_api -.->|"requests upload URL"| node_presign
node_presign -->|"creates upload URL"| node_s3
node_presign -->|"registers batch"| node_db
node_s3 -->|"triggers worker"| node_ingest
node_ingest -->|"stores borrowers"| node_db
node_ingest -->|"signals completion"| node_workflow_b
node_workflow_a -.->|"runs discovery"| node_discovery
node_discovery -->|"upserts products"| node_db
node_workflow_b -.->|"runs matching"| node_matching
node_matching -->|"reads and saves matches"| node_db
node_matching -->|"requests advice"| node_advisor
node_advisor -->|"requests generation"| node_gemini
node_workflow_c -.->|"runs notifications"| node_email
node_email -->|"loads and marks matches"| node_db
node_email -->|"sends email"| node_ses
node_pipeline -->|"initializes database"| node_db
node_pipeline -->|"calls discovery"| node_discovery
node_pipeline -->|"calls ingestion"| node_ingest
node_pipeline -->|"calls matching"| node_matching
node_pipeline -->|"dispatches notifications"| node_email

click node_frontend "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/frontend/app.js"
click node_api "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/app.py"
click node_presign "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/presign_lambda.py"
click node_ingest "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/ingest_lambda.py"
click node_discovery "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/crawler.py"
click node_workflow_a "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/n8n/workflow_a_discovery.json"
click node_matching "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/matcher.py"
click node_workflow_b "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/n8n/workflow_b_matching.json"
click node_advisor "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/llm_advisor.py"
click node_db "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/database.py"
click node_email "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/email_service.py"
click node_workflow_c "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/n8n/workflow_c_notification.json"
click node_pipeline "https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/run_pipeline.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_frontend,node_api,node_pipeline toneBlue
class node_presign,node_s3,node_ingest toneAmber
class node_discovery,node_workflow_a,node_matching,node_workflow_b,node_advisor,node_gemini toneMint
class node_db,node_email,node_workflow_c,node_ses toneRose
class node_borrower toneIndigo
```

## Components

### Borrower Dashboard

- [Web dashboard](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/frontend/app.js): `frontend/app.js`
- [FastAPI service](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/app.py): `backend/app.py`
- [CLI pipeline runner](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/run_pipeline.py): `backend/run_pipeline.py`

### Upload and Ingestion

- [Upload URL handler](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/presign_lambda.py): `backend/presign_lambda.py`
- **S3 upload bucket**
- [CSV stream worker](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/ingest_lambda.py): `backend/ingest_lambda.py`

### Discovery and Matching

- [Product discovery](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/crawler.py): `backend/crawler.py`
- [n8n discovery](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/n8n/workflow_a_discovery.json): `n8n/workflow_a_discovery.json`
- [Eligibility matcher](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/matcher.py): `backend/matcher.py`
- [n8n matching](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/n8n/workflow_b_matching.json): `n8n/workflow_b_matching.json`
- [AI advice](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/llm_advisor.py): `backend/llm_advisor.py`

### Persistence and Delivery

- [Loan engine database](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/database.py): `backend/database.py`
- [Email notification service](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/backend/email_service.py): `backend/email_service.py`
- [n8n notifications](https://github.com/dharanitharan27/the-loan-eligibility-engine/blob/main/n8n/workflow_c_notification.json): `n8n/workflow_c_notification.json`
- **AWS SES**

### Other components

- **Borrower / operator**
- **Gemini API**

## Connections

- Borrower / operator → Web dashboard: uses (evidence: `README.md`)
- Web dashboard → FastAPI service: calls API (evidence: `frontend/app.js`)
- Web dashboard → S3 upload bucket: uploads CSV (evidence: `README.md`)
- FastAPI service → Upload URL handler: requests upload URL
- Upload URL handler → S3 upload bucket: creates upload URL (evidence: `backend/presign_lambda.py`)
- Upload URL handler → Loan engine database: registers batch (evidence: `backend/presign_lambda.py`)
- S3 upload bucket → CSV stream worker: triggers worker (evidence: `README.md`)
- CSV stream worker → Loan engine database: stores borrowers (evidence: `README.md`)
- CSV stream worker → n8n matching: signals completion (evidence: `README.md`)
- n8n discovery → Product discovery: runs discovery
- Product discovery → Loan engine database: upserts products (evidence: `backend/crawler.py`)
- n8n matching → Eligibility matcher: runs matching
- Eligibility matcher → Loan engine database: reads and saves matches (evidence: `backend/matcher.py`)
- Eligibility matcher → AI advice: requests advice (evidence: `backend/matcher.py`)
- AI advice → Gemini API: requests generation (evidence: `backend/llm_advisor.py`)
- n8n notifications → Email notification service: runs notifications
- Email notification service → Loan engine database: loads and marks matches (evidence: `backend/email_service.py`)
- Email notification service → AWS SES: sends email (evidence: `README.md`)
- CLI pipeline runner → Loan engine database: initializes database (evidence: `backend/run_pipeline.py`)
- CLI pipeline runner → Product discovery: calls discovery (evidence: `backend/run_pipeline.py`)
- CLI pipeline runner → CSV stream worker: calls ingestion (evidence: `backend/run_pipeline.py`)
- CLI pipeline runner → Eligibility matcher: calls matching (evidence: `backend/run_pipeline.py`)
- CLI pipeline runner → Email notification service: dispatches notifications (evidence: `backend/run_pipeline.py`)
