# strandedkitty/streets-gl-legacy architecture

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

- Interactive diagram: https://gitdiagram.com/strandedkitty/streets-gl-legacy
- Repository: https://github.com/strandedkitty/streets-gl-legacy

## Overview

##### Main Components
- Browser/UI Layer: Represented by the main HTML file (src/index.html) which bootstraps the application.
- Rendering Engine: The heart of Streets GL, found primarily in src/js. This includes:
– Core modules (e.g., Object3D, SceneGraph, Cameras in src/js/core)
– Renderer and WebGL abstraction (src/js/renderer/)
– Shader manager and shader passes (src/js/passes/; also related GLSL shaders in src/glsl/)
– Material and mesh handling (src/js/materials/ and src/js/Models.js)
- Data & Resource Management:
– Assets such as textures (src/textures/), models (src/models/), and additional static resources.
- /OSM Data Handling & Workers:
– Worker scripts (located in src/js/worker/) for asynchronous processing, vector tile handling, and mapping functionalities (including files like MapWorker.js, MapWorkerManager.js).
- Configuration & Build Tools: Files such as package.json, webpack.config.js, which govern dependency management and bundling.

##### Relationships and Interactions
- The Browser/UI layer launches the application and initiates main.js, which in turn creates the rendering context.
- The Rendering Engine, through its various submodules, organizes the scene graph, loads assets, applies material/shader pipelines, and renders each frame.
- Resources (textures, models) are loaded from the file system via resource manager components and then passed to the renderer.

##### Architectural Patterns & Design Principles
- Asynchronous Processing: Emphasize web workers for offloading map data and tile processing. This is critical for performance in a WebGL visualization.

##### Technology & Framework Detail
- JavaScript for application logic (all source in src/js).
- WebGL 2 for rendering, indicated by custom GLSL shader files in src/glsl.
- Web Workers handling heavy computation in parallel.
- Use of npm for dependency management (package.json, package-lock.json) and webpack for bundling (webpack.config.js).

## Diagram (Mermaid)

```mermaid
flowchart TD
    UI["Browser/UI Layer (src/index.html)"]:::ui
    INIT["App Initialization (main.js)"]:::init
    UI --> INIT

    subgraph "Rendering Engine"
        CORE["Core Modules (/src/js/core)"]:::render
        RENDERER["Renderer & WebGL Abstraction (/src/js/renderer)"]:::render
        SHADER["Shader Manager & Passes (/src/js/passes)"]:::render
        GLSL["GLSL Shaders (/src/glsl)"]:::render
        MATERIAL["Material & Mesh Handling (/src/js/materials, src/js/Models.js)"]:::render
    end

    subgraph "Data & Resource Management"
        TEXTURES["Textures (src/textures)"]:::data
        MODELS["Models (src/models)"]:::data
        RESOURCES["Resource Files (src/js/resources)"]:::data
    end

    WORKER["Map Workers (/src/js/worker)"]:::worker

    FINAL["Final Visualization"]:::init

    CONFIG["Configuration & Build Tools (package.json, webpack.config.js)"]:::config

    %% Data Flow Connections
    INIT --> CORE
    INIT --> TEXTURES
    INIT --> WORKER
    INIT --- CONFIG

    CORE --> RENDERER
    RENDERER --> SHADER
    SHADER --> GLSL
    RENDERER --> MATERIAL

    %% Convergence to Final Output
    CORE --> FINAL
    TEXTURES --> FINAL
    MODELS --> FINAL
    RESOURCES --> FINAL
    WORKER --> FINAL

    %% Click Events
    click UI "https://github.com/strandedkitty/streets-gl-legacy/blob/dev/src/index.html"
    click CORE "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/js/core"
    click RENDERER "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/js/renderer"
    click SHADER "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/js/passes"
    click GLSL "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/glsl"
    click MATERIAL "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/js/materials"
    click TEXTURES "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/textures"
    click MODELS "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/models"
    click RESOURCES "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/js/resources"
    click WORKER "https://github.com/strandedkitty/streets-gl-legacy/tree/dev/src/js/worker"
    click CONFIG "https://github.com/strandedkitty/streets-gl-legacy/blob/dev/webpack.config.js"

    %% Styles
    classDef ui fill:#1abc9c,stroke:#16a085,color:#ecf0f1;
    classDef init fill:#3498db,stroke:#2980b9,color:#ecf0f1;
    classDef render fill:#9b59b6,stroke:#8e44ad,color:#ecf0f1;
    classDef data fill:#e67e22,stroke:#d35400,color:#ecf0f1;
    classDef worker fill:#e74c3c,stroke:#c0392b,color:#ecf0f1;
    classDef config fill:#f1c40f,stroke:#f39c12,color:#2c3e50;

    linkStyle default stroke:#ecf0f1,stroke-width:2px;
```
