Inspiration

The lending industry is drowning in complex legal documentation. Loan agreements can span hundreds of pages with critical clauses buried deep within, making due diligence time-consuming and error-prone. We envisioned an AI-powered platform that transforms these dense documents into actionable digital insights.

What it does

LoanTwin OS is an AI-powered loan document intelligence platform that:

  • Extracts Digital Loan Records (DLR): Converts complex PDF loan agreements into structured JSON data with AI-extracted metadata
  • Enables Intelligent Clause Search: Provides full-text search across all clauses with page-level citations
  • Automates Compliance Tracking: Generates obligation calendars with automated due date tracking
  • Facilitates Secondary Trading: Creates comprehensive due diligence packs with risk assessment and transferability analysis

How we built it

Frontend: Built with Next.js 14 (App Router), TypeScript, and modern CSS variables for a responsive, mobile-first interface with dark mode support.

Backend: Powered by FastAPI 0.115.6, SQLModel ORM, and SQLite database. The PDF processing pipeline uses PyMuPDF for text extraction and custom NLP patterns for legal document intelligence.

AI Processing: Advanced pattern matching extracts governing law, agreement dates, parties, currency, facility information, covenants, and assignment provisions. The system generates compliance calendars and risk assessments automatically.

Testing: Comprehensive test suite with 100% backend coverage (28 tests) and E2E testing with Playwright (23 Jest tests + 8 E2E tests).

Challenges we ran into

  • Parsing complex multi-page PDFs while maintaining accurate page references
  • Detecting diverse legal clause numbering formats and structures
  • Extracting metadata reliably across different loan agreement templates
  • Building a robust NLP pipeline for legal terminology without pre-trained models
  • Ensuring data consistency across document uploads and processing stages

Accomplishments that we're proud of

  • Achieved 100% backend test coverage with comprehensive integration tests
  • Built a production-ready E2E platform with Docker orchestration
  • Created an intuitive UI that makes complex legal documents accessible
  • Implemented intelligent search with page-level citations
  • Developed automated compliance calendar generation
  • Successfully deployed on Google Cloud Run with live demo

What we learned

  • Legal document processing requires sophisticated pattern matching and context awareness
  • FastAPI's async capabilities enable efficient multi-document processing
  • Next.js App Router provides excellent developer experience for complex applications
  • Comprehensive testing is essential for document processing accuracy
  • Cloud deployment strategies for containerized multi-service applications

What's next for LoanTwin OS

  • Integration with GROQ realtime API for voice-based document querying
  • Enhanced MCP (Model Context Protocol) integration for AI-powered insights
  • Multi-language support for international loan agreements
  • Advanced covenant compliance prediction using ML
  • Integration with loan management systems and trading platforms
  • Mobile app for on-the-go document access

Built With

  • cloud
  • next.jstypescriptfastapipythonsqlmodelsqlitepymupdfdockergoogle
Share this project:

Updates