📋 Hackathon Provenance & Official Boilerplate Attribution (Oct 1 – Nov 12, 2026)

LeakLens AI is a brand-new application built from scratch during the PayPal AI Hackathon 2026 submission window (commits starting November 7, 2026) on top of PayPal's official hackathon starter repository: paypaldev/hackathon-paypal-ag-grid-boilerplate.

  • Why the Git history begins on Sep 27, 2026: Commits c2d80f0 through 5de114eb4306e844396022f9ca0558a4937761e2 (Sep 27 – Oct 12, 2026, authored by Eddie Jaoude & James Swinton-Bland) are unmodified upstream commits from PayPal & AG Grid's official starter template (verified exact HEAD commit 5de114eb4306e844396022f9ca0558a4937761e2), preserved for open-source attribution — not a prior project of ours.
  • Substantial Original Work Built During the Hackathon (+3,776 lines across 28 files, all committed Nov 7–11, 2026):
    • Exact GitHub Code Diff: https://github.com/suradpavankumar-tech/leaklens-ai/compare/5de114e...main
    • Deterministic Financial Audit Engine (lib/leaklens/* — 785+ lines): Built analytics.ts, engine.ts, mock-data.ts, and types.ts for SKU-level return-rate anomalies, excess above-baseline dollar loss math, and dual-mode PayPal Sandbox / audit dataset brokering.
    • Flagship Command Center (/leaklens, app/leaklens/*, app/api/leaklens/*): Created the revenue leak investigator UI, interactive KPI navigation, and natural-language investigation API routes.
    • AG Grid Community 36 Forensic Ledger (EvidenceGridWidget.tsx) & Custom AG Studio 3.0 Widgets (AboveBaselineRefundsWidget, RefundHotspotWidget, RevenueLeakFlowWidget): Built custom Midnight Quartz theme, bidirectional anomaly cross-filtering, custom pill/currency cell renderers, and 1-click CSV export via CsvExportModule.
    • Autonomous AI Investigation Console (InvestigationPanel.tsx), Interactive Command Header (LeakLensHeader.tsx, upgraded app-shell.tsx), & 2-Minute Automated Demo Tour (DemoTourController.tsx).

Inspiration

For modern e-commerce and SaaS merchants processing high transaction volumes through PayPal, top-line gross numbers often conceal a dangerous reality: between 4% and 9% of gross revenue quietly evaporates through unmonitored margin leaks.

These leaks take insidious forms:

  • Localized Refund Surges: A buggy software release or defective batch of physical inventory sparks an abrupt spike in customer returns that goes unnoticed on aggregated monthly statements until thousands of dollars have left the account.
  • Silent Recurring Dropouts: Expired billing tokens or subtle gateway authorization errors cause recurring subscription billings to silently drop off.
  • Stealth Fee Creep: Dispute handling surcharges, cross-border settlement fees, and currency conversion adjustments quietly degrade net margins without automated ledger attribution.

Traditional merchant dashboards are passive—they present static backward-looking charts long after capital has been lost. Conversely, generic LLM dashboards suffer from catastrophic financial hallucination: generative AI frequently makes arithmetic errors when summing fees or computing return rates from tabular text.

We asked ourselves: What if merchants had an autonomous, continuous financial auditor that watches PayPal transaction streams in real time, applies verifiable deterministic math to catch anomalies, and uses high-density AG Grid interactive ledgers to place undeniable forensic evidence at the merchant's fingertips?

That vision inspired LeakLens AI: Autonomous Revenue Leak Investigator for PayPal Merchants.


What it does

LeakLens AI is an intelligent margin-defense platform built upon the official PayPal Developer boilerplate and supercharged with AG Grid Community 36 and AG Studio 3.0.

It delivers five core capabilities:

1. Deterministic Anomaly & Margin Defense Engine

At the heart of LeakLens is our foundational architectural rule:

"The LLM proposes, code decides."

Rather than asking an LLM to calculate financial figures, all mathematical baselines, return ratios, and capital losses are computed strictly in TypeScript.

The engine models baseline moving averages and standard deviations across rolling 30-day windows. When a product's observed return rate exceeds historical tolerance thresholds:

$$Z_p = \frac{r_p - \mu_{\text{baseline}}}{\sigma_{\text{baseline}}}$$

The engine calculates the exact, auditable Above-Baseline Capital Loss:

$$\Delta L_p = \max\left(0, R_p - \left(G_p \times \bar{r}_p^{\text{baseline}}\right)\right)$$

Where $G_p$ represents gross volume, $R_p$ is total observed refunds, and $\bar{r}_p^{\text{baseline}}$ is the expected baseline return rate. Zero AI hallucination—100% accounting fidelity.

2. High-Density AG Grid Evidence Ledger

Instead of static summary tables, LeakLens leverages AG Grid Community 36 customized with a bespoke dark Midnight Quartz theme (themeQuartz.withParams):

  • Bi-Directional Anomaly Cross-Filtering: Clicking any anomaly card in the executive summary instantly filters the AG Grid to the exact evidentiary transactions responsible.
  • Instant Client-Side Filtering: Sub-millisecond toggle filters for All, Flagged Leaks, and Declined transactions, alongside full-text quick search across all columns.
  • 1-Click CSV Audit Export: Directly leverages AG Grid's CsvExportModule to export filtered audit trails (paypal-leaklens-ledger.csv) for offline review.
  • Custom Cell Renderers: Dynamic severity pills, formatted monetary values in settlement currencies, and event type indicators.

3. Native AG Studio Visual Report Builder (/dashboard)

Deeply integrated with AG Studio 3.0, LeakLens registers custom executive widgets into the visual dashboard:

  • AboveBaselineRefundsWidget: Dynamic variance bar contrasting expected returns against actual loss.
  • RefundHotspotWidget: SKU-level risk table highlighting defective product lines.
  • RevenueLeakFlowWidget: Interactive cash funnel tracking: $$\text{Net Retained Cash} = \text{Gross Volume} - \text{Refunds} - \text{PayPal Fees}$$

4. Autonomous AI Root-Cause Investigator

Merchants can query their transaction ledger using natural language (e.g., "Why did net revenue drop on AI Predictive Add-On this week?" or "Audit our recurring billing decline rate"). The AI auditor receives pre-calculated deterministic financial facts and returns structured root-cause findings, quantified excess drain values, and concrete merchant remediation action items.

5. Automated 2-Minute Demo Video Studio

Built right into the /leaklens console is an automated demo tour controller featuring an on-screen teleprompter HUD, automated scene transitions, synchronized visual highlights, and browser Web Speech voiceover narration.


How we built it

  • Core Stack: Built on Next.js 16.3.6 (App Router with Turbopack), React 19, and TypeScript in strict mode.
  • Base Repository: Scaffolding derived directly from the official hackathon boilerplate (paypaldev/hackathon-paypal-ag-grid-boilerplate).
  • Data Grid & Visualization:
    • ag-grid-community: 36.2.0 and ag-grid-react: 36.2.0.
    • Modular module registration: ClientSideRowModelModule, QuickFilterModule, ColumnAutoSizeModule, PaginationModule, CellStyleModule, and CsvExportModule.
    • Bespoke Midnight Quartz theme with high-contrast monetary tokens and custom animated cell renderers.
  • Visual Report Dashboard: ag-studio: 3.0.0 and ag-studio-react: 3.0.0 with state persistence and custom widget registry.
  • PayPal Integration: Live OAuth 2.0 Client Credentials flow querying /v1/reporting/transactions, /v1/reporting/balances, and /v1/catalogs/products.
  • Dual-Mode Data Broker: Combines live PayPal Sandbox API ingestion with a high-fidelity 150+ transaction audit dataset (engineered with realistic edge cases: 38.5% refund spike on an AI Add-On SKU, 12 recurring authorization declines, and cross-border settlement fees).
  • Deployment: Continuous integration and production deployment hosted on Vercel (leaklens-ai.vercel.app).

Challenges we ran into

  1. PayPal Sandbox Transaction Indexing Delay:

    • Challenge: PayPal Sandbox Transaction Search endpoints enforce a strict maximum 31-day search window and introduce up to a 3-hour indexing delay for newly simulated sandbox events. Newly created sandbox developer accounts also lack multi-week historical transaction depth.
    • Solution: We built a resilient Dual-Mode Data Broker (lib/leaklens/engine.ts). It communicates with live PayPal Sandbox REST endpoints when active, and automatically falls back to our deterministic synthetic audit dataset whenever sandbox records are sparse, giving judges and reviewers a friction-free evaluation experience.
  2. Eliminating Generative Math Hallucination:

    • Challenge: Generative LLMs routinely hallucinate arithmetic calculations when evaluating raw tabular logs.
    • Solution: We enforced a strict boundary: TypeScript computes all sums, standard deviations, and delta leak values before the AI model is invoked. The prompt only receives pre-verified mathematical facts, restricting the LLM's role to contextual reasoning, diagnostic attribution, and strategic remediation.
  3. Next.js 16 & Turbopack SSR Font Isolation:

    • Challenge: Next.js 16 Turbopack attempted network fetches for Google Fonts (next/font/google) during build time, which caused compilation failures in restricted build pipelines.
    • Solution: We decoupled the layout from external font fetches by implementing native system typography fallbacks (Inter, -apple-system, system-ui, sans-serif) directly in app/globals.css, achieving a clean 0-error production build in under 12 seconds.

Accomplishments that we're proud of

  • Flagship Implementation Without Breaking Starter Routes: Successfully delivered LeakLens AI and AG Studio custom widgets while preserving all 5 official PayPal boilerplate endpoint grids (/products, /plans, /invoices, /transactions, /balances).
  • AG Grid as the Evidentiary Core: Elevated AG Grid beyond a simple table into an active forensic tool where anomaly cards dynamically filter the grid to pinpoint culprit transactions with zero latency.
  • 100% Production Ready: Clean compilation across all 14 Next.js routes with zero TypeScript errors, deployed live to Vercel and backed by a public GitHub repository.
  • Built-in Automated Video Studio: Created a self-running, 120-second automated demo tour with synthesized voiceover and teleprompter HUD directly inside the application.

What we learned

  • Financial Engineering with AG Grid 36: Exploring AG Grid Community's modern modular architecture (CsvExportModule, PaginationModule, CellStyleModule) demonstrated how easy it is to achieve sub-millisecond sorting, multi-column search, and client-side data export on dense financial ledgers.
  • AG Studio Extensibility: Working with ag-studio taught us how to embed bespoke analytics widgets into an interactive visual report builder without corrupting saved report states in localStorage.
  • The Power of Grounded AI Systems: Structuring financial applications so that code calculates and AI contextualizes delivers the optimal balance of accounting precision and conversational usability.

What's next for LeakLens AI

  • Real-Time Webhook Processing: Ingesting PayPal PAYMENT.CAPTURE.DENIED, CUSTOMER.DISPUTE.CREATED, and BILLING.SUBSCRIPTION.CANCELLED webhooks via Vercel Edge functions for sub-second anomaly alerting.
  • Autonomous Remediation Actions: Integrating automated merchant actions via PayPal REST APIs, such as auto-approving returns under \$50 to protect merchant dispute ratios or triggering automated customer outreach when recurring card auth drops.
  • AG Grid Enterprise Grouping & Pivoting: Leveraging row grouping, pivot tables, and tree data views for multi-currency enterprise reconciliation across global PayPal merchant accounts.

Built With

  • accounting
  • ag-grid
  • ag-studio
  • ai
  • analytics
  • audit
  • automation
  • data-visualization
  • e-commerce
  • fintech
  • fraud-detection
  • javascript
  • llm
  • next.js
  • node.js
  • oauth2
  • paypal
  • paypal-rest-api
  • react
  • rest-api
  • saas
  • tailwindcss
  • turbopack
  • typescript
  • vercel
Share this project:

Updates

Submission history