# haruma-k/addler architecture

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

- Interactive diagram: https://gitdiagram.com/haruma-k/addler
- Repository: https://github.com/haruma-k/addler

## Overview

##### Core Components
- Lifetime Binding System
- Preloading System
- Object Pooling System

- Addler                                            |

- Lifetime Binding |  |      Preloading     |  |        Object Pooling    |          |

##### Component Details

a. Lifetime Binding System:
- IReleaseEvent interface
- To implementations (MonoBehaviourBasedReleaseEvent, ParticleSystemBasedReleaseEvent)
- Binding relationship with Unity GameObjects

b. Preloading System:
- AddressablePreloader class
- Connection to Unity's Addressable system
- Preload and synchronous retrieval flow

c. Object Pooling System:
- AddressablePool class
- Pool management flow
- Instance lifecycle

##### Specific relationships
- GameObject -----> IReleaseEvent <----- LifetimeBinding
- AddressablePreloader -----> Addressables
- AddressablePool -----> Addressables

##### Important notes
- UniTask integration as optional
- Compile-time switches (ADDLER_DISABLE_PRELOADING, ADDLER_DISABLE_POOLING)
- Async/sync operations

##### Optional features and integration points

- Core Systems: Blue
- Unity Integration: Green
- External Dependencies: Orange
- Optional Features: Gray

- Special symbols (if any)
- Optional feature indicators

This will provide a clear visualization of how Addler manages memory and integrates with Unity's systems while maintaining proper separation of concerns and showing the relationships between components.

Remember to show both compile-time and runtime relationships, and indicate where async operations occur versus sync operations. This is particularly important for the preloading system's behavior.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Addler
        subgraph LifetimeBindingSystem["Lifetime Binding System"]
            IReleaseEvent["IReleaseEvent Interface"]:::interface
            MonoEvent["MonoBehaviourBased ReleaseEvent"]:::implementation
            ParticleEvent["ParticleSystemBased ReleaseEvent"]:::implementation
            AnonEvent["Anonymous ReleaseEvent"]:::implementation
            
            IReleaseEvent --> MonoEvent
            IReleaseEvent --> ParticleEvent
            IReleaseEvent --> AnonEvent
        end

        subgraph PreloadingSystem["Preloading System"]
            Preloader["AddressablePreloader"]:::core
            PreloaderExt["Preloader Extensions"]:::extension
            PreloaderUniTask["UniTask Integration"]:::optional
            
            Preloader --> PreloaderExt
            Preloader -.-> PreloaderUniTask
        end

        subgraph PoolingSystem["Object Pooling System"]
            Pool["AddressablePool"]:::core
            PoolExt["Pool Extensions"]:::extension
            PoolUniTask["UniTask Integration"]:::optional
            PooledObj["Pooled Object"]:::core
            
            Pool --> PoolExt
            Pool -.-> PoolUniTask
            Pool --> PooledObj
        end
    end

    UnityGO["Unity GameObject"]:::unity
    Addressables["Unity Addressables"]:::external
    
    UnityGO --> IReleaseEvent
    Preloader --> Addressables
    Pool --> Addressables

    %% Click events for file navigation
    click IReleaseEvent "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/LifetimeBinding/IReleaseEvent.cs"
    click MonoEvent "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/LifetimeBinding/MonoBehaviourBasedReleaseEvent.cs"
    click ParticleEvent "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/LifetimeBinding/ParticleSystemBasedReleaseEvent.cs"
    click AnonEvent "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/LifetimeBinding/AnonymousReleaseEvent.cs"
    click Preloader "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Preloading/AddressablePreloader.cs"
    click PreloaderUniTask "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Preloading/AddressablePreloader.UniTask.cs"
    click PreloaderExt "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Preloading/AddressablePreloaderExtensions.cs"
    click Pool "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Pooling/AddressablePool.cs"
    click PoolUniTask "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Pooling/AddressablePool.UniTask.cs"
    click PoolExt "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Pooling/AddressablePoolExtensions.cs"
    click PooledObj "https://github.com/Haruma-K/Addler/blob/master/Assets/Addler/Runtime/Core/Pooling/PooledObject.cs"
    
    %% Style definitions
    classDef core fill:#2374ab
    classDef interface fill:#457b9d
    classDef implementation fill:#a8dadc
    classDef extension fill:#48cae4
    classDef optional fill:#adb5bd,stroke-dasharray: 5 5
    classDef unity fill:#52b788
    classDef external fill:#e76f51
```
