This repository is now a multi-service marketplace intelligence stack. It analyzes product photos, generates listing-ready metadata, estimates prices from live web listings, stores results in Convex, and exposes marketplace actions through an MCP server.
At a high level, the system supports this flow:
- Analyze one or more product images with OpenAI Vision.
- Produce structured output (category, product details, condition, listing text, search payload).
- Optionally estimate a recommended price using web search.
- Persist analysis and pricing data to Convex via HTTP actions.
- Publish/search/buy marketplace listings through Convex and MCP tools.
cv-base-main
Main product analysis service (Flask UI + FastAPI + core detector).price-estimator
Price estimation API/CLI that enriches analysis JSON with market research.Convex-main
Backend data model and APIs for analyses, estimates, and listings.mcp-server-main
FastMCP server exposing marketplace tools (find_products,get_payment_link,finalize_purchase).num-object-detector-main
Separate lightweight detector focused on one binary rule: "exactly one object present".fastapi-endpoints.md,fastapi-endpoints-details.md
Short endpoint notes.
Primary purpose: generate rich listing intelligence from images.
Key components:
detector.py:MarketplaceDetectorclass with OpenAI vision prompts.app.py: Flask web UI for webcam/upload workflows.api.py: FastAPI endpoint for programmatic image analysis.
Main API:
POST /api/analyze(port8001by default)GET /api/health
Output shape includes:
marketplace_suitabletier1category detectiontier2detailed product and condition analysisbarcode_lookuplisting(listing-ready content)search(search-optimized payload)
Convex integration:
- If
CONVEX_HTTP_URLis set, analysis is posted to Convex/api/save-analysis.
Primary purpose: append market-based pricing to an existing analysis payload.
Key file:
price_estimator.py
Main API:
POST /estimate(port8002)GET /health
Behavior:
- Builds a pricing prompt from
analysis.tier2. - Uses OpenAI Responses API +
web_searchtool. - Returns strict JSON with:
recommended_priceprice_range(min,max)existing_listings(title, URL, price, marketplace)
- Optionally posts to Convex
/api/save-price-estimatewhenCONVEX_HTTP_URLis configured.
CLI mode:
python price_estimator.py <analysis.json>
Primary purpose: store analysis/price records and power listing/purchase workflow.
Schema (convex/schema.ts) includes tables:
analysespriceEstimatesusers(sellers)buyerslistings
Important functions:
convex/analysis.tssaveAnalysis(internal mutation)savePriceEstimate(internal mutation)
convex/publish.tscreateListingFromAnalysislistListings
convex/marketplace.tssearchProductsgeneratePayment(mock payment URL)confirmSale
HTTP actions (convex/http.ts):
POST /api/save-analysisPOST /api/save-price-estimatePOST /api/publish-listingGET /api/listings
Note: current HTTP actions use demo identity defaults for some writes (demo_user / demo seller path).
Primary purpose: expose marketplace operations to MCP-compatible clients (for example Claude Desktop).
Key file:
convex_marketplace.py
Tools exposed:
find_products(query)get_payment_link(id)finalize_purchase(id, name, address, email)
This server calls Convex functions via ConvexClient and requires CONVEX_URL.
Primary purpose: detect if an image has exactly one object.
Includes:
- CLI (
object_detector.py) - FastAPI service (
api.py, default port8000) - quick API test script (
test_api.py)
This is separate from the richer marketplace analyzer and is useful for intake validation/simple CV checks.
Typical path in this repo:
- Client sends product images to
cv-base-main/api.py. - Detector returns structured analysis payload.
- Analysis may be persisted to Convex (
/api/save-analysis). - Analysis is sent to
price-estimatorfor market research. - Price estimate may be persisted to Convex (
/api/save-price-estimate). - Listing can be published via Convex HTTP (
/api/publish-listing) and then searched/purchased through Convex or MCP tools.
- Python 3.8+ (some modules may run on 3.7+ but 3.8+ is safer)
- Node.js for Convex backend
- OpenAI API key
cd Convex-main
npm install
npm run devcd cv-base-main
pip install -r requirements.txt
# set OPENAI_API_KEY
# optional: set CONVEX_HTTP_URL to your Convex HTTP endpoint
python api.pycd price-estimator
pip install -r requirements.txt
# set OPENAI_API_KEY
# optional: set CONVEX_HTTP_URL
python price_estimator.pycd mcp-server-main
uv venv
uv pip install -r requirements.txt
# set CONVEX_URL
uv run convex_marketplace.pyCommon vars used across services:
OPENAI_API_KEY(required by analyzer/estimator)CONVEX_HTTP_URL(optional; for posting analysis/price data to Convex HTTP actions)CONVEX_URL(required by MCP server)OPENAI_MODEL(optional in some modules/examples)
- Payment generation is currently mock-based (
payments.example.com). - Several write paths rely on demo identity defaults.
- CORS is open in the analyzer API (
allow_origins=["*"]) for development convenience. - Multiple detector services exist with overlapping naming, which can confuse onboarding.
- No unified automated test suite at the repo root.
- Unify shared contracts for analysis payload keys between services.
- Add a root orchestration script (or Docker Compose) for one-command startup.
- Replace demo IDs with authenticated user context.
- Add integration tests for analysis -> estimate -> persist flow.
- Add secret scanning and ensure
.envfiles are never committed with real keys.