Inspiration

Every freelancer knows the feeling: the work is done, the invoice is overdue, and now you have to write a polite-but-firm message to someone you'd rather not annoy. Chasing money is the least creative part of freelancing, and it quietly eats time and cash flow.

AI can obviously write that invoice and that reminder. But letting an AI move money on its own is a bad idea: one misread decimal or hallucinated client and real money goes to the wrong place. I built DuePilot around one principle: the AI does the work, the human makes the decision.

What it does

DuePilot is an AI invoicing copilot for freelancers, built on PayPal. It does four things:

  • Chat-to-Invoice: Paste a messy sentence like "Invoice Ada for 5 logo drafts at $150 each, due in 2 weeks". The AI extracts the client, line items, currency and a real due date from the relative phrase, and computes the total:

$$Total = \sum_{i=1}^{n} Quantity_i \times UnitPrice_i$$

  • Human-in-the-Loop Approval: The AI never touches PayPal on its own. It produces a structured proposal and pauses. Nothing happens until the freelancer clicks Approve.
  • Chasing, automated: On approval, DuePilot creates a PayPal checkout link and drafts a client message. Later, it writes reminders whose tone depends on how overdue the payment is, friendly at day one and firmer at day thirty.
  • Cash-flow Q&A: Ask "Who owes me money?" and the agent answers from your live order data, which stays in sync with PayPal payment status.

When the client pays, the dashboard flips to Paid. No spreadsheets, no awkward emails.

How i built it

  • Backend: FastAPI (Python) with a lightweight HTML/JS frontend.
  • AI engine: Google Gemini with structured JSON output (response_mime_type="application/json") and a strict schema, so the backend receives predictable, parseable data instead of free text.
  • Guardrails: A dedicated guardrails.py module independently re-checks the AI's math and validates the data before an approval is even possible. Blocked proposals can't be approved.
  • PayPal integration: PayPal REST API (Sandbox) to create orders, generate approval links, check status and capture payments.
  • State and audit trail: SQLite stores pending approvals, orders, and a log of every AI and user action, so each decision is traceable.
  • Deployment: Render.

Challenges i ran into

Most of my learning came from things breaking:

  1. Switching LLMs mid-build. We started on Claude, hit an access wall, and pivoted the whole AI layer to Gemini. Because the AI logic sits behind one service module, the switch didn't touch the rest of the app.
  2. JSON mode needed v1beta. Forcing structured output wasn't available on the SDK's default API version. It took some digging to find.
  3. PayPal's ORDER_ALREADY_CAPTURED error. While testing, we kept deleting our local database, which reset our pending IDs to 1. PayPal remembers request IDs for a long time, so it saw duepilot-1 again and treated our new order as the old, already-paid one. We fixed it by making every request ID unique:
request_id=f"duepilot-{pid}-{uuid.uuid4().hex[:10]}"
  1. A model disappeared mid-build. Our fallback model, gemini-2.5-flash-lite, was closed to new users. We wrote a small script to list the models our key could actually use, then built a three-model fallback chain:
MODELS = ["gemini-2.5-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite"]

Accomplishments that i am proud of

  • The full loop works, end to end. I type a messy sentence, review the AI's proposal, approve it, get a real PayPal Sandbox checkout link, pay it as a buyer in a private window, and watch the dashboard turn Paid.
  • An agent that's safe with money. Approval is enforced in both the UI and the backend, and every AI action is logged.
  • It survives failure. The app keeps working when a model is busy or retired, and it no longer breaks when test data is reset.
  • Messages that sound human. The reminders adjust their tone to how late the payment is, instead of sending the same template every time.

What i learned

  • Finance needs structure. Strict schemas plus independent validation make LLM output reliable enough to sit next to payments. Free-form text isn't.
  • Idempotency matters. Payment APIs remember request IDs, so IDs must be unique and deliberate, especially when your test database keeps resetting.
  • Assume the model will fail. Fallback models turned outages and deprecations from crashes into non-events.
  • The best agents ask first. For anything involving money, a good approval step is a feature, not friction.

What's next for DuePilot

  • Go live: Move from the PayPal Sandbox to production so freelancers can get paid for real.
  • Multimodal input: Snap a photo of a receipt or handwritten note and turn it into an invoice.
  • Cash-flow forecasting: A dashboard that charts incoming money over time and warns when unpaid invoices put you at risk.
  • Accounting integrations: Connectors for QuickBooks and Xero.

Built With

Share this project:

Updates

Submission history