Inspiration
Small businesses don't fail because they're unprofitable — they fail because of cash flow timing. A catering company can have $22,000 in outstanding invoices and still miss payroll. The owner knows the money is owed, but chasing it manually means writing awkward emails, tracking spreadsheets, and hoping clients pay before the bank account hits zero.
We wanted to build something that removes that anxiety entirely: an AI system that watches the numbers, sees the gap coming, and takes action — before it's too late.
How We Built It
CashGuard is a multi-agent pipeline built on LangGraph, deployed on Google Cloud Run, with Fivetran syncing invoice data and Gemini drafting the collections emails.
The pipeline has 6 nodes that execute in sequence:
Fivetran Sync → Invoice Monitor → Relationship Analyzer → Cash Flow Forecaster → Communication Agent → Escalation Agent
The cash flow forecaster starts with the current balance ($12,400) and subtracts $1,000/day in operating burn, plus scheduled obligations — payroll ($8,000 on June 18) and rent ($4,500 on June 25). It flags the first day the balance goes negative as the cash gap date, then links it to the specific overdue invoices whose collection would prevent it.
The relationship analyzer scores each client and picks a tone:
Relationship Score Days Overdue Tone ≥ 80 non-critical warm < 50 any serious default any firm Gemini then drafts a tone-matched email. The business owner reviews it in the dashboard and approves with one click — triggering SendGrid to send it.
The frontend is React + Vite + Chart.js, served as a static build from the same Cloud Run container as the FastAPI backend.
Challenges
Quota exhaustion during demo prep. We hit Gemini free-tier limits repeatedly while testing. The fix: the communication agent gracefully falls back to pre-written tone-matched templates when the API is unavailable, so the demo never breaks.
FastAPI + StaticFiles routing conflict. Mounting the React build at / caused FastAPI to intercept trailing-slash redirects on API routes before they could resolve. The fix required changing all list routes from @router.get("/") to @router.get("").
MongoDB Atlas SSL on Cloud Run. The default TLS handshake failed inside the container. Fixed by passing tlsCAFile=certifi.where() to the Motor client.
Multi-stage Docker on Cloud Build. Getting the Node 20 → Python 3.11 multi-stage build to push correctly to Artifact Registry and trigger a Cloud Run deploy required writing a custom cloudbuild.yaml with an explicit gcloud run deploy step.
What We Learned
Building a real multi-agent system is less about the AI and more about state handoff. Each node in the LangGraph pipeline reads from MongoDB, does one job, and writes back — and getting that contract right between agents is what makes the system reliable.
We also learned that human-in-the-loop is not a limitation — it's the feature. An AI that drafts the email and lets the owner approve it gets used. An AI that sends automatically gets turned off after the first awkward message to a 3-year client.
Log in or sign up for Devpost to join the conversation.