# dioxuslabs/blitz architecture

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

- Interactive diagram: https://gitdiagram.com/dioxuslabs/blitz
- Repository: https://github.com/dioxuslabs/blitz

## Overview

##### Project Type and Purpose
- The project is a rendering engine focused on displaying HTML/CSS. It falls within the “engine” / “browser-lite” domain rather than a full-featured browser.
- Its modularity is emphasized: core DOM, rendering, HTML parsing, networking, windowing, and two high-level wrapper crates for integrating with applications (one for plain HTML/markdown and one for Dioxus applications).

##### Break Down the File Structure
- The file tree shows several top-level directories:
- packages – contains the modular components and libraries (e.g., blitz-dom, blitz-html, blitz-net, blitz-renderer-vello, blitz-shell, blitz-traits, dioxus-native, stylo_taffy, blitz).
- apps – contains example applications like “readme” and “wpt” which likely illustrate different uses of the engine.
- examples – a large collection of HTML/CSS examples and Rust test files demonstrating various rendering scenarios.
- Notice the modular organization: each “crate” in the packages folder addresses a specific concern (DOM, HTML parsing, rendering, networking, shell, etc.). This separation suggests a plug-and-play, loosely coupled architecture.

##### Summarize the Architectural Insights from the README
- The documentation explains two high-level “wrapper” crates:
- blitz: for HTML/markdown rendering – uses components like blitz-dom, blitz-html, blitz-shell, blitz-renderer-vello.
- dioxus-native: for building native Dioxus applications.
- It describes a series of core and additional modular components:
- Core: blitz-dom (DOM abstraction) and blitz-traits (shared traits/types).
- Additional: blitz-renderer-vello (using Vello/WGPU), blitz-net (networking), blitz-html (HTML parsing), blitz-shell (windowing and input handling).

a. And Label Main Components:
- High-Level Wrappers: “blitz” and “dioxus-native”.
- Core Components: “blitz-dom” and “blitz-traits”.
- Additional Modules/Crates: “blitz-renderer-vello”, “blitz-net”, “blitz-html”, “blitz-shell”.
- External Libraries/Dependencies: Stylo, Taffy, Parley, Vello, WGPU, Winit, AccessKit, Reqwest, html5ever.
- Supporting Applications: “apps/readme” and “apps/wpt” (as examples or demo drivers).
- Examples: as usage samples showing how the engine interacts with HTML/CSS inputs.

b. Relationships and Data Flow:
For instance, the “blitz” wrapper should be shown as consuming “blitz-dom”, “blitz-html”, “blitz-shell”, and “blitz-renderer-vello” (optionally through blitz-net).
- Core “blitz-dom” depending on “blitz-traits” and utilizing styling and layout engines (Stylo, Taffy, Parley).
- That “dioxus-native” similarly wraps around the core components and leverages Blitz’s modular pieces.
- That “blitz-net” interacts externally (HTTP networking via Reqwest) to fetch resources, which are then integrated into the HTML rendering pipeline.
- Integration of system-level modules (blitz-shell) with external libraries like Winit and AccessKit to manage windowing and accessibility support.

c. Architectural Patterns and Principles:
- Modularity and loose coupling: each crate handles a dedicated aspect of the rendering and windowing processes.
- Separation of concerns between the rendering engine (DOM manipulation and layout), parsing (HTML/CSS), rendering (Vello/WGPU), networking, and system integration (windowing, input).
- The layering can be depicted with high-level wrappers at the top, then the core engine components, and finally the additional specialized modules. This clarifies how the system remains extensible and replaceable.

d. Relevant Technologies:
- Component with its main external dependency (e.g., blitz-dom has Stylo, Taffy, Parley; blitz-renderer-vello shows Vello and WGPU).
- High-level wrappers (perhaps rounded rectangles)
- Core modules (standard rectangles)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% High-Level Wrappers
    subgraph "High-Level Wrappers"
        BLITZ("blitz"):::highLevel
        DIOXUS("dioxus-native"):::highLevel
    end

    %% Core Components
    subgraph "Core Components"
        DOM("blitz-dom"):::core
        TRAITS("blitz-traits"):::core
    end

    %% Additional Modules
    subgraph "Additional Modules"
        HTML("blitz-html"):::additional
        NET("blitz-net"):::additional
        RENDERER("blitz-renderer-vello"):::additional
        SHELL("blitz-shell"):::additional
    end

    %% External Libraries and Dependencies
    subgraph "External Libraries"
        STYLO("Stylo/Taffy"):::external
        PARLEY("Parley"):::external
        REQWEST("Reqwest"):::external
        HTML5EVER("html5ever"):::external
        VELLO("Vello"):::external
        WGPU("WGPU"):::external
        WINIT("Winit"):::external
        ACCESSKIT("AccessKit"):::external
    end

    %% Example Applications
    subgraph "Example Applications"
        README("readme"):::demo
        WPT("wpt"):::demo
    end

    %% Relationships - Application usage
    README -->|"uses"| BLITZ
    WPT -->|"uses"| BLITZ

    %% Relationships - High-Level Wrappers to Core/Modules
    BLITZ -->|"calls"| DOM
    BLITZ -->|"calls"| HTML
    BLITZ -->|"calls"| NET
    BLITZ -->|"calls"| RENDERER
    BLITZ -->|"calls"| SHELL

    DIOXUS -->|"calls"| DOM

    %% Relationships - Core Components details
    DOM -->|"depends_on"| TRAITS
    DOM -->|"uses"| STYLO
    DOM -->|"uses"| PARLEY

    %% Relationships - Additional Modules details
    NET -->|"fetches_with"| REQWEST
    HTML -->|"parses_with"| HTML5EVER
    RENDERER -->|"renders_with"| VELLO
    RENDERER -->|"renders_with"| WGPU
    SHELL -->|"handles_with"| WINIT
    SHELL -->|"handles_with"| ACCESSKIT

    %% Click Events
    click BLITZ "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz"
    click DIOXUS "https://github.com/dioxuslabs/blitz/tree/main/packages/dioxus-native"
    click DOM "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz-dom"
    click TRAITS "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz-traits"
    click HTML "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz-html"
    click NET "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz-net"
    click RENDERER "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz-renderer-vello"
    click SHELL "https://github.com/dioxuslabs/blitz/tree/main/packages/blitz-shell"
    click STYLO "https://github.com/dioxuslabs/blitz/tree/main/packages/stylo_taffy"
    click README "https://github.com/dioxuslabs/blitz/tree/main/apps/readme"
    click WPT "https://github.com/dioxuslabs/blitz/tree/main/apps/wpt"

    %% Styles
    classDef highLevel fill:#f9c74f,stroke:#000,stroke-width:2px,color:#000;
    classDef core fill:#90be6d,stroke:#000,stroke-width:2px,color:#000;
    classDef additional fill:#f8961e,stroke:#000,stroke-width:2px,color:#000;
    classDef external fill:#43aa8b,stroke:#000,stroke-width:2px,color:#fff;
    classDef demo fill:#f3722c,stroke:#000,stroke-width:2px,color:#000;
```
