What it does

SpendGuard lets you give an AI shopping agent a spending policy instead of a blank check. You write rules in plain language, for example: “Max $150/month, electronics and books only, ask me before anything over $40.” The rules are converted into a structured policy that you review and confirm before it takes effect.

When you ask the agent to buy something, it searches real listings through the Channel3 API and proposes a purchase. A policy engine written as deterministic code, not the language model, then decides whether the purchase is auto-approved, needs your approval, or is blocked, and records which rule applied. Approved purchases create a PayPal Orders v2 sandbox order. You approve the payment as the buyer, and the app captures it. Every step is written to an audit log, and PayPal webhooks update order status.

Why it matters

Agents that can pay are useful, but people won’t trust them with money if a model’s mistake or a prompt injection can spend it. SpendGuard keeps one principle: the model proposes and deterministic code decides. The policy engine has no network access, so the same purchase always gets the same decision.

How I built it

Next.js and TypeScript, SQLite, and Render for hosting. Gemini (function calling and structured output) parses rules and drives the agent loop. The app shows which parser handled each request and falls back to rule-based parsing if the Gemini API is unavailable, never silently. PayPal Orders v2 and webhook signature verification handle checkout. Channel3 supplies real product listings. 42 automated tests cover policy rules, startup validation, order idempotency, failure cases and health checks.

Challenges

Keeping the agent from ever touching payments directly, and handling the PayPal approval step, which requires the buyer to approve each payment. I made that step part of the design as a human checkpoint. Hosting on a free tier with ephemeral storage also required automatic seeding on startup.

What’s next

Persistent storage, multiple users, per-merchant rules, and a refund window.

Limitations

Sandbox only, with no real money. There is a single demo user. The free Render host resets its database when it restarts, so complete a checkout in one session, and if it restarts mid-checkout, create the order again.

Built With

Share this project:

Updates

Submission history