# vinay8git/visual-product-matcher architecture

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

- Interactive diagram: https://gitdiagram.com/vinay8git/visual-product-matcher
- Repository: https://github.com/vinay8git/visual-product-matcher

## Overview

##### Project type and purpose
- This is a full-stack, AI-powered visual product search engine.
- Frontend: React + Vite UI for uploading or pasting an image and displaying results.
- Backend: Node.js + Express to handle HTTP requests, orchestrate Python CLIP model, manage data.
- Python service using PyTorch + OpenAI’s CLIP model for generating image embeddings.
- Data store: JSON files for product catalog and precomputed embeddings, plus local file caches.

##### File structure
- Top level splits into Back-End, Front-End, Test_Images, and documentation.
- Back-End:
- server.js – Express HTTP API
- clip_model.py – Python entry point for embedding logic
- data/ – products.json (catalog), embeddings.json (index), images_cache/
- public/index.html – fallback static UI
- uploads/ – user-uploaded images
- package.json, requirements.txt – Node and Python deps
- Front-End:
- src/ – React components (App.jsx), assets, styles
- index.html + Vite config – entry and build settings
- package.json – React and tooling deps
- Architectural_Diagram.png exists as an example reference.

##### README for additional insights
- Features call out:
- Visual search via upload or URL
- Instant preview in the UI
- Products and auto-rebuild the embedding index
- Configurable Top-K and similarity threshold
- Cached image downloads for performance
- Tech stack and data flow are described: user → React UI → Express API → CLIP → JSON index → results.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["User's Browser\n(React UI)"]:::frontend
        App["App.jsx"]:::frontend
        Main["main.jsx"]:::frontend
        FEIndex["index.html"]:::frontend
        ViteConf["vite.config.js"]:::frontend
    end

    %% Backend API Layer
    subgraph "Backend API Server"
        direction TB
        API["Express API Server\n(server.js)"]:::backend
        BEPkg["package.json"]:::backend
        StaticUI["Static Fallback UI\n(public/index.html)"]:::frontend
    end

    %% ML Service Layer
    subgraph "CLIP Inference Service"
        direction TB
        CLIP["clip_model.py"]:::ml
        ReqTxt["requirements.txt"]:::ml
    end

    %% Data Store Layer
    subgraph "Data Store & Caches"
        direction TB
        Products["products.json"]:::storage
        Embeddings["embeddings.json"]:::storage
        Cache["images_cache"]:::storage
        Uploads["uploads"]:::storage
        TestImgs["Test_Images"]:::storage
    end

    %% External Sources
    External["External Image Sources"]:::external

    %% Connections
    Browser -->|"HTTP /search, /add-product"| API
    API -->|"invoke embedding"| CLIP
    CLIP -->|"return vectors"| API
    API -->|"read/write metadata"| Products
    API -->|"read/write index"| Embeddings
    API -->|"cache uploads"| Uploads
    API -->|"cache downloads"| Cache
    API -->|"serve UI fallback"| StaticUI
    External -->|"download images"| Cache
    API -.->|"rebuild embeddings (add-product)"| CLIP

    %% File structure listings
    Browser --> App
    Browser --> Main
    Browser --> FEIndex
    Browser --> ViteConf
    API --> API
    API --> BEPkg
    CLIP --> CLIP
    CLIP --> ReqTxt

    %% Click Events
    click App "https://github.com/vinay8git/visual-product-matcher/blob/main/Front-End/src/App.jsx"
    click Main "https://github.com/vinay8git/visual-product-matcher/blob/main/Front-End/src/main.jsx"
    click FEIndex "https://github.com/vinay8git/visual-product-matcher/blob/main/Front-End/index.html"
    click ViteConf "https://github.com/vinay8git/visual-product-matcher/blob/main/Front-End/vite.config.js"
    click API "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/server.js"
    click BEPkg "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/package.json"
    click CLIP "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/clip_model.py"
    click ReqTxt "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/requirements.txt"
    click Products "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/data/products.json"
    click Embeddings "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/data/embeddings.json"
    click Cache "https://github.com/vinay8git/visual-product-matcher/tree/main/Back-End/data/images_cache"
    click StaticUI "https://github.com/vinay8git/visual-product-matcher/blob/main/Back-End/public/index.html"
    click TestImgs "https://github.com/vinay8git/visual-product-matcher/tree/main/Test_Images"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,color:#000
    classDef backend fill:#90EE90,stroke:#333,color:#000
    classDef ml fill:#32CD32,stroke:#333,color:#000
    classDef storage fill:#FFA500,stroke:#333,color:#000
    classDef external fill:#d3d3d3,stroke:#333,color:#000
```
