How maneesha1618/e_commercesupport_chatbot works
Summary / project type and purpose
• This is a small RAG (Retrieval-Augmented Generation) application: a Streamlit-based frontend + Python backend that serves an E‑commerce FAQ chatbot. Its purpose is to answer user questions by retrieving relevant FAQ passages and generating LLM responses with LangChain + Hugging Face models.
How I reached that conclusion (quick pointers to the repo)
• Frontend: app/streamlit_app.py — Streamlit UI and user interaction.
• Document ingestion: loaders/document_loader.py — loads/splits ecommerce_faq.md (data/).
• Embeddings: embeddings/embedder.py — computes vector embeddings.
• Retriever / vector DB: retriever/vector_retriever.py and vector_store/faiss_index/* — FAISS-based retrieval.
• LLM / RAG chain: llm/rag_chain.py — constructs LangChain QA chain with Hugging Face LLMs.
• Config/env: config.py and optional .env (README mentions Hugging Face token).
• Persistent index files: vector_store/faiss_index/index.faiss and index.pkl.
Frontend (User Interface)
• Files: app/streamlit_app.py
• Responsibilities: accept queries, display results, handle user controls (choose model, start ingestion).
Ingestion / Offline Pipeline (build-time)
• Document Loader
• Files: loaders/document_loader.py
• Input: data/ecommerce_faq.md, data/ecomm_faq.json
• Output: document chunks
• Embedder
• Files: embeddings/embedder.py
• Responsibility: turn chunks into vectors (embedding model selection)
• Vector Store Persister
• Files: retriever/vector_retriever.py (indexing parts), vector_store/faiss_index/* (index files)
• Output: index.faiss, index.pkl
Runtime Retrieval + Generation (request-time)
• Query Embedding (often part of retriever or embedder)
• Vector Retriever
• Files: retriever/vector_retriever.py
• Responsibility: nearest-neighbor search to fetch top-k chunks
• RAG / QA Chain
• Files: llm/rag_chain.py
• Responsibility: assemble prompt + retrieved docs, call model pipeline, produce answer
• LLM Provider (external)
• External dependency: Hugging Face Hub / Transformers, possibly gated models requiring token
• Config: HUGGINGFACEHUB_API_TOKEN (.env) and config.py
Storage & Config
• Persistent Data: data/ (original docs), vector_store/faiss_index/* (index files)
• Config and secrets: config.py, .env (token)
• Requirements/deployment: requirements.txt, README.md
1. Offline / Build pipeline (left/top):
• data/* -> Document Loader -> Embedder -> FAISS Index Builder -> vector_store/faiss_index (index files)
• This as "one-time or on-update" pipeline.
2. Runtime / Query pipeline (center/right):
• User (Streamlit UI) -> Streamlit App -> Query Encoder (embedder) -> FAISS Retriever -> RAG Chain -> Hugging Face LLM -> RAG Chain -> Streamlit App -> User
• That the retriever reads the persisted index files.
• If caching is used, show a cache layer between retriever and FAISS.
Important architectural patterns and principles used
• RAG pattern (separate retrieval and generation steps).
• Separation of concerns: UI (Streamlit) vs retrieval service vs LLM chain vs storage.
• Persistence of vector index enables fast retrieval and decouples ingestion vs query-time.
• Configurable model layer: design allows swapping models (google/flan-t5-small vs gated LLaMA) — treat model provider as an interchangeable external service abstraction.
• External services: Hugging Face Hub (models), optionally model-hosting infra (Hugging Face Spaces / cloud)
• Use clear labels for each component (use the names above).
• Frontend/UI: green rectangle
• Runtime services: orange rectangles (real-time)
• Distinguish synchronous call flows (user -> app -> retriever -> LLM) vs asynchronous/batch flows (data ingestion -> index build).
• That retriever reads the persisted FAISS index (vector_store).
• Query embedding step explicitly (sometimes embedder is reused for both ingestion and queries).
• Where model selection occurs (UI or config) and that LLM calls may be gated (token .env).
• Possibility of storing chat history / metrics (not present now — show as future extension).
Guidelines tailored to this project type (full-stack / RAG app)
• Separation of offline ingestion vs request-time retrieval/generation.
• Make it explicit that the system is currently a monolith but has clearly separable components that can be converted to microservices:
• Extract retriever/embedder as a service with an API in the future.
• Treat the LLM provider as another service (remote hosting or local GPU).
• Persistency and reusability: indexing only needed when knowledge base changes.
• Points where you would add monitoring, auth, caching, and async queuing for scale.
• Index files location: vector_store/faiss_index/index.faiss, index.pkl.
• Mention token management: HUGGINGFACEHUB_API_TOKEN in .env or huggingface-cli login; model access gating.
• Expected latency hotspots: embedding call, FAISS kNN, LLM generation.
• Provide two views:
• Both offline ingestion and runtime flow as separate, clearly-labeled sections.
• Where secrets/config are used, and where persistence occurs.
• Scalability and extensibility notes (e.g., which components are safe to convert to microservices).
• UI (Streamlit) — app/streamlit_app.py
• Loader / Chunker — loaders/document_loader.py
• Embeddings (train & query) — embeddings/embedder.py
• Retriever (FAISS) — retriever/vector_retriever.py; vector_store/faiss_index/*
• RAG / LangChain chain — llm/rag_chain.py
• Raw KB — data/ecommerce_faq.md
• External LLM provider — Hugging Face Hub (requires token)
Concluding note