Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

2 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฆ Shadow Credit

AI-Powered Credit Assessment for Indian MSMEs

Python Next.js FastAPI License

Automating credit decisions for unbanked small businesses in 90 seconds

Features โ€ข Quick Start โ€ข Architecture โ€ข API โ€ข Demo


๐ŸŽฏ Problem Statement

380 million Indians lack access to formal credit. Traditional banks require:

  • ๐Ÿ“„ 3+ years of ITR filings
  • ๐Ÿ›๏ธ GST registration
  • ๐Ÿ’ณ Credit history (CIBIL score)

Kirana stores and small retailers operate informally with:

  • WhatsApp payment confirmations
  • UPI transaction screenshots
  • Handwritten ledgers (Khata books)
  • No formal documentation

Shadow Credit bridges this gap by extracting financial signals from informal documents and generating bank-grade credit assessments.


โœจ Features

๐Ÿค– 7 Specialized AI Agents

Agent Function
Agent 00 Google Maps verification โ€” validates business existence, ratings, reviews
Agent 01 OCR extraction โ€” processes bills, UPI screenshots with Hindi support
Agent 02 WhatsApp parser โ€” classifies financial transactions from Hinglish chats
Agent 03 Khata Book โ€” parses handwritten ledger entries
Agent 04 Credit Warmth Score โ€” ML-based scoring using 7 financial signals
Agent 05 Forensic Reconciliation โ€” detects gaps, generates RBI-compliant hypotheses
Agent 06 Compliance โ€” RBI MSME checklist verification
Agent 07 Credit Report โ€” generates professional PDF memos

๐ŸŽ›๏ธ Intelligent Orchestration

  • Supervisor Agent coordinates all agents with dynamic execution
  • Human-in-the-loop โ€” pipeline pauses for clarification, resumes automatically
  • Real-time WebSocket streaming shows live agent progress
  • Auto-decision engine: AUTO_ACCEPT / CLARIFY / FALLBACK based on confidence

๐Ÿ”’ Privacy & Compliance

  • AES-256-GCM encryption for all sensitive data
  • DPDP Act 2023 compliant โ€” consent tracking, right-to-erasure
  • Immutable audit log โ€” database triggers prevent tampering
  • No unencrypted PII stored

๐Ÿš€ Quick Start

Prerequisites

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

1. Clone & Setup Environment

git clone https://github.com/pranavpanchal1326/shadow-credit.git
cd shadow-credit

# Backend
cp backend/.env.example backend/.env
# Edit backend/.env with your API keys

2. Configure Environment Variables

# Required
MASTER_ENCRYPTION_KEY=<generate: python -c "import secrets; print(secrets.token_hex(32))">
GROQ_API_KEY=<get free key from console.groq.com>

# Optional
GOOGLE_MAPS_API_KEY=<for business verification>

3. Start Backend

cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

4. Start Frontend

cd frontend
npm install
npm run dev

5. Open Application

http://localhost:3000/apply

Docker Alternative

docker-compose up

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        FRONTEND (Next.js 15)                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Apply   โ”‚  โ”‚Processingโ”‚  โ”‚  Result  โ”‚  โ”‚    Dashboard     โ”‚ โ”‚
โ”‚  โ”‚   Form   โ”‚  โ”‚  Stream  โ”‚  โ”‚  Display โ”‚  โ”‚    (RM View)     โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚ WebSocket + REST
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        BACKEND (FastAPI)                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚                    SUPERVISOR AGENT                       โ”‚   โ”‚
โ”‚  โ”‚   Orchestrates pipeline โ€ข Decision engine โ€ข Clarification โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                              โ”‚                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚Agent 00โ”‚Agent 01โ”‚Agent 02โ”‚Agent 03โ”‚Agent 04โ”‚Agent 05โ”‚  06 โ”‚  โ”‚
โ”‚  โ”‚  Maps  โ”‚  OCR   โ”‚WhatsAppโ”‚ Khata  โ”‚Warmth  โ”‚Forensicโ”‚Complโ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                              โ”‚                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚              Agent 07 โ€” Credit Report Generator          โ”‚    โ”‚
โ”‚  โ”‚                   (ReportLab PDF + QR Code)              โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     EXTERNAL SERVICES                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Groq    โ”‚  โ”‚  Google  โ”‚  โ”‚ EasyOCR  โ”‚  โ”‚     SQLite       โ”‚ โ”‚
โ”‚  โ”‚  LLM     โ”‚  โ”‚  Maps    โ”‚  โ”‚ (Local)  โ”‚  โ”‚   (Encrypted)    โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ก API Endpoints

Session Management

Method Endpoint Description
POST /api/v1/sessions Create new session (requires consent)
GET /api/v1/sessions/{id} Fetch session status
POST /api/v1/sessions/{id}/analyze Trigger analysis pipeline
POST /api/v1/sessions/{id}/clarify Answer clarification question
POST /api/v1/sessions/{id}/export Download PDF report
DELETE /api/v1/sessions/{id} Right-to-erasure (DPDP)

Document Ingestion

Method Endpoint Description
POST /api/v1/ingest/whatsapp/{id} Upload WhatsApp chat
POST /api/v1/ingest/upi/{id} Upload UPI screenshot
POST /api/v1/ingest/bill/{id} Upload utility bill
POST /api/v1/ingest/khata/{id} Upload ledger photo

Real-time Events

Protocol Endpoint Description
WebSocket /ws/{session_id} Live agent progress stream

๐ŸŽญ Demo Mode

Three pre-configured personas for testing:

Persona Scenario Duration
Suresh Clean approval โ€” straightforward case ~45 sec
Meena Discrepancy detected โ€” triggers clarification modal ~60 sec
Raju Seasonal pattern โ€” requires analysis ~48 sec
# Create demo session
curl -X POST http://localhost:8000/api/v1/sessions \
  -H "Content-Type: application/json" \
  -d '{"demo_mode": true, "consent_given": true}'

# Trigger analysis with persona
curl -X POST "http://localhost:8000/api/v1/sessions/{session_id}/analyze?persona_id=persona02_discrepancy"

๐Ÿง  Credit Scoring Model

XGBoost-based ML model with 7 weighted signals:

Signal Weight Description
Income Regularity 26.6% Consistency of monthly inflows
Inflow-Claim Consistency 20.9% WhatsApp claims vs. UPI verification
Business Continuity 19.0% Google Maps presence, reviews, tenure
Seasonal Patterns 14.25% Revenue fluctuation analysis
Network Reliability 9.5% Repeat customer transactions
Data Source Diversity 4.75% Multiple verification sources
Behavioral Consistency 5.0% Transaction timing patterns

Credit Grade Scale:

  • A+: โ‰ฅ0.85 โ€” Auto-approve
  • A: โ‰ฅ0.75 โ€” High confidence
  • B+: โ‰ฅ0.65 โ€” Moderate confidence
  • B: โ‰ฅ0.55 โ€” Clarification needed
  • C: <0.55 โ€” Manual review

๐Ÿ› ๏ธ Tech Stack

Backend

  • FastAPI โ€” async Python web framework
  • Groq โ€” LLaMA 3.3 70B for reasoning
  • XGBoost + SHAP โ€” ML scoring with explainability
  • EasyOCR โ€” offline OCR with Hindi support
  • SQLite โ€” encrypted database with WAL mode
  • ReportLab โ€” PDF generation

Frontend

  • Next.js 15 โ€” React framework
  • Tailwind CSS โ€” styling
  • Radix UI โ€” accessible components
  • Zustand โ€” state management
  • React Query โ€” data fetching
  • Recharts โ€” visualizations

๐Ÿ“ Project Structure

shadow-credit/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ agents/           # 7 AI agents + supervisor
โ”‚   โ”œโ”€โ”€ api/              # REST endpoints
โ”‚   โ”œโ”€โ”€ core/             # Security, events, AI client
โ”‚   โ”œโ”€โ”€ db/               # Database schema & queries
โ”‚   โ””โ”€โ”€ main.py           # FastAPI application
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ app/              # Next.js pages
โ”‚   โ”œโ”€โ”€ components/       # React components
โ”‚   โ””โ”€โ”€ hooks/            # Custom hooks
โ””โ”€โ”€ docker-compose.yml    # Container orchestration

๐Ÿ’ฐ Cost

Service Cost
Groq API Free (500+ calls/day)
EasyOCR Free (local)
Google Maps ~$0.50 (on $200 free credit)
Total $0.00

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


Built for Indian MSMEs ๐Ÿ‡ฎ๐Ÿ‡ณ

Democratizing credit access through AI

About

AI-powered credit assessment for Indian MSMEs using OCR, WhatsApp analysis, and 7 specialized agents. Processes informal documents into bank-grade credit reports in 90 seconds.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages