Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Product Suggestor - Real-Time E-Commerce Decision Intelligence

Product Suggestor is an MVP that helps buyers make better purchase decisions before checkout. It analyzes Amazon and Flipkart product links, matches products against a pre-indexed review narrative dataset, and falls back to local LLM analysis when no strong dataset match exists.

Problem Statement

E-commerce shoppers lack reliable decision support before purchase. They frequently face:

  • Inconsistent sizing and quality expectations
  • Misleading product representation
  • Untrustworthy or low-signal review sections

This uncertainty contributes to high return rates (often 20-40%), logistics waste, and reduced user trust.

What This Project Builds

This project is a real-time decision intelligence platform that intercepts buyer uncertainty at the point of consideration.

  • Input: A product URL from Amazon.in/Amazon.com or Flipkart.com
  • Process: Scrape key product metadata, attempt dataset-based confidence match, then optionally run AI analysis
  • Output: A concise objective insight (summary, pros/cons, verdict) to support purchase decisions

Core Approach

The backend uses a two-stage inference strategy:

  1. Fast deterministic dataset match
  2. AI fallback for unmatched products

Stage 1: Dataset Match (Primary Path)

  • dataset/final_narratives.csv is loaded at startup.
  • Product titles are indexed with Fuse.js fuzzy search.
  • If a confident match is found (score <= 0.35), the API returns precomputed narrative output immediately.

Benefits:

  • Low latency
  • Consistent output format
  • No LLM dependency for known products

Stage 2: AI Fallback (Secondary Path)

  • If no confident dataset match exists, the system scrapes on-page reviews.
  • Reviews and product metadata are sent to a local Ollama model.
  • The model is prompted to return: SUMMARY, PROS, CONS, VERDICT.
  • Response text is parsed into structured JSON for the UI.

Architecture

Backend

  • Runtime: Node.js + Express
  • API route: POST /api/analyze
  • Health route: GET /api/health
  • Scraping: Puppeteer
  • Matching: Fuse.js
  • AI: Ollama local inference API

Frontend

  • Vanilla HTML/CSS/JS single-page interface
  • URL validation for supported domains
  • Loading skeleton + rotating status messages
  • Result card with source labels:
    • Dataset Match
    • AI Generated
    • Fallback

Request Flow

  1. User submits a product URL.
  2. API validates domain support.
  3. Scraper extracts title, price, rating, review count, image.
  4. Matcher searches dataset for confident title match.
  5. If matched: return precomputed narrative insight.
  6. If unmatched: scrape reviews and generate AI insight via Ollama.
  7. UI renders product facts + insight source and recommendation.

Tech Stack

  • Node.js
  • Express
  • Puppeteer
  • Fuse.js
  • csv-parser
  • dotenv
  • Ollama (local model serving)

Project Structure

.
├─ server.js                  # App bootstrap, dataset init, route mounting
├─ src/
│  ├─ routes/analyze.js       # Main analyze endpoint
│  ├─ scraper.js              # Amazon/Flipkart extraction logic
│  ├─ matcher.js              # CSV indexing + fuzzy match logic
│  └─ ai.js                   # Ollama prompting + response parsing
├─ public/
│  ├─ index.html              # UI layout
│  ├─ style.css               # UI styling and animation
│  └─ app.js                  # UI behavior + API calls
└─ dataset/
   ├─ final_narratives.csv    # Runtime matching dataset
   └─ complete_results.csv    # Extended processing artifact

Prerequisites

  • Node.js 18+
  • npm
  • (Optional but recommended) Ollama for AI fallback mode

Setup

npm install

Create an .env file in the project root:

PORT=3000
CSV_PATH=./dataset/final_narratives.csv
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=gemma2-local

Notes:

  • CSV_PATH defaults to ./dataset/final_narratives.csv if unset.
  • If Ollama is offline, dataset match mode still works.

Run

Development:

npm run dev

Production:

npm start

Open in browser:

  • http://localhost:3000

API

POST /api/analyze

Request body:

{
  "url": "https://www.amazon.in/..."
}

Success response shape:

{
  "product": {
    "title": "string",
    "price": "string",
    "rating": "string",
    "reviewCount": "string",
    "image": "string|null",
    "url": "string",
    "site": "amazon|flipkart"
  },
  "insight": {
    "summary": "string",
    "pros": ["string"],
    "cons": ["string"],
    "verdict": "string",
    "source": "dataset|ai|fallback"
  }
}

Possible error codes:

  • 400: Missing/invalid URL or unsupported domain
  • 422: Product page scraping failed
  • 500: Unexpected server-side error

GET /api/health

Returns:

  • Server status and uptime
  • Number of indexed products
  • Ollama availability and discovered models

Current Limitations

  • Supports only Amazon and Flipkart domains.
  • Scraping selectors may break if site markup changes.
  • Dataset quality can affect narrative reliability.
  • AI fallback quality depends on local model availability and hardware performance.
  • No automated test suite is currently configured.

Why This Matters

The system demonstrates a practical hybrid design for buyer decision support:

  • Deterministic retrieval for speed and consistency
  • Generative reasoning for long-tail products
  • Source-aware transparency so users know where insight came from

This pattern can reduce uncertainty before purchase, improve trust, and potentially reduce avoidable returns.

Future Improvements

  • Add richer trust scoring and confidence calibration
  • Expand site support and selector resilience
  • Add review authenticity and anomaly checks
  • Introduce evaluation benchmarks and automated tests
  • Add persistent analytics for decision outcomes

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages