đź§  Agentic Marketplace: AI-Powered Trust for Digital Deals

🚀 Inspiration

Modern marketplaces make it easy to connect buyers and suppliers—but trust remains a major gap. Deals often rely on fragmented communication, unverifiable updates, and weak enforcement of contracts. This leads to disputes, fraud, and uncertainty.

We were inspired to solve a simple but powerful problem:

What if every deal had built-in intelligence to verify actions, track progress, and enforce trust automatically?

That idea led us to build an AI-powered marketplace pipeline where contracts aren’t just static documents—they’re actively analyzed, monitored, and enforced.


🛠️ What We Built

We built a 5-stage deal pipeline that ensures a transaction moves safely from start to finish:

  1. Make Contract (AI Risk Scanner)
    Suppliers upload or generate contracts. AI analyzes clauses and flags risks (e.g., liability caps, indemnification imbalance).

  2. Agreement Loop (Buyer ↔ Supplier)
    Buyers can accept or request changes until both parties agree.

  3. Deal Execution (Evidence Tracking)
    Both parties upload real-time updates (text, images) as proof of progress.

  4. AI Analysis
    AI evaluates the full deal:

    • Contract compliance
    • Timeline adherence
    • Evidence consistency

It produces:

  • Scores for both parties
  • Risk findings
  • A final verdict
  1. Dispute Window (Escrow Protection)
    Parties can dispute within 24 hours before escrow is released.

⚙️ How We Built It

đź§© Tech Stack

  • Frontend: Next.js (App Router), React, Tailwind CSS
  • Backend: Next.js API Routes
  • Database & Storage: Supabase
  • AI Model: Gemma 4 (via Google Generative AI API)
  • File Parsing: pdftotext for robust PDF extraction

đź§  AI Pipeline

We built a structured AI pipeline instead of relying on raw responses:

  1. Extract contract text from PDFs
  2. Construct a strict prompt enforcing JSON output
  3. Parse AI output using:
    • Marker-based extraction (FINAL_JSON:)
    • Fallback scanning for valid JSON blocks
  4. Validate schema before sending to frontend

📊 Scoring Logic

AI evaluates performance based on:

  • Delivery time vs contract:

$$ \text{timeliness score} = \frac{\text{expected days}}{\text{actual days}} $$

  • Evidence consistency:

$$ \text{confidence} \propto \text{number of verifiable updates} $$

  • Contract compliance:

$$ \text{score} = f(\text{violations}, \text{risk clauses}) $$


⚔️ Challenges We Faced

1. Unreliable AI Output

LLMs often returned:

  • Multiple JSON objects
  • Placeholder data ("...", {...})
  • Partial or truncated responses

👉 Solution:
We built a robust parser that:

  • Anchors output using FINAL_JSON
  • Scans for multiple JSON blocks
  • Validates structure before accepting results

2. PDF Parsing in Node Environments

Libraries like pdfjs and pdf-parse caused:

  • ESM import issues
  • Missing browser APIs (e.g., DOMMatrix)

👉 Solution:
We switched to a system-level approach using pdftotext, which proved far more stable.


3. State Synchronization Across Pipeline

Managing deal stages (contract → execution → AI → disputes) required careful routing and state consistency.

👉 Solution:
We structured the app around dynamic routes and a shared deal ID, ensuring each stage reflects real-time state.


4. AI Determinism vs Flexibility

We needed:

  • Consistent outputs (for trust)
  • But also meaningful analysis

👉 Solution:
We tuned the model with low temperature and strict schema enforcement.


📚 What We Learned

  • AI is powerful—but only when constrained properly
  • Parsing AI output is as important as generating it
  • Trust systems require both UX and backend rigor
  • Real-world reliability > perfect AI responses

🌍 What’s Next

  • Highlight risky clauses directly in contracts
  • Improve dispute resolution with AI arbitration
  • Introduce trust scores across marketplace users
  • Scale to real-world B2B marketplaces

đź’ˇ Final Thought

We didn’t just build a marketplace—we built a system where trust is enforced, not assumed.


Built With

Share this project:

Updates