# swagath18/semanticfoodsearch architecture

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

- Interactive diagram: https://gitdiagram.com/swagath18/semanticfoodsearch
- Repository: https://github.com/swagath18/semanticfoodsearch

## Overview

##### Main components
- User Query Interface: Though not explicitly a web front-end, the “user query” serves as the input prompt for the system.
- Query Embedding Module: This component uses embedding algorithms (baseline from test1 and an alternative from test2) to convert the textual query into a vector representation.
- Data Ingestion/Preparation: The CSV file (menu_items.csv) is read and processed; each menu item would be converted to vector embeddings to be stored.
- Vector Database: The vectorized representations of the menus are stored here; this component supports similarity search operations.
- Search Engine/Matching Component: This takes the query’s embedding, runs a similarity search against the vector database and retrieves matching restaurant menus.
- Result Formatting & Output: The matched items are then formatted and returned to the user.

##### Their relationships and interactions
- The process starts when a user submits a query.
- The Query Embedding Module then transforms the query into a vector.
- The Search Engine uses this vector to search in the Vector Database (which was populated earlier by processing the CSV file via an embedding mechanism).
- The matched results (restaurant menu items/entries) are fetched and returned through the Result Formatting component back to the user.
- In tests (as seen in test.ipynb versus test2.ipynb), different embedding methods are compared to improve result quality.

##### Architectural patterns/design principles
- Data Pipeline Concept: The system follows a clear pipeline—ingest data → preprocess/encode → store in database → query transform → similarity search.
- Modularity: The notebook experiments suggest modular development where different embedding strategies can be swapped (or compared) with minimal changes.
- Separation of Concerns: Even though the project is compact, the responsibilities are separated between data preprocessing (CSV handling), embedding generation, and query matching.

##### Relevant technologies/frameworks/libraries
- Embedding Generation: Likely using Sentence Transformers (as mentioned in the README), with an alternative embedding method tested in test2.
- Data Handling: CSV file handling for menu items.
- Experimentation/Prototyping: Jupyter Notebooks indicate a research/prototype stage.

##### Recommended elements
- Use clear labels for each component: “User Query Input”, “Query Embedding Module”, “Data Preprocessing (CSV Ingestion)”, “Vector Embedding Store”, “Similarity Search Engine”, and “Result Output”.
- Input components (e.g., user query) vs. computation (embedding modules) vs. storage (vector database) vs. output (result display).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    UQI("User Query Input"):::input

    %% Embedding Modules Subgraph
    subgraph "Query Embedding Modules"
        QE1("Query Embedding Module (Default)"):::compute
        QE2("Query Embedding Module (Alternative)"):::compute
    end

    %% Data Pipeline Subgraph
    subgraph "Data Pipeline"
        DIP("Data Ingestion/Preparation (CSV Handling)"):::data
        VD("Vector Database"):::database
    end

    %% Search and Result Processing
    SE("Similarity Search Engine"):::search
    RO("Result Formatting & Output"):::output

    %% Documentation node
    DOC("Documentation & System Overview"):::doc

    %% Data Flow
    UQI -->|"initiates"| QE1
    UQI -->|"initiates"| QE2
    QE1 -->|"produces embedding"| SE
    QE2 -->|"produces embedding"| SE
    DIP -->|"processes CSV data"| VD
    VD -->|"provides vectors"| SE
    SE -->|"returns matches"| RO
    RO -->|"delivers results"| UQI

    %% Documentation Reference (Informational)
    UQI -.->|"overview"| DOC

    %% Click Events
    click QE1 "https://github.com/swagath18/semanticfoodsearch/blob/main/test.ipynb"
    click QE2 "https://github.com/swagath18/semanticfoodsearch/blob/main/test2.ipynb"
    click DIP "https://github.com/swagath18/semanticfoodsearch/blob/main/menu_items.csv"
    click DOC "https://github.com/swagath18/semanticfoodsearch/blob/main/README.md"

    %% Styles
    classDef input fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef compute fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef data fill:#e0ffff,stroke:#333,stroke-width:2px;
    classDef database fill:#fafad2,stroke:#333,stroke-width:2px,stroke-dasharray: 5,5;
    classDef search fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef output fill:#d3d3d3,stroke:#333,stroke-width:2px;
    classDef doc fill:#ee82ee,stroke:#333,stroke-width:2px;
```
