# styly-dev/styly-spatial-layer-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/styly-dev/styly-spatial-layer-plugin
- Repository: https://github.com/styly-dev/styly-spatial-layer-plugin

## Overview

##### Main Components
- Core Unity Environment – This represents the entire Unity project, including the Assets folder (which holds sample scenes, shaders, interactions, XR configurations, and various visual examples) and ProjectSettings (which manage Unity-specific configuration like render pipelines, quality, and XR settings).
- STYLY Vision Pro Plugin – Divide this into two main layers:
◦ Editor Module: Contains components found in the “Packages/com.styly.styly-spatial-layer-plugin/Editor” directory. These are the tools for asset management (for example, Add-on installers, configuration tools, and menu items) and integration with the Unity Editor.
◦ Runtime Module: Found under “Packages/com.styly.styly-spatial-layer-plugin/Runtime” (including system info, URL parameter handling, utility classes, and Visual Scripting units). This module actually powers the built content while running in visionOS.
- Visual Scripting Components – Many Visual Scripting samples, nodes, and related assemblies (in both Editor and Runtime subdirectories) should be recognized as a separate collection that enhances how Unity content can be built without C# scripting. These nodes are integrated with Unity’s Visual Scripting system.
- External Dependencies & Tools – Include the following elements:
◦ Xcode (for visionOS simulator testing).
◦ STYLY content pipeline – The process that builds prefabs into .styly files (as seen by the built output in the _Output folder) and uploads them to a web service. Also include the external STYLY app for visionOS.

##### Relationships and Interactions
- The Unity Editor serves as the main development environment, hosting the STYLY Plugin both at design time (Editor modules, configuration menus, Visual Scripting design surfaces) and at runtime (plugin’s runtime functionality that interprets scene data/inputs).
- A clear boundary exists between the Editor components (used for creating and configuring visual content within Unity) and the Runtime components (packaged and built content that runs on STYLY for Vision Pro).
- The overall pipeline includes testing steps run through Unity’s play mode and integration with Xcode/Simulator, linking the Unity project to the testing environment (simulator).

##### Architectural Patterns and Design Principles
- Modular Design: The separation between Assets, Editor tools, Runtime logic, and Visual Scripting nodes reflects a clear modular architecture. Label these modules specifically.
- Separation of Concerns: Editor vs. Runtime separation is essential. The Editor module is only used during development, whereas the runtime module is part of the deployed package content.

##### Relevant Technologies, Frameworks, and Libraries
- Built-in Unity Visual Scripting framework enhanced by custom Visual Scripting nodes (as detailed by components in the Packages).
- VisionOS Build Support and the integration with Xcode for simulator testing.
- External dependencies like OpenUPM (for package management) are involved for plugin installation.

##### Specific Elements
- Clear labels for each module/component such as:
- Assets (Sample Scenes, Interactions, Visual Scripting nodes)
- Editor Tools (STYLY Plugin Editor, Menus, Config)
- Runtime Components (STYLY Plugin Runtime, Visual Scripting Units)
- Build & Upload Pipeline (Prefab build tool, .styly output, content upload service)
- External Systems (Unity Engine, Xcode/Simulator, STYLY Vision Pro App)
- Data flow from Editor to Runtime
- Build process and subsequent upload
- Interaction between Visual Scripting modules and runtime logic

- Do not oversimplify: each module should be specifically labeled with its Unity package/directory name where applicable (for example, “Packages/com.styly.styly-spatial-layer-plugin/Editor” and “Runtime”).
- Guarantee that architectural design principles (modular design, separation of concerns, layered architecture) are clearly captured.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Unity Environment
    subgraph "Core Unity Environment"
        A["Assets (Samples, Scenes, VisualScripting)"]:::unity
        B["ProjectSettings (Unity Config)"]:::unity
    end

    %% STYLY Vision Pro Plugin
    subgraph "STYLY Vision Pro Plugin"
        subgraph "Editor Module"
            C["STYLY Plugin Editor"]:::editor
            D["Visual Scripting (Editor)"]:::visual
        end
        subgraph "Runtime Module"
            E["STYLY Plugin Runtime"]:::runtime
            F["Visual Scripting (Runtime)"]:::visual
        end
    end

    %% Build & Upload Pipeline
    G["Build & Upload Pipeline"]:::pipeline

    %% External Systems
    I["Unity Engine (2022.3+ URP)"]:::external
    J["Xcode/Simulator"]:::external
    K["STYLY Vision Pro App"]:::external
    L(("STYLY Content Upload Service")):::external

    %% Relationships
    A -->|"supplies"| C
    A -->|"supplies"| E
    C -->|"contains"| D
    E -->|"contains"| F
    D -->|"integrates"| E
    E -->|"integrates"| D

    A -->|"triggers"| G
    G -->|"uploadsTo"| L
    L -->|"deliversTo"| K

    %% External testing & engine integration
    I -->|"drives"| A
    A -->|"testsWith"| J

    %% Styles
    classDef unity fill:#CFE2F3,stroke:#084298,stroke-width:2px;
    classDef editor fill:#FCE5CD,stroke:#B45F06,stroke-width:2px;
    classDef runtime fill:#D9EAD3,stroke:#38761D,stroke-width:2px;
    classDef visual fill:#FFF2CC,stroke:#BF9000,stroke-width:2px;
    classDef pipeline fill:#E2EFDA,stroke:#1C7C54,stroke-width:2px;
    classDef external fill:#D9D2E9,stroke:#5E3C99,stroke-width:2px;

    %% Click Events
    click A "https://github.com/styly-dev/styly-spatial-layer-plugin/tree/develop/Assets"
    click B "https://github.com/styly-dev/styly-spatial-layer-plugin/tree/develop/ProjectSettings"
    click C "https://github.com/styly-dev/styly-spatial-layer-plugin/tree/develop/Packages/com.styly.styly-spatial-layer-plugin/Editor"
    click D "https://github.com/styly-dev/styly-spatial-layer-plugin/tree/develop/Packages/com.styly.styly-spatial-layer-plugin/Editor/VisualScripting"
    click E "https://github.com/styly-dev/styly-spatial-layer-plugin/tree/develop/Packages/com.styly.styly-spatial-layer-plugin/Runtime"
    click F "https://github.com/styly-dev/styly-spatial-layer-plugin/tree/develop/Packages/com.styly.styly-spatial-layer-plugin/Runtime/VisualScripting"
```
