# mhsenkow/infinitevegacharts architecture

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

- Interactive diagram: https://gitdiagram.com/mhsenkow/infinitevegacharts
- Repository: https://github.com/mhsenkow/infinitevegacharts

## Overview

##### Project Type and Purpose
- This is a hybrid desktop/web full-stack front-end application built with Electron and Vite.
- Its purpose is to provide a React-based data-visualization gallery and editor using Vega-Lite, with features like OCR-based image data extraction, AI recommendations, data curation, and a live code editor.

##### File Structure
- Top-level “vega-gallery” directory contains:
- electron/ (Electron main process entry: main.cjs)
- src/electron/preload.js (exposes safe APIs to the renderer)
- src/ (React renderer code)
– components/ (UI modules: Gallery, Editor, DataManagement, ChartCreator, common)
– services/ (AI recommendations, external API wrappers)
– utils/ (chart rendering, data utils, IndexedDB wrappers)
– assets/, constants/, types/, tests/
- public/ (static assets & manifest)
- config (tsconfig*, vite.config.ts, eslint.config.js, jest.config.js)
- No separate backend server – Electron’s main/preload processes act as “backend” for file I/O and native integrations.

##### Key Architecture Insights from README
- Renderer process runs a React + TypeScript + Vite build.
- Electron main process handles desktop packaging, file dialogs, and can call Node/OS APIs.
- IndexedDB is used for local storage of datasets and chart specs.
- External services: Tesseract.js (in-browser OCR), optional Google Cloud Vision API (via services/aiRecommendations).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Electron Main Process"
        EM["Electron Main Process"]:::electron
    end
    subgraph "Preload Script"
        PS["Preload IPC Bridge"]:::electron
    end
    EM -->|"Creates Window & IPC"| PS

    subgraph "Renderer Process"
        RE["Renderer Entry Point"]:::electron
        subgraph "UI Components"
            G["Gallery"]:::ui
            E["Editor"]:::ui
            DM["Data Management"]:::ui
            CC["Chart Creator"]:::ui
            CM["Common UI"]:::ui
        end
        subgraph "Services"
            OCR["OCR Image Extraction"]:::service
            AI["AI Recommendation Service"]:::service
        end
        subgraph "Utils & Data Layer"
            CA["Vega-Lite Adapters"]:::utils
            CE["Chart Enhancements"]:::utils
            CR["Chart Rendering Utility"]:::utils
            DU["Data Utilities"]:::utils
            IDB["IndexedDB Persistence"]:::storage
        end
        subgraph "External Services"
            VL["Vega-Lite Library"]:::ext
            TESS["Tesseract.js Engine"]:::ext
            GCV["Google Cloud Vision API"]:::ext
        end
        subgraph "Static Assets"
            SA["Static Assets & Manifest"]:::static
        end
    end

    PS -->|IPC| RE
    PS -->|IPC| G
    PS -->|IPC| E
    PS -->|IPC| DM
    PS -->|IPC| CC

    G -->|uses| CR
    E -->|edits specs| CR
    DM -->|manages data| IDB
    DM -->|extracts via| OCR
    DM -->|requests AI rec| AI
    CR -->|renders via| VL
    OCR -->|calls| TESS
    OCR -->|calls| GCV
    AI -->|calls| GCV
    G -->|loads assets| SA

    subgraph "Config & Templates"
        CFG["Vite Configuration"]:::config
        EN["Application HTML Template"]:::config
    end
    CFG --- EN

    classDef electron fill:#a2c4fc,stroke:#084b8a,stroke-width:1px
    classDef ui fill:#b6d7a8,stroke:#38761d,stroke-width:1px
    classDef service fill:#ffe599,stroke:#7f6000,stroke-width:1px
    classDef utils fill:#f9cb9c,stroke:#b45f06,stroke-width:1px
    classDef storage fill:#93c47d,stroke:#38761d,stroke-width:1px
    classDef ext fill:#cfe2f3,stroke:#134f5c,stroke-width:1px
    classDef static fill:#d9d2e9,stroke:#5b0f6c,stroke-width:1px
    classDef config fill:#ead1dc,stroke:#741b47,stroke-width:1px

    click EM "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/electron/main.cjs"
    click PS "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/electron/preload.js"
    click RE "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/main.tsx"
    click G "https://github.com/mhsenkow/infinitevegacharts/tree/main/vega-gallery/src/components/Gallery"
    click E "https://github.com/mhsenkow/infinitevegacharts/tree/main/vega-gallery/src/components/Editor"
    click DM "https://github.com/mhsenkow/infinitevegacharts/tree/main/vega-gallery/src/components/DataManagement"
    click CC "https://github.com/mhsenkow/infinitevegacharts/tree/main/vega-gallery/src/components/ChartCreator"
    click CM "https://github.com/mhsenkow/infinitevegacharts/tree/main/vega-gallery/src/components/common"
    click OCR "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/components/DataManagement/ImageDataExtractor.tsx"
    click AI "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/services/aiRecommendations.ts"
    click CA "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/utils/chartAdapters.ts"
    click CE "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/utils/chartEnhancements.tsx"
    click CR "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/utils/chartRenderer.ts"
    click DU "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/utils/dataUtils.ts"
    click IDB "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/src/utils/indexedDB.ts"
    click SA "https://github.com/mhsenkow/infinitevegacharts/tree/main/vega-gallery/public"
    click CFG "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/vite.config.ts"
    click EN "https://github.com/mhsenkow/infinitevegacharts/blob/main/vega-gallery/index.html"
```
