Inspiration

If you’ve ever done freelance work, you already know the worst part of the job isn't writing the code or designing the UI—it’s chasing people for money.

I’ve had moments where a project was delivered, the client loved the result, and then weeks went by without payment. Chasing clients feels awkward. You don't want to sound rude and burn a relationship, but you also have bills to pay. And traditional tools don't help much:

  • Automated reminders from accounting software sound robotic and cold.
  • You can easily forget to follow up when you're busy with the next project.
  • And if a client actually paid an hour ago and your automated tool sends them an overdue reminder, it looks terrible.

I wanted to build an agent that handles this entire cycle for freelancers—from drafting the invoice in plain English to doing the follow-ups safely, without ever sending an embarrassing email. That’s how DueFlow was born.


What it does

DueFlow takes over the uncomfortable parts of invoicing while keeping the freelancer in total control:

  • Plain-English Invoicing: Instead of clicking through form fields, I just type: "Invoice Rahul $200 for branding and logo design, due in 7 days". The agent turns that into a real PayPal invoice draft.
  • Real PayPal Integration: Once confirmed, it calls the PayPal Invoicing API to create and send the official invoice link to the client.
  • Smart Follow-Ups: If the due date passes without payment, DueFlow prepares a friendly follow-up. It respects quiet hours (no emails in the middle of the night), waits at least 3 days between messages, and stops after 3 reminders.
  • Human Approval Inbox: I don't want an AI sending random messages to my clients without my consent. In Balanced mode, DueFlow drafts the message and asks for a quick 1-click approval before sending.
  • Immediate Chase Halt: The second a client pays via PayPal, a webhook hits DueFlow and immediately cancels any scheduled follow-up.
  • Judge Demo Bar: Because nobody wants to wait 7 real days to test overdue reminders, I built a fast-forward tool right at the top of the app to advance virtual time by 3 days at a time.

How I built it

I wanted the app to feel fast, reliable, and production-ready:

  • Frontend: Built with Next.js 16 and Framer Motion for smooth transitions, deployed on Cloudflare Pages.
  • Backend: Next.js Serverless API routes deployed on Vercel.
  • Database: PostgreSQL running on Neon, managed with Prisma.
  • Payments: Official PayPal Invoicing REST API v2 (Sandbox).
  • Background Tasks: Upstash QStash and Redis for queueing follow-up checks with deduplication.
  • AI Engine: Google Gemini (gemini-2.5-flash) for parsing natural language into structured data and drafting empathetic messages.

The Rule: AI Suggests, Code Decides

From day one, I set a strict rule: The LLM is never allowed to talk to payment APIs directly.

The AI only does two things:

  1. Parse plain English into structured JSON.
  2. Draft polite reminder copy.

All the critical logic—checking if an invoice is overdue, enforcing quiet hours, making sure reminders don't exceed the limit, and calling PayPal—is handled by deterministic TypeScript code. I also added a regex validator to block banned phrases like legal threats, late-fee penalties, or altered amounts before any text can leave the app.


Challenges I ran into

  • Cross-Origin Setup: Splitting the static frontend on Cloudflare Pages and the backend on Vercel created CORS preflight headaches on POST requests. I had to write custom Next.js middleware to handle OPTIONS requests and origin headers properly.
  • Testing Time Shifts Without Breaking Data: I needed judges to see what happens when an invoice is 7 days overdue without faking dates in the database. I ended up writing an in-memory virtual clock that offsets time dynamically.
  • Webhook Race Conditions: What if a client pays at the exact moment a reminder is about to send? I solved this with a "Check-Then-Act" step: right before dispatching any message, the system re-verifies the live status with PayPal. If it's already marked paid, the reminder is aborted on the spot.

What I'm proud of

  • Built an automated 30-scenario test suite (scripts/evaluate_agent.ts) that runs against the policy engine—testing edge cases like timezone quiet hours, fee inflation, and cooldowns. It passed all 30 tests with zero violations.
  • Getting the full loop working with live PayPal Sandbox APIs and webhooks instead of just mocking the UI.
  • The interface feels calm and transparent. You always see what the agent is thinking and why.

What I learned

Agentic AI in finance only works when there are hard guardrails. People don't want an autonomous bot making money decisions on its own—they want a helpful assistant that does the repetitive drafting while code keeps everything safe and predictable.


What's next

  • WhatsApp and SMS notifications alongside email.
  • Syncing directly with QuickBooks and Xero.
  • Multi-currency support for freelancers working across different countries.

Built With

Share this project:

Updates

Submission history