Inspiration

Subscription businesses silently lose 2–4% of their Monthly Recurring Revenue (MRR) every month to preventable billing failures — expired cards that never get retried, accounts stuck in suspended limbo for weeks, accidental duplicate charges from network timeouts, and quiet subscriber churn after pricing updates.

Most small-to-medium merchants on PayPal don't have dedicated billing ops teams to audit thousands of transactions. But letting an unsupervised AI freely mutate payments or email customers is a financial and compliance nightmare.

We set out to solve this with one architectural rule:

The AI Proposes → The Human Approves → The System Executes.

What it does

Salvage AI is an autonomous revenue recovery agent for PayPal Subscriptions that:

->Detects revenue leaks in real time using 5 deterministic rules — failed renewals, stalled suspensions (>7 days), duplicate charges (within 72h), price-change fallout, and ML-predicted churn risk. ->Diagnoses each case using Google Gemini 2.5 Flash as a read-only financial analyst that investigates subscriber timelines, identifies root causes, and drafts personalized recovery emails. ->Presents the diagnosis and proposed action to the merchant on an interactive dashboard for human review. ->Executes the approved action (retry payment, reactivate subscription) via the PayPal Subscriptions API, logging every dollar recovered in an immutable audit trail.

How we built it

Backend (Python, FastAPI, SQLAlchemy 2.0):

Integrated PayPal Webhooks API for real-time event ingestion (PAYMENT.FAILED, SUBSCRIPTION.SUSPENDED, SALE.COMPLETED) with cryptographic signature verification. Built 5 deterministic detection rules (R1–R5) in pure Python — leak detection is never delegated to LLM heuristics. Severity scoring combines MRR impact with urgency: Severity = min(100, ⌊60 × MRR/500⌋ + 40 × UrgencyMultiplier). Integrated Google Gemini 2.5 Flash via the official google-genai SDK with strict typed JSON output (response_schema=AgentOutput) and read-only diagnostic tools only. Built a Scikit-Learn churn classifier scoring subscriber tenure, billing cadence, and failure history to predict churn probability before cancellation. Idempotent executor service prevents duplicate mutations even on webhook replays or double-clicks.

Frontend (React 19, TypeScript, Tailwind CSS):

Real-time financial dashboard with Total MRR at Risk, Recovered MRR, and leak-cause breakdown. Side-by-side case modal: raw PayPal facts on the left, Gemini's diagnosis and one-click approval on the right. Built-in Hackathon Demo Simulator to seed subscribers and inject live failure scenarios on demand.

Deployment:

Multi-stage Dockerfile (Node 22 + Python 3.11) deployed live on Render as a unified single-service container. Live at: salvage-ai.onrender.com

Challenges we ran into

Preventing AI hallucinations in financial workflows: Ensuring Gemini never triggers incorrect payment retries required strict architectural separation — deterministic detection in Python, read-only context tools for the LLM, and a rigid validated action enum (RETRY_PAYMENT, REACTIVATE_SUBSCRIPTION, NO_ACTION, etc.). Cross-platform Docker builds: Windows-specific Rollup bindings in package.json broke Linux Alpine container builds on Render. We diagnosed build logs, pruned platform-bound dependencies, and standardized on Node 22. Async sandbox loopback restrictions: Windows AppContainer sandboxes intermittently blocked internal loopback sockets needed by Python's async event loop, requiring us to restructure integration test execution.

Accomplishments that we're proud of

->60/60 tests passing — full unit and integration coverage across detection rules, webhook verification, AI schema parsing, and end-to-end recovery loops. ->Zero-write AI invariant enforced — the Gemini agent has no database or PayPal write permissions by architectural design, not just by prompt instruction. ->Live production deployment with real-time demo simulator and automated database seeding.

What we learned

In fintech, the highest-leverage AI application is synthesizing complex multi-source telemetry into clear root-cause diagnoses and empathetic customer outreach — leaving the execution trigger in human hands. Gemini's native response_schema enforcement completely eliminated JSON parsing failures, making frontend-backend AI contracts rock-solid.

What's next for Salvage AI

Multi-currency dynamic recovery adapting retry scheduling to global banking hours and regional card decline patterns. Multi-channel dunning via SMS and WhatsApp alongside email for higher win-back conversion. Automated chargeback defense ingesting PayPal Dispute webhooks to auto-compile evidence packages for merchant dispute resolution.

Built With

Share this project:

Updates

Submission history