# harshchan/qdrant-search-methods architecture

> Architecture diagram of the GitHub repository harshchan/qdrant-search-methods, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harshchan/qdrant-search-methods
- Repository: https://github.com/harshchan/qdrant-search-methods

## Overview

##### Project Type and Purpose
- This is a Python-based information retrieval/search application.
- It ingests a CSV dataset of shoe products, preprocesses text data, builds both traditional (BM25, TF-IDF) and vector-based indexes in Qdrant, and exposes:
- A pipeline mode to set up or refresh indexes
- A CLI search mode
- A Streamlit frontend for interactive queries

##### File Structure
- Top-level scripts:
- main.py (entry point with modes: pipeline, streamlit, search)
- app.py / search_engine.py (core retrieval logic)
- data_preprocessing.py, data_indexing.py, vector_generation.py (ETL + indexing)
- qdrant_setup.py (index/collection setup in Qdrant)
- evaluation.py (runs evaluation metrics, outputs evaluation_report.txt)
- Folders and artifacts:
- data/ (shoe_products_dataset.csv)
- saved_models/ (pickled BM25 corpus, TF-IDF vectorizer)
- qdrant-search-methods.zip (possibly sample query helpers)

##### Extract Additional Insights from README
- Dependencies defined in requirements.txt
- Qdrant (hosted via Docker on ports 6333/6334) as vector store + search engine
- Virtual environment recommended
- Three modes:
- pipeline → data ingestion, preprocessing, index building
- streamlit → run frontend UI
- search → CLI query and evaluation

##### Main Components
a. Data Ingestion & Preprocessing
- Input: CSV (data/shoe_products_dataset.csv)
- Scripts: data_preprocessing.py → text cleaning/tokenization
b. Traditional Indexing Module
- data_indexing.py → creates BM25 corpus + TF-IDF vectorizer → saved_models/
c. Vector Generation Module
- vector_generation.py → embed cleaned text (using some embedding model)
d. Qdrant Vector Store
- qdrant_setup.py → collection configuration
- Qdrant Docker containers on ports 6333/6334
e. Retrieval Layer
- search_engine.py / app.py → abstracts querying BM25 & Qdrant
f. Evaluation Module
- evaluation.py → runs queries, computes metrics, writes evaluation_report.txt
g. Frontend UI
- Streamlit app (launched via main.py --mode streamlit)

##### Relationships and Data Flow
- → Traditional Index Builder → saved_models → Retrieval
- → Vector Generator → Qdrant
- Retrieval Layer → queries both saved_models (in-memory) and Qdrant → returns ranked results
- UI Layer (Streamlit) and CLI Layer (main.py --mode search) both invoke Retrieval Layer
- Evaluation module can call Retrieval Layer to compute IR metrics

##### Architectural Patterns & Design Principles
- Modular ETL pipeline (separate scripts for preprocessing, indexing, vector gen)
- Separation of concerns:
- Index build vs. Index store vs. Query logic vs. UI
- Adapter pattern in search_engine.py to unify different search backends (BM25, TF-IDF, vector)
- Dockerized external service for scalability (Qdrant)

##### Essential Details to Capture
- The three modes in main.py and how they trigger different subsystems
- The saved_models artifacts vs. vector store in Qdrant
- The Streamlit server listening on a port vs. CLI interface
- Docker ports and network boundary

##### Final Advice
Level 1: High-level boundaries (Data, Indexing, Qdrant, Retrieval, UI)
Level 2: Zoom into key modules (preprocessing, vector generation, search engine abstraction)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% ETL Pipeline
    subgraph "ETL Pipeline"
        direction TB
        DataCSV["CSV Dataset (data/shoe_products_dataset.csv)"]:::storage
        Preprocess["Preprocessing (data_preprocessing.py)"]:::etl
        TraditionalIndexer["Traditional Indexing (data_indexing.py)"]:::etl
        VectorGen["Vector Generation (vector_generation.py)"]:::etl
    end

    %% Storage / Indexes
    subgraph "Storage & Index"
        direction TB
        BM25Corpus["BM25 Corpus (bm25_corpus.pkl)"]:::storage
        TFIDF["TF-IDF Vectorizer (tfidf_vectorizer.pkl)"]:::storage
        subgraph "Qdrant Service"
            direction TB
            QdrantSetup["Qdrant Setup (qdrant_setup.py)"]:::etl
            QdrantService["Qdrant Docker (ports 6333/6334)"]:::external
        end
    end

    %% Retrieval Layer
    subgraph "Retrieval Layer"
        direction TB
        SearchEngine["Search Engine (search_engine.py)"]:::retrieval
        AppCore["App Core (app.py)"]:::retrieval
    end

    %% Presentation Layer
    subgraph "Presentation"
        direction TB
        CLI["CLI Mode"]:::ui
        Streamlit["Streamlit UI"]:::ui
    end

    %% Evaluation Module
    Evaluation["Evaluation (evaluation.py)"]:::etl
    EvalReport["Evaluation Report (evaluation_report.txt)"]:::storage

    %% Orchestration
    Main["Main (main.py)"]:::etl
    Requirements["Requirements (requirements.txt)"]:::storage
    QdrantZip["Qdrant Helpers (qdrant-search-methods.zip)"]:::storage
    Readme["Documentation (README.md)"]:::storage

    %% Flows
    DataCSV --> Preprocess
    Preprocess --> TraditionalIndexer
    Preprocess --> VectorGen

    TraditionalIndexer --> BM25Corpus
    TraditionalIndexer --> TFIDF

    VectorGen --> QdrantSetup
    QdrantSetup --> QdrantService

    BM25Corpus --> SearchEngine
    TFIDF --> SearchEngine
    QdrantService <-->|"search()"| SearchEngine

    SearchEngine --> AppCore
    AppCore --> CLI
    AppCore --> Streamlit

    SearchEngine --> Evaluation
    Evaluation --> EvalReport

    Main --> Preprocess
    Main --> SearchEngine
    Main --> Streamlit

    %% Click Events
    click DataCSV "https://github.com/harshchan/qdrant-search-methods/blob/main/data/shoe_products_dataset.csv"
    click Preprocess "https://github.com/harshchan/qdrant-search-methods/blob/main/data_preprocessing.py"
    click TraditionalIndexer "https://github.com/harshchan/qdrant-search-methods/blob/main/data_indexing.py"
    click VectorGen "https://github.com/harshchan/qdrant-search-methods/blob/main/vector_generation.py"
    click BM25Corpus "https://github.com/harshchan/qdrant-search-methods/blob/main/saved_models/bm25_corpus.pkl"
    click TFIDF "https://github.com/harshchan/qdrant-search-methods/blob/main/saved_models/tfidf_vectorizer.pkl"
    click QdrantSetup "https://github.com/harshchan/qdrant-search-methods/blob/main/qdrant_setup.py"
    click SearchEngine "https://github.com/harshchan/qdrant-search-methods/blob/main/search_engine.py"
    click AppCore "https://github.com/harshchan/qdrant-search-methods/blob/main/app.py"
    click Evaluation "https://github.com/harshchan/qdrant-search-methods/blob/main/evaluation.py"
    click EvalReport "https://github.com/harshchan/qdrant-search-methods/blob/main/evaluation_report.txt"
    click Main "https://github.com/harshchan/qdrant-search-methods/blob/main/main.py"
    click Requirements "https://github.com/harshchan/qdrant-search-methods/blob/main/requirements.txt"
    click QdrantZip "https://github.com/harshchan/qdrant-search-methods/blob/main/qdrant-search-methods.zip"
    click Readme "https://github.com/harshchan/qdrant-search-methods/blob/main/README.md"

    %% Styles
    classDef etl fill:#D6E9FF,stroke:#333,stroke-width:1px
    classDef storage fill:#DFF0D8,stroke:#333,stroke-width:1px
    classDef retrieval fill:#FCF8E3,stroke:#333,stroke-width:1px
    classDef ui fill:#F2DEDE,stroke:#333,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#333,stroke-width:1px
```
