An intelligent loan compliance system that leverages AI and Elasticsearch to analyze loan documents, assess risk, and ensure regulatory compliance in real-time.
- Google Gemini Integration: Advanced NLP for document understanding and risk assessment
- Semantic Search: Find similar loans and clauses using vector embeddings
- Automated Risk Scoring: ML-driven risk calculation at document and clause level
- Compliance Monitoring: Real-time detection of regulatory violations
- Portfolio Health Score: Visual gauge showing overall portfolio status
- Risk Distribution: Interactive charts showing risk breakdown
- Regional Analysis: Geographic risk patterns and trends
- Trend Tracking: Historical risk score evolution over time
- Active Alerts: Real-time compliance violation notifications
- Full-Text Search: Fast document retrieval using Elasticsearch
- Semantic Search: Context-aware search using embeddings
- Clause-Level Analysis: Granular risk assessment for each clause
- Highlighted Results: Visual emphasis on risk factors
- PDF Ingestion: Automated extraction from loan documents
- Clause Chunking: Intelligent document segmentation
- Risk Factor Detection: Identify problematic clauses
- Metadata Extraction: Borrower info, amounts, rates, dates
┌─────────────────┐
│ Next.js UI │ ← React Dashboard with Charts
└────────┬────────┘
│
↓
┌─────────────────┐
│ FastAPI Backend│ ← Python REST API
└────────┬────────┘
│
┌────┴────┬──────────┬──────────┐
↓ ↓ ↓ ↓
┌────────┐ ┌──────┐ ┌────────┐ ┌────────┐
│Elastic │ │Gemini│ │PyPDF2 │ │Pydantic│
│Search │ │ AI │ │Parser │ │Models │
└────────┘ └──────┘ └────────┘ └────────┘
- Python 3.8+
- Node.js 18+
- Elasticsearch Cloud account (or local instance)
- Google Gemini API key
git clone https://github.com/UnknownGod2011/Edge-Ledger.git
cd Edge-Ledgercd loan-compliance-engine
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your credentials:
# - ELASTIC_CLOUD_ID
# - ELASTIC_API_KEY
# - GEMINI_API_KEY
# Start the backend server
python app/main.pyBackend will run on: http://localhost:8000
cd loan-compliance-engine/frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will run on: http://localhost:3000
- Navigate to http://localhost:3000
- Use the sidebar to drag & drop PDF loan documents
- Watch real-time processing logs
- View results in the dashboard
- Dashboard: Portfolio overview with health metrics
- Loans: Browse all processed loan documents
- Search: Semantic search across all documents
- Compliance: View regulatory violations
- Analytics: Deep dive into risk patterns
- Reports: Detailed loan-by-loan analysis
- Activity: System logs and workflow tracking
Create .env file in loan-compliance-engine/:
# Elasticsearch Configuration
ELASTIC_CLOUD_ID=your_cloud_id_here
ELASTIC_API_KEY=your_api_key_here
# Google Gemini API
GEMINI_API_KEY=your_gemini_api_key_here
# Optional: Custom Settings
ELASTIC_INDEX_NAME=loan_documents
EMBEDDING_MODEL=models/text-embedding-004
EMBEDDING_DIMENSIONS=768- Create a free account at Elastic Cloud
- Create a deployment
- Get your Cloud ID and API Key
- Add to
.envfile
- Visit Google AI Studio
- Create an API key
- Add to
.envfile
- FastAPI: Modern Python web framework
- Elasticsearch: Search and analytics engine
- Google Gemini: AI language model
- PyPDF2: PDF text extraction
- Pydantic: Data validation
- Uvicorn: ASGI server
- Next.js 16: React framework with App Router
- TypeScript: Type-safe JavaScript
- Tailwind CSS: Utility-first styling
- Recharts: Data visualization
- React Hooks: State management
POST /upload- Upload loan documentsGET /search- Search loans with filtersGET /loans/{loan_id}- Get loan details
GET /dashboard/summary- Portfolio metricsGET /analytics/risk-distribution- Risk breakdownGET /analytics/region- Regional analysisGET /analytics/trend- Historical trends
POST /semantic_search- AI-powered searchGET /workflow_logs- System activity logs
# Backend tests
cd loan-compliance-engine
python -m pytest tests/
# Frontend tests
cd loan-compliance-engine/frontend
npm testEdge-Ledger/
├── loan-compliance-engine/ # Backend
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── ingestion.py # Document processing
│ │ ├── risk_engine.py # Risk calculation
│ │ ├── semantic_search.py # Vector search
│ │ ├── gemini_client.py # AI integration
│ │ └── elastic_client.py # Elasticsearch client
│ ├── sample_loans/ # Demo PDF files
│ ├── requirements.txt # Python dependencies
│ └── .env.example # Environment template
│
├── loan-compliance-engine/frontend/ # Frontend
│ ├── app/ # Next.js pages
│ │ ├── page.tsx # Dashboard
│ │ ├── loans/ # Loan listing & details
│ │ ├── search/ # Semantic search
│ │ ├── compliance/ # Violations
│ │ ├── analytics/ # Analytics
│ │ └── reports/ # Detailed reports
│ ├── components/ # React components
│ │ ├── Dashboard/ # Charts & metrics
│ │ ├── Layout/ # Sidebar, TopNav
│ │ ├── LoanDetail/ # Loan view components
│ │ └── SemanticSearch/ # Search UI
│ ├── layouts/ # Page layouts
│ └── package.json # Node dependencies
│
├── README.md # This file
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Elastic for the powerful search and analytics platform
- Google for Gemini AI capabilities
- Vercel for Next.js framework
- FastAPI for the excellent Python web framework
Project Link: https://github.com/UnknownGod2011/Edge-Ledger
Built with ❤️ for better loan compliance