Inspiration
Autonomous AI agents are increasingly entrusted with purchasing tasks—comparing prices, sourcing products, and placing orders. But in group contexts (startup teams, co-ops, student clubs, or shared households), giving an AI agent unrestricted access to a treasury or company credit card is a major risk. Even worse, individual members could instruct an agent to make unauthorized or out-of-policy purchases.
Current payment solutions assume a single payer with absolute authority. We built Quorum to solve this missing link: deterministic governance for AI-assisted group purchases.
Our non-negotiable core promise:
"No individual member can independently authorize a purchase. Every expenditure must satisfy the group's agreed policy and approval requirements."
What It Does
Quorum enforces a four-stage governed purchasing loop:
- 🤖 AI Proposes (The Adapt Loop): A member requests an item (e.g., "Find a projector for movie night"). The Google Gemini agent queries our curated vendor catalog. If the agent picks an item exceeding policy limits ($350 item vs $200 hard cap), Quorum Guard immediately blocks it. Guided by Guard's structured feedback, the agent auto-adapts and submits a compliant alternative ($145 OptiView HD).
- 🗳️ Democratic Approval: The group's policy dictates approval tiers based on dollar amount:
- Up to $60: 2 votes required
- Up to $150: 4 votes required
- Up to $200 (hard cap): all 6 members required
- ⏱️ Mandatory 2-Minute Veto Window: Once approval thresholds are met, the purchase does not execute immediately. It enters a mandatory 2-minute cooling period during which any active member can unilaterally cast a veto, immediately canceling the proposal and protecting the pool. During this window, execution is strictly refused (HTTP 403
NO_UNILATERAL_EXECUTION). - 💳 Row-Locked PayPal Payout: Once the veto window closes without objection, the proposal becomes executable. Quorum executes the payout via the PayPal Sandbox Payouts API under a PostgreSQL row-level lock (
FOR UPDATE), ensuring zero race conditions or double-spend. - 📜 Append-Only Financial Ledger: Every state change—contribution captures, fund reservations, approvals, vetoes, and payout completions—is written to an immutable audit ledger with raw transaction IDs and PayPal batch IDs.
Quorum also gracefully handles edge cases: if a member's contribution card fails during round funding, the pool enters a partial failure state where remaining members vote democratically to either proceed with a reduced budget or trigger an automated safe unwind.
How We Built It
- AI Agent & Structured Tool Calling: Powered by Google Gemini 3.8 Flash with deterministic low temperature (
0.1). Gemini uses function calling against an explicit schema (get_group_state,search_options,create_proposal) with a resilient rule-based fallback if rate limits occur. - Quorum Guard (Deterministic Rules Engine): Written in pure TypeScript with zero external network or database I/O during evaluation. Guard inspects 18 distinct governance checks (budget headroom, hard caps, eligible voters, vendor allowlists, voting deadlines, and veto windows).
- PayPal Payouts & Webhooks: Direct server-to-server integration with PayPal's Sandbox Payouts API (
POST /v1/payments/payouts) and Webhook signature verification (verify-webhook-signature), paired with background reconciliation polling. - Database & Concurrency: Supabase PostgreSQL utilizing strict
SERIALIZABLEisolation and row locks (FOR UPDATE) on balance queries, preventing double-deduction. - Frontend & Audit UI: Built with Next.js 14 (App Router), Tailwind CSS, and AG Grid Community for high-density, real-time ledger inspection.
- Automated Verification: 109 passing unit and integration tests covering the Adapt Loop, idempotency, veto window enforcement, and failure recoveries.
Challenges We Ran Into
- Separating AI Hallucination from Financial Rules: Early on, we recognized that an LLM should never be trusted to decide whether an expenditure complies with policy or when to release funds. We strictly isolated Gemini to the research and proposal phase. The authorization and money movement belong 100% to Quorum Guard and PostgreSQL.
- True Veto Window Enforcement: Preventing premature execution required hardened guards in both the
PROPOSALandEXECUTIONphases. Even if an executor script or client calls the API directly during the open countdown, Guard rejects it with HTTP 403. - Idempotency Between Webhooks and Polling: Network jitter can delay PayPal webhooks or deliver them twice. We built an idempotent reconciliation engine where both the webhook consumer and active polling share an atomic check-and-set state machine, guaranteeing funds are only deducted once.
Accomplishments That We're Proud Of
- Verified End-to-End Live Payouts: Every executed demo purchase calls the real PayPal Sandbox API and produces real PayPal Payout Batch IDs and Transaction IDs viewable in the PayPal Developer Dashboard.
- Zero-Bypass Architecture: The AI agent literally cannot spend money unilaterally, nor can any single member—the policy card is absolute law.
- 109 Automated Tests: 100% pass rate on test suites verifying race conditions, funding failure recoveries, and policy checks.
- Resilient Cold Starts: Integrated reactive recovery and status alerts for server wake-up on free-tier deployments.
What We Learned
Building at the intersection of autonomous agents and financial infrastructure requires pessimistic security. In consumer chat, a 95% LLM accuracy rate is great; in payments, a 5% failure rate is catastrophic. Separating the probabilistic agent (Gemini) from the deterministic guardian (Quorum Guard + PayPal APIs) is the foundational architecture for the future of agentic commerce.
What's Next For Quorum
- Multi-Vendor Direct Cart Settlement: Expanding from direct Payouts to multi-cart vendor checkouts using PayPal Orders v2.
- Dynamic Policy Amendments: Allowing groups to propose and vote on changing their own spending caps and approval tiers through the same governance loop.
- Slack & Discord Bot Integrations: Bringing Quorum proposal discussions and 1-click approvals directly into team chat channels.
Notice: Quorum enforces group governance policy. It is not an escrow service.
Built With
- ag-grid
- ai-agents
- fintech
- gemini-api
- google-gemini
- nextjs
- paypal
- paypal-payouts-api
- paypal-webhooks
- postgresql
- react
- supabase
- tailwindcss
- typescript
- vitest