Skip to content

UnknownGod2011/Edge-Ledger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏦 Edge Ledger - AI-Powered Loan Compliance Engine

License: MIT Python 3.8+ Next.js Elastic Stack

An intelligent loan compliance system that leverages AI and Elasticsearch to analyze loan documents, assess risk, and ensure regulatory compliance in real-time.

🌟 Features

🤖 AI-Powered Analysis

  • 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

📊 Analytics Dashboard

  • 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

🔍 Advanced Search

  • 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

📄 Document Processing

  • 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

🏗️ Architecture

┌─────────────────┐
│   Next.js UI    │  ← React Dashboard with Charts
└────────┬────────┘
         │
         ↓
┌─────────────────┐
│  FastAPI Backend│  ← Python REST API
└────────┬────────┘
         │
    ┌────┴────┬──────────┬──────────┐
    ↓         ↓          ↓          ↓
┌────────┐ ┌──────┐ ┌────────┐ ┌────────┐
│Elastic │ │Gemini│ │PyPDF2  │ │Pydantic│
│Search  │ │ AI   │ │Parser  │ │Models  │
└────────┘ └──────┘ └────────┘ └────────┘

🚀 Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • Elasticsearch Cloud account (or local instance)
  • Google Gemini API key

1. Clone the Repository

git clone https://github.com/UnknownGod2011/Edge-Ledger.git
cd Edge-Ledger

2. Backend Setup

cd 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.py

Backend will run on: http://localhost:8000

3. Frontend Setup

cd loan-compliance-engine/frontend

# Install dependencies
npm install

# Start development server
npm run dev

Frontend will run on: http://localhost:3000

📖 Usage

Upload Loan Documents

  1. Navigate to http://localhost:3000
  2. Use the sidebar to drag & drop PDF loan documents
  3. Watch real-time processing logs
  4. View results in the dashboard

Explore Features

  • 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

🔧 Configuration

Environment Variables

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

Elasticsearch Setup

  1. Create a free account at Elastic Cloud
  2. Create a deployment
  3. Get your Cloud ID and API Key
  4. Add to .env file

Gemini API Setup

  1. Visit Google AI Studio
  2. Create an API key
  3. Add to .env file

📊 Tech Stack

Backend

  • 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

Frontend

  • Next.js 16: React framework with App Router
  • TypeScript: Type-safe JavaScript
  • Tailwind CSS: Utility-first styling
  • Recharts: Data visualization
  • React Hooks: State management

🎯 API Endpoints

Document Management

  • POST /upload - Upload loan documents
  • GET /search - Search loans with filters
  • GET /loans/{loan_id} - Get loan details

Analytics

  • GET /dashboard/summary - Portfolio metrics
  • GET /analytics/risk-distribution - Risk breakdown
  • GET /analytics/region - Regional analysis
  • GET /analytics/trend - Historical trends

Search

  • POST /semantic_search - AI-powered search
  • GET /workflow_logs - System activity logs

🧪 Testing

# Backend tests
cd loan-compliance-engine
python -m pytest tests/

# Frontend tests
cd loan-compliance-engine/frontend
npm test

📁 Project Structure

Edge-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

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • 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

📧 Contact

Project Link: https://github.com/UnknownGod2011/Edge-Ledger

🎓 Learn More


Built with ❤️ for better loan compliance

About

Loan documents sorted

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors