Real-time Covenant Monitoring with AI-Powered Document Extraction
An intelligent financial agent that monitors loan covenants in real-time, extracting data from complex financial documents and alerting on breaches instantly.
Investors, M&A professionals, and finance leaders need to monitor covenant compliance across evolving data rooms. Manual tracking is slow, error-prone, and misses critical breaches.
Our Solution: An AI-powered copilot that:
- β Extracts covenant terms from PDFs, images, and tables using LandingAI DPT-2
- β Monitors financial data in real-time using Pathway framework
- β Detects breaches instantly with red flag alerts
- β Sends automated email notifications
- β Generates living memos that auto-update
- β Provides conversational Q&A interface
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA ROOM (Live Files) β
β PDF β JSON β Images β CSV β HTML/iXBRL β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PATHWAY LIVE FILE MONITOR β
β (Watches for new/modified files - instant processing) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LANDINGAI ADE (DPT-2) EXTRACTION β
β β’ Covenant terms from PDFs/Images β
β β’ Financial tables with high accuracy β
β β’ Parallel extraction for speed β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β COVENANT COMPLIANCE ENGINE β
β β’ Leverage Ratio Check β
β β’ Interest Coverage Check β
β β’ Liquidity Check β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β INTELLIGENT OUTPUTS β
β π§ Email Alerts β π Living Memos β π¬ Chatbot Q&A β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- LandingAI ADE (DPT-2): Document extraction with vision capabilities
- Pathway Framework: Live file monitoring and real-time indexing
- Python 3.10+: Core language
- PyPDF2: PDF processing and truncation
- Watchdog: File system monitoring
- SMTP: Email alert delivery
- FastAPI: REST API (optional)
FinSight_Copilot/
βββ hackathon_copilot.py # Main copilot implementation
βββ pathway_monitor.py # Live file monitoring
βββ due_diligence_copilot (1).py # Original prototype
βββ .env # Environment configuration
βββ covenant-copilot/
β βββ data/ # Data room
β β βββ JSON/file.json # SEC financial data
β β βββ PDF/file.pdf # Credit agreements
β β βββ Image/file.jpeg # Covenant tables
β β βββ CSV/ # Normalized data
β β βββ HTML : iXBRL/ # SEC filings
β βββ apps/
β β βββ api/ # FastAPI backend
β βββ memos/ # Generated memos
βββ HACKATHON_README.md # This file
git clone https://github.com/kushal511/FinSight_Copilot.git
cd FinSight_Copilotpython3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install --upgrade pip
pip install pandas beautifulsoup4 lxml requests PyPDF2 pillow pdf2image \
watchdog python-dotenv landingai_ade fastapi uvicornCreate .env file:
# LandingAI API Key (get from https://va.landing.ai/)
LANDING_AI_API_KEY=your_api_key_here
# Data paths
LOCAL_DATA_PATH=./covenant-copilot/data
# Email alerts (optional)
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
EMAIL_FROM=alerts@covenantcopilot.ai
EMAIL_PASSWORD=your_app_password
ALERT_RECIPIENTS=analyst@company.com,manager@company.comEnsure these files exist in covenant-copilot/data/:
JSON/file.json- SEC CompanyFacts API dataPDF/file.pdf- Credit agreement (auto-truncated to 50 pages)Image/file.jpeg- Covenant table screenshotCSV/file.csv- Normalized financial metrics
python hackathon_copilot.pyWhat it does:
- β Extracts covenant terms using LandingAI DPT-2
- β Analyzes financial data from SEC JSON
- β Runs covenant compliance checks
- β Detects red flags and breaches
- β Sends email alerts (or saves to file)
- β Generates living memo (Markdown + HTML)
- β Runs conversational chatbot demo
Expected Output:
π HACKWITHBAY 2025 - DUE DILIGENCE COPILOT
Track 1: Covenant Monitoring with Live Updates
================================================================================
π STEP 1: Document Extraction (LandingAI DPT-2)
--------------------------------------------------------------------------------
πΌοΈ Extracting from Image: file.jpeg
β
Extracted 7 chunks
π STEP 2: Financial Data Extraction
--------------------------------------------------------------------------------
π Reading SEC JSON: file.json
β
Debt=$4994M, EBITDA=$1322M, Cash=$15587M
π STEP 3: Covenant Compliance Check
--------------------------------------------------------------------------------
Company: Tesla Inc.
Period: Q2 2025
Status: π΄ BREACH
β LEVERAGE: 3.78 (limit: 3.5) - BREACH
β
COVERAGE: 8.16 (limit: 2.0) - PASS
β
LIQUIDITY: 15587.0 (limit: 100.0) - PASS
π§ STEP 4: Email Alert System
--------------------------------------------------------------------------------
π§ Sending breach alert to 1 recipients...
β
Alert saved to: covenant-copilot/data/breach_alert_20251004_183331.html
π STEP 5: Living Memo Generation
--------------------------------------------------------------------------------
π Generating living memo...
β
Memo saved to: covenant-copilot/data/memos/covenant_memo_20251004_183331.md
β
HTML version: covenant-copilot/data/memos/covenant_memo_20251004_183331.html
π¬ STEP 6: Conversational Chatbot Demo
--------------------------------------------------------------------------------
β Q: What is the overall covenant status?
π‘ A: The overall covenant status for Tesla Inc. is **BREACH**. There are 1 red flag(s) detected.
β Q: What is the leverage ratio?
π‘ A: The leverage ratio is 3.78x against a limit of 3.5x. Status: BREACH. Margin: -0.28x.
β
DEMO COMPLETE - All Components Working
# Monitor for 30 seconds
python pathway_monitor.py 30
# Monitor indefinitely (Ctrl+C to stop)
python pathway_monitor.pyWhat it does:
- π Scans existing files in data room
- π Watches for new/modified files
- β‘ Processes changes instantly
- π¨ Triggers alerts on breaches
- π Updates living memos automatically
Demo Scenario:
- Start monitoring:
python pathway_monitor.py - In another terminal, update a file:
# Simulate new financial data cp covenant-copilot/data/JSON/file.json covenant-copilot/data/JSON/file_updated.json - Watch instant processing and alerts!
cd covenant-copilot/apps/api
venv/bin/uvicorn main:app --reload --port 8000Access API docs: http://localhost:8000/docs
- Accurate table extraction from covenant documents
- Parallel processing for faster parsing
- Vision capabilities for scanned documents
- Automatic PDF truncation to 50 pages for API limits
- Real-time file watching with instant processing
- Hybrid indexing (ready for vector + BM25)
- Event-driven architecture for scalability
- Automatic re-processing on file updates
- Red flag detection with severity levels
- Email notifications with HTML formatting
- Evidence-based alerts with source citations
- Configurable thresholds per covenant type
- Auto-updating documentation on every check
- Markdown + HTML formats for flexibility
- Executive summary with actionable insights
- Audit trail with timestamps
- Natural language Q&A about covenant status
- Context-aware responses with financial data
- Conversation history tracking
- Extensible to LLM for advanced queries
- covenant_results.json - Full compliance check results
- red_flags.json - Detected breaches with severity
- covenant_memo_*.md - Living memo (Markdown)
- covenant_memo_*.html - Living memo (HTML)
- breach_alert_*.html - Email alert (HTML)
- chatbot_conversation.json - Q&A history
- pathway_results/check_*.json - Live monitoring results
[
{
"rule": "leverage",
"actual": 3.78,
"limit": 3.5,
"margin": 0.28,
"severity": "HIGH",
"message": "π¨ LEVERAGE BREACH: 3.78x exceeds 3.5x limit",
"timestamp": "2025-10-04T18:33:31.481529"
}
]- Playground: https://va.landing.ai/
- Developer Docs: https://docs.landing.ai/ade/ade-overview
- Python Library: https://github.com/landing-ai/ade-python
- Discord: https://discord.com/invite/RVcW3j9RgR
- Documentation: https://pathway.com/developers/
- GitHub: https://github.com/pathwaycom/pathway
- RAG 101 Bootcamp: https://pathway.com/developers/showcases/
- LLM Integration: Advanced conversational AI with GPT-4
- Vector Search: Hybrid indexing for intelligent document search
- Multi-Company Support: Monitor multiple portfolios simultaneously
- Mobile Applications: iOS/Android apps for on-the-go monitoring
- Enterprise Integrations: Slack, Teams, Bloomberg Terminal connectivity
MIT License - Built for HackWithBay 2025
π Ready to revolutionize covenant monitoring!