# om-alve/wheres_my_pic architecture

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

- Interactive diagram: https://gitdiagram.com/om-alve/wheres_my_pic
- Repository: https://github.com/om-alve/wheres_my_pic

## Overview

##### Project Type Analysis
This is a machine learning-powered application that combines:
- A local file system interface
- A vector database (Chroma)
- A pre-trained AI model (CLIP)
- A web-based UI (Gradio)

##### Main Components

A. User Interface Layer:
- Gradio web interface
- Search input component
- Image results display

B. Application Core:
- CLIP model for embedding generation
- Query processing system
- Image processing pipeline

C. Storage Layer:
- Chroma vector database
- Local file system for images
- Database indexing system

**[User Interface Layer]**

- ▼
**[Application Core]**

- ▼
**[Storage Layer]**

**[Gradio UI] ─────────────────────┐**

**[User Query] ───► [CLIP Model] ──┤**

**[Image Upload] ──────────────────┤**
- ▼
**[Query Processor] ◄──── [Vector Embeddings]**

- ▼
**[Chroma DB] ◄───► [Local File System]**

##### Key Flows to Highlight

A. Indexing Flow:
- Directory scanning
- Image processing
- CLIP embedding generation
- Database storage

B. Search Flow:
- Query input
- Text embedding generation
- Vector similarity search
- Results retrieval and display

##### Important Technical Details

- CLIP model integration point
- Chroma DB connection
- File system watchers for updates
- Gradio interface endpoints

##### Implementation Notes

- The separation between the indexing process (build-db.py) and the search interface (app.py)
- The asynchronous nature of database updates
- The vector similarity search mechanism
- The connection between stored embeddings and original image files

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI
        GradioUI["Gradio Web Interface"]:::ui
        SearchInput["Search Input"]:::ui
        ImageResults["Image Results Display"]:::ui
    end

    subgraph Core
        QueryProcessor["Query Processor"]:::core
        CLIPModel["CLIP Model"]:::core
        VectorEmbed["Vector Embeddings"]:::core
        IndexingSystem["Database Builder & Indexer"]:::core
    end

    subgraph Storage
        ChromaDB[(Chroma Vector DB)]:::storage
        FileSystem["Local File System"]:::storage
        StaticRes["Static Resources"]:::storage
    end

    GradioUI --> SearchInput
    GradioUI --> ImageResults
    SearchInput --> QueryProcessor
    QueryProcessor --> CLIPModel
    CLIPModel --> VectorEmbed
    VectorEmbed --> ChromaDB
    ChromaDB --> QueryProcessor
    FileSystem --> IndexingSystem
    IndexingSystem --> CLIPModel
    StaticRes --> FileSystem
    ChromaDB --> ImageResults

    %% Component Mappings
    click GradioUI "https://github.com/Om-Alve/Wheres_My_Pic/blob/main/app.py"
    click IndexingSystem "https://github.com/Om-Alve/Wheres_My_Pic/blob/main/build-db.py"
    click StaticRes "https://github.com/Om-Alve/Wheres_My_Pic/tree/main/assets/"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef storage fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        UI_Legend["UI Component"]:::ui
        Core_Legend["Core Component"]:::core
        Storage_Legend["Storage Component"]:::storage
    end
```
