# ilidemi/visa-viz architecture

> Architecture diagram of the GitHub repository ilidemi/visa-viz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ilidemi/visa-viz
- Repository: https://github.com/ilidemi/visa-viz

## Overview

##### Component Relationships

A. Data Flow Layer:
- Thread Data Storage → Layout System → Render System → WebGL Output

B. Render Pipeline:
- Layout Managers → Render Primitives → Shader Programs → Screen Output

##### Detailed Subcomponents

Layout System (Group these together):
- Gallery Layout
- Thread Layout (Absolute/Relative)
- World Layout
- Hit Rectangle System

- Common Render Components
- Canvas Context
- Image Cache
- Coordinate Space
- Layout Primitives
- Specialized Renderers
- Circles
- Text
- Images
- Rounded Frames
- User Pictures

##### Technical Details

Annotations for:
- WebAssembly/Native Bridge
- WebGL Context Management
- Shader Program Management
- Memory Management System
- Input Handling System

##### Shader programs connected to their respective renderers

Key Architectural Patterns to Highlight:
- Component-based rendering system
- Shader program management
- Layout management hierarchy
- Data flow pipeline

Additional Notes:
- Performance-critical paths in bold
- Memory management flows

- Heavy use of WebGL for rendering
- Minimal traditional web technologies
- Complex layout system for thread visualization
- Efficient memory management for large datasets

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core
        WA[WebAssembly Module]
        WGL[WebGL Engine]
        HTML[HTML Shell]
    end

    subgraph "Data Management"
        TDS[Thread Data Storage]
        IC[Image Cache]
        MM[Memory Management]
    end

    subgraph "Layout System"
        LS[Layout System]
        GL[Gallery Layout]
        TL[Thread Layout]
        WL[World Layout]
        HRS[Hit Rectangle System]
    end

    subgraph "Render System"
        RS[Render System]
        
        subgraph "Common Components"
            CC[Canvas Context]
            ICache[Image Cache]
            CS[Coordinate Space]
            LP[Layout Primitives]
        end
        
        subgraph "Specialized Renderers"
            AR[Arrows]
            CR[Circles]
            TR[Text]
            IR[Images]
            RF[Rounded Frames]
            UP[User Pictures]
        end
    end

    subgraph "Shader Programs"
        ASH[Arrow Shaders]
        CSH[Circle Shaders]
        TSH[Text Shaders]
        VSH[Common Vertex Shader]
    end

    subgraph "Utility Systems"
        PO[Performance Overlay]
        IM[Input Management]
        FC[Frame Context]
        SM[Style Management]
    end

    %% Core Relationships
    TDS --> WA
    WA --> WGL
    HTML --> WA

    %% Layout System Relationships
    TDS --> LS
    LS --> GL & TL & WL & HRS
    LS --> RS

    %% Render System Flow
    RS --> CC
    CC --> WGL
    RS --> AR & CR & TR & IR & RF & UP

    %% Shader Relationships
    AR --> ASH
    CR --> CSH
    TR --> TSH
    ASH & CSH & TSH --> VSH
    VSH --> WGL

    %% Utility Connections
    PO --> WGL
    IM --> WA
    FC --> RS
    SM --> RS

    %% Styling
    classDef core fill:#3498db
    classDef data fill:#f1c40f
    classDef layout fill:#2ecc71
    classDef render fill:#e74c3c
    classDef shader fill:#9b59b6
    classDef utility fill:#95a5a6

    class WA,WGL,HTML core
    class TDS,IC,MM data
    class LS,GL,TL,WL,HRS layout
    class RS,CC,ICache,CS,LP,AR,CR,TR,IR,RF,UP render
    class ASH,CSH,TSH,VSH shader
    class PO,IM,FC,SM utility

    %% Click Events
    click LS "https://github.com/ilidemi/visa-viz/tree/master/src/layout/"
    click GL "https://github.com/ilidemi/visa-viz/blob/master/src/layout/galleryLayout.cpp"
    click TL "https://github.com/ilidemi/visa-viz/blob/master/src/layout/threadLayout.cpp"
    click WL "https://github.com/ilidemi/visa-viz/blob/master/src/layout/worldLayout.cpp"
    click HRS "https://github.com/ilidemi/visa-viz/blob/master/src/layout/hitRect.cpp"
    click RS "https://github.com/ilidemi/visa-viz/tree/master/src/render/"
    click CC "https://github.com/ilidemi/visa-viz/blob/master/src/render/common/canvasContext.cpp"
    click ICache "https://github.com/ilidemi/visa-viz/blob/master/src/render/common/imageCache.cpp"
    click CS "https://github.com/ilidemi/visa-viz/blob/master/src/render/common/coordinateSpace.cpp"
    click AR "https://github.com/ilidemi/visa-viz/tree/master/src/render/arrows/"
    click CR "https://github.com/ilidemi/visa-viz/tree/master/src/render/circle/"
    click TR "https://github.com/ilidemi/visa-viz/tree/master/src/render/text/"
    click IR "https://github.com/ilidemi/visa-viz/tree/master/src/render/image/"
    click RF "https://github.com/ilidemi/visa-viz/tree/master/src/render/roundedFrames/"
    click UP "https://github.com/ilidemi/visa-viz/tree/master/src/render/userPic/"
    click ASH "https://github.com/ilidemi/visa-viz/blob/master/src/render/arrows/arrowCornersFragmentShader.glsl"
    click CSH "https://github.com/ilidemi/visa-viz/blob/master/src/render/circle/circleFragmentShader.glsl"
    click TSH "https://github.com/ilidemi/visa-viz/blob/master/src/render/text/textVertexShader.glsl"
    click VSH "https://github.com/ilidemi/visa-viz/blob/master/src/render/vertexShader.glsl"
    click TDS "https://github.com/ilidemi/visa-viz/blob/master/src/tweetDataLoad.cpp"
    click MM "https://github.com/ilidemi/visa-viz/blob/master/src/util/deque.cpp"
    click PO "https://github.com/ilidemi/visa-viz/blob/master/src/perfOverlay.cpp"
    click IM "https://github.com/ilidemi/visa-viz/blob/master/src/input.cpp"
    click FC "https://github.com/ilidemi/visa-viz/blob/master/src/frameContext.cpp"
    click SM "https://github.com/ilidemi/visa-viz/blob/master/src/style.cpp"
    click HTML "https://github.com/ilidemi/visa-viz/blob/master/src/shell/index.html"
    click WA "https://github.com/ilidemi/visa-viz/blob/master/src/main.cpp"
```
