Case Study
SaleBuy
An AI-powered C2C classifieds marketplace where sellers upload a photo and Google Gemini writes the listing β reducing ad creation time from 4 minutes to 10 seconds.

Sellers drop off during listing creation
Every C2C marketplace faces the same problem: sellers sign up, browse the platform, start creating a listing... and abandon it. The listing creation form is where classifieds platforms lose most of their supply-side users.
Writing a good title, composing a description that actually sells the item, choosing the right category from a dropdown with 30+ options, and filling in condition and specifications takes 4+ minutes. For casual sellers listing a used phone or a piece of furniture, that's too much friction. They'll just post a photo on Instagram Stories instead.
SaleBuy's hypothesis was simple: what if the photo itself could write the listing? Upload a picture of a used iPhone, and the platform generates the title ("iPhone 14 Pro Max 256GB Deep Purple"), description, category (Electronics > Mobile Phones), and condition (Used - Good) automatically. The seller just sets a price and posts.
Goals
- Reduce ad-listing time from 4+ minutes to under 15 seconds
- Auto-populate title, description, and category from a product photo
- Achieve 90%+ accuracy on AI-generated category mappings
- Build seller-buyer chat for real-time negotiation
- Secure the platform against spam bots and automated listing abuse
Constraints
- AI output must be structured JSON β not freeform text
- Image processing must be fast enough to feel 'instant' to users
- Rate limiting must protect AI endpoints without blocking real users
- 14-day timeline from concept to deployable MVP
AI-driven marketplace metrics
Measured across the first 500 AI-generated listings after beta launch.
The Gemini vision pipeline
Client-Side Image Compression
Camera photos are 3-5MB. Sending raw files to Gemini wastes bandwidth and increases response time. We compress images client-side using HTML5 Canvas resampling β reducing file size to under 1MB without visible quality loss. This cut API latency by 50% and makes the feature usable on mobile data connections.
Structured Prompt Engineering
The Gemini prompt explicitly requests raw JSON with specific field names (title, description, category, condition) β no markdown, no commentary. We tested 15+ prompt variations to find the format that produces consistent, parseable output. The server-side parser has fallbacks for the 10% of cases where the model wraps output in code fences or adds explanatory text.
Form Pre-Population Flow
The parsed JSON is immediately injected into the React form state. The seller sees a completed draft in under 10 seconds β title, description, category all filled in. They review, adjust if needed, set a price, and post. The cognitive load drops from 'write a listing from scratch' to 'verify and price.'
Seller-Buyer Real-Time Chat
Once a listing is live, interested buyers can open a chat thread directly on the product page. Messages are stored in MongoDB with user references. The chat interface shows online status and supports multiple concurrent conversations per listing.
Marketplace screens



Why we chose each tool
Next.js 16
Server-side rendering for marketplace listing pages (critical for SEO β every product listing needs to be indexable). API routes handle Gemini integration and chat endpoints.
Google Gemini 1.5 Flash
The vision model analyzes product photos and returns structured JSON with title, description, category, and condition. Flash (not Pro) because latency matters more than depth for form pre-population.
MongoDB + Mongoose
User-generated marketplace data is inherently unstructured. Document databases handle variable product attributes across 30+ categories without rigid schema constraints.
Next-Auth
Pre-built authentication with social login support. Users can sign up with Google, reducing friction compared to email/password registration for a marketplace where trust matters.
Canvas Image Compression
Client-side image resampling before sending to Gemini API. Reduces 5MB camera photos to under 1MB without visible quality loss β cuts API latency by 50%.
express-rate-limit + Helmet
AI listing endpoints are expensive (each call costs API credits). Rate limiting prevents bot abuse. Helmet security headers protect against XSS and content injection in user-generated listings.
14-day sprint to MVP
Database & Auth Setup
Days 1β3
Designed MongoDB schemas for users, listings, and chat threads. Integrated Next-Auth with social login providers and session management.
Marketplace UI Build
Days 4β7
Built responsive search with category filters, product detail pages with image galleries, and the seller dashboard for managing active listings.
Gemini Vision Pipeline
Days 8β11
Developed the image compression layer, prompt engineering for structured JSON output, server-side response parsing, and form pre-population flow.
Security & Launch
Days 12β14
Configured rate limiting on AI endpoints, Helmet security headers, spam detection on listings, and deployed the production build.
Problems we solved
Parsing Non-Deterministic AI Output
LLM outputs aren't consistent. Gemini sometimes wraps JSON in markdown code fences, sometimes adds explanatory text before the JSON, and occasionally uses different field names than requested.
Solution: A multi-layer parser: (1) strip markdown code fences with regex, (2) find the first valid JSON object using bracket matching, (3) normalize field names to our schema, (4) apply defaults for any missing fields. The user always sees a complete form β the parser handles the AI's inconsistencies silently.
AI Endpoint Cost Protection
Each Gemini API call costs money. A bot creating thousands of fake listings could drain the API budget in hours.
Solution: Three protection layers: (1) Next-Auth session requirement β you must be logged in to create listings, (2) per-IP rate limiting β max 20 AI calls per hour, (3) file type validation β only JPEG/PNG/WebP are accepted. Combined, these prevent both automated abuse and accidental over-use.
"The AI listing feature is genuinely magical from a user perspective. You upload a photo of a used guitar, and in 10 seconds the form is filled with 'Yamaha FG800 Acoustic Guitar β Natural Finish, Used - Good Condition.' The seller just sets the price. That's the kind of UX that makes people tell their friends.
Questions about this project
How does the AI auto-listing feature work?+
Why Gemini 1.5 Flash instead of GPT-4 Vision or Claude?+
How do you handle AI output inconsistencies?+
What security measures protect the marketplace from spam?+
Can you build a similar AI-integrated marketplace for us?+
Similar projects
Forces Express
Full-stack logistics portal with shipping calculator and live tracking.
KaamConnekt
Job portal with AI-powered matching and multi-role dashboards.
Online Planet
E-commerce platform with admin dashboard and order management.
Want to build an AI-powered marketplace?
We integrate Gemini, GPT-4, and Claude into production applications β not demos.