Inspiration

AI is changing how people discover products and make purchasing decisions. Shopping assistants can understand natural-language requests, compare products, and recommend purchases in seconds.

However, there is an important question: What happens when an AI makes a recommendation that violates a user's financial rules?

Imagine asking an AI to recommend a keyboard under $50. What if it recommends a $299 product? What if an untrusted product description tells the AI to ignore spending limits? What if the same payment is accidentally processed twice?

An AI assistant should not be able to authorize financial transactions simply because it recommended a product.

This inspired us to build GuardCart AI 2.0 — Secure Agentic Commerce with Explainable Payment Governance.

Our core philosophy is simple:

Let AI Shop. Keep Humans in Control.

Instead of giving AI unrestricted purchasing authority, we introduce an independent Financial Safety Gateway between AI recommendations and payment execution.

The AI helps users choose what to buy, while deterministic backend security rules and explicit human approval control whether a purchase can proceed.

What it does

GuardCart AI 2.0 is a full-stack AI-assisted shopping and payment-governance prototype that combines intelligent product recommendations, financial security enforcement, human approval, PayPal Sandbox checkout, and explainable transaction auditing.

1. AI-powered shopping assistant

Users describe what they need in natural language, such as:

"Recommend a wireless keyboard for programming under $50."

Our Gemini-powered assistant analyzes products from a controlled demonstration catalog and recommends suitable options based on the user's request.

Users can compare product names, prices, merchants, descriptions, and features before selecting a product.

The system also supports a deterministic catalog-matching fallback when Gemini is unavailable.

2. Independent Financial Safety Gateway

Before a purchase can proceed, our FastAPI backend evaluates the proposal against independently enforced financial policies.

The gateway checks:

  • Product availability and status
  • Valid purchase quantity
  • Maximum per-transaction spending
  • Remaining daily spending allowance
  • Approved merchant restrictions
  • Blocked product categories
  • Supported payment currency

The result is an explainable ALLOW or BLOCK decision, accompanied by individual validation results.

Crucially, the AI cannot override these financial rules.

3. Human-controlled purchase approval

A successful financial validation does not automatically execute a payment.

The user must explicitly approve the proposed purchase.

To protect approved purchase details, GuardCart generates a SHA-256 order snapshot and a keyed HMAC integrity check.

Before continuing with payment, the backend verifies the approved order against trusted product data and the applicable policy version.

This helps prevent unauthorized changes to the product price, quantity, merchant, or approved transaction details.

4. PayPal Sandbox checkout

After a purchase passes validation and receives human approval, GuardCart integrates with PayPal Orders v2 using CAPTURE intent.

The backend creates a PayPal Sandbox order, redirects the user for buyer authorization, and verifies the payment before recording successful capture.

We implemented payment safeguards including:

  • PayPal request idempotency
  • Duplicate-capture prevention
  • Verification of order amount and currency
  • Unique order and capture references
  • Spending reservations to help enforce daily limits
  • Explicit handling of uncertain payment states

We successfully completed and verified Sandbox payment captures during end-to-end integration testing.

All payments use PayPal Sandbox test accounts and simulated funds.

5. Security Test Lab

GuardCart includes an interactive Security Test Lab that demonstrates how the gateway responds to five controlled scenarios:

Scenario Expected result
Normal purchase within policy ALLOW
Purchase exceeding the transaction limit BLOCK
Malicious product text attempting to override the budget BLOCK
Purchase from an unauthorized merchant BLOCK
Duplicate payment capture attempt BLOCK

These tests use the actual backend governance functions and produce explainable results.

The Security Test Lab uses isolated spending fixtures and does not execute PayPal payments.

The prompt-injection scenario demonstrates that untrusted text cannot bypass the independent spending rule in this case; it is not intended to represent a universal prompt-injection detector.

6. Transaction monitoring and analytics

GuardCart provides an interactive financial activity dashboard powered by AG Grid and AG Charts.

Users can inspect:

  • Completed, blocked, pending, failed, and cancelled records
  • Financial security decisions and violated rules
  • PayPal order and capture references
  • Human approval and order-integrity status
  • Transaction amounts and merchant information
  • Security Test Lab results, clearly identified as test records

AG Grid supports searching, sorting, filtering, pagination, transaction inspection, and CSV export.

AG Charts visualizes transaction outcomes and security-rule violations.

This makes payment governance understandable, measurable, and auditable.

How we built it

We designed GuardCart around one architectural principle:

The AI recommendation layer must remain separate from financial authorization and payment execution.

Our architecture follows this workflow:

User Request → Gemini Shopping Assistant → Trusted Product Catalog → Financial Safety Gateway → Human Approval → PayPal Sandbox → PostgreSQL Audit Trail

Frontend

We built the web application using:

  • React and TypeScript
  • Vite
  • Tailwind CSS
  • React Router
  • Axios
  • AG Grid
  • AG Charts

The frontend provides shopping conversations, product comparison, purchase validation, approval controls, PayPal checkout navigation, security testing, transaction history, analytics, and integration diagnostics.

Backend

Our backend uses:

  • Python and FastAPI
  • SQLAlchemy
  • PostgreSQL
  • Google Gemini API
  • PayPal REST APIs
  • SHA-256 and HMAC
  • Pytest

FastAPI exposes endpoints for product discovery, AI recommendations, financial policies, purchase proposals, human approval, PayPal order creation and capture, security tests, transaction history, and analytics.

The financial gateway uses deterministic Python checks rather than relying on an AI model to enforce spending limits.

PostgreSQL stores product and policy records, purchase proposals, payment references, spending reservations, security-test executions, and audit events.

We implemented backend verification at critical payment stages to ensure that AI-generated text or frontend-submitted values are not treated as trusted financial authorization.

Challenges we ran into

Separating AI intelligence from financial authority

One of our main challenges was designing a system where Gemini could help users shop without gaining permission to control payments.

We solved this by restricting the AI to product recommendation tasks and moving every important financial decision into an independent backend governance layer.

Preventing duplicate payment capture

Payment workflows involve redirects, retries, and uncertain network outcomes.

We had to ensure that repeated requests did not cause additional captures of an already completed payment.

We addressed this using persistent payment states, PayPal request IDs, stored capture references, and duplicate-capture checks.

Maintaining consistent spending limits

A purchase can pass an initial budget check but become invalid if other purchases consume the available daily allowance.

We implemented spending reservations and PostgreSQL locking during payment-order creation to strengthen budget enforcement across overlapping checkout attempts.

Integrating multiple frontend and backend workflows

Connecting AI recommendations, product selection, security validation, purchase approval, PayPal redirects, payment verification, and transaction dashboards required consistent API contracts and careful state management.

We resolved integration issues through end-to-end testing and incremental debugging.

Keeping security demonstrations independent from real spending

Our initial security tests could be affected by spending accumulated during previous Sandbox checkouts.

We improved the Security Test Lab by using isolated test spending while preserving the real governance rules.

This allowed repeatable security demonstrations without changing actual payment or spending records.

Accomplishments that we're proud of

Our biggest accomplishment is building an integrated, functioning prototype rather than only presenting a conceptual architecture.

We successfully implemented:

  • Gemini-powered product recommendations with a catalog fallback
  • Independent backend financial validation
  • Explainable allow/block decisions
  • Explicit purchase approval
  • SHA-256 and HMAC order-integrity verification
  • PayPal Sandbox order creation and verified capture
  • Duplicate-capture prevention and payment idempotency
  • PostgreSQL-backed transaction and audit records
  • Five interactive Security Test Lab scenarios
  • AG Grid transaction monitoring and AG Charts analytics

We also achieved 10 passing backend automated tests and a successful frontend production build.

Most importantly, we demonstrated the separation of AI recommendations from payment authority using a working end-to-end workflow.

What we learned

Building GuardCart helped us better understand the engineering challenges of AI-assisted commerce and financial systems.

We learned that:

  • AI recommendations should not be treated as trusted payment instructions.
  • Deterministic financial policies are essential when AI-generated output can influence purchases.
  • Human approval and payment capture are separate stages that must be independently verified.
  • Idempotency, persistent payment state, and reconciliation are important for reliable payment processing.
  • Cryptographic integrity checks help detect unauthorized changes to approved purchase data.
  • Security demonstrations should be reproducible without requiring actual payment execution.
  • Clear audit records are as important as security decisions because users need to understand why purchases were approved or blocked.

We also gained practical experience integrating Gemini, FastAPI, PostgreSQL, PayPal APIs, AG Grid, and AG Charts into one application.

What's next for GuardCart AI 2.0 — Secure Agentic Commerce

GuardCart is currently a Sandbox-only hackathon prototype using a controlled product catalog and a single demonstration user.

Our next steps are to:

  1. Expand product discovery: Integrate supported marketplace and merchant APIs for a larger, regularly updated product catalog.
  2. Enable real merchant checkout workflows: Connect trusted seller checkout systems so approved payments correspond to genuine merchant orders.
  3. Add secure user accounts: Implement authentication, per-user authorization, and individual spending policies.
  4. Expand security testing: Introduce more adversarial prompt-injection tests, transaction-integrity scenarios, and automated attack simulations.
  5. Improve operational reliability: Add database migrations, monitoring, reconciliation workflows, and stronger deployment security.
  6. Support wider use cases: Extend the Financial Safety Gateway to other AI-assisted purchasing and payment workflows.

Our long-term vision is to make financial governance a reusable safety layer for AI-powered commerce.

The goal is not to stop AI from helping people shop. It is to ensure that AI-assisted purchases remain transparent, policy-compliant, and under human control.


GuardCart AI 2.0 — Let AI Shop. Keep Humans in Control.

GitHub: https://github.com/s-monisha11/GuardCart-AI-2.0

Built With

Share this project:

Updates

Submission history