Skip to content

Google Agent2Agent-Powered Multi-Platform E-Commerce System

Notifications You must be signed in to change notification settings

sskarz/AgentBay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AgentBay Logo

AgentBay

A2A-Powered Multi-Platform E-Commerce System

🎬 Watch the Demo

Built by Sanskar Thapa, Damarrion (DIIZZY) Morgan-Harper, and Joshua Soteras


An intelligent e-commerce orchestration platform that uses Google ADK agents to automatically create, manage, and negotiate product listings across multiple marketplaces (eBay and Tetsy).

Table of Contents


Features

Skillfully using Google's Agent 2 Agent (A2A) Protocol

  • Intelligent Agent Orchestration β€” Multi-agent system with specialized agents for each platform
  • AI-Powered Product Analysis β€” Upload product images and automatically extract details using Google Gemini AI
  • Multi-Platform Listing β€” Seamlessly create listings on eBay and Tetsy from a single interface
  • Automated Price Negotiation β€” AI agents handle buyer-seller negotiations on Tetsy with intelligent pricing strategies
  • Real-Time Dashboard β€” WebSocket-powered live updates of all listings
  • Unified Management β€” Track and manage inventory across all platforms in one place

Architecture Overview

This project uses a multi-tier architecture with:

Layer Technology
Agent System Google ADK Multi-Agent System (Gemini 2.5-Flash)
Frontend React, TypeScript, Tailwind CSS, Shadcn UI
Backend FastAPI, Python, WebSocket support
Database SQLite (Listings and negotiations)
Integrations eBay Sandbox API, Tetsy API

Project Structure

AgentBay/
β”œβ”€β”€ backend/                    # Main API server (Port 8000)
β”‚   β”œβ”€β”€ apis.py                # Primary API routes and WebSocket
β”‚   β”œβ”€β”€ db.py                  # SQLite database helpers
β”‚   β”œβ”€β”€ ebay_api.py            # eBay sandbox integration (Port 8001)
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   └── offersb.db             # SQLite database
β”‚
β”œβ”€β”€ front/                      # React frontend (Port 5173)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/             # Dashboard and CreateListing pages
β”‚   β”‚   β”œβ”€β”€ components/        # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ lib/               # API client and utilities
β”‚   β”‚   └── types/             # TypeScript type definitions
β”‚   └── package.json
β”‚
β”œβ”€β”€ specialty_agents/           # Google ADK agent system
β”‚   β”œβ”€β”€ my_agent/              # Root orchestrator (Port 10000)
β”‚   β”œβ”€β”€ ebay_agent/            # eBay specialist (Port 10002)
β”‚   └── tetsy_agent/           # Tetsy specialist (Port 10001)
β”‚
└── Tetsy/                      # Tetsy platform implementation
    β”œβ”€β”€ backend/               # Negotiation API (Port 8050)
    └── frontend/              # Buyer-seller interface

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • Google API Key (for Gemini AI)
  • eBay Developer Account (for eBay integration)

Installation

1. Clone the Repository

git clone https://github.com/sskarz/AgentBay.git
cd AgentBay

2. Backend Setup

cd backend
pip install -r requirements.txt

Create a .env file in the backend/ directory:

GOOGLE_API_KEY=your_google_api_key_here
EBAY_CLIENT_ID=your_ebay_client_id
EBAY_CLIENT_SECRET=your_ebay_client_secret
EBAY_REDIRECT_URI=http://localhost:8001/oauth/callback

3. Frontend Setup

cd front
npm install

4. Agent Setup

The agents use Google ADK and share the same requirements.txt from the backend:

cd specialty_agents/my_agent
pip install -r ../../backend/requirements.txt

Running the Application

You need to start 7 services in separate terminal windows:

Terminal Service Command Port
1 Main Backend API cd backend && python apis.py 8000
2 eBay Backend cd backend && uvicorn ebay_api:app --reload --port 8001 8001
3 Tetsy Backend cd Tetsy/backend && python main.py 8050
4 Root Orchestrator Agent cd specialty_agents/my_agent && python -m __main__ 10000
5 Tetsy Agent cd specialty_agents/tetsy_agent && python -m __main__ 10001
6 eBay Agent cd specialty_agents/ebay_agent && python -m __main__ 10002
7 Frontend cd front && npm run dev 5173

Usage

Creating a Listing

  1. Navigate to the Create Listing page
  2. Upload Product Image β€” Drag & drop or click to upload
  3. AI Analysis β€” Gemini automatically extracts product details (name, price, description, brand)
  4. Review & Edit β€” Confirm or modify the extracted details
  5. Select Platform β€” Choose eBay or Tetsy
  6. Submit β€” The orchestrator agent routes to the appropriate platform agent
  7. View Dashboard β€” See your listing appear in real-time

Managing Listings

  • Dashboard β€” View all listings across platforms with live updates
  • Status Tracking β€” Monitor listing status (Draft, Pending, Live, Sold)
  • Platform Filtering β€” See which platform each listing is on (color-coded)

Handling Negotiations (Tetsy)

The Tetsy agent automatically handles buyer offers with intelligent pricing:

Offer Range Agent Response
β‰₯ 85% of asking price Accept the offer
< 85% of asking price Counter at 90%
Very low offers Reject politely

All negotiations are tracked in the Tetsy backend database.

API Endpoints

Main Backend (Port 8000)

Endpoint Method Description
/ GET API information
/health GET Health check
/api/analyze-product-image POST AI image analysis (Gemini)
/api/stream WebSocket Real-time listing updates
/api/create-listing-with-agent POST Create listing via agent system
/api/add_item POST Direct database insertion

eBay Backend (Port 8001)

Endpoint Method Description
/start-auth GET Initiate eBay OAuth
/oauth/callback GET OAuth redirect handler
/publish POST Publish listing to eBay
/create-all-policies POST Create business policies

Tetsy Backend (Port 8050)

Endpoint Method Description
/api/negotiations GET Get all negotiations
/api/negotiations/{id} GET Get negotiation details
/api/negotiations POST Start new negotiation
/api/negotiations/{id}/messages POST Send message/offer

Database Schema

Main Database (offersb.db)

CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    description TEXT,
    platform TEXT NOT NULL,
    price REAL NOT NULL,
    high_price REAL,              -- Highest offer received
    status TEXT,                   -- 'listed', 'sold', 'pending'
    quantity INTEGER,
    imageSrc BLOB,                -- Product image bytes
    createdAt TIMESTAMP,
    updatedAt TIMESTAMP
);

Tetsy Database (negotiations.db)

CREATE TABLE negotiations (
    id TEXT PRIMARY KEY,
    product_id TEXT,
    buyer_id TEXT,
    seller_id TEXT,
    status TEXT,                   -- 'pending', 'accepted', 'rejected', 'counter'
    last_offer_amount REAL,
    created_at TIMESTAMP
);

CREATE TABLE messages (
    id TEXT PRIMARY KEY,
    negotiation_id TEXT,
    sender_id TEXT,
    sender_type TEXT,              -- 'buyer', 'seller'
    type TEXT,                     -- 'message', 'offer', 'counter_offer'
    offer_amount REAL
);

Technology Stack

Backend

Technology Purpose
FastAPI Modern Python web framework
Uvicorn ASGI server
SQLite Embedded database
WebSockets Real-time communication
Google Generative AI Gemini 2.0-flash for image analysis
Google ADK Multi-agent orchestration framework
Httpx Async HTTP client
Pydantic Data validation

Frontend

Technology Purpose
React 19 UI library
TypeScript Type-safe JavaScript
Vite Build tool and dev server
Tailwind CSS Utility-first CSS
Shadcn UI Component library (Radix UI + Tailwind)
React Router Client-side routing
React Hook Form Form management
Zod Schema validation
Axios HTTP client
Sonner Toast notifications

AI / Agents

Technology Purpose
Google ADK Agent development kit
Gemini 2.5-Flash LLM for agent intelligence
RemoteA2aAgent Agent-to-agent communication pattern

Multi-Agent System

Root Orchestrator Agent (Port 10000)

  • Purpose: Routes listing requests to appropriate platform agents
  • Model: Gemini 2.5-Flash
  • Sub-agents: tetsy_agent, ebay_agent

eBay Agent (Port 10002)

  • Purpose: Publishes listings to eBay Sandbox
  • Tools:
    • publish_to_ebay() β€” Creates inventory items and offers
    • Database integration for tracking

Tetsy Agent (Port 10001)

  • Purpose: Manages Tetsy listings and handles negotiations
  • Tools:
    • post_listing_to_tetsy() β€” Creates listings
    • check_tetsy_notifications() β€” Monitors offers
    • respond_to_negotiation() β€” Intelligent offer handling
  • Strategy:
    • Accept offers β‰₯ 85% of asking price
    • Counter at 90% for lower offers
    • Professional communication with buyers

Data Flow

User uploads image β†’ Gemini AI analysis β†’ Frontend form
    ↓
User confirms details + selects platform β†’ API call
    ↓
Main Backend /api/create-listing-with-agent
    ↓
Root Agent (Gemini 2.5-Flash) decides routing
    ↓
    β”œβ”€β†’ eBay Agent β†’ eBay API β†’ eBay Sandbox
    β”‚   └─→ Database save
    β”‚
    └─→ Tetsy Agent β†’ Tetsy Backend β†’ Tetsy Database
        └─→ Database save
            ↓
WebSocket broadcasts update β†’ All connected dashboards refresh

System Architecture

Complete System Architecture Diagram (click to expand)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              USER INTERFACE LAYER                            β”‚
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              React Frontend (Port 5173)                               β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚  CreateListing Page β”‚      β”‚      Dashboard Page              β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  - Image Upload     β”‚      β”‚  - Real-time listing view        β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  - AI Analysis      β”‚      β”‚  - Status tracking               β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  - Platform Select  β”‚      β”‚  - Platform filtering            β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚               β”‚                            β–²                          β”‚  β”‚
β”‚  β”‚               β”‚ HTTP POST                  β”‚ WebSocket                β”‚  β”‚
β”‚  β”‚               β”‚ (FormData)                 β”‚ (real-time)              β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚                            β”‚
                  β–Ό                            β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          MAIN BACKEND LAYER (Port 8000)                      β”‚
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                     FastAPI Application (apis.py)                      β”‚  β”‚
β”‚  β”‚                                                                         β”‚  β”‚
β”‚  β”‚  POST /api/analyze-product-image                                       β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚  β”‚
β”‚  β”‚  β”‚ 1. Receive image upload (multipart/form-data)          β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 2. Encode to base64                                    β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 3. Send to Gemini 2.0-flash-exp                        β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 4. Parse JSON response                                 β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 5. Extract: name, description, price, brand            β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 6. Return product details to frontend                  β”‚           β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚  β”‚
β”‚  β”‚                                                                         β”‚  β”‚
β”‚  β”‚  POST /api/create-listing-with-agent                                   β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚  β”‚
β”‚  β”‚  β”‚ 1. Receive: name, description, price,                  β”‚           β”‚  β”‚
β”‚  β”‚  β”‚             quantity, brand, platform                   β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 2. Create Runner with root_agent                       β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 3. Invoke agent with prompt                            β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 4. Collect agent response                              β”‚           β”‚  β”‚
β”‚  β”‚  β”‚ 5. Return response to frontend                         β”‚           β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚  β”‚
β”‚  β”‚                                                                         β”‚  β”‚
β”‚  β”‚  WebSocket /api/stream                                                 β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚  β”‚
β”‚  β”‚  β”‚ 1. Accept WebSocket connection          β”‚                          β”‚  β”‚
β”‚  β”‚  β”‚ 2. Every 2s: query DB β†’ send JSON       β”‚                          β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                              β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                β”‚
β”‚         β”‚  SQLite DB     β”‚    β”‚  Gemini AI  β”‚                                β”‚
β”‚         β”‚ (offersb.db)   β”‚    β”‚  (Google)   β”‚                                β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β”‚ Invokes via Runner
                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       MULTI-AGENT ORCHESTRATION LAYER                        β”‚
β”‚                                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚              Root Orchestrator Agent (Port 10000)                      β”‚  β”‚
β”‚  β”‚              Model: Gemini 2.5-Flash (Google ADK)                      β”‚  β”‚
β”‚  β”‚                                                                         β”‚  β”‚
β”‚  β”‚  Sub-agents:                                                            β”‚  β”‚
β”‚  β”‚  - tetsy_agent (RemoteA2aAgent, localhost:10001)                       β”‚  β”‚
β”‚  β”‚  - ebay_agent (RemoteA2aAgent, localhost:10002)                        β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚                  β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  └────────────────┐
              β–Ό                                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Tetsy Agent (Port 10001)          β”‚    β”‚    eBay Agent (Port 10002)       β”‚
β”‚    Model: Gemini 2.5-Flash           β”‚    β”‚    Model: Gemini 2.5-Flash       β”‚
β”‚                                      β”‚    β”‚                                  β”‚
β”‚  Tools:                              β”‚    β”‚  Tools:                          β”‚
β”‚  - post_listing_to_tetsy()           β”‚    β”‚  - publish_to_ebay()             β”‚
β”‚  - check_tetsy_notifications()       β”‚    β”‚                                  β”‚
β”‚  - respond_to_negotiation()          β”‚    β”‚  Publishes to eBay Sandbox       β”‚
β”‚                                      β”‚    β”‚  via eBay Backend (Port 8001)    β”‚
β”‚  Posts to Tetsy Backend (Port 8050)  β”‚    β”‚                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Detailed Flow Sequences (click to expand)

Flow 1: Create Listing via AI Analysis

User uploads image
    ↓
CreateListing Page (React Frontend)
    ↓ POST /api/analyze-product-image (multipart/form-data)
Main Backend API (Port 8000)
    ↓ Send image + prompt
Google Generative AI (gemini-2.0-flash-exp)
    ↓ Returns: { name, description, price, brand, quantity }
Main Backend API β†’ Parse JSON β†’ Return to frontend
    ↓
CreateListing Page β†’ Pre-fill form β†’ User reviews β†’ User submits
    ↓
[Continue to Flow 2]

Flow 2: Agent-Based Listing Creation

CreateListing Page
    ↓ POST /api/create-listing-with-agent (name, description, price, quantity, brand, platform)
Main Backend API (Port 8000)
    ↓ Invoke agent via ADK Runner
Root Orchestrator Agent (Port 10000) β€” Gemini 2.5-Flash
    ↓ Routes based on platform
    β”œβ”€β†’ Tetsy Agent (Port 10001) β†’ [Flow 3]
    └─→ eBay Agent (Port 10002)  β†’ [Flow 4]

Flow 3: Tetsy Platform Listing

Tetsy Agent
    ↓ Calls post_listing_to_tetsy()
    β”œβ”€β†’ POST http://localhost:8050/api/listings β†’ Tetsy DB (negotiations.db)
    └─→ POST http://localhost:8000/api/add_item β†’ Main DB (offersb.db)
            ↓ WebSocket broadcasts every 2s
        All Dashboard clients update

Flow 4: eBay Platform Listing

eBay Agent
    ↓ Calls publish_to_ebay()
    β”œβ”€β†’ POST http://localhost:8001/publish
    β”‚       ↓ 1. Validate OAuth token
    β”‚       ↓ 2. Create inventory item
    β”‚       ↓ 3. Create & publish offer
    β”‚       ↓ 4. Return listing URL
    └─→ POST http://localhost:8000/api/add_item β†’ Main DB (offersb.db)

Flow 5: Tetsy Buyer Negotiation

Buyer makes offer ($40 on a $50 item)
    ↓ POST /api/negotiations
Tetsy Backend (Port 8050) β†’ Creates negotiation record
    ↓ Webhook: POST http://localhost:10001/webhook/message
Tetsy Agent β€” Decision Logic (Gemini 2.5-Flash):
    β”‚ offer_percentage = 40/50 = 80%
    β”‚ 80% < 85% threshold β†’ Counter at 90% ($45)
    ↓ Calls respond_to_negotiation(type="counter", amount=45)
Tetsy Backend β†’ Updates negotiation β†’ Buyer sees counter-offer

Flow 6: WebSocket Real-Time Updates

Dashboard clients connect β†’ ws://localhost:8000/api/stream
    ↓
Main Backend (every 2 seconds):
    β†’ Query SQLite DB (SELECT * FROM users)
    β†’ Convert BLOB images to base64
    β†’ Send JSON array to all connected clients
    ↓
Dashboard re-renders with updated listings, status badges, platform indicators

Port Allocation

Port Service Technology Purpose
5173 React Frontend Vite User interface
8000 Main Backend API FastAPI Core orchestration & WebSocket
8001 eBay Integration Backend FastAPI eBay Sandbox API integration
8050 Tetsy Backend FastAPI Negotiation & listing management
10000 Root Orchestrator Agent Google ADK Multi-agent routing
10001 Tetsy Agent Google ADK Tetsy operations & negotiation
10002 eBay Agent Google ADK eBay listing publication

Component Dependencies

Frontend (React)
    ↓
    β”œβ”€β†’ Main Backend API ──→ SQLite DB (offersb.db)
    β”‚       ↓
    β”‚       β”œβ”€β†’ Google Gemini (image analysis)
    β”‚       └─→ Root Agent ──→ Google ADK
    β”‚               β”œβ”€β†’ Tetsy Agent
    β”‚               β”‚       β”œβ”€β†’ Tetsy Backend ──→ SQLite DB (negotiations.db)
    β”‚               β”‚       └─→ Main Backend (save listing)
    β”‚               └─→ eBay Agent
    β”‚                       β”œβ”€β†’ eBay Backend ──→ eBay Sandbox API
    β”‚                       └─→ Main Backend (save listing)
    └─→ Tetsy Backend (for buyer negotiations)
            └─→ Tetsy Agent (webhook for auto-response)

eBay Integration Notes

  • Uses eBay Sandbox environment for testing
  • Requires OAuth 2.0 authentication flow
  • Business policies (fulfillment, payment, return) are mandatory
  • SKU format: alphanumeric only (no special characters)
  • Category-specific product attributes required

eBay Setup Steps

  1. Visit /start-auth to initiate OAuth
  2. Complete authorization on eBay
  3. Run /optin-to-business-policies
  4. Create policies via /create-all-policies
  5. Now ready to publish listings

Troubleshooting

Agents not connecting
  • Ensure all backend services are running first
  • Check that ports 8000, 8001, 8050, 10000–10002 are available
  • Verify GOOGLE_API_KEY is set in .env
eBay authentication fails
  • Check eBay credentials in .env
  • Ensure redirect URI matches eBay app settings
  • Verify you're using sandbox credentials for sandbox environment
WebSocket disconnects
  • Check browser console for errors
  • Ensure main backend (port 8000) is running
  • Frontend auto-reconnects every 3 seconds
Image analysis fails
  • Verify GOOGLE_API_KEY is valid
  • Check image format is supported (JPEG, PNG)
  • Ensure image file size is reasonable (< 10MB)

Development

Running Tests

# Backend tests
cd backend && pytest

# Frontend tests
cd front && npm test

Code Style

# Frontend linting
cd front && npm run lint

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

This project was developed for CalHacks 2025.

Acknowledgments

About

Google Agent2Agent-Powered Multi-Platform E-Commerce System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •