# babytaro14/myntra-rag-chatbot architecture

> Architecture diagram of the GitHub repository babytaro14/myntra-rag-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/babytaro14/myntra-rag-chatbot
- Repository: https://github.com/babytaro14/myntra-rag-chatbot

## Overview

This is a Streamlit fashion-catalogue RAG chatbot. A shopper submits a question; the app passes it with conversation history and search settings to the RAG core, which interprets the question, retrieves catalogue products, applies relevance and answer-safety checks, and returns a grounded answer with product citations for display. The repository also documents data preparation and index rebuilding. The main stages are supported by the README and excerpts; some internal RAG call details and unsampled subsystems are documented but not directly shown in the excerpts.

Main entry points: [`src/index.py`](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/index.py) (Index loading and verification), [`src/rag.py`](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py) (RAG answer flow), [`app.py`](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/app.py) (Streamlit chat), [`src/prepare_data.py`](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/prepare_data.py) (Catalogue cleaning and enrichment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_app["Streamlit chat<br/>[app.py]"]
  node_product_display["Product citations and trace<br/>[app.py]"]
end

subgraph group_rag["Question answering"]
  node_rag_answer["RAG answer flow<br/>[rag.py]"]
  node_query_understanding["Question understanding<br/>[rag.py]"]
  node_query_parser["Constraint and intent parsing<br/>[query.py]"]
  node_retrieval["Hybrid retrieval and ranking<br/>[rag.py]"]
  node_answer_safety["Relevance and answer checks<br/>[rag.py]"]
end

subgraph group_catalogue["Catalogue and retrieval"]
  node_text_util["Text cleaning and tokenisation<br/>[textutil.py]"]
  node_index_runtime["Index loading and verification<br/>[index.py]"]
  node_vector_store[("Chroma vector index")]
  node_catalogue_csv["Cleaned product catalogue<br/>[products_clean.csv]"]
  node_config["Models and retrieval settings<br/>[config.py]"]
end

subgraph group_ingestion["Catalogue preparation"]
  node_data_prep["Catalogue cleaning and enrichment<br/>[prepare_data.py]"]
  node_index_builder["Index build<br/>[build_index.py]"]
end

node_shopper(("Shopper"))
node_llm["Groq or OpenAI LLM"]
node_raw_catalogue["Raw fashion catalogue"]

node_shopper -->|"asks"| node_app
node_app -->|"loads index"| node_index_runtime
node_app -->|"submits question"| node_rag_answer
node_rag_answer -->|"returns answer and sources"| node_app
node_app -->|"renders citations"| node_product_display
node_rag_answer -->|"interprets question"| node_query_understanding
node_query_understanding -.->|"parses constraints"| node_query_parser
node_rag_answer -->|"retrieves products"| node_retrieval
node_retrieval -->|"searches catalogue"| node_index_runtime
node_retrieval -->|"semantic search"| node_vector_store
node_retrieval -.->|"uses BM25 index"| node_index_runtime
node_rag_answer -->|"gates and validates"| node_answer_safety
node_rag_answer -->|"rewrites or generates"| node_llm
node_index_runtime -->|"loads products"| node_catalogue_csv
node_index_runtime -->|"verifies or rebuilds"| node_vector_store
node_data_prep -->|"cleans"| node_raw_catalogue
node_data_prep -->|"cleans and sanitises text"| node_text_util
node_data_prep -->|"writes catalogue"| node_catalogue_csv
node_index_builder -->|"builds index"| node_index_runtime
node_index_builder -->|"indexes products"| node_catalogue_csv
node_index_builder -->|"writes vectors"| node_vector_store
node_index_runtime -->|"reads settings"| node_config
node_query_parser -->|"uses vocabulary and tokens"| node_text_util

click node_app "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/app.py"
click node_product_display "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/app.py"
click node_rag_answer "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py"
click node_query_understanding "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py"
click node_query_parser "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/query.py"
click node_retrieval "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py"
click node_answer_safety "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py"
click node_text_util "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/textutil.py"
click node_index_runtime "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/index.py"
click node_vector_store "https://github.com/babytaro14/myntra-rag-chatbot/tree/main/chroma_db"
click node_catalogue_csv "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/data/processed/products_clean.csv"
click node_data_prep "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/prepare_data.py"
click node_index_builder "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/build_index.py"
click node_config "https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_product_display toneBlue
class node_rag_answer,node_query_understanding,node_query_parser,node_retrieval,node_answer_safety toneAmber
class node_text_util,node_index_runtime,node_vector_store,node_catalogue_csv,node_config toneMint
class node_data_prep,node_index_builder toneRose
class node_shopper,node_llm,node_raw_catalogue toneIndigo
```

## Components

### Chat interface

- [Streamlit chat](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/app.py): `app.py`
- [Product citations and trace](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/app.py): `app.py`

### Question answering

- [RAG answer flow](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py): `src/rag.py`
- [Question understanding](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py): `src/rag.py`
- [Constraint and intent parsing](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/query.py): `src/query.py`
- [Hybrid retrieval and ranking](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py): `src/rag.py`
- [Relevance and answer checks](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/rag.py): `src/rag.py`

### Catalogue and retrieval

- [Text cleaning and tokenisation](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/textutil.py): `src/textutil.py`
- [Index loading and verification](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/index.py): `src/index.py`
- [Chroma vector index](https://github.com/babytaro14/myntra-rag-chatbot/tree/main/chroma_db): `chroma_db`
- [Cleaned product catalogue](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/data/processed/products_clean.csv): `data/processed/products_clean.csv`
- [Models and retrieval settings](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/config.py): `src/config.py`

### Catalogue preparation

- [Catalogue cleaning and enrichment](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/prepare_data.py): `src/prepare_data.py`
- [Index build](https://github.com/babytaro14/myntra-rag-chatbot/blob/main/src/build_index.py): `src/build_index.py`

### Other components

- **Shopper**
- **Groq or OpenAI LLM**
- **Raw fashion catalogue**

## Connections

- Shopper → Streamlit chat: asks (evidence: `README.md`)
- Streamlit chat → Index loading and verification: loads index (evidence: `app.py`)
- Streamlit chat → RAG answer flow: submits question (evidence: `app.py`)
- RAG answer flow → Streamlit chat: returns answer and sources (evidence: `README.md`)
- Streamlit chat → Product citations and trace: renders citations (evidence: `app.py`)
- RAG answer flow → Question understanding: interprets question (evidence: `README.md`)
- Question understanding → Constraint and intent parsing: parses constraints (evidence: `src/rag.py`)
- RAG answer flow → Hybrid retrieval and ranking: retrieves products (evidence: `README.md`)
- Hybrid retrieval and ranking → Index loading and verification: searches catalogue (evidence: `README.md`)
- Hybrid retrieval and ranking → Chroma vector index: semantic search (evidence: `README.md`)
- Hybrid retrieval and ranking → Index loading and verification: uses BM25 index (evidence: `src/rag.py`)
- RAG answer flow → Relevance and answer checks: gates and validates (evidence: `README.md`)
- RAG answer flow → Groq or OpenAI LLM: rewrites or generates (evidence: `README.md`)
- Index loading and verification → Cleaned product catalogue: loads products (evidence: `src/index.py`)
- Index loading and verification → Chroma vector index: verifies or rebuilds (evidence: `src/index.py`)
- Catalogue cleaning and enrichment → Raw fashion catalogue: cleans (evidence: `README.md`)
- Catalogue cleaning and enrichment → Text cleaning and tokenisation: cleans and sanitises text (evidence: `src/prepare_data.py`)
- Catalogue cleaning and enrichment → Cleaned product catalogue: writes catalogue (evidence: `README.md`)
- Index build → Index loading and verification: builds index (evidence: `src/build_index.py`)
- Index build → Cleaned product catalogue: indexes products (evidence: `src/build_index.py`)
- Index build → Chroma vector index: writes vectors (evidence: `README.md`)
- Index loading and verification → Models and retrieval settings: reads settings (evidence: `src/index.py`)
- Constraint and intent parsing → Text cleaning and tokenisation: uses vocabulary and tokens (evidence: `src/query.py`)
