An Agentic AI system for NBFCs that automates the end-to-end personal loan journey β from customer intent to sanction letter generation β using Groq LLM, FastAPI, and React.
Live link : https://fin-bot-azure.vercel.app/
User (React Chat UI)
β
βΌ
FastAPI Backend
β
Master Agent βββ Groq LLaMA 3.3 70B (intent, conversation)
β
ββββββ΄βββββββββββββββββββββββββββ
β Worker Agents β
ββ Sales Agent β β Loan term extraction & negotiation
ββ Verification Agent β β KYC via Mock CRM
ββ Underwriting Agent β β Deterministic Rules Engine
ββ Sanction Agent β β PDF sanction letter generator
β
Backend Services
ββ Mock CRM (JSON) β KYC / PAN / credit score
ββ Underwriting Rules Engine β 6-rule deterministic engine
ββ Sanction Service β Letter generation
| Layer | Technology |
|---|---|
| LLM | Groq β llama-3.3-70b-versatile |
| Backend | Python 3.11+, FastAPI (ASGI), Uvicorn |
| Frontend | React 18, Vite, Tailwind CSS |
| Session Storage | In-memory (replace with Redis/Postgres for prod) |
| Decision Logic | Hybrid: Groq for NLU + deterministic rules engine |
| Document Gen | Plain text (swap in fpdf2/reportlab for real PDF) |
The rules engine is fully deterministic and auditable β Groq is never used for financial decisions. Rules run in sequence; the first failure causes rejection.
| # | Rule | Threshold |
|---|---|---|
| 1 | Loan bounds | βΉ10,000 β βΉ20,00,000 |
| 2 | Tenure bounds | 6 β 60 months |
| 3 | Minimum credit score | β₯ 700 |
| 4 | Pre-approved limit check | Loan β€ limit β approve; limit < loan β€ 2Γ limit β need salary slip; > 2Γ limit β reject |
| 5 | Loan-to-income ratio | β€ 36Γ monthly income |
| 6 | EMI affordability | EMI β€ 40% of monthly income |
EMI is computed using the standard reducing-balance formula:
EMI = P Γ r Γ (1+r)^n / ((1+r)^n β 1)
where r = annual_rate / 12, n = tenure_months.
- Owns the full conversation state machine
- Stages:
greeting β sales β verification β underwriting β approved/rejected - Orchestrates worker agents; makes no financial decisions itself
- Extracts
loan_amount,tenure_months,purpose,monthly_incomefrom free-text - Handles "2 lakh" β 200000 conversion, years β months, etc.
- Returns structured JSON; Master Agent writes to session DB
- Collects and format-validates
phone(10 digits) andPAN(ABCDE1234Fpattern) - Looks up customer in Mock CRM; cross-validates PAN
- Populates credit score, income, pre-approved limit into session
- Reads session data, calls
rules/underwriting_rules.py - Rules engine returns structured
UnderwritingResult - Groq only used to humanize the explanation text (no decision power)
- Generates a formatted sanction letter with all loan terms
- Stores file in
/tmp/finbot_sanctions/ - Returns a download URL
- Python 3.11+
- Node.js 18+
- Groq API Key (free tier available)
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and set: GROQ_API_KEY=your_key_here
# Run the server
uvicorn main:app --reload --port 8000Backend runs at: http://localhost:8000
API docs: http://localhost:8000/docs
cd frontend
# Install dependencies
npm install
# Start dev server
npm run devFrontend runs at: http://localhost:5173
Use these phone + PAN combinations during KYC verification:
| Phone | PAN | Credit Score | Income | Result |
|---|---|---|---|---|
9876543210 |
ABCDE1234F |
750 | βΉ60,000 | β Likely approved |
9123456780 |
FGHIJ5678K |
680 | βΉ35,000 | β Low credit score |
9988776655 |
LMNOP9012Q |
610 | βΉ25,000 | β Low credit + invalid slip |
8000000001 |
RSTUV3456W |
720 | βΉ45,000 | β Likely approved |
User: I need a home renovation loan
Bot: Great! How much would you like to borrow and for how long?
User: 2 lakh for 24 months, my salary is 50000
Bot: Got it β βΉ2,00,000 over 24 months.
To verify your identity, please share your mobile number.
User: 9876543210
Bot: And your PAN card number?
User: ABCDE1234F
Bot: β
KYC verified, Rahul Sharma!
π Underwriting: Congratulations! Your loan of βΉ2,00,000 has been approved.
Monthly EMI: βΉ9,982 at 18% p.a.
π [Download Sanction Letter]
finbot/
βββ backend/
β βββ main.py # FastAPI app entry point
β βββ requirements.txt
β βββ .env.example
β βββ agents/
β β βββ master_agent.py # State machine + orchestrator
β β βββ sales_agent.py # Loan term extraction
β β βββ verification_agent.py # KYC validation
β β βββ underwriting_agent.py # Rules engine wrapper
β βββ rules/
β β βββ underwriting_rules.py # 6-rule deterministic engine
β βββ services/
β βββ groq_service.py # Groq API client
β βββ crm_service.py # Mock CRM / KYC database
β βββ session_store.py # In-memory session state
β βββ sanction_service.py # Sanction letter generator
β
βββ frontend/
βββ index.html
βββ vite.config.js
βββ tailwind.config.js
βββ src/
βββ App.jsx # Root component + layout
βββ index.css # Global styles + animations
βββ main.jsx
βββ hooks/
β βββ useChat.js # Conversation state management
βββ utils/
β βββ api.js # Axios API client
βββ components/
βββ Header.jsx
βββ StageBar.jsx # Progress indicator
βββ MessageBubble.jsx # Chat messages
βββ TypingIndicator.jsx
βββ QuickReplies.jsx # Suggestion chips
βββ ChatInput.jsx # Text input bar
βββ LoanPanel.jsx # Sidebar loan summary
βββ WelcomeScreen.jsx # Initial landing view
All underwriting thresholds are in backend/rules/underwriting_rules.py:
MIN_CREDIT_SCORE = 700
MAX_LOAN_TO_INCOME_RATIO = 36
MAX_EMI_TO_INCOME_RATIO = 0.40
MAX_LOAN_ABSOLUTE = 2_000_000
MIN_LOAN_ABSOLUTE = 10_000
MAX_TENURE_MONTHS = 60
ANNUAL_INTEREST_RATE = 0.18
OVER_LIMIT_MULTIPLIER = 2.0- Replace Mock CRM with real KYC / PAN / bureau APIs
- Swap in
fpdf2for proper PDF sanction letters - Redis session store for horizontal scaling
- WhatsApp / SMS channel via Twilio
- Fraud & AML detection agents
- Multilingual support (Hindi, Tamil, etc.)
- Cross-sell agents (credit cards, insurance, BNPL)
- Firebase Auth for user identity management
MIT β built for the IIIT Guwahati FinTech AI project.