Skip to content

dhruvpuri/Policy-Compare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏦 Ai Bank Policy Comparator

Discover. Compare. Secure. Your Perfect Home Loan

Born from my parents' struggle with home loan documents - an AI-powered platform built with React, TypeScript, and Python that uses NLP and document parsing to simplify complex policy comparisons for everyday people.

🎯 Overview

The AI Bank Policy Comparator empowers customers and analysts to:

  • πŸ“€ Upload Documents: Ingest 2-4 bank home loan MITC documents (PDF/TXT/DOCX)
  • πŸ€– AI Analysis: Extract key terms using Google Gemini LLM with confidence scoring
  • βš–οΈ Smart Comparison: Side-by-side analysis with human-readable explanations
  • πŸ” Evidence Tracing: Click any cell to see normalized value, explanation, and source evidence
  • πŸ“Š Export Results: Generate CSV/JSON reports for decision making
  • 🎨 Butter Money Branding: Beautiful blue gradient theme matching Butter Money's website

🎯 User Workflow

For Customers:

  1. Upload 2-4 home loan MITC documents from different banks
  2. Wait for AI processing (30-60 seconds per document)
  3. Compare policies side-by-side with clear explanations
  4. Click any cell to understand differences and see evidence
  5. Export comparison report for decision making

For Analysts:

  1. Batch process multiple customer document sets
  2. Review confidence scores and flag low-confidence extractions
  3. Validate AI extractions against source documents
  4. Generate reports for customer consultations

πŸ“ Project Structure

bank-comparator/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ models/              # Pydantic data models
β”‚   β”œβ”€β”€ services/            # Business logic
β”‚   β”‚   β”œβ”€β”€ document_service.py    # Document processing
β”‚   β”‚   β”œβ”€β”€ extraction_service.py  # AI fact extraction
β”‚   β”‚   β”œβ”€β”€ comparison_service.py  # Policy comparison
β”‚   β”‚   └── export_service.py      # Report generation
β”‚   β”œβ”€β”€ api/                 # FastAPI endpoints
β”‚   β”‚   β”œβ”€β”€ documents.py           # Document upload/management
β”‚   β”‚   β”œβ”€β”€ comparison.py          # Comparison endpoints
β”‚   β”‚   └── main.py               # API application
β”‚   └── ui/                  # Streamlit interface
β”‚       β”œβ”€β”€ main.py               # Main UI application
β”‚       β”œβ”€β”€ beautiful_comparison.py # Comparison display
β”‚       └── components.py         # Reusable UI components
β”œβ”€β”€ tests/                   # Test suite
β”œβ”€β”€ data/                    # Sample documents and uploads
β”œβ”€β”€ logs/                    # Application logs
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ run_api.py              # API server launcher
β”œβ”€β”€ run_ui.py               # UI server launcher
└── README.md               # This documentation

πŸš€ Quick Start

1. Environment Setup

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

2. Configuration

# Set up environment variables
cp .env.example .env
# Add your Google Gemini API key to .env

3. Run the Application

# Terminal 1: Start FastAPI backend
python run_api.py
# Or: uvicorn app.api.main:app --reload --port 8000

# Terminal 2: Start Streamlit UI  
python run_ui.py
# Or: streamlit run app/ui/main.py

4. Access the App

βœ… Current Status

βœ… Completed Features

  • Document Processing: PDF/TXT/DOCX upload and text extraction
  • AI Integration: Google Gemini LLM for fact extraction with confidence scoring
  • Smart Extraction: Rule-based + LLM hybrid approach for accuracy
  • Comparison Engine: Side-by-side analysis with status indicators
  • Beautiful UI: Butter Money branded interface with blue gradient theme
  • Evidence Tracing: Click cells to see normalized values and source evidence
  • Export Functionality: CSV/JSON report generation
  • API Architecture: FastAPI backend with comprehensive endpoints

πŸ”„ In Progress

  • Performance optimization for large documents
  • Enhanced error handling and validation
  • Comprehensive test coverage
  • Docker containerization

🎯 Planned Enhancements

  • Batch processing for multiple document sets
  • Advanced analytics and insights
  • Integration with Butter Money's existing systems
  • Mobile-responsive design improvements

🌟 Key Features

οΏ½ Bank-Specific Intelligence

  • Auto-detects major Indian banks (HDFC, ICICI, SBI, Axis, Kotak)
  • Clean bank names in comparison headers (no more confusing filenames)
  • Contextual explanations for each policy term
  • Indian financial notation support (β‚Ή, Rs, Lakhs, Crores)

πŸ€– Advanced AI Processing

  • Hybrid extraction: Rule-based + Google Gemini LLM
  • Confidence scoring with color-coded indicators
  • Smart gap filling for missing information
  • Conflict detection for contradictory data

πŸ“Š Beautiful Comparison Interface

  • Expandable cells showing full values (no truncation)
  • Human-readable explanations for each difference
  • Evidence tracing with clean source text display
  • Status indicators: Same/Different/Missing with clear badges

πŸ” Evidence & Transparency

When you click any cell, see:

  1. Normalized value with clear formatting
  2. Brief explanation in plain English
  3. Confidence score with reliability indicator
  4. Exact evidence from source document
  5. Document reference for verification

🎨 User Experience

  • No truncated text - see complete information
  • Clear bank identification - HDFC Bank vs ICICI Bank
  • Intuitive navigation - click to explore
  • Responsive layout for different screen sizes

πŸ“ˆ Export & Analysis

  • CSV reports for spreadsheet analysis
  • JSON exports for system integration
  • Comparison summaries with key metrics
  • Evidence documentation for audit trails

πŸ›  Technology Stack

Backend

  • FastAPI - Modern Python web framework
  • Google Gemini - LLM for document analysis
  • PyMuPDF & PDFPlumber - PDF text extraction
  • Pandas - Data processing and analysis
  • Pydantic - Data validation and serialization

Frontend

  • Streamlit - Interactive web interface
  • Plotly - Data visualization
  • Custom CSS - Butter Money branding

Development

  • pytest - Testing framework
  • uvicorn - ASGI server
  • python-dotenv - Environment management

πŸ”§ Configuration

Environment Variables (.env)

# Required
GOOGLE_API_KEY=your_gemini_api_key_here

# Optional
LOG_LEVEL=INFO
MAX_FILE_SIZE_MB=10
UPLOAD_DIR=./data/uploads

API Configuration

  • Port: 8000 (configurable)
  • Max file size: 10MB per document
  • Supported formats: PDF, TXT, DOCX
  • Concurrent uploads: Up to 4 documents

πŸ› Troubleshooting

Common Issues

1. "No module named 'app'" Error

# Make sure you're in the bank-comparator directory
cd bank-comparator
python run_api.py

2. "Google API Key not found" Error

# Check your .env file has the correct API key
echo $GOOGLE_API_KEY  # Should show your key

3. "Port already in use" Error

# Kill existing processes
pkill -f "uvicorn"
pkill -f "streamlit"
# Or use different ports
uvicorn app.api.main:app --port 8001
streamlit run app/ui/main.py --server.port 8502

4. PDF Processing Issues

  • Ensure PDFs are text-based (not scanned images)
  • Check file size is under 10MB
  • Try converting to TXT if extraction fails

5. Slow Processing

  • Large documents take longer to process
  • Check internet connection for Gemini API calls
  • Monitor logs for processing status

Performance Tips

  • Smaller files process faster
  • Text files are processed quicker than PDFs
  • Clear document structure improves extraction accuracy
  • Good internet connection reduces API latency

πŸ“ž Support

For issues or questions:

  1. Check the troubleshooting section above
  2. Review API logs in logs/ directory
  3. Test with sample documents in data/ folder
  4. Verify all dependencies are installed correctly

πŸš€ Deployment

Local Development

# Development mode with auto-reload
python run_api.py --reload
python run_ui.py --debug

Production Deployment

# Production mode
uvicorn app.api.main:app --host 0.0.0.0 --port 8000
streamlit run app/ui/main.py --server.port 8501 --server.address 0.0.0.0

Helping customers discover, compare, and secure their perfect home loan

About

Born from my parents' struggle with home loan documents - an AI-powered platform that simplifies complex policy comparisons for everyday people.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors