Skip to content

Repository files navigation

🏦 Loner — AI-Powered Loan Assistant

Democratizing credit access for 190M+ credit-invisible Indians through conversational AI

Python LangChain ChromaDB Gemini TypeScript Docker

Main Application Interface Multilingual Interface


🎯 Problem

190M+ Indians are credit-invisible — they can't access formal loans because:

  • Bank processes are complex and intimidating
  • Forms and communication are English-only
  • No guidance through the application process
  • Loan decisions feel arbitrary with no explanation

💡 Solution

Loner is a conversational multi-agent AI system that guides anyone through the entire loan application process — in their own language, with voice support, and with every decision grounded in actual policy documents.


✨ Features

  • 🤖 Multi-Agent Architecture — 4 specialized LLM agents handle different stages
  • 🔍 RAG Pipeline — ChromaDB + Gemini embeddings for policy-grounded decisions
  • 🎙️ Voice Support — Hands-free interaction with speech-to-text and text-to-speech
  • 🌐 Multilingual — Full support for English, Hindi, and Spanish
  • 📄 OCR Salary Verification — Tesseract OCR with LLM fallback
  • 🛡️ Output Guardrails — Validates LLM responses for policy compliance
  • 📊 Audit Trail — Complete SQLite logging of all decisions

🏗️ Architecture

User
 ↓
Frontend (TypeScript/Vite)
 ↓
Backend (Python/Gradio)
 ↓
Agent Router
 ↙    ↓      ↓        ↘
Sales  Verify  Underwrite  Sanction
              ↓
         RAG Pipeline
         ↙         ↘
    ChromaDB    Gemini API
    (Vector DB) (Embeddings + LLM)
         ↓
   Policy Documents
   (RBI Guidelines, Loan Policy)

Agent Flow

1. Sales Agent      → Understand loan needs, collect amount & tenure
2. Verification Agent → KYC verification
3. Underwriting Agent → RAG-powered decision with policy citations
4. Sanction Agent   → Generate sanction letter

🧠 RAG Pipeline (How It Works)

loan_policy.md
     ↓
Chunked (500 tokens, 50 overlap)
     ↓
Gemini Embeddings (gemini-embedding-001)
     ↓
Stored in ChromaDB
     ↓
At underwriting: query → top 3 relevant chunks
     ↓
Injected into Gemini prompt
     ↓
Policy-grounded decision reason ✅

Without RAG:

Decision: REJECTED
Reason: "Low credit score"  ← generic, unhelpful

With RAG:

Decision: REJECTED
Reason: "Per Section 4.2, applicants with CIBIL 
score below 700 are auto-rejected. Your score of 
650 falls below the minimum threshold required 
for personal loans."  ← grounded in actual policy

🛠️ Tech Stack

Layer Technology
LLM Google Gemini 2.5 Flash
RAG LangChain + ChromaDB
Embeddings Gemini Embedding 001
Backend Python, Gradio, FastAPI
Frontend TypeScript, Vite
Database SQLite
OCR Tesseract + LLM fallback
Containerization Docker + Docker Compose

🚀 Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Tesseract OCR
  • Docker (optional)

Option 1 — Docker (Recommended)

# Clone the repo
git clone https://github.com/sam131725/loner-ai-loan-assistant.git
cd loner-ai-loan-assistant

# Add your API key
cp backend/.env.example backend/.env
# Edit backend/.env and add GEMINI_API_KEY

# Run everything
docker-compose up --build

Option 2 — Manual

Backend:

cd ey_techathon
pip install -r backend/requirements.txt

# Set environment variables
cp backend/.env.example backend/.env
# Add your GEMINI_API_KEY to backend/.env

# Ingest knowledge base
python -m backend.rag.ingest

# Start backend
python backend/app_gradio.py

Frontend:

cd frontend
npm install
npm run dev

Access:


🌍 Environment Variables

Create backend/.env:

GEMINI_API_KEY=your_key_here
GEMINI_MODEL=gemini-2.5-flash
APP_DB_PATH=backend/output/app.db
USE_GENAI=true

Get your free Gemini API key at: aistudio.google.com


📁 Project Structure

loner/
├── backend/
│   ├── agents/          # Sales, Verification, Underwriting, Sanction
│   ├── rag/             # ingest.py, retriever.py
│   ├── utils/           # llm.py, ocr, guardrails
│   ├── db/              # SQLite + ChromaDB
│   ├── data/            # Knowledge base documents
│   └── app_gradio.py    # Main application
├── frontend/            # TypeScript/Vite frontend
├── Dockerfile.backend
├── Dockerfile.frontend
├── docker-compose.yml
└── README.md

🎙️ Voice Features

  • Speech-to-Text — Web Speech API, auto-transcription
  • Text-to-Speech — Agent responses spoken aloud
  • Multi-language Voice — Works in EN, HI, ES

🛡️ Guardrails

Output validation ensures:

  • Decisions are only APPROVED / REJECTED / CONDITIONAL
  • Interest rates are within valid policy ranges
  • No PII leakage between sessions
  • Responses reference actual policy rules

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

MIT License — see LICENSE for details.


Built with ❤️ to make financial services accessible to everyone

About

AI-powered agentic loan assistant with RAG pipeline, multilingual voice & OCR"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages