How naveenmldeveloper/supermarket-chatbot-ai-powered-customer-support-application-using-rag-system- works
Project Type and Purpose
• This is a full-stack, web-based RAG (Retrieval-Augmented Generation) application: the “Supermarket Chatbot.”
• Purpose: serve customer queries on product availability, pricing, stock, categories, etc., by combining semantic search over a FAISS index built from a MySQL product database and an LLM (DeepSeek V3 via OpenRouter) for response generation.
File Structure
• Top-level:
• data/ (faiss_index/, mappings/) – serialized FAISS index and ID-to-vector mappings
• scripts/database.sql – schema & seed data for MySQL
• src/ – core Python modules
• templates/chatbot.html – frontend UI
• src/ breakdown:
• app.py – Flask server, HTTP routes, UI rendering
• db_connect.py – MySQL connection wrapper
• build_index.py – ingests DB rows, generates embeddings (SentenceTransformers), builds/persists FAISS index
• rag_pipeline.py – retrieval + prompt construction + LLM API call
• utils.py – helpers (logging, fuzzy matching)
• Config & dependencies: .env, requirements.txt
README Insights
• Architecture described as:
User ↔ Flask UI → RAG pipeline → [FAISS semantic search + fuzzy matching over product data] → constructs prompt → calls LLM API → returns answer
• Tech stack: Flask, MySQL, FAISS, Sentence Transformers, OpenRouter LLM, FuzzyWuzzy
Main Components
a. Frontend Layer:
• Static HTML/JS (templates/chatbot.html)
• User input (chat bubbles), AJAX or form POST to Flask
b. Backend Layer (Flask):
• app.py routes request to rag_pipeline
• db_connect service for raw product data
• utils for string cleaning/fuzzy matching
c. Indexing Subsystem (offline or pre-processing):
• build_index.py reads DB → embeddings via Sentence Transformers → builds FAISS index → stores in data/faiss_index/
d. Retrieval & Generation:
• RAG Pipeline:
1. Query → fuzzy match + normalized text
2. Semantic search: FAISS index lookup → top k product vectors
3. Prompt assembly (product metadata from DB)
4. LLM call via OpenRouter (DeepSeek V3)
e. Data Stores:
• MySQL (Product_details table)
• FAISS index files + mapping pickle
f. External Services:
• OpenRouter / DeepSeek V3 LLM API
Architectural Patterns & Design Principles
• Separation of concerns:
• Pre-processing/indexing (build_index.py) vs. runtime (app.py + rag_pipeline)
• Data layer (db_connect.py) abstracted from business logic
• Modular pipeline for retrieval (FAISS) + generation (LLM)
• Use of caching/persistence: FAISS index reused between requests