# uwdata/mosaic architecture

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

- Interactive diagram: https://gitdiagram.com/uwdata/mosaic
- Repository: https://github.com/uwdata/mosaic

## Overview

##### Key Components

- Applications     |
- vgplot        |
- Jupyter Widget |
- Web Apps      |

- Mosaic Core       |
- Coordinator     |
- Parameters      |
- Selections      |
- Query Manager   |

- DuckDB Layer     |
- WASM Client    |
- Python Server  |
- Rust Server    |

##### Connection Flows

- Data flow from database to visualizations
- Query flow from components to coordinator
- Parameter/Selection updates between components
- Client-server communication paths

##### Integration Points

Integration capabilities with:
- Observable Plot
- Jupyter Notebooks
- DuckDB (both WASM and server-side)
- Custom visualization components

##### Component Details

For each major component, include:

- Component Name  |

- Key Features  |
- Dependencies  |
- Interfaces    |

- → Data Flow      |
- ⇢ Query Flow     |
- ⇄ Sync Flow      |
- □ Core Component |
- ○ Extension Point|

##### Implementation Notes

- The central role of the Coordinator
- Multiple database deployment options
- Extensible architecture
- Cross-component linking capabilities
- Query optimization paths

##### Additional Elements

Callouts for:
- API entry points
- Configuration options
- Deployment scenarios

- Nested components
- Different line styles
- Text annotations
- Export to vector format

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef core fill:#e8f5e9,stroke:#1b5e20
    classDef database fill:#fff3e0,stroke:#e65100
    classDef input fill:#f3e5f5,stroke:#4a148c
    classDef sql fill:#fce4ec,stroke:#880e4f
    classDef viz fill:#e3f2fd,stroke:#0d47a1

    %% Frontend Layer
    subgraph Frontend
        VGPlot["VGPlot"]:::frontend
        JupyterWidget["Jupyter Widget"]:::frontend
        SpecLayer["Specification Layer"]:::frontend
    end

    %% Core Layer
    subgraph Core
        Coordinator["Coordinator"]:::core
        ParamMgmt["Parameter Management"]:::core
        SelectionMgmt["Selection Management"]:::core
        QueryMgmt["Query Management"]:::core
    end

    %% Database Layer
    subgraph Database
        DuckDB["DuckDB Implementation"]:::database
        PythonServer["Python Server"]:::database
        RustServer["Rust Server"]:::database
    end

    %% Input and SQL Layers
    InputMgmt["Input Management"]:::input
    SQLImpl["SQL Implementation"]:::sql

    %% Visualization Components
    subgraph Visualization
        PlotComp["Plot Components"]:::viz
        MarksImpl["Marks Implementation"]:::viz
        Interactors["Interactors"]:::viz
    end

    %% Relationships
    VGPlot --> Coordinator
    JupyterWidget --> Coordinator
    SpecLayer --> Coordinator
    
    Coordinator --> ParamMgmt
    Coordinator --> SelectionMgmt
    Coordinator --> QueryMgmt
    
    QueryMgmt --> SQLImpl
    SQLImpl --> DuckDB
    SQLImpl --> PythonServer
    SQLImpl --> RustServer
    
    InputMgmt --> ParamMgmt
    
    Coordinator --> PlotComp
    PlotComp --> MarksImpl
    PlotComp --> Interactors

    %% Click Events
    click VGPlot "https://github.com/uwdata/mosaic/tree/main/packages/vgplot/"
    click JupyterWidget "https://github.com/uwdata/mosaic/tree/main/packages/widget/"
    click SpecLayer "https://github.com/uwdata/mosaic/tree/main/packages/spec/"
    click Coordinator "https://github.com/uwdata/mosaic/blob/main/packages/core/src/Coordinator.js"
    click ParamMgmt "https://github.com/uwdata/mosaic/blob/main/packages/core/src/Param.js"
    click SelectionMgmt "https://github.com/uwdata/mosaic/blob/main/packages/core/src/Selection.js"
    click QueryMgmt "https://github.com/uwdata/mosaic/blob/main/packages/core/src/QueryManager.js"
    click DuckDB "https://github.com/uwdata/mosaic/tree/main/packages/duckdb/"
    click PythonServer "https://github.com/uwdata/mosaic/tree/main/packages/duckdb-server/"
    click RustServer "https://github.com/uwdata/mosaic/tree/main/packages/duckdb-server-rust/"
    click InputMgmt "https://github.com/uwdata/mosaic/tree/main/packages/inputs/"
    click SQLImpl "https://github.com/uwdata/mosaic/tree/main/packages/sql/"
    click PlotComp "https://github.com/uwdata/mosaic/tree/main/packages/plot/"
    click MarksImpl "https://github.com/uwdata/mosaic/tree/main/packages/plot/src/marks/"
    click Interactors "https://github.com/uwdata/mosaic/tree/main/packages/plot/src/interactors/"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Core_L["Core Component"]:::core
        DB_L["Database Component"]:::database
        Input_L["Input Component"]:::input
        SQL_L["SQL Component"]:::sql
        Viz_L["Visualization Component"]:::viz
    end
```
