# ridabayi/flipkart-product-recommender architecture

> Architecture diagram of the GitHub repository ridabayi/flipkart-product-recommender, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ridabayi/flipkart-product-recommender
- Repository: https://github.com/ridabayi/flipkart-product-recommender

## Overview

##### Project type and purpose
- This is a full-stack web application that:
– Ingests and preprocesses Flipkart product review data
– Builds/runs a Retrieval-Augmented Generation (RAG) chain using an LLM
– Serves product recommendations via a web UI
- Key indicators: `templates/` + `static/` directories (Flask front end), `Flipkart/` package (backend logic), `Data/flipkart_product_review.csv` (raw data).

##### File structure
Top-level directories/files:
- Data/
– Raw CSV of reviews
- Flipkart/ (backend core)
– Data_ingestion.py (loads raw data)
– Data_converter.py (processes/embeds data)
– rag_chain.py (LLM + vectorstore orchestration)
– config.py (app configuration)
– vault_api_keys.py (securely fetches secrets)
- static/, templates/
– Frontend assets (CSS, HTML)
- utils/
– custom_exception.py, logger.py (shared utilities)
- setup.py, requirements.txt (packaging + dependencies)

##### Key insights from README
- You must infer architecture from code and folders

a. Frontend
– Browser → HTML (templates/index.html) + CSS (static/style.css)
– Sends user queries (e.g., “recommend me…”) via HTTP
b. Backend (Flask application)
– API endpoints (e.g., `/recommend`)
– config.py + vault_api_keys.py for environment & secrets
– utils/logger.py & utils/custom_exception.py
c. Data Pipeline
– Data_ingestion: reads Data/flipkart_product_review.csv
– Data_converter: text cleaning, embedding generation
– Vector Store (e.g., in-memory or disk-based—explicit or abstract)
d. RAG Chain (rag_chain.py)
– Retrieval: query vector store for nearest neighbors
– LLM call: passes context + prompt to external LLM service (OpenAI or similar)
e. External Services
– Vault or secret manager (for API keys)
– LLM provider (OpenAI, Azure OpenAI, etc.)

##### Relationships and interactions
- User → Frontend (HTTP GET/POST)
- Frontend → Flask Server (HTTP request)
- Flask Server → Data Pipeline / RAG Chain (in-process calls)
- RAG Chain → Vector Store (local or remote DB)
- RAG Chain → External LLM API → returns generated recommendations
- Flask Server → Frontend (HTTP response with recommendations)

##### Architectural patterns/design principles
- Separation of concerns:
– Presentation layer (templates/static)
– Business logic (Flipkart/ modules)
– Data access & processing (Data_ingestion, Data_converter)
- Modular design: easy to swap out vector store or LLM provider
- Utility layer for cross-cutting concerns (logging, exception handling)
- Package structure supports `pip install .` (setup.py + `.egg-info`)

##### Detail
- Every Python module as a component or sub-component
- Both data storage (CSV, vector store) and external dependencies

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::external
    User -->|"HTTP POST /recommend"| FrontendUI["Frontend UI\n(templates/index.html)"]:::frontend
    FrontendUI --> FrontendAssets["Frontend Assets\n(static/style.css)"]:::frontend
    FrontendUI -->|"HTTP Request"| FlaskServer["Flask App Server\n(Flask, Python 3.x)"]:::backend

    subgraph "Backend Server"
        FlaskServer
        Config["Configuration\n(config.py)"]:::backend
        VaultKeys["Secrets Management\n(vault_api_keys.py)"]:::external
        Exception["Exception Handling\n(utils/custom_exception.py)"]:::util
        Logger["Logging\n(utils/logger.py)"]:::util

        subgraph "Data Pipeline"
            Ingest["Data Ingestion\n(Flipkart/Data_ingestion.py)"]:::data
            Convert["Data Conversion\n(Flipkart/Data_converter.py)"]:::data
            RawData["Raw CSV Data\n(Data/flipkart_product_review.csv)"]:::data
        end

        subgraph "RAG Chain"
            RAG["RAG Chain Module\n(Flipkart/rag_chain.py)"]:::backend
            VectorStore["Vector Store"]:::data
            LLMAPI["External LLM API"]:::external
        end
    end

    FlaskServer --> Config
    FlaskServer -.->|"fetch secrets"| VaultKeys
    FlaskServer --> Exception
    FlaskServer --> Logger
    FlaskServer --> Ingest
    Ingest --> RawData
    FlaskServer --> Convert
    Convert --> Ingest
    FlaskServer --> RAG
    RAG --> VectorStore
    RAG --> LLMAPI
    FlaskServer -->|"HTTP Response"| FrontendUI

    subgraph "Packaging & Dependencies"
        Setup["Package Definition\n(setup.py)"]:::packaging
        Req["Dependencies\n(requirements.txt)"]:::packaging
        Egg["Installed Metadata\n(FLIPKART_LLMOPS_Agent.egg-info/)"]:::packaging
    end

    FlaskServer --> Setup
    FlaskServer --> Req
    FlaskServer --> Egg

    classDef frontend fill:#cfe2ff,stroke:#0366d6,color:#0366d6
    classDef backend fill:#d1e7dd,stroke:#198754,color:#198754
    classDef data fill:#fff3cd,stroke:#d39e00,color:#856404
    classDef external fill:#f8d7da,stroke:#dc3545,color:#842029
    classDef util fill:#e2e3e5,stroke:#6c757d,color:#343a40
    classDef packaging fill:#e7f3fe,stroke:#0d6efd,color:#084298

    click FrontendUI "https://github.com/ridabayi/flipkart-product-recommender/blob/main/templates/index.html"
    click FrontendAssets "https://github.com/ridabayi/flipkart-product-recommender/blob/main/static/style.css"
    click Ingest "https://github.com/ridabayi/flipkart-product-recommender/blob/main/Flipkart/Data_ingestion.py"
    click Convert "https://github.com/ridabayi/flipkart-product-recommender/blob/main/Flipkart/Data_converter.py"
    click RawData "https://github.com/ridabayi/flipkart-product-recommender/blob/main/Data/flipkart_product_review.csv"
    click RAG "https://github.com/ridabayi/flipkart-product-recommender/blob/main/Flipkart/rag_chain.py"
    click Config "https://github.com/ridabayi/flipkart-product-recommender/blob/main/Flipkart/config.py"
    click VaultKeys "https://github.com/ridabayi/flipkart-product-recommender/blob/main/Flipkart/vault_api_keys.py"
    click Exception "https://github.com/ridabayi/flipkart-product-recommender/blob/main/utils/custom_exception.py"
    click Logger "https://github.com/ridabayi/flipkart-product-recommender/blob/main/utils/logger.py"
    click Setup "https://github.com/ridabayi/flipkart-product-recommender/blob/main/setup.py"
    click Req "https://github.com/ridabayi/flipkart-product-recommender/blob/main/requirements.txt"
    click Egg "https://github.com/ridabayi/flipkart-product-recommender/tree/main/FLIPKART_LLMOPS_Agent.egg-info/"
```
