CoolFace
Apppublic

Bharath2769/AI-Powered-Conversational-Commerce-Platform

sourceHugging Faceupdated 4mo agoView on Hugging Face
1likes
App README

๐Ÿ›๏ธ AI-Powered Conversational Commerce Platform

Hybrid Recommendation Engine & RAG-Powered AI Shopping Assistant with Real-Time Analytics

๐ŸŒŸ Live Demo

(Note: The Hugging Face Space serves both the React Frontend and the FastAPI Backend natively from a single unified Docker container!)


๐Ÿ“ Overview

The AI-Powered Conversational Commerce Platform is a full-stack, enterprise-grade e-commerce engine that blends traditional recommendation algorithms with modern Generative AI. It solves the classic e-commerce discovery problem by offering both dynamic product grids based on user interactions and a Retrieval-Augmented Generation (RAG) Chat Assistant that users can talk to naturally.

Why it Exists:

Standard e-commerce systems struggle with the cold-start problem (handling new users) and rigid search bars. This system solves these issues by orchestrating a dynamic machine learning pipeline that shifts strategies in real-time, while offering a conversational AI assistant that understands complex queries (e.g., "I'm looking for a gaming laptop under $2000 with at least 16GB RAM").


๐Ÿ—๏ธ System Architecture

The application uses a decoupled but unified architecture. A React SPA (Single Page Application) serves as the presentation layer, communicating with a FastAPI backend API that handles ML execution, vector searches, and state preservation using a MongoDB database.

mermaid
graph TD
    A[React Client UI] <-->|HTTP / JSON| C[FastAPI Backend Application]
    C <-->|CRUD & Auth| D[(MongoDB Atlas Cloud)]
    C <-->|Generate Conversational Responses| LLM[Google Gemini 2.5 Flash]
    
    subgraph Machine Learning Pipeline
    C --> E[Hybrid ML Recommendation Engine]
    E --> F[Popularity Recommender]
    E --> G[Content-Based Recommender]
    E --> H[Collaborative Filtering Recommender]
    end
    
    subgraph RAG Pipeline
    C --> RAG[RAG Service]
    RAG -->|Vector Search| VDB[(ChromaDB Vector Store)]
    VDB <-->|Embeddings| ONNX[Local ONNX Model: all-MiniLM-L6-v2]
    end

End-to-End Sequence Flow (RAG Chat)

When a user asks the AI Assistant for a product:

  1. 1.The user's query is sent to the FastAPI backend.
  2. 2.ChromaDB embeds the query using a local ONNX model (all-MiniLM-L6-v2) to bypass API rate limits and ensure lightning-fast vector search.
  3. 3.The top 10 semantically relevant products are retrieved from the vector database.
  4. 4.The Hybrid ML Engine cross-references the retrieved products with the user's personal recommendation scores to re-rank the results.
  5. 5.The final context is passed to Google's Gemini 2.5 Flash LLM.
  6. 6.Gemini generates a conversational, personalized response explaining exactly why those products fit the user's needs.

โšก Key Features

  • โ€”๐Ÿ’ฌ RAG-Powered AI Chat Assistant: Talk naturally to the store. Built with ChromaDB, local ONNX embeddings, and Gemini 2.5 Flash.
  • โ€”๐Ÿง  Multi-Strategy ML Pipeline: Native support for Popularity-based ranking, Content-based filtering, User-User Collaborative filtering, and SVD Matrix Factorization.
  • โ€”โš™๏ธ Adaptive Strategy Selection: Recommender engine automatically changes algorithms based on individual user interaction density (Views vs. Purchases).
  • โ€”๐Ÿ“Š Product Analytics Dashboard: Interactive graphs displaying database counts and active model performance metrics.
  • โ€”๐Ÿ”’ Secure Authentication: JWT-based login, signup, and protected routing.
  • โ€”๐ŸŽจ State-of-the-Art UX: Modern dark-themed user interface styled with Tailwind CSS, featuring radial gauges, responsive product grids, and interactive search.
  • โ€”๐Ÿณ Hugging Face Deployment: Fully dockerized to run as a unified service on Hugging Face Spaces (16GB RAM / 2 vCPU).

๐Ÿง  Recommendation Strategy

The machine learning engine dynamically orchestrates recommendation generation based on a user's interaction count. This ensures users are never shown empty recommendations, solving the classic cold-start problem.

User Interaction CountActive Recommender StrategyDescription
0 Interactions๐Ÿ”ฅ Popularity-BasedBaseline ranker. Recommends globally trending and high-rated items to new users.
1 โ€“ 4 Interactions๐Ÿ“ Content-BasedComputes similarity using TF-IDF vectors on product descriptions and features.
5+ Interactions๐Ÿ‘ฅ Collaborative FilteringEmploys User-User Cosine Similarity matrices with an SVD Matrix Factorization fallback.

๐Ÿ› ๏ธ Tech Stack

LayerTechnologies UsedKey Purpose
FrontendReact (Vite), Tailwind CSS, Lucide icons, ChartJSClient-side routing, modern visual analytics, responsive layout
BackendFastAPI, Python 3.11, Pydantic v2, UvicornHigh-performance async API endpoints, static file serving
DatabaseMongoDB AtlasDocument-based data store for user, product, and interaction records
Vector StoreChromaDBLocal vector database for semantic product retrieval
Machine Learningscikit-learn, ONNX RuntimeMatrix construction, TF-IDF calculation, local sentence embeddings
Generative AILangChain, Google Gemini APIOrchestrating RAG prompts and generating conversational text
InfrastructureDocker, Hugging Face SpacesContainer encapsulation, continuous cloud deployment

๐ŸŽจ Screenshots

1. Analytics & Model Performance Dashboard

[image]

2. Dashboard System Overview

[image]

3. Personalized User Recommendations

[image]


๐Ÿš€ Installation & Local Setup

Running with Docker (Quickest)

  1. 1.Clone the repository:
bash
    git clone https://github.com/BharathReddyRamasani/AI-Powered-Conversational-Commerce-Platform.git
    cd AI-Powered-Conversational-Commerce-Platform
  1. 1.Set up environment variables in .env:
  2. 2.MONGODB_URL: Your MongoDB Connection String
  3. 3.DB_NAME: Database name
  4. 4.SECRET_KEY: Random string for JWT tokens
  5. 5.GEMINI_API_KEY: Your Google Gemini API Key
  6. 6.Build and run the unified Docker container:
bash
    docker build -t conversational-commerce .
    docker run -p 7860:7860 --env-file .env conversational-commerce
  1. 1.Access the unified application:
  2. 2.App: http://localhost:7860
  3. 3.API Docs: http://localhost:7860/docs

๐Ÿ”ฎ Future Improvements

  • โ€”[ ] Redis Cache Layer: Implement Redis caching for user recommendations to lower latency below 10ms.
  • โ€”[ ] Streaming Chat Responses: Add server-sent events (SSE) to stream Gemini responses token-by-token.
  • โ€”[ ] Real-Time Stream Processing: Utilize Kafka or RabbitMQ to stream user interactions directly to the ML models.