# boscohyun/rxpresenter architecture

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

- Interactive diagram: https://gitdiagram.com/boscohyun/rxpresenter
- Repository: https://github.com/boscohyun/rxpresenter

## Overview

##### Project Type and Purpose
- Project Type: A Unity plugin/library for handling presenter/view interactions in a reactive manner using the MVP pattern.
- Purpose: To streamline Unity UI/scene presentation logic by encapsulating show/hide behavior (with animation support) into Presenter and ReactivePresenter components that leverage reactive streams and asynchronous operations.

##### File Structure
- Top-Level Directories:
- Assets/Plugins: Contains the core plugin (RxPresenter) files plus subfolders segregating runtime scripts, examples, animators, and tests.
- Assets/Plugins/RxPresenter-Examples: Houses several examples that demonstrate different usages – e.g., “00-Common”, “01-Show and Hide Presenter”, “02-DOTween” – showcasing how to control presenters.
- Assets/Plugins/RxPresenter/Scripts/Runtime: Contains the core runtime implementations like Presenter.cs, ReactivePresenter.cs, IView, IViewAnimator, and other related interfaces/classes.
- Assets/Plugins/RxPresenter/External: Contains integrations with external libraries (e.g., DOTween) and their view animator scripts.
- Assets/Plugins/RxPresenter/Tests: Contains EditMode unit tests that verify the functionality.
- Configuration files and assembly definitions (*.asmdef) indicate module separations for Unity’s compilation pipeline.

##### Extract Additional README Insights
- The README tells us the project implements reactive behavior on top of the traditional MVP structure, detailing how to show or hide presenters with animations.
- It illustrates sample usages, channelling animations (Unity Animator/DOTween) and showing how callback-based, observable, or async-await patterns can be used.

##### Main Components and Their Relationships
- Core Plugin Modules:
- Presenter (handles basic show/hide operations)
- ReactivePresenter (extends Presenter with reactive stream handling, exposing observable hooks)
- IPresenter, IReactivePresenter, IView, IViewAnimator (interfaces that drive contract definitions and allow different implementations)
- Animation Support:
- AnimatorViewAnimator, AnimatorReactivePresenter (Unity Animator-based animations)
- DOTweenViewAnimator, DOTweenPresenter, DOTweenReactivePresenter (integrate DOTween for animations)
- Example Scenes/Components:
- Example scene controllers (e.g., ExampleSceneController.cs), example scenes in “01-Show and Hide Presenter” and “02-DOTween”
- Common components like TextButton.cs and TextButtonEditor.cs (for UI/demo purposes)
- External Dependencies:
- DOTween: As an external support library for certain Animator-related implementations.
- Test Modules:
- Nodes representing unit tests from “Assets/Plugins/RxPresenter/Tests/EditMode”, which validate the behavior of presenters and animators.

##### Relationships and Interactions
- Control flow from user input or scene events (via example controllers) to presenters to trigger show/hide animations.
- Communication between presenters and their associated view animators (IViewAnimator implementations) for executing animations.
- The reactive/event-driven flow using UniRx for state changes (e.g., OnShowAnimationBeginning, OnShowAnimationEnd, etc.) via subscription.
- Asynchronous flows using UniTask for waiting on show/hide operations.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Plugin Modules
    subgraph "Core Plugin Modules"
        IPresenter["IPresenter Interface"]:::core
        IReactivePresenter["IReactivePresenter Interface"]:::core
        IView["IView Interface"]:::core
        IViewAnimator["IViewAnimator Interface"]:::core
        Presenter["Presenter"]:::core
        ReactivePresenter["ReactivePresenter"]:::core
    end

    %% Animator Implementations
    subgraph "Animator Modules"
        AnimatorPresenter["AnimatorPresenter"]:::animator
        AnimatorReactivePresenter["AnimatorReactivePresenter"]:::animator
        AnimatorViewAnimator["AnimatorViewAnimator"]:::animator
    end

    %% DOTween Implementations
    subgraph "DOTween Modules"
        DOTweenPresenter["DOTweenPresenter"]:::dotween
        DOTweenReactivePresenter["DOTweenReactivePresenter"]:::dotween
        DOTweenViewAnimator["DOTweenViewAnimator"]:::dotween
    end

    %% Examples Section
    subgraph "Examples"
        ExampleScene["ExampleSceneController"]:::examples
        VanillaPresenter["VanillaPresenter"]:::examples
        VanillaReactivePresenter["VanillaReactivePresenter"]:::examples
        DOTweenExamples["DOTween Examples"]:::examples
    end

    %% Tests Section
    subgraph "Tests"
        UnitTests["Unit Tests"]:::tests
    end

    %% External Dependencies
    subgraph "External Dependencies"
        UniRx["UniRx"]:::external
        UniTask["UniTask"]:::external
        DOTweenLib["DOTween Library"]:::external
    end

    %% Relationships within Core Modules
    Presenter -->|"implements"| IPresenter
    ReactivePresenter -->|"implements"| IReactivePresenter
    Presenter -->|"updates"| IView
    Presenter -->|"controls"| IViewAnimator
    ReactivePresenter -->|"updates"| IView
    ReactivePresenter -->|"controls"| IViewAnimator

    %% Relationships from Core to Implementations
    AnimatorPresenter -->|"extends"| Presenter
    AnimatorReactivePresenter -->|"extends"| ReactivePresenter
    AnimatorViewAnimator -->|"implements"| IViewAnimator

    DOTweenPresenter -->|"extends"| Presenter
    DOTweenReactivePresenter -->|"extends"| ReactivePresenter
    DOTweenViewAnimator -->|"implements"| IViewAnimator

    %% Relationships with External Dependencies
    UniRx ---|"supports"| ReactivePresenter
    UniTask ---|"supports"| ReactivePresenter
    DOTweenLib ---|"integrates_with"| DOTweenPresenter
    DOTweenLib ---|"integrates_with"| DOTweenReactivePresenter
    DOTweenLib ---|"integrates_with"| DOTweenViewAnimator

    %% Relationships with Examples
    ExampleScene -->|"triggers"| Presenter
    ExampleScene -->|"triggers"| ReactivePresenter
    VanillaPresenter -->|"uses"| Presenter
    VanillaReactivePresenter -->|"uses"| ReactivePresenter
    DOTweenExamples -->|"demonstrates"| DOTweenPresenter
    DOTweenExamples -->|"demonstrates"| DOTweenReactivePresenter
    DOTweenExamples -->|"demonstrates"| DOTweenViewAnimator

    %% Relationships with Tests
    UnitTests -->|"validates"| Presenter
    UnitTests -->|"validates"| ReactivePresenter
    UnitTests -->|"validates"| IViewAnimator

    %% Styling Classes
    classDef core fill:#f9e79f,stroke:#A569BD,stroke-width:2px;
    classDef animator fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef dotween fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef examples fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef tests fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;

    %% Click Events for Core Plugin Modules
    click Presenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/Presenter.cs"
    click ReactivePresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/ReactivePresenter.cs"
    click IPresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/IPresenter.cs"
    click IReactivePresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/IReactivePresenter.cs"
    click IView "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/IView.cs"
    click IViewAnimator "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/IViewAnimator.cs"

    %% Click Events for Animator Implementations
    click AnimatorPresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/AnimatorPresenter.cs"
    click AnimatorReactivePresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/AnimatorReactivePresenter.cs"
    click AnimatorViewAnimator "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/Scripts/Runtime/AnimatorViewAnimator.cs"

    %% Click Events for DOTween Implementations
    click DOTweenPresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/External/DOTween/Scripts/DOTweenPresenter.cs"
    click DOTweenReactivePresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/External/DOTween/Scripts/DOTweenReactivePresenter.cs"
    click DOTweenViewAnimator "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter/External/DOTween/Scripts/DOTweenViewAnimator.cs"

    %% Click Events for Examples
    click ExampleScene "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter-Examples/00-Common/ExampleSceneController.cs"
    click VanillaPresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter-Examples/01-Show and Hide Presenter/VanillaPresenter.cs"
    click VanillaReactivePresenter "https://github.com/boscohyun/rxpresenter/blob/main/Assets/Plugins/RxPresenter-Examples/01-Show and Hide Presenter/VanillaReactivePresenter.cs"
    click DOTweenExamples "https://github.com/boscohyun/rxpresenter/tree/main/Assets/Plugins/RxPresenter-Examples/02-DOTween/"

    %% Click Event for Tests
    click UnitTests "https://github.com/boscohyun/rxpresenter/tree/main/Assets/Plugins/RxPresenter/Tests/EditMode/"
```
