Skip to content

About

Flask shopping assistant: plain-language product search with budget parsing, category detection and a deal score

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🛍️ ShopAI

Smart Shopping Assistant

Type what you want in plain words, like "best gaming laptop under 80000" or "sasta phone", and ShopAI finds matching products, ranks them and scores the deals.

Python Flask JavaScript Pyodide Tests

Live Demo

ShopAI home page with chat and product cards

The live demo runs entirely in your browser with Pyodide; the first load takes a few seconds.


ShopAI is a Flask-based smart shopping platform that helps users search for products, get ranked recommendations, and find the best deals using a deal scoring system.

💬 Try These Queries

Query What ShopAI understands
4k tv under 50000 TV category, 4K feature, budget up to ₹50,000
phone 15k-20k Phones between ₹15,000 and ₹20,000
noise cancelling earbuds Earbuds with noise cancellation (not the Noise brand)
samsung tv Only Samsung TVs
sony xm5 The exact Sony WF-1000XM5 model first
sasta phone Phones sorted cheapest first
mujhe 15000 ka phone chahiye Hinglish works too: phones up to ₹15,000

✨ Features

  • Natural Language Search - Search products using plain queries like "best gaming laptop under 80000" or "phone above 20k"
  • Smart Category & Brand Detection - Maps synonyms (e.g., "mobile", "smartphone", "head phones") to the right category with whole-word matching, and recognises brands, brand families (Mi → Redmi/POCO) and product lines (iPhone, MacBook)
  • Budget Extraction - Understands "20k", "under 15000", "above 30000", "15k-20k", "between 10k and 20k", "around 25000" and "under 1.5L", and ignores spec numbers like "16gb" or "55 inch"
  • Deal Score Engine - Ranks products using a formula based on discount percentage, rating, and customer sentiment
  • Feature & Brand Matching - Matches queries against product brands, tags, and features (camera, battery, 5G, etc.)
  • Conversational Responses - Handles identity questions, category browsing, and customer support queries in addition to product search

🧰 Tech Stack

  • Backend: Python, Flask
  • Data Storage: JSON-based product database
  • Frontend: HTML, CSS, JavaScript

🗂️ Project Structure

ShoppingPro/
├── app.py              # Flask app and API routes
├── assistant.py        # Query handling shared by Flask and the browser demo
├── recommender.py      # Search, category detection, and recommendation logic
├── deal_score.py        # Deal score calculation engine
├── db_manager.py        # Data access layer for products.json
├── products.json        # Product database
├── index.html           # GitHub Pages demo (same Python logic via Pyodide)
├── templates/
│   └── index.html       # Main frontend page
└── static/
    ├── css/
    └── js/

🚀 Getting Started

Prerequisites

  • Python 3.8 or higher
  • pip

Installation

  1. Clone the repository

    git clone https://github.com/HIRA04IRSHAD/ShoppingPro.git
    cd ShoppingPro
    
  2. Install dependencies

    pip install -r requirements.txt
    
  3. Run the application

    python app.py
    
  4. Open your browser and go to

    http://localhost:5000
    

⚙️ How It Works

  1. User submits a search query through the frontend
  2. The app checks for special intents (identity, support, categories) before running a product search
  3. recommender.py extracts category, budget, brand, and feature signals from the query
  4. Matching products are scored and ranked using both a match score and a deal score
  5. Results are returned as JSON and rendered on the frontend

🌐 Live Demo on GitHub Pages

GitHub Pages can only serve static files, so the root index.html loads Pyodide (Python compiled to WebAssembly) and runs the same assistant.py, recommender.py, deal_score.py and db_manager.py in the browser. The Flask app and the demo share one copy of the logic.

🧪 Tests

python -m unittest discover -s tests

The tests cover budget parsing, category and brand detection, ranking and the Flask route.

🔌 API

POST /search

Request body:

{
  "query": "best gaming laptop under 80000"
}

Response:

{
  "status": "success",
  "reply": "I found 5 matches for you. Sorting them by the best deals!",
  "products": [ ... ],
  "type": "search"
}

👥 Contributors

📄 License

This project is for academic purposes.

About

Flask shopping assistant: plain-language product search with budget parsing, category detection and a deal score

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages