跳到正文
DEV Community· Aditya·· 3 小時前AI 評分33

ShelfSense:結合 TabPFN、Gemma 及 ElevenLabs 的電子商務自動化缺貨套利引擎

ShelfSense: Automated E-Commerce Stockout Arbitrage Engine with TabPFN, Gemma & ElevenLabs

AI 導讀

ShelfSense 是面向 Shopify 與 Amazon 商戶的自動化庫存套利引擎,採用 TabPFN-3.5 預測缺貨時間,並透過 SerpApi 監測競爭對手缺貨及價格。Gemma 根據庫存與競爭對手狀況生成動態定價建議和搜尋廣告文案,ElevenLabs 則合成 60 秒晨間語音簡報。完整程式碼已在 GitHub 開源。

正文

Aditya

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

Independent Shopify and Amazon marketplace merchants operate in a brutal, margin-compressed environment. When a high-volume competitor runs out of stock, customer search demand does not vanish—it instantly shifts to the next available merchant. Capturing this "stockout vacuum" window via dynamic price surges and targeted ad campaigns yields immediate, high-margin profit. However, monitoring competitors manually 24/7 and calculating inventory depletion curves from messy vendor CSVs is impossible for solo sellers.

ShelfSense is an autonomous inventory arbitrage engine that solves this end-to-end:

  1. Forecasts Internal Stockout Runway: Uses TabPFN-3.5 to run zero-shot non-parametric regression directly on historical inventory velocity CSVs, determining exact remaining runway days without requiring custom dataset training or hyperparameter tuning.
  2. Monitors Competitor Vacuums in Real-Time: Scrapes Google Shopping listings with SerpApi to detect competitor stockout flags and live pricing spreads.
  3. Formulates Arbitrage Directives: Employs Gemma to reason across tabular runway metrics and live competitor shortages, generating surge pricing rules and 30-character search ad headlines.
  4. Delivers Morning Spoken Briefs: Synthesizes a natural, 60-second executive audio briefing via ElevenLabs so merchants can listen to overnight market shifts during their morning routine.

Who would pay for this? High-volume Amazon FBA and Shopify D2C arbitrage sellers managing 20–500 SKUs. A \$49/month micro-SaaS tier is instantly justified if the engine captures just one competitor stockout window per month.


Demo

The application features a Warm Industrial Gray brutalist design system (built with Next.js, Framer Motion, and Tailwind CSS) featuring a 12-column architectural wireframe grid, drag-and-drop CSV intake console, live competitor price matrices, and an integrated audio frequency wave player.


Code

The complete full-stack codebase—including the FastAPI backend service, TabPFN/SerpApi/Gemma/ElevenLabs orchestration pipelines, integration tests, and the Next.js frontend—is open source on GitHub:

GitHub logo AdityaNarayanPadhi / SelfSense

Autonomous D2C inventory arbitrage engine for Amazon & Shopify sellers. Forecasts stockouts with TabPFN-3.5, tracks competitor signals via SerpApi, reasons pricing rules with Gemma, and delivers daily morning audio briefs via ElevenLabs.

ShelfSense 🚀

E-Commerce Inventory Arbitrage & Stockout Detection Engine

ShelfSense is a high-throughput, production-ready backend service designed for high-volume Shopify and Amazon merchants. It predicts internal inventory depletion with state-of-the-art tabular foundation models, continuously crawls real-time competitor prices and stockouts, synthesizes dynamic pricing arbitrage playbooks with Google Gemma, and delivers a personalized 60-second morning audio brief synthesized by ElevenLabs.


🏛️ System Architecture

flowchart TD
    subgraph Client ["Client Layer"]
        FE["Next.js / Vercel Frontend"]
        Merchant["Merchant / Automated Job"]
    end
    subgraph ShelfSenseAPI ["ShelfSense Backend (FastAPI on Render)"]
        Router["/api/analyze Endpoint"]
        AudioRoute["/audio/{filename} Endpoint"]
        subgraph Engine1 ["1. Tabular Forecasting"]
            TabPFN["TabPFN-3.5 Regressor<br/>(Depletion Days & Velocity)"]
        end
        
        subgraph Engine2 ["2. Competitor Intelligence"]
            Serp["SerpApi Google Shopping<br/>(Live Prices, Stores & Stock Status)"]
        end

        subgraph Engine3 ["3. Reasoning & Arbitrage"]
            Gemma["Google Gemma LLM<br/>(Dynamic Pricing & Ad Copy)"]
        end

        subgraph Engine4 ["4. Audio Brief Synthesis"]
            Eleven["ElevenLabs API<br/>(eleven_multilingual_v2)"]
        end
    end

    Merchant -->|CSV + Product Query| FE
    FE -->|POST /api/analyze| Router
    Router -->|Async Gather|

…


How I Built It

ShelfSense coordinates four specialized AI and cloud technologies into a non-blocking asynchronous pipeline:

  1. Tabular Machine Learning (TabPFN-3.5): Small merchant inventory logs (typically 5 to 50 rows of historical sales velocity and price variance) are too small to train gradient-boosted trees or deep neural networks without extreme overfitting. We integrated Prior Labs' TabPFN-3.5 Regressor, passing the historical batch to predict exact days-to-stockout on the current inventory row.
  2. Market Grounding (SerpApi): The backend asynchronously queries the Google Shopping engine via SerpApi, parsing merchant names (Amazon, Walmart, Best Buy), numerical price spreads, and out-of-stock badge snippets.
  3. Cognitive Arbitrage Reasoning (Gemma): Using Google's open-weight Gemma, the engine receives the combined context: TabPFN's depletion runway and SerpApi's live stock status. If competitors are depleted, Gemma formulates a 10%–20% surge pricing recommendation and drafts high-conversion search ad copy.
  4. Voice AI (ElevenLabs): The spoken segment from Gemma's directive is synthesized using ElevenLabs' eleven_multilingual_v2 model into a streamable MP3 brief.
  5. Cloud Infrastructure:
    • Render: Hosts the Python 3.11 FastAPI backend, handling async task execution, CSV parsing, and model coordination.
    • Vercel: Hosts the Next.js App Router frontend with real-time audio playback and telemetry visualizations.

Why Does Open Innovation Matter?

Open innovation and open-weight models are what make ShelfSense commercially viable as a sustainable micro-SaaS:

  1. Deterministic Arithmetic vs. Closed LLM Hallucination: Proprietary conversational LLMs notoriously struggle with tabular numerical calculations, often hallucinating stockout trends or failing at multi-variable regression. By utilizing TabPFN, we use a true tabular foundation model that performs Bayesian inference over tabular priors directly on CSV bytes with zero arithmetic drift.
  2. Viable Unit Economics for High-Frequency Scraping: Running continuous competitor inventory audits across hundreds of SKUs with proprietary closed APIs leads to compounding per-token API bills that erode thin e-commerce margins. Open-weight models like Gemma allow continuous local or self-hosted batch inference on fixed-cost infrastructure (like Render) without unpredictable token markups.
  3. Data Privacy for Sensitive Supplier Ledgers: Merchants are reluctant to upload proprietary supplier costs and sales velocity data to closed third-party model providers that may use commercial data for training. Open-weight pipelines allow running inference in controlled, private runtime environments.

My First User

Before finalizing the submission, I shared ShelfSense with a solo e-commerce seller managing home audio and electronics accessories across Amazon and Shopify.

  • The Test: They uploaded a sample 7-day velocity ledger for over-ear wireless headphones while a major category competitor experienced stockouts.
  • Their Feedback: "Normally, I only find out a competitor is out of stock days after the surge has already passed. Seeing the TabPFN runway countdown paired with the ready-to-run Google ad copy and price surge suggestion in an audio brief was surreal."
  • Willingness to Pay: They confirmed that an automated daily alert catching even two stockout arbitrage opportunities a month would justify a \$40–\$50/month subscription.

Prize Categories

  • Best Use of TabPFN (\$200) — Uses TabPFN-3.5 tabular foundation regression to forecast inventory depletion and categorize stockout urgency.
  • Best Use of Render (\$200) — Deployed the Python FastAPI backend service and AI runtime on Render using an automated build blueprint.
  • Best Use of Gemma (\$200) — Uses Google's open-weight Gemma model to analyze market pressure, formulate dynamic pricing rules, and generate search ad copy.
  • Best Use of SerpApi (\$100) — Uses SerpApi Google Shopping engine to crawl real-time competitor prices, store listings, and stock availability.
  • Best Use of ElevenLabs (\$100) — Uses ElevenLabs Voice AI to synthesize a daily 60-second morning audio brief for merchants.

來源:DEV Community · dev.to