This is a submission for the Built with Google Gemini: Writing Challenge
Building Credexia: How Gemini Became My 48-Hour Co-Founder
The Event
I built Credexia at the LMA Edge Hackathon, where the theme was loan market innovation. The challenge was to modernize how banks handle loan servicing after the trade is signed. While trading platforms have gone digital, post-closing operations are still stuck in Excel hell. I had 48 hours to change that.
The LMA ecosystem has tools for drafting loans and platforms for price discovery, but there is a massive white space in between. Banks can agree on trades and sign loans digitally, yet post-closing servicing and settlement remain fragmented. Excel sheets, endless email chains, manual data re-entry, broken reconciliation. Liquidity is not blocked by lack of capital. It is blocked by operational friction.
My goal was to build the Operating System for Loans. A unified platform connecting covenant monitoring, trade settlement, and cash distribution in real time.
What I Built
Credexia is a unified desktop platform covering three critical loan lifecycle stages in one dashboard. It is built on Next.js 16 with React 19, TypeScript 5.8, and styled with Tailwind CSS 4, MUI 7, and Framer Motion for animations.
Demo Video
See Credexia in action:
https://youtu.be/3GrR22gW9SU?si=aFDLldcB2vOJYxK8
Live Website
Try the platform:
GitHub Repository
View the code:
Credexia
A Next.js + Supabase + Ethers-powered platform for blockchain-verified loan covenant monitoring, OCR-driven data extraction, and portfolio analytics.
Features
- AI-assisted chat for covenant guidance (Gemini)
- OCR-backed document intake with fallback parsing
- Covenant calculations (Debt/EBITDA, ICR, current ratio)
- Polygon Amoy sealing for compliance events
- Dashboard for loans, uploads, reports, and trade utilities
Stack
- Next.js 16, TypeScript, Tailwind
- Supabase (auth, DB, storage)
- Ethers.js for Polygon interactions
- Google Gemini for AI responses and parsing
Prerequisites
- Node 18+ and npm
- Supabase project with SUPABASE_URL and service key
- Polygon Amoy RPC endpoint and funded deployer key
- Gemini API key for AI features
Setup
- Install deps: npm install
- Copy .env.local.example to .env.local (if present) and set:
SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=
SUPABASE_ANON_KEY=
GEMINI_API_KEY=
POLYGON_RPC_URL=
BLOCKCHAIN_PRIVATE_KEY=
API_KEY= # optional API auth
ALLOWED_ORIGINS=* # comma-separated list in prod
- Run dev server: npm run dev
- Optional: compile contracts: npx hardhat compile
Scripts
- npm run dev – start Next.js dev server
- npm…
Monitoring
Tracks financial covenants like Debt/EBITDA and ESG covenants like Carbon Emissions. Users upload a PDF financial report. AI extracts values and calculates compliance. A traffic light system shows status: Green for Safe, Amber for Warning, Red for Breach. If an ESG covenant is breached, the interest rate automatically adjusts according to loan terms.
TradeClear
Digitizes the transfer of loan ownership. Users upload a Notice of Assignment PDF. AI extracts Seller, Buyer, and Trade Amount. After approval, the Ownership Register updates instantly. This removes manual ledger updates entirely.
AgentFlow
Automates the Payment Waterfall. It distributes borrower payments across lender banks, enforces zero rounding error, assigns any remainder to the Agent Bank, and generates SWIFT-ready CSV in seconds.
Global State
All three modules share a Global State. If ownership changes in TradeClear, AgentFlow instantly reflects the new owner without a page reload. This is managed through an in-memory global singleton with hot-reload safety, though this would need Redis or a database for true production multi-instance deployment.
How Gemini Powered Everything
I used Gemini at every layer of the stack. Not as a helper. As a co-builder. The AI layer centers on Google Gemini 2.5 Flash with a 4-tier fallback system: Gemini 2.5 Flash, Gemini 2.5 Pro, Gemini 1.5 Flash, and Gemini 1.5 Pro. OCR.space serves as a raw text backup when needed. A confidence gate at 60% ensures that if AI confidence drops below this threshold, the user must confirm before proceeding.
Document Understanding
The core feature is PDF ingestion. A credit analyst uploads Q4 financials. Gemini extracts the numbers, calculates ratios, and flags breaches. The extraction targets totalDebt and ebitda fields with confidence scoring. When confidence is low or parsing fails, an OCR fallback path activates.
The first extraction test I ran returned a Debt/EBITDA ratio of 47x. The real number was 4.7x. Gemini had misread a table cell. That single failure taught me why finance demands confidence gates and deterministic logic. I rebuilt the extraction layer with strict validation and the 60% confidence threshold.
Code Generation
I wrote maybe 40% of the React components myself. The rest came from Gemini prompts. The traffic light dashboard, the upload flow, the audit log interface. I would describe what I needed, iterate twice, and have production-ready code. The marketing landing page with animated hero, the login authentication flow, the portfolio dashboard with analytics cards, the loan tables, the document intake with OCR processing, the compliance reporting, the trade workflow UI, and the AI agent orchestration view all benefited from Gemini-generated code.
Blockchain Integration
I used Gemini to write the Solidity contracts for Polygon Amoy testnet. The CovenantRegistry.sol contract handles SHA-256 covenant sealing. Each compliance event gets a txHash for immutable audit trails. When I hit the "private key fiasco" at 3 AM, where my .env key had an extra character, Ethereum keys must be exactly 64 hex characters, Gemini debugged the error message with me. I also implemented a demo mode using FNV-1a hash simulation when the network fails, ensuring the demo never crashes regardless of API failure.
Trade Clearing Architecture
The trade module has 7 sub-routes forming a complete lifecycle: upload, parse, validate, owners, approve, confirm, and events. This supports partial ownership transfers between banks. The in-memory trade state singleton prevents loss during Next.js hot reload, though production would need a persistent store.
Payment Waterfall Precision
The waterfall distributes cash to syndicate members by ownership share. Floating-point remainder always assigns to Agent Bank to ensure exact totals. This handles fractional splits and guarantees perfect totals, solving the zero-variance requirement that took six hours to perfect. Not because the math is hard. Because financial systems demand perfection.
AI Chat Assistant
I built a covenant guidance chatbot powered by Gemini. It answers questions about loan covenants, risk analysis, debt-to-EBITDA calculations, document uploads, OCR extraction, blockchain verification, and portfolio insights.
The Pitch Deck
Yes, I even used Nano Banana, Gemini's image generation, for the pitch deck visuals. The LMA judges saw AI-generated diagrams explaining AI-powered compliance. Meta, but effective. Gemini helped structure the narrative and create visuals that made institutional infrastructure feel tangible.
Technical Architecture
The frontend runs on Next.js 16 App Router with 18 API routes covering loans, chat, OCR, parsing, extraction, covenant calculations, blockchain sealing, compliance events, portfolio data, uploads, waterfalls, and the full trade lifecycle.
All business logic is implemented as pure functions with deterministic outputs. The covenant engine in particular has no side effects, calculating Debt/EBITDA ratios, Interest Coverage Ratios, and Current Ratios with strict mathematical precision.
Database and authentication use Supabase with Postgres and Storage. The blockchain layer uses Ethers.js 6 with Hardhat 3 for smart contract development. Smart contracts are written in Solidity and deployed to Polygon Amoy testnet.
What I Learned
AI Needs Guardrails
My first extraction failure taught me that finance cannot tolerate hallucination. The 47x versus 4.7x error led to the confidence gate system and deterministic validation layers. Every AI output gets verified before it touches a financial calculation.
Model Names Are Chaos
I spent two hours debugging 404 errors before realizing "gemini-2.5-flash" and "gemini-2.5-flash-preview" are different endpoints. The 4-tier fallback system was born from necessity, not planning. Incorrect model names caused API failures that required the retry logic I implemented.
Simulation Beats Broken Reality
OCR on messy financial tables failed constantly. Rather than fight it, I built demo-friendly PDFs with clean formatting and a manual override. The demo worked. The architecture was real. Resilient architecture means the app never crashes during demo regardless of API failure.
The Last Mile Is Process, Not Math
Getting the payment waterfall to sum to exactly 100% with no rounding errors took six hours. Not because the math is hard. Because financial systems require perfection. The operational friction in fintech is not about complex calculations. It is about ensuring those calculations are auditable, deterministic, and zero-error.
Schema Drift Happens Fast
Frontend expected fields that did not exist in Supabase. I adapted the frontend to the database rather than migrating the database mid-hackathon. This pragmatic approach preserved velocity when time was critical.
What Worked and What Didn't
What Worked
Speed. I prototyped a full-stack fintech platform in 48 hours because Gemini accelerated every decision. Multi-modal document understanding. The ability to throw a PDF at an API and get structured JSON back feels like magic when it works. The traffic light UI gave instant risk visibility across the portfolio. Honest error handling meant no silent failures. Users see real confidence and validation errors.
The Friction
Inconsistency. Same prompt, different results across model versions. Structured output sometimes ignored my schema. Financial tables in PDFs remain a hard problem. I needed OCR.space as a backup for messy scans. The messy financial tables broke OCR repeatedly, requiring the demo-friendly PDF approach.
What I Needed
Better documentation on model capabilities. Clearer error messages when context windows overflow. Native support for financial table extraction without custom preprocessing. More predictable structured output formatting for financial data.
Who This Is For
Credexia serves Credit Risk Analysts, Loan Agency Teams, Syndicated Loan Traders, Treasury Operations, ESG Compliance Teams, and Audit & Regulatory Teams. Eventually it will serve rating agencies, regulators, and institutional investors. This is not consumer SaaS. This is institutional infrastructure.
Business Model
Monetization can happen through per-loan subscription, per-document processing fees, per-settlement fees, compliance enterprise licenses, ESG pricing modules, and audit trail services.
What's Next
Credexia is not a hackathon toy. It is institutional infrastructure. I am adding real-time ESG covenant monitoring, expanding to trade settlement workflows, and building out the audit trail for regulatory compliance.
Gemini got me from idea to working demo in 48 hours. The next 48 days are about making it production-grade. The architecture is real. The global state works. The blockchain sealing provides immutable audit trails. The payment waterfall guarantees zero variance. The AI extraction learns from every validation.
The foundation is built. Now it is time to scale.
Built with Next.js, Supabase, Polygon, and Google Gemini.





Top comments (0)