# immersal/imdk-unity architecture

> Architecture diagram of the GitHub repository immersal/imdk-unity, 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/immersal/imdk-unity
- Repository: https://github.com/immersal/imdk-unity

## Overview

The Immersal SDK Core project is a Unity package designed for augmented reality (AR) mapping and localization, built on Unity (2022.3 LTS and AR Foundation 5.1+). The package is split primarily into Editor components (for tooling and editor integration) and Runtime components (which include core functionality, plugins, and resource assets). In addition, there is a Samples~/ folder that provides demo scenes, scripts, and resources for testing and illustrating how the SDK works in practice.

##### Main Components
- Editor Module: Contains all scripts, utilities, and custom editors (e.g., Localization editors, validation components, and specialized UI drawers) to integrate the SDK with the Unity Editor.
- Runtime Module: Includes core assembly definitions, library scripts, and plugins for different platforms (Android, iOS, WSA, x86_64). Also contains assets such as shaders, prefabs, and resources that are loaded during application runtime.
- Platform Plugins: Separate directories under Runtime/Plugins for Android, iOS, WSA, etc., encapsulating native bindings and platform-specific functionality.
- Samples/Examples: Demonstration projects and scenes (e.g., ContentPlacementSample, NavigationSample, etc.) that show how to use the SDK’s features. These provide a practical view of how the components interact.
- Supporting Assets: Resources such as fonts, materials, models, textures, shaders, and sounds used by both runtime and sample scenes.

##### Relationships and Interactions
- The Editor module and its tools (found in the Editor folder) integrate closely with the Unity Editor environment, providing user interfaces, project validations and custom inspectors to facilitate proper setup and configuration of the AR functionalities.
- The Runtime module is the heart of the SDK. Its assembly definitions (asmdef files) and code files (under Runtime/Scripts) implement the core AR session management, mapping, data processing (such as filtering and localization), and interfaces for platform-specific operations.
- Runtime/Plugins host native libraries that bridge Unity with platform-specific SDKs (e.g., Android's AAR files, iOS native libraries) ensuring proper AR and mapping integrations.
- Samples serve as a showcase on how the runtime components (and possibly settings configured via the Editor scripts) work together to deliver an AR experience.

##### Architectural Patterns and Design Principles
- Separation of concerns: The division between Editor and Runtime code is clear, ensuring tools used during development do not pollute the final runtime build.
- Plugin-based architecture: With platform-specific plugins, the project demonstrates an extensible design to support multiple operating environments.
- Modular design via Assembly Definitions: asmdef files in both Editor and Runtime directories help encapsulate behaviors and simplify dependency management.
- Interfaces and abstraction: Several interfaces (e.g., ILocalizer, IImmersalSession) in the XR folder clearly promote loose coupling between system components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Editor Module
    subgraph "Editor Module"
        E["Editor Tools & Scripts"]:::editor
    end

    %% Runtime Module
    subgraph "Runtime Module"
        R["Runtime Core"]:::runtime
    end

    %% Platform Plugins
    subgraph "Platform Plugins"
        A["Android Plugins"]:::plugin
        I["iOS Plugins"]:::plugin
        W["WSA Plugins"]:::plugin
        X["x86_64 Plugins"]:::plugin
    end

    %% Supporting Assets
    subgraph "Resources & Assets"
        RES["Resources & Assets"]:::assets
    end

    %% Samples/Examples
    subgraph "Samples/Examples"
        C["ContentPlacementSample"]:::samples
        N["NavigationSample"]:::samples
    end

    %% Connections
    E -->|"configure"| R
    R -->|"native_calls"| A
    R -->|"native_calls"| I
    R -->|"native_calls"| W
    R -->|"native_calls"| X
    R -->|"loads"| RES
    C -->|"demonstrates"| R
    C -->|"uses"| RES
    N -->|"demonstrates"| R
    N -->|"uses"| RES

    %% Click Events
    click E "https://github.com/immersal/imdk-unity/tree/main/Editor"
    click R "https://github.com/immersal/imdk-unity/tree/main/Runtime"
    click A "https://github.com/immersal/imdk-unity/tree/main/Runtime/Plugins/Android"
    click I "https://github.com/immersal/imdk-unity/tree/main/Runtime/Plugins/iOS"
    click W "https://github.com/immersal/imdk-unity/tree/main/Runtime/Plugins/WSA"
    click X "https://github.com/immersal/imdk-unity/tree/main/Runtime/Plugins/x86_64"
    click RES "https://github.com/immersal/imdk-unity/tree/main/Runtime/Resources"
    click C "https://github.com/immersal/imdk-unity/tree/main/Samples~/"
    click N "https://github.com/immersal/imdk-unity/tree/main/Samples~/"

    %% Styles
    classDef editor fill:#f9d6cc,stroke:#d96e56,stroke-width:2px;
    classDef runtime fill:#d0e6a5,stroke:#88b04b,stroke-width:2px;
    classDef plugin fill:#add8e6,stroke:#4682b4,stroke-width:2px;
    classDef assets fill:#ffe699,stroke:#d4af37,stroke-width:2px;
    classDef samples fill:#e3d1ff,stroke:#9b59b6,stroke-width:2px;
```
