We will be undergoing planned maintenance on January 16th, 2026 at 1:00pm UTC. Please make sure to save your work.

Inspiration

The idea for LoanGuard AI came from a fundamental problem in syndicated lending: covenant monitoring is still done in spreadsheets.

At major banks, loan agents spend hours every week manually tracking covenant compliance across hundreds of loans. They discover breaches after they happen—sometimes weeks late—leading to frantic waiver negotiations, unexpected losses, and regulatory scrutiny.

When the LMA Edge Hackathon announced the "Keeping Loans on Track" category, we saw an opportunity to solve this problem using modern AI and machine learning. We asked ourselves: What if we could predict covenant breaches before they happen? What if loan agents could see risk across their entire portfolio at a glance?

We were also motivated by the growing importance of ESG compliance in lending. With the rise of Sustainability-Linked Loans, banks need to track environmental KPIs and calculate margin adjustments based on borrower performance. This is exactly the kind of complex, manual work that software should automate.

What it does

LoanGuard AI is a comprehensive AI-powered covenant monitoring platform that transforms reactive compliance into proactive risk management. The system consists of 14 production pages, all connected to a real BigQuery database.

🎯 Core Covenant Monitoring

Portfolio Dashboard

  • Displays 27 loans with real-time status: 7 GREEN (compliant), 9 AMBER (warning), 10 RED (breach)
  • 7 KPI cards showing portfolio health at a glance
  • Total exposure: $2.3 billion across all loans
  • 63 active alerts requiring attention
  • Portfolio ESG score: 72.7%

Loan Detail View

  • 9 tabs per loan: Overview, Covenants, ML Predictions, LGD Analysis, Prepayment Risk, Risk Velocity, Cure Calculator, Stress Testing, ESG
  • Complete covenant breakdown with threshold, actual value, and buffer percentage
  • Historical tracking and trend analysis

🤖 ML Breach Prediction

The Approach

  • Machine learning model trained on 720,966 real Lending Club loans to demonstrate predictive capability
  • Shows how ML can predict risk ahead of time
  • Every prediction includes SHAP explainability showing WHY the model made that prediction
  • Framework designed for EU AI Act compliance—no black box predictions

Important Note: The model uses Lending Club consumer loan data as a proxy, since real covenant breach data from syndicated lending is not publicly available. In production, banks would retrain on their historical covenant data.

How It Works

  • LightGBM model for fast inference
  • SHAP waterfall chart shows top contributing factors
  • Real-time predictions on every loan detail page

📊 Monte Carlo Value at Risk

25,000 Simulations

  • Monte Carlo simulation engine for portfolio-level risk assessment
  • Configurable correlation between loans (default: 0.40)
  • Stressed vs. unstressed scenarios
  • Results: VaR 95% = $1.25B, VaR 99% = $1.39B, CVaR 99% = $1.45B

What-If Scenario Builder

  • Create custom stress scenarios by adjusting PD, LGD, GDP, unemployment
  • Preset scenarios: Mild Recession (+32% ECL), Moderate (+68%), Severe (+124%)
  • Instant ECL impact calculation

🌱 SLL Monitoring (LMA SLLP 2024)

Sustainability-Linked Loan Tracking

  • 8 SLL loans in portfolio with full KPI monitoring
  • 24 ESG KPIs tracked: Carbon Emissions, Renewable Energy, Water Consumption
  • KPI types: GHG Emissions (tCO2e), Energy (%), Water (m³)
  • Progress bars showing baseline → current → target

Two-Way Margin Adjustments

  • Calculates margin step-ups and step-downs based on SPT achievement
  • Per LMA SLLP 2024 guidelines
  • Average margin impact: -5 bps for achieved SPTs
  • Displays previous margin vs. new margin calculation

SPT Performance

  • Sustainability Performance Targets with achievement probability
  • ACHIEVED / ACTIVE / NOT_ACHIEVED status badges
  • Margin impact per SPT (e.g., -2 bps, -5 bps)

📄 Document Intelligence

Affinda AI Integration

  • Upload credit agreements in PDF, DOCX, or TXT format
  • AI parses and extracts covenants automatically
  • Identifies 5+ covenant types: Debt/EBITDA, Interest Coverage, Current Ratio, CapEx Limit, Carbon Emissions
  • Confidence scores for each extraction

Automatic Loan Creation

  • Option to create new loan record from uploaded document
  • Covenants auto-linked to loan in BigQuery
  • Fallback regex parser for edge cases

🔍 AI Risk Committee

5-Agent Debate System

  • Gemini 2.0 powers 5 specialized agents:
    1. CRO (Chief Risk Officer) - Overall risk assessment
    2. ESG Officer - Environmental and sustainability concerns
    3. Legal Counsel - Covenant and compliance issues
    4. Quant Analyst - Quantitative risk metrics
    5. Industry Expert - Sector-specific insights

Debate Mode

  • Agents can debate to reach consensus
  • Multiple rounds until convergence
  • Final recommendation: APPROVE / REFER / DECLINE
  • Audit trail for regulatory compliance
  • PDF export for approval documentation

📈 Stress Testing

IFRS 9 Economic Scenarios (4)

  • Mild Recession (1.3x PD multiplier): +30% ECL
  • Moderate Recession (1.8x): +101% ECL
  • Severe Recession (2.5x): +150% ECL
  • 2008-Level Crisis (3.0x): +200% ECL

NGFS v5 Climate Scenarios (4)

  • Net Zero 2050: +33% ECL (1.1x PD)
  • Disorderly Transition: +74% ECL (1.5x PD)
  • Hot House World: +79% ECL (1.6x PD)
  • Current Policies: Baseline

NGFS Short-Term 2025

  • Disasters & Policy: +152% ECL
  • Highway to Paris: +16% ECL
  • Sudden Wake-Up: +134% ECL
  • Diverging Realities: +121% ECL

🛡️ Additional Modules

Fund Finance (ILPA July 2024)

  • 1 NAV facility tracked: Acme Growth Partners II
  • NAV: $500M, Facility: $50M, Drawn: $30M
  • LTV ratio: 6% (covenant threshold: 15%)
  • ILPA compliance tracking: LPAC consent, LPA permission

Transition Loans (LMA TLP Principles)

  • 5 TLP principles validation
  • Carbon lock-in assessment
  • Asset lifetime, technology pathway, stranded asset risk scores

Greenwashing Detection

  • Google Custom Search integration
  • Real news article citations
  • Verdict categories: VERIFIED / QUESTIONABLE / UNVERIFIED / CONTRADICTED
  • Confidence percentages per claim

Alert Management

  • 63 alerts from BigQuery
  • COVENANT_WARNING and COVENANT_BREACH types
  • Acknowledge functionality with timestamp
  • Mark All Read for bulk processing

🏗️ Architecture & Scale

Frontend (Next.js 15)

  • 14 production pages
  • React 19 with server components
  • Tailwind CSS + shadcn/ui components
  • Real-time updates via API polling

Backend (FastAPI)

  • Python 3.11 on Google Cloud Run
  • 200+ API endpoints
  • Auto-scaling serverless deployment
  • BigQuery client for data operations

Database (BigQuery)

  • 29 tables in loanguard_data dataset
  • Real loan data (not synthetic)
  • Tables: loans, covenants, alerts, esg_kpis, esg_spts, nav_facilities, document_extractions

ML Models (4 Total)

  • Breach Predictor: LightGBM trained on Lending Club data (demonstrates approach)
  • LGD Estimator: Two-stage LightGBM for loss-given-default
  • Prepayment Risk: XGBoost with FRED interest rate data
  • ESG Risk Scorer: XGBoost with SASB industry mappings

How we built it

Phase 1: Data Foundation

We started by setting up BigQuery with 29 tables to store loan data. We chose real Lending Club data (720,966 loans) rather than synthetic data to ensure our ML models would have genuine predictive power.

Phase 2: ML Model Training

We trained 4 machine learning models:

  • Breach predictor using LightGBM on charged-off vs. fully-paid loans
  • LGD estimator using a two-stage approach (classification + regression)
  • Prepayment risk model using XGBoost with FRED interest rate data
  • ESG risk scorer using SASB industry materiality mappings

Phase 3: Backend Development

We built a FastAPI backend deployed on Google Cloud Run. The backend connects to BigQuery for data, Affinda for document parsing, Climatiq for carbon calculations, FRED for macro rates, and Gemini 2.0 for AI features.

Phase 4: Frontend Development

We created 14 production pages using Next.js 15 with a focus on loan agents as the primary user. Each page connects to real BigQuery data through our API.

Phase 5: LMA Standards Integration

We implemented multiple LMA standards:

  • SLLP 2024 for SLL monitoring and margin adjustments
  • TLP Principles for transition loan validation
  • SLP Principles for social loan categories
  • ILPA July 2024 for fund finance NAV facilities

Challenges we ran into

1. Training ML on Real Data

Using 720,966 real Lending Club loans was more challenging than synthetic data. We had to handle missing values, encode categorical features properly, and validate that our model wasn't overfitting to quirks in the data.

2. SHAP Explainability at Scale

Adding SHAP explanations to every prediction required careful optimization. Computing SHAP values on every API call would be too slow, so we pre-computed feature importance rankings and generate explanations efficiently.

3. LMA Standards Complexity

Each LMA standard (SLLP, TLP, SLP, ILPA) has detailed requirements. We spent significant time reading the actual standard documents to ensure our implementation was accurate, not just superficially compliant.

4. EU AI Act Compliance

The EU AI Act requires explainability for high-risk AI systems. We made every ML prediction explainable by default, showing users exactly which factors drove each prediction.

Accomplishments that we're proud of

Technical Achievements

  • 4 production ML models with SHAP explainability
  • 14 fully functional pages connected to BigQuery
  • 5-agent AI Risk Committee with debate mode
  • Monte Carlo VaR with 25,000 simulations
  • Real-time predictions on every loan

Business Impact

  • Transforms manual covenant tracking into automated monitoring
  • Predicts breaches 90 days ahead—enough time to take action
  • Calculates margin adjustments for SLL loans per LMA SLLP 2024
  • Provides stress testing across 8 economic and climate scenarios

Compliance & Standards

  • EU AI Act ready with SHAP explainability
  • LMA SLLP 2024 implementation for SLL monitoring
  • LMA TLP Principles validation for transition loans
  • ILPA July 2024 compliance for fund finance
  • IFRS 9 + NGFS v5 stress testing scenarios

What we learned

About LMA Standards

The Loan Market Association has created excellent frameworks for sustainable lending. Implementing these standards taught us how the industry is evolving toward transparency and ESG accountability.

About ML in Finance

Machine learning in financial services requires explainability. Black box predictions are not acceptable for compliance or trust. SHAP explanations add value beyond just ticking a regulatory box—they help users understand and trust the predictions.

About Hackathon Judging

Judges from HSBC, Barclays, and AWS are industry experts, not developers. They care about business impact and usability, not the intricacies of our code. We learned to communicate in terms of efficiency gains and risk reduction.

What's next for LoanGuard AI

Immediate

  • Pilot with 1-2 banks to validate in production environment
  • Expand NAV facility coverage beyond current demo
  • Add more granular NGFS scenario parameters

Medium-term

  • DORA compliance module for EU digital resilience requirements
  • Multi-currency support for cross-border syndicated loans
  • Integration APIs for core banking systems

Long-term Vision

  • Industry standard for AI-powered covenant monitoring
  • Continuous model retraining on new loan performance data
  • Expansion to APAC and Americas markets

Built With

  • affinda
  • bigquery
  • climatiq
  • eleven-labs
  • fastapi
  • fred-api
  • gemini-2.0
  • google-cloud-run
  • lightgbm
  • next.js
  • python
  • react
  • sendgrid
  • shap
  • tailwind-css
  • xgboost
Share this project:

Updates