{"id":50548797,"url":"https://github.com/designer-coderajay/bfsi-credit-intelligence","last_synced_at":"2026-06-04T01:02:38.847Z","repository":{"id":355071502,"uuid":"1226453690","full_name":"designer-coderajay/bfsi-credit-intelligence","owner":"designer-coderajay","description":"Agentic AI loan underwriting platform for Indian BFSI sector. LangGraph v0.3 + 5 MCP servers (Bureau, GST, KYC, RBI Compliance, Account Aggregator) + XGBoost + SHAP + Kafka. RBI/DPDP 2023 compliant. Deployed on AWS Mumbai (ap-south-1).","archived":false,"fork":false,"pushed_at":"2026-05-01T17:36:00.000Z","size":80,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T19:19:41.328Z","etag":null,"topics":["agentic-ai","bfsi","fastapi","fintech","kafka","langgraph","loan-underwriting","mcp","mlflow","mlops","ocr","python","rbi-compliance","shap","xgboost"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/designer-coderajay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-01T12:21:00.000Z","updated_at":"2026-05-01T17:36:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/designer-coderajay/bfsi-credit-intelligence","commit_stats":null,"previous_names":["designer-coderajay/bfsi-credit-intelligence"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/designer-coderajay/bfsi-credit-intelligence","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designer-coderajay%2Fbfsi-credit-intelligence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designer-coderajay%2Fbfsi-credit-intelligence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designer-coderajay%2Fbfsi-credit-intelligence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designer-coderajay%2Fbfsi-credit-intelligence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/designer-coderajay","download_url":"https://codeload.github.com/designer-coderajay/bfsi-credit-intelligence/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/designer-coderajay%2Fbfsi-credit-intelligence/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33886154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agentic-ai","bfsi","fastapi","fintech","kafka","langgraph","loan-underwriting","mcp","mlflow","mlops","ocr","python","rbi-compliance","shap","xgboost"],"created_at":"2026-06-04T01:02:37.386Z","updated_at":"2026-06-04T01:02:38.842Z","avatar_url":"https://github.com/designer-coderajay.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BFSI Credit Intelligence — Agentic Loan Underwriting Platform\n\n\u003e **Production-grade agentic AI platform for real-time loan underwriting in Indian BFSI sector.**\n\u003e Built with LangGraph v0.3, MCP (Model Context Protocol), XGBoost + SHAP, and RBI-compliance guardrails.\n\n---\n\n## What This Does\n\nAn end-to-end loan underwriting system that replaces a 3-5 day manual process with a **\u003c 5 second AI decision**:\n\n1. Applicant submits loan application with documents\n2. OCR pipeline extracts data (English + Hindi via Surya OCR)\n3. 6 specialized LangGraph agents run in parallel:\n   - **Document Validator** → verifies KYC documents, OCR extraction\n   - **Financial Analyst** → income, obligations, DTI ratio\n   - **Credit Scorer** → XGBoost model + CIBIL bureau (parallel)\n   - **Fraud Detector** → Isolation Forest + rule engine (parallel)\n   - **Compliance Checker** → RBI Master Directions, DPDP Act 2023\n   - **Decision Agent** → final underwriting decision\n4. SHAP values explain every decision (regulator-ready)\n5. Decision published to Kafka → audit log → PostgreSQL\n\n---\n\n## Architecture\n\n```\n┌─────────────┐    ┌──────────────────────────────────────────────────┐\n│   Next.js   │    │              LangGraph StateGraph                │\n│  Dashboard  │───▶│                                                  │\n│  Port 3000  │    │  [Doc Validator] → [Financial Analyst]           │\n└─────────────┘    │         ↙                    ↘                   │\n                   │  [Credit Scorer]    [Fraud Detector]  ← parallel │\n       FastAPI     │         ↘                    ↙                   │\n       Port 8000   │  [Compliance Checker] → [Decision Agent]         │\n          │        │         interrupt_before=[\"decision_agent\"]      │\n          │        └──────────────────────────────────────────────────┘\n          │\n   ┌──────┴──────┐    ┌─────────────────────────────────────────┐\n   │ MCP Servers │    │           Infrastructure                │\n   │ Bureau 9001 │    │  PostgreSQL 16  │  Redis 7              │\n   │ BankTxn9002 │    │  Kafka (MSK)   │  MLflow               │\n   │  GST   9003 │    │  Qdrant Vector │  Evidently Monitoring  │\n   │  RBI   9004 │    │  Airflow DAGs  │  Prometheus + Grafana  │\n   │ PennyDp9005 │    └─────────────────────────────────────────┘\n   └─────────────┘\n```\n\n---\n\n## Key Technical Stack\n\n| Layer | Technology |\n|-------|-----------|\n| Agent Orchestration | LangGraph v0.3 (StateGraph, parallel fan-out, human-in-loop) |\n| LLM | Claude Sonnet (Anthropic) via LangChain |\n| MCP Servers | FastMCP + Streamable HTTP transport (5 servers) |\n| Credit Model | XGBoost + Optuna HPO + SMOTE + SHAP |\n| Fraud Detection | Isolation Forest + rule engine |\n| OCR | PyMuPDF + Surya OCR (Hindi + English) |\n| Streaming | Apache Kafka (Confluent) |\n| API | FastAPI (async) |\n| Frontend | Next.js 14 App Router + Tailwind |\n| MLOps | MLflow + Evidently + Airflow (weekly retrain) |\n| Infra | EKS (ap-south-1) + Terraform + GitHub Actions |\n| Compliance | RBI Master Directions, DPDP Act 2023, PMLA 2002 |\n\n---\n\n## Quick Start\n\n```bash\n# Clone and setup\ncd ~/Desktop/bfsi-credit-intelligence\ncp .env.example .env\n# Fill in your ANTHROPIC_API_KEY\n\n# Start everything\nmake dev-full          # Docker Compose: all services\nmake kafka-topics      # Create required Kafka topics\nmake train-all         # Train credit + fraud ML models\n\n# Or run backend only\npip install -r requirements.txt\nmake mcp-start         # Start all 5 MCP servers\nmake dev               # Start FastAPI on :8000\ncd frontend \u0026\u0026 npm install \u0026\u0026 npm run dev   # Next.js on :3000\n```\n\n---\n\n## MCP Servers\n\n| Server | Port | Tools | Purpose |\n|--------|------|-------|---------|\n| `bureau_mcp` | 9001 | `fetch_bureau_score`, `fetch_bureau_report_details` | CIBIL/Experian credit bureau data |\n| `bank_txn_mcp` | 9002 | `fetch_bank_statement`, `detect_obligations` | AA Framework — account aggregation |\n| `gst_mcp` | 9003 | `verify_gstin`, `fetch_gst_returns` | MSME/business loan GST verification |\n| `rbi_compliance_mcp` | 9004 | `check_rbi_compliance`, `get_fair_lending_guidelines` | RBI Master Directions validator |\n| `penny_drop_mcp` | 9005 | `verify_pan`, `verify_bank_account`, `verify_aadhaar_otp`, `check_ckyc` | KYC identity verification |\n\n---\n\n## Agentic Flow Detail\n\n```python\n# Parallel fan-out after Financial Analyst\ngraph.add_edge(\"financial_analyst\", \"credit_scorer\")\ngraph.add_edge(\"financial_analyst\", \"fraud_detector\")\n\n# Human-in-the-loop before final decision\ngraph.compile(interrupt_before=[\"decision_agent\"])\n\n# Auto-reject gates\ndef route_post_compliance(state):\n    if state.fraud_risk_score \u003e 0.85:\n        return \"auto_reject\"\n    if \"CRITICAL\" in state.compliance_flags:\n        return \"auto_reject\"\n    return \"decision_agent\"\n```\n\n---\n\n## ML Models\n\n### Credit Scoring\n- **Features**: 11 engineered features (credit score, bureau score, DTI, bank balance, income stability, loan-to-income ratio, fraud risk)\n- **Model**: XGBoost with Optuna 50-trial hyperparameter optimization\n- **Class Imbalance**: SMOTE oversampling (default rate ~5%)\n- **Explainability**: SHAP TreeExplainer — every decision has feature attributions\n- **MLflow**: Experiment tracking + model registry + deployment gating (AUC quality gate)\n\n### Fraud Detection\n- **Model**: Isolation Forest (anomaly detection — no labelled fraud data required)\n- **Rule Engine**: Income-bank ratio, DTI \u003e 60%, loan \u003e 5× annual income\n- **Combined Score**: `min(1.0, rules_score + ml_score × 0.4)`\n\n### Drift Monitoring\n- **Evidently AI**: Weekly drift reports on credit features\n- **Airflow DAG**: Auto-retrain on drift detection with AUC quality gate\n\n---\n\n## RBI Compliance\n\n| Rule | Implementation |\n|------|---------------|\n| DTI ≤ 50% | Automated check in `compliance_checker.py` |\n| KYC mandatory | Penny drop + Aadhaar OTP + PAN verification |\n| PMLA ₹2L threshold | Automated suspicious transaction flag |\n| Age eligibility | Min 18, max varies by loan type |\n| Fair lending | No discrimination on caste/religion/gender |\n| DPDP Act 2023 | PII masked in logs, consent tracked, 180-day retention |\n| Audit trail | Immutable audit log in PostgreSQL, S3 backup |\n| SHAP explanation | Regulator-ready decision explanation for every loan |\n\n---\n\n## API Reference\n\n### `POST /api/v1/loans/underwrite`\n```json\n{\n  \"applicant_name\": \"Ajay Mahale\",\n  \"pan_number\": \"ABCPM1234A\",\n  \"loan_type\": \"personal\",\n  \"loan_amount\": 500000,\n  \"tenure_months\": 36,\n  \"monthly_income\": 80000,\n  \"account_number\": \"123456789012\",\n  \"ifsc_code\": \"HDFC0001234\"\n}\n```\n\n**Response:**\n```json\n{\n  \"application_id\": \"APP-20260501-001\",\n  \"decision\": \"APPROVED\",\n  \"approved_amount\": 500000,\n  \"interest_rate\": 11.5,\n  \"credit_score\": 0.78,\n  \"risk_tier\": \"NEAR_PRIME\",\n  \"fraud_risk_score\": 0.08,\n  \"shap_values\": { \"credit_score\": 0.15, \"dti_ratio\": -0.04, ... },\n  \"decision_explanation\": \"Application approved. Strong income stability...\",\n  \"rbi_compliant\": true,\n  \"processing_time_ms\": 2840\n}\n```\n\n---\n\n## Running Tests\n\n```bash\nmake test          # All tests\nmake test-agents   # Agent unit tests\nmake test-ml       # ML model tests\nmake test-mcp      # MCP server tests\nmake test-cov      # With coverage report (target: 70%+)\n```\n\n---\n\n## Deployment\n\n```bash\n# Terraform (AWS Mumbai ap-south-1)\ncd infra/terraform\nterraform init\nterraform plan\nterraform apply    # Creates: EKS, RDS, ElastiCache, MSK Kafka, S3 (KMS encrypted)\n\n# CI/CD: GitHub Actions on push to main\n# → Tests → Security scan (Trivy) → Build ECR image → Deploy to EKS\n```\n\n---\n\n## Resume Bullet Points 🚀\n\nUse these in your Naukri / LinkedIn profile:\n\n- **Architected** production agentic AI underwriting platform using LangGraph v0.3 with 6 parallel agents, reducing loan decision time from 3 days to under 5 seconds\n- **Built** 5 MCP (Model Context Protocol) servers for real-time bureau, GST, Account Aggregator, and KYC integrations using FastMCP + Streamable HTTP transport\n- **Implemented** XGBoost credit scoring model with SHAP explainability, Optuna HPO, and SMOTE class balancing; deployed via MLflow model registry with AUC quality gates\n- **Engineered** DPDP Act 2023 and RBI Master Direction compliance layer with automated DTI, KYC, and PMLA checks; full audit trail in PostgreSQL\n- **Deployed** on AWS EKS (Mumbai) with Terraform, MSK Kafka, encrypted RDS multi-AZ, and GitHub Actions CI/CD including Trivy security scanning\n- **Integrated** Surya OCR for Hindi + English document extraction, Evidently AI for model drift monitoring, and Airflow for weekly automated model retraining\n\n---\n\n## Folder Structure\n\n```\nbfsi-credit-intelligence/\n├── backend/\n│   ├── agents/          # 6 LangGraph agents\n│   ├── ml/              # XGBoost, Isolation Forest, SHAP\n│   ├── mcp_servers/     # 5 MCP servers (Bureau, BankTxn, GST, RBI, PennyDrop)\n│   ├── document_processing/  # OCR pipeline (PyMuPDF + Surya)\n│   ├── streaming/       # Kafka producer + consumer\n│   └── main.py          # FastAPI app\n├── frontend/            # Next.js 14 underwriter dashboard\n├── mlops/airflow/       # Weekly model retrain DAGs\n├── infra/\n│   ├── k8s/             # EKS manifests + HPA\n│   ├── terraform/       # AWS infrastructure (ap-south-1)\n│   └── docker/          # Multi-stage Dockerfiles\n├── tests/               # pytest suite (agents, ML, MCP, API)\n├── docker-compose.yml   # Full local stack\n└── Makefile             # All dev commands\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesigner-coderajay%2Fbfsi-credit-intelligence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesigner-coderajay%2Fbfsi-credit-intelligence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesigner-coderajay%2Fbfsi-credit-intelligence/lists"}