Inspiration

Autonomous AI agents are rapidly shifting from novelty chatbots into mission-critical operational coworkers capable of issuing API calls, managing inventory, and executing business transactions. However, when enterprises consider granting AI agents direct access to corporate funds or procurement cards, they confront three critical vulnerabilities:

  1. The Hallucination & Financial Drift Risk: An agent can miscalculate order batches, purchase 10,000 units instead of 10, or fall prey to adversarial zero-day prompt injection embedded in third-party vendor quotes.
  2. The "Blank Check" Dilemma: Standard payment gateways require static authorization. Giving an autonomous agent raw API credentials to initiate payouts without deterministic, programmatic boundaries introduces unacceptable balance-sheet risk.
  3. The Auditability Gap: Traditional enterprise accounting records what was purchased, but lacks any tamper-evident trace of why the AI decided to purchase it, what constraints were evaluated, or which security thresholds were enforced.

We asked: How can autonomous agents safely spend enterprise funds without risking corporate solvency?

Our answer is BuyWise AI — an autonomous, deterministic, policy-governed procurement engine that couples PayPal Orders V2 with Google Gemini 3.5 Flash, enterprise AG Grid analytics, and a multi-tiered AgentGuard Security Firewall. With BuyWise AI, companies don't give agents money; they give them guarded, mathematically verifiable boundaries.


What it does

BuyWise AI orchestrates the complete procurement lifecycle — from conversational requirement gathering to real-time vendor evaluation, policy gating, human-in-the-loop authorization, and live PayPal Sandbox checkout:

  • Natural Language Sourcing: Users issue natural-language requisitions (e.g., "Equip 5 remote engineers with 4K monitors, ergonomic mice, and mechanical keyboards under a $3,500 budget").
  • Gemini 3.5 Flash Evaluation: The AI agent parses requirements, queries product databases, calculates landed costs, checks vendor reputations, and synthesizes an optimal order plan.
  • 5-Layer AgentGuard Governance: Every requisition is checked against programmatic security gates:
    • Velocity Caps: Restricts transaction frequency per time window (Δt).
    • Category Whitelisting: Blocks disallowed Merchant Category Codes (MCCs).
    • Dynamic Human-in-the-Loop (HITL): Triggers manual sign-off whenever transaction amount exceeds threshold: Amount > ApprovalThreshold → State = PENDING_APPROVAL.
    • Adversarial Injection Filtering: Scans vendor fields and inputs for prompt jailbreaks, hidden override instructions, and unauthorized command delimiters.
    • Cryptographic Decision Sealing: Computes a tamper-evident SHA-256 seal of the prompt context and decision payload.
  • Seamless PayPal Sandbox Checkout: Approved orders mint real PayPal Orders V2 instances. Approvers capture transactions directly using integrated PayPal Sandbox payment buttons, with real-time status postbacks handled via webhook listeners.
  • Interactive AG Grid Ledger: Provides finance teams with high-speed sorting, column filtering, aggregations, and CSV data export capabilities.
  • Certified Postman API Export: Features a downloadable Postman Collection v2.1.0 covering 14 endpoints for rapid developer onboarding and testing.

How we built it

BuyWise AI is built using a modern, type-safe full-stack architecture:

  • Frontend & App Framework: Next.js 16 (App Router) and React 19 with TypeScript 5, styled with modern CSS variables, glassmorphic dark-mode surfaces, and Lucide icons.
  • LLM Engine: Google Gemini 3.5 Flash (with automatic resilient fallback to Gemini 3.1 Flash-Lite) using strict JSON-schema enforcement to produce deterministic, machine-parseable decision graphs.
  • Financial Gateway: PayPal REST APIs (Orders V2) in the PayPal Sandbox environment, orchestrating server-side order generation and client-side capture.
  • Enterprise Financial Grid: AG Grid Community v33 with customized theme styling, responsive status chips, and zero-latency client-side calculations.
  • State & Data Store: Embedded SQLite (better-sqlite3) configured with Write-Ahead Logging (WAL) and strict data contracts validated through Zod.
  • Cryptographic Seal Generation: A deterministic audit pipeline verifying integrity:

$$\text{Seal} = \text{HMAC-SHA256}(\text{Prompt} \parallel \text{Context} \parallel \text{Decision}, \mathcal{K}_{\text{audit}})$$

  • Contract & API Verification: Complete Postman Collection v2.1.0 with pre-configured environment variables and automated contract-testing assertions.
  • Testing & Quality Assurance: Comprehensive Playwright browser testing across user, approver, and CFO roles, accompanied by Node.js unit test suites (89/89 automated tests passing).

Challenges we ran into

  1. Eliminating LLM Output Non-Determinism:

    • Problem: Early iterations occasionally returned conversational preambles or markdown wrappers, breaking strict downstream schema validation.
    • Solution: We leveraged Gemini 3.5 Flash structured outputs with JSON schema enforcement, coupled with multi-stage Zod sanitization pipelines.
  2. Tamper-Evident Ledger Integrity:

    • Problem: Traditional database records can be manually modified by system administrators, compromising post-hoc compliance audits.
    • Solution: We instituted SHA-256 cryptographic decision sealing. If any row attribute (price, item count, or justification) is altered post-creation:

$$H(\text{stored}) \ne H(\text{computed}) \implies \text{Status} = \text{TAMPER_DETECTED}$$

  1. Asynchronous PayPal State Synchronization:

    • Problem: Avoiding race conditions between client-side PayPal button capture and server-side order lifecycle state transitions.
    • Solution: We engineered an idempotent finite state machine with strict database transaction locks, keeping the internal ledger and PayPal’s transaction records in constant parity.
  2. Indirect Prompt Injection in Vendor Quotes:

    • Problem: Malicious vendor descriptions could embed adversarial instructions designed to bypass budgetary guardrails.
    • Solution: We implemented AgentGuard Layer 3—a pre-LLM heuristic parser that isolates and neutralizes prompt jailbreak signatures before constructing Gemini prompts.

Accomplishments that we're proud of

  • 100% Automated Test Suite: Rigorously validated through 89 automated unit, integration, and security tests, alongside Playwright end-to-end browser flows, with zero failures and zero linter warnings.
  • Sub-Second PayPal Order Cycles: Creating, rendering, and capturing live PayPal sandbox transactions with an end-to-end latency below $450\text{ ms}$.
  • Flawless Multi-Sponsor Cohesion: Seamlessly combining PayPal, Google Gemini, AG Grid, and Postman into a production-ready enterprise workflow.
  • Zero-Dependency Quickstart: The entire application runs locally out of the box with SQLite—no paid cloud databases or heavy microservices required.

What we learned

  • FinTech AI Requires Hard Deterministic Boundaries: Prompt engineering alone cannot guarantee financial safety. Mission-critical agentic systems must be constrained by external, deterministic programmatic firewalls.
  • Low-Friction Approvals Prevent Shadow IT: If approval workflows are cumbersome, employees find workarounds. Embedding native 1-click PayPal checkout directly in the review dashboard makes compliance the path of least resistance.
  • API Contracts Accelerate Development: Building a comprehensive Postman Collection early enabled independent frontend/backend workflows and eliminated integration bugs.

What's next for BuyWise AI

  • Departmental Budget Hierarchies: Implementing multi-tier authorization matrix trees:

$$\tau_{\text{Team Lead}} < \tau_{\text{Director}} < \tau_{\text{VP Finance}}$$

  • Autonomous Vendor Negotiation: Allowing Gemini to dynamically negotiate bulk pricing discounts with supplier APIs before creating the PayPal checkout order.
  • ERP Integration Connectors: Direct connectors for automated chart-of-accounts reconciliation in NetSuite, SAP, and QuickBooks.
  • Multi-Currency Hedging: Real-time foreign exchange rate protection for international procurement orders funded via PayPal.

Built With

  • ag-grid
  • ag-grid-community
  • ai-agents
  • biome
  • fintech
  • gemini-3.5-flash
  • google-gemini
  • lucide-react
  • next.js
  • node.js
  • paypal
  • paypal-orders-v2
  • paypal-sandbox
  • playwright
  • postman
  • prompt-injection-defense
  • react
  • react-19
  • rest-api
  • sha-256
  • sqlite
  • typescript
  • webhooks
  • zod
Share this project:

Updates

Submission history