Loan Agreement → Structured Deal + Covenant Monitor
Transform LMA-style loan documents into structured deal data with automated analysis, covenant monitoring, and trade pack exports.
- Solves Real Pain: LMA loan docs are long and labor-intensive; extracting data = big efficiency gains
- Crosses Categories: Digital Loans, Loan Documents, Keeping Loans on Track, Transparent Trading
- Clear Commercial Value: SaaS for banks/arrangers, or license for LMA automation
- PDF Upload & Parsing: Upload loan agreements and extract structured data automatically
- AI-Powered Extraction: Uses Cerebras AI (qwen-3-235b) to intelligently extract deal terms
- Commercial Term Sheet: Auto-generated one-page summary for stakeholder presentations
- Covenant Monitor: Live dashboard with breach simulation and remediation suggestions
- Trade Pack Export: Standardized CSV and PDF exports for secondary trading
- FastAPI for REST API
- pdfplumber for PDF parsing
- Cerebras Cloud SDK for AI extraction (with load balancing)
- Supabase for database
- ReportLab for PDF generation
- Hypothesis for property-based testing
- Next.js 16 with App Router
- shadcn/ui components
- Tailwind CSS
- TypeScript
- Recharts for visualizations
- Python 3.11+
- Node.js 20+
- pnpm
- Supabase account
- Cerebras API key(s)
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file and configure
cp .env.example .env
# Edit .env with your Supabase and Cerebras credentials
# Run database migrations (copy schema.sql to Supabase SQL Editor)
# Generate sample PDFs for demo
python demo/generate_sample_pdfs.py
# Seed demo data (optional)
python demo/seed_demo_data.py
# Start server
uvicorn main:app --reload --port 8000cd frontend
# Install dependencies
pnpm install
# Copy environment file
cp .env.example .env.local
# Edit .env.local: NEXT_PUBLIC_API_URL=http://localhost:8000
# Start development server
pnpm dev- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
The backend/demo/ folder contains:
| File | Description |
|---|---|
sample_loan_agreement.txt |
ACME Corporation - USD 50M Term Loan |
sample_syndicated_loan.txt |
TechGlobal - EUR 150M Syndicated RCF |
sample_real_estate_loan.txt |
Skyline Properties - GBP 75M CRE Loan |
seed_demo_data.py |
Script to populate database with demo deals |
generate_sample_pdfs.py |
Script to create PDF versions of samples |
# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-supabase-anon-key
# Cerebras API keys (comma-separated for load balancing)
CEREBRAS_API_KEYS=csk-key1,csk-key2,csk-key3
CEREBRAS_MODEL=qwen-3-235b-a22b-instruct-2507
# Settings
MAX_FILE_SIZE_MB=50
CORS_ORIGINS=http://localhost:3000NEXT_PUBLIC_API_URL=http://localhost:8000| Method | Endpoint | Description |
|---|---|---|
| POST | /api/documents/upload |
Upload and parse PDF |
| GET | /api/deals |
List all deals |
| GET | /api/deals/{id} |
Get deal details |
| DELETE | /api/deals/{id} |
Delete deal |
| GET | /api/deals/{id}/term-sheet |
Get term sheet data |
| POST | /api/deals/{id}/simulate |
Simulate covenant breaches |
| GET | /api/deals/{id}/export/csv |
Export CSV |
| GET | /api/deals/{id}/export/pdf |
Export PDF |
- Upload: Navigate to
/dashboard/deals/uploadand drop a sample PDF - Review: View the auto-extracted term sheet with deal terms and covenants
- Monitor: Go to Covenants tab, enter simulated metrics, see breach detection
- Export: Generate trade pack CSV/PDF for secondary trading
- Processing Time: < 30 seconds per document
- Extraction Accuracy: 95%+ for standard LMA documents
- Max File Size: 50MB
- Supported Format: PDF (LMA-style facility agreements)
├── backend/
│ ├── main.py # FastAPI app entry point
│ ├── config.py # Environment configuration
│ ├── schema.sql # Supabase database schema
│ ├── models/ # Pydantic data models
│ ├── services/ # Business logic
│ │ ├── parser.py # PDF parsing with pdfplumber
│ │ ├── cerebras_client.py # AI extraction with load balancing
│ │ ├── deal_service.py # Deal CRUD operations
│ │ ├── covenant_service.py # Breach detection logic
│ │ └── export_service.py # CSV/PDF generation
│ ├── routers/ # API route handlers
│ └── demo/ # Sample documents and seeders
│
├── frontend/
│ ├── src/
│ │ ├── app/dashboard/deals/ # Deal pages
│ │ ├── features/deals/ # Deal components
│ │ │ ├── deal-upload.tsx # File upload with dropzone
│ │ │ ├── deal-list.tsx # Deal listing with search
│ │ │ ├── term-sheet.tsx # Commercial summary view
│ │ │ ├── covenant-monitor.tsx # Breach simulation
│ │ │ ├── covenant-chart.tsx # Visual compliance chart
│ │ │ ├── trade-pack-export.tsx # Export interface
│ │ │ └── deals-overview.tsx # Portfolio dashboard
│ │ ├── lib/api.ts # API client
│ │ └── types/deal.ts # TypeScript types
│ └── ...
│
└── .kiro/specs/doc2deal/ # Spec documentation
- API keys are loaded from environment variables
- File uploads are validated for type and size
- CORS is configured for specific origins
- Supabase RLS can be enabled for production
MIT
