Inspiration
Imagine giving an AI agent the ability to shop for you.
It can compare products, understand your requirements, find suitable options, and prepare a purchase. Convenient, right?
But there is a question we rarely ask:
What happens when an AI agent makes the wrong purchase — or spends more than you ever intended?
As AI moves from answering questions to taking real-world actions, financial autonomy creates a new challenge. Users need more than intelligent agents. They need control over what those agents are allowed to do.
We saw an opportunity to build the missing layer between AI-powered decisions and real financial transactions.
That idea became TRUSTLOOP AI.
Our vision is to make autonomous commerce possible without making financial control autonomous.
What it does
TRUSTLOOP AI is a financial governance layer for AI-assisted shopping.
It sits between a shopping request and payment execution, evaluating whether a proposed purchase is permitted before it can proceed.
Instead of trusting an AI agent with unrestricted payment access, TRUSTLOOP AI applies user-defined financial policies.
What it can do:
- Understand shopping requests: Uses Google Gemini to interpret natural-language shopping requirements and help generate product explanations.
- Enforce spending limits: Evaluates proposed purchases against configured budgets and spending thresholds.
- Control merchant and category access: Checks whether a proposed purchase falls within permitted merchants and product categories.
- Automatically authorize permitted purchases: Allows eligible requests to proceed when they satisfy the configured rules.
- Request human approval: Routes purchases requiring additional authorization to a user for approval or rejection.
- Block restricted transactions: Prevents requests that violate configured policies, such as exceeding spending limits or using an unapproved merchant.
- Assess transaction risk: Uses rule-based checks, with optional AI-assisted signals, to help identify potentially risky requests.
- Integrate PayPal payments: Provides a PayPal Orders API workflow for payment order creation and capture.
- Maintain transaction history: Records transaction events and decisions so users can inspect the purchase journey.
The fundamental rule: An AI recommendation is not financial authorization.
TRUSTLOOP AI makes sure that a purchase must pass the governance layer before moving toward payment.
How we built it
We built TRUSTLOOP AI as a full-stack application with a clear separation between AI assistance, financial governance, and payment execution.
Frontend
- Next.js
- React
- TypeScript
- Tailwind CSS
Backend
- Python
- FastAPI
- SQLAlchemy
- SQLite / PostgreSQL support
- Alembic database migrations
AI integration
- Google Gemini for natural-language shopping request interpretation and product explanations.
- AI-assisted signals are treated as advisory inputs, not as the final authority for transaction approval.
Payment integration
- PayPal Orders API workflow for order creation and capture.
- PayPal Sandbox-oriented payment integration.
Governance and security
- A deterministic policy engine checks budgets, merchant permissions, category restrictions, and approval requirements.
- A risk assessment layer evaluates transaction signals.
- Approval decisions are associated with the intended transaction and validated before proceeding.
- Duplicate-protection mechanisms help prevent repeated payment operations.
- Transaction events are recorded for later inspection.
System architecture
The architecture deliberately separates intelligence from authority.
+--------+
| USER |
+--------+
|
v
+--------------------------------------------------------+
| 01 - APPLICATION LAYER |
| |
| [ TRUSTLOOP AI Web App ] |
| | |
| v |
| [ Natural-Language Shopping Request ] |
+--------------------------------------------------------+
|
v
+--------------------------------------------------------+
| 02 - AI INTELLIGENCE LAYER (advisory only) |
| |
| [ Google Gemini: Request Understanding ] |
| | |
| v |
| [ Product Search & Purchase Proposal ] |
+--------------------------------------------------------+
|
v
+--------------------------------------------------------+
| 03 - FINANCIAL GOVERNANCE LAYER (deterministic) |
| |
| [ Risk Assessment ] |
| | risk score |
| v |
| [ Policy Engine: Budget / Merchant / Category ] |
| | |
| v |
| < GOVERNANCE DECISION > |
+---------+----------------+------------------+----------+
| | |
Permitted Approval required Policy violation
| | |
v v v
+--------------------------------------------------------+
| 04 - AUTHORIZATION AND PAYMENT |
| |
| [ Automatic ] [ Human ] [ BLOCKED ] |
| [ Approval ] [ Approval ] ^ |
| | | Approved | |
| +----------------+ | |
| v | |
| [ REVALIDATE ] -- Fail -----------+ |
| | Pass |
| v |
| [ PayPal Orders v2: Create & Capture ] |
+--------------------------------------------------------+
| |
v v
+--------------------------------------------------------+
| 05 - TRANSACTION VISIBILITY |
| |
| [ Transaction Event History ] |
+--------------------------------------------------------+
The most important architectural decision is that Gemini does not authorize payments. The governance engine evaluates the request against explicit rules. Payment execution is a separate step that follows authorization.
Challenges we ran into
Building an AI shopping experience was only one part of the challenge. The harder problem was deciding how to safely connect AI decisions to financial actions.
Some of the biggest challenges were:
1. Balancing autonomy with financial control
We wanted purchases to be automated where appropriate, without giving an agent unrestricted spending authority. This required different paths for automatic authorization, human approval, and blocked transactions.
2. Separating AI intelligence from financial authority
LLMs can misunderstand instructions or produce uncertain outputs. We therefore designed deterministic policy checks so that financial authorization does not depend solely on an AI-generated response.
3. Building a reliable approval workflow
An approval must apply to the intended transaction. We worked on transaction-bound validation, approval expiry, and revalidation before payment.
4. Preventing duplicate payment operations
Payment workflows need careful handling of repeated requests and capture operations. We incorporated duplicate-protection mechanisms into the prototype.
5. Connecting multiple technologies
Integrating the frontend, FastAPI backend, database, Gemini, policy engine, risk checks, and PayPal workflow required us to think carefully about how each component communicates and where responsibility belongs.
6. Treating input as untrusted
Natural-language requests and AI-generated content cannot automatically be treated as trusted instructions. This influenced how we approached validation and authorization.
Accomplishments that we're proud of
We are proud that TRUSTLOOP AI goes beyond recommending products. It demonstrates a governance-oriented approach to AI-assisted purchasing.
Some accomplishments we value most:
- Built a full-stack AI-assisted shopping and financial governance prototype.
- Implemented deterministic spending and permission checks.
- Developed separate automatic authorization, human approval, and transaction-blocking paths.
- Added transaction-bound approval validation and duplicate-protection mechanisms.
- Integrated Gemini into the shopping experience.
- Built a PayPal Orders API payment workflow.
- Created transaction event history to make decisions more inspectable.
- Designed an architecture where AI assistance and financial authorization have clearly separated responsibilities.
Our biggest accomplishment is turning a simple but important question — "Can we trust an AI agent with our money?" — into a working prototype that demonstrates one possible answer.
What we learned
This project taught us that building an autonomous AI system is not just about making it intelligent. It is also about defining the boundaries within which it can act.
We learned that:
- Autonomy should not mean unrestricted authority.
- Financial authorization needs deterministic and enforceable rules.
- Human approval is an important part of responsible automation.
- Payment systems require careful transaction-state management and duplicate protection.
- AI-generated risk signals should support, not replace, explicit security policies.
- Trust, transparency, and accountability need to be considered from the beginning of system design.
Most importantly, we learned to think beyond the AI agent itself and focus on the infrastructure needed to make its actions trustworthy.
What's next for TRUSTLOOP AI: Governed Agentic Commerce
We see shopping as the first use case, not the final destination.
Our long-term vision is to develop TRUSTLOOP AI into a reusable authorization and financial governance layer for autonomous agents.
Our next priorities are:
- Independent agent identity: Give connected agents their own credentials, scoped permissions, and revocation controls.
- Real-time notifications: Notify users when a transaction needs approval or requires attention.
- Stronger auditability: Explore cryptographically verifiable transaction histories.
- Improved risk intelligence: Develop and evaluate more advanced risk detection using representative transaction scenarios.
- Verified commerce integrations: Move beyond demo catalogs toward real merchant and product integrations.
- Payment reliability: Complete and strengthen end-to-end PayPal Sandbox validation.
- Multi-agent governance: Allow multiple agents to operate under shared user-defined financial policies.
We want users to benefit from increasingly capable AI agents without having to surrender control over their financial decisions.
Let AI buy. Let humans stay in control.
Built With
- agenticai
- aiagents
- artificialintelligence
- fastapi
- fintech
- generativeai
- python
