# nannou-org/nannou architecture

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

- Interactive diagram: https://gitdiagram.com/nannou-org/nannou
- Repository: https://github.com/nannou-org/nannou

## Overview

##### Project Type and Purpose
- nannou is a creative coding framework targeting artists and designers using Rust. Its goal is to provide an ecosystem (a collection of libraries, examples, and tools) for graphics, drawing, windowing, audio, UI integration, shader pipelines, and more.
- The README and file structure indicate that the project isn’t a single monolithic application. Instead, it includes multiple libraries (each in its own directory) that cover different areas (graphics, audio, OSC messaging, laser output, etc.), along with a large set of examples and guides.

##### Analyzing the File Structure
- Top-level directories include a number of sub-projects and libraries: “nannou”, “nannou_audio”, “nannou_core”, “nannou_egui”, “nannou_isf”, “nannou_laser”, “nannou_mesh”, “nannou_osc”, “nannou_package”, “nannou_wgpu”, and “nannou_new”. This indicates a modular, multi-library setup.
- Separate “examples”, “generative_design”, “nature_of_code” directories show how the libraries are used in practice.
- The “guide” directory provides tutorials and documentation about creating and managing nannou-based projects.
- Additionally, assets (fonts, images, sounds, shaders, etc.) indicate that media resources are also integral to creative coding applications.
- Configuration files (Cargo.toml, GitHub workflows) suggest continuous integration and modular Cargo workspace management.

a. Main Components:
- Core Framework:
– nannou: Main application framework (windowing, drawing, sketch management)
- Specialized Libraries:
– nannou_audio: Handles audio device management, audio streaming and processing.
– nannou_wgpu: Provides helpers around WGPU for rendering and GPU operations.
– nannou_egui: Integrates the egui UI framework with nannou apps.
– nannou_isf: Manages the interactive shader pipeline (ISF) functionality.
– nannou_laser: Deals with laser device integration and path optimization.
– nannou_mesh: Provides APIs for managing meshes.
– nannou_osc: Provides OSC messaging for external communication.
- Tools:
– nannou_new: A project generator tool.
– nannou_package: Packaging tools for distributing nannou applications.
- Examples and Guides:
– Directories “examples”, “generative_design”, and “nature_of_code” are sample applications that use one or more of the libraries.
– “guide” provides user/developer documentation and onboarding.

b. Relationships and Interactions:
- The core (nannou_core) supports nannou’s higher-level functionality, which in turn forms the base for many examples.
- nannou acts as the central component and uses the core library and optionally integrates with specialized libraries—for instance:
– nannou_wgpu for modern GPU rendering.
– nannou_audio for audio processing.
– nannou_egui for UI overlays.
– nannou_isf for shader effects.
– nannou_osc for network messaging.
- Tools like nannou_new and nannou_package depend on the core libraries to scaffold and package applications.

c. Important Architectural Patterns/Principles:
- Modular Design: Each functional area is encapsulated in its own library.
- Separation of Concerns: There is a clear separation between the core engine, specialized domain libraries (audio, UI, lasers, shaders), and user-facing examples/guides.
- Extensibility: Example projects and tools illustrate how the libraries can be extended or incorporated into new creative coding sketches.
- Reusability: The design supports reuse of critical components across various applications in the ecosystem.

d. Relevant Technologies and Frameworks:
- Rust language (cargo workspace management, Cargo.toml for dependencies)
- WGPU for GPU-based rendering (nannou_wgpu)
- egui (via nannou_egui) for UI design
- OSC protocol (nannou_osc) for data communication
- Graphics shader pipelines (nannou_isf, and shader assets provided in asset directories)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Framework
    subgraph "Core Framework"
        nannou_core["nannou_core\n(Lower-level utilities)"]
        nannou["nannou\n(Main framework)"]
    end

    %% Specialized Libraries
    subgraph "Specialized Libraries"
        nannou_audio["nannou_audio\n(Audio processing)"]
        nannou_wgpu["nannou_wgpu\n(GPU rendering helper)"]
        nannou_egui["nannou_egui\n(UI integration)"]
        nannou_isf["nannou_isf\n(Interactive shader pipeline)"]
        nannou_laser["nannou_laser\n(Laser integration)"]
        nannou_mesh["nannou_mesh\n(Mesh management)"]
        nannou_osc["nannou_osc\n(OSC messaging)"]
    end

    %% Tools
    subgraph "Tools"
        nannou_new["nannou_new\n(Project generator)"]
        nannou_package["nannou_package\n(Packaging tool)"]
    end

    %% Examples and Guides
    subgraph "Examples & Guides"
        examples["Examples\n(Demo & Sample projects)"]
        guide["Guide\n(Documentation & Tutorials)"]
    end

    %% Relationships
    %% Core relationship: nannou uses nannou_core
    nannou -->|"uses"| nannou_core

    %% nannou integrates with specialized libraries
    nannou -->|"integrates"| nannou_audio
    nannou -->|"integrates"| nannou_wgpu
    nannou -->|"integrates"| nannou_egui
    nannou -->|"integrates"| nannou_isf
    nannou -->|"integrates"| nannou_laser
    nannou -->|"integrates"| nannou_mesh
    nannou -->|"integrates"| nannou_osc

    %% Tools depend on core framework
    nannou_new -->|"scaffolds"| nannou
    nannou_new -->|"scaffolds"| nannou_core
    nannou_package -->|"packages"| nannou
    nannou_package -->|"packages"| nannou_core

    %% Examples and Guides use the libraries
    examples -->|"demonstrates"| nannou
    guide -->|"documents"| nannou

    %% Styles
    classDef core fill:#cce5ff,stroke:#007bff,stroke-width:2px;
    classDef specialized fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef tools fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef example fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef guide fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;

    class nannou_core,nannou core;
    class nannou core;
    class nannou_audio,nannou_wgpu,nannou_egui,nannou_isf,nannou_laser,nannou_mesh,nannou_osc specialized;
    class nannou_new,nannou_package tools;
    class examples example;
    class guide guide;

    %% Click Events
    click nannou "https://github.com/nannou-org/nannou/tree/master/nannou/"
    click nannou_core "https://github.com/nannou-org/nannou/tree/master/nannou_core/"
    click nannou_audio "https://github.com/nannou-org/nannou/tree/master/nannou_audio/"
    click nannou_wgpu "https://github.com/nannou-org/nannou/tree/master/nannou_wgpu/"
    click nannou_egui "https://github.com/nannou-org/nannou/tree/master/nannou_egui/"
    click nannou_isf "https://github.com/nannou-org/nannou/tree/master/nannou_isf/"
    click nannou_laser "https://github.com/nannou-org/nannou/tree/master/nannou_laser/"
    click nannou_mesh "https://github.com/nannou-org/nannou/tree/master/nannou_mesh/"
    click nannou_osc "https://github.com/nannou-org/nannou/tree/master/nannou_osc/"
    click nannou_new "https://github.com/nannou-org/nannou/tree/master/nannou_new/"
    click nannou_package "https://github.com/nannou-org/nannou/tree/master/nannou_package/"
    click examples "https://github.com/nannou-org/nannou/tree/master/examples/"
    click guide "https://github.com/nannou-org/nannou/tree/master/guide/"
```
