# sirspam/nya architecture

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

## Overview

##### Main Components
- Plugin & Core Mod Initialization:
- Main entry point in Plugin.cs.
- Installers (NyaAppInstaller, NyaGameInstaller, NyaMenuInstaller) as they handle dependency injection setup.
- Configuration & API Management:
- Configuration folder (EndpointData.cs, PluginConfig.cs) which stores endpoint configurations.
- ImageSourcesManager (found in Managers) and associated Entries.
- UI Components:
- UI folder structure: FlowCoordinators, ViewControllers (for modal dialogs like Settings, GitHub page, nsfw confirm, etc.), and the Views defined in .bsml files.
- That UI elements interact with the mod’s settings and image display functionality.
- Core Functionalities:
- AffinityPatches (which are possibly runtime patches to modify the game behavior).
- Utility & Helpers:
- Utils (FloatingScreenUtils, ImageUtils, UIUtils, WebUtils) that support the mod’s operations such as image processing, web operations, or UI adjustments.
- Resources & Assets:
- Resources folder and manifest.json that likely bundle assets (such as the nya.bundle) needed by the mod.

##### Relationships and Interactions
- Dependency Injection Flow:
- UI Interaction Flow:
- How interface elements (FlowCoordinators and ViewControllers) interact with the Components to trigger image fetches, settings changes, or to reset positions for the floating screen.
- Data & Configuration Handling:
- Out how Configuration classes feed into both ImageSourcesManager and the Installer’s dependency injection configurations.
- Integration with External APIs:
- Connection between the JSON configuration (ImageSourcesJsonLink in Plugin.cs) and how ImageSourcesManager fetches API endpoints.

##### Architectural Patterns and Key Technologies
- Layers and Separation of Concerns:
- MVC or MVVM-like Structure in UI:
- That the UI folder contains both controllers and views (the bsml files support a declarative view framework), which suggests a clear separation between graphical presentation and logic.
- Dependency Injection:
- Since the project uses installer classes (probably leveraging frameworks like SiraUtil), highlight this as a key pattern for managing dependencies.
- External and Local Data Sources:
- That the mod consumes external web APIs (via JSON configurations) as well as local file directories managed through its configuration and entries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Mod Initialization
    subgraph "Core Mod Initialization"
        PLUGIN["Plugin.cs"]:::plugin
        subgraph "Installers"
            INSTALLER1["NyaAppInstaller"]:::installers
            INSTALLER2["NyaGameInstaller"]:::installers
            INSTALLER3["NyaMenuInstaller"]:::installers
        end
    end

    %% Configuration & API Management
    subgraph "Configuration & API Management"
        CONFIG["Configuration"]:::config
        subgraph "Entries"
            ENTRY1["CommentedImageSourcesEntries"]:::entries
            ENTRY2["ImageSourceEntry"]:::entries
            ENTRY3["NyaImageInfo"]:::entries
        end
    end

    %% Managers
    subgraph "Managers"
        MANAGER["ImageSourcesManager"]:::managers
    end

    %% UI Components
    subgraph "UI Components"
        subgraph "Flow Coordinators"
            FLOW["NyaSettingsFlowCoordinator"]:::ui
        end
        subgraph "View Controllers"
            VIEWCTRL["ViewControllers"]:::ui
        end
        subgraph "Views"
            VIEWS["BSML Views"]:::ui
        end
    end

    %% Core Functionalities
    subgraph "Core Functionalities"
        COMP1["NyaGameplaySetupTabActiveHandler"]:::components
        COMP2["NyaSettingsClickableImage"]:::components
        PATCH["GoodBoyPatch (AffinityPatches)"]:::components
    end

    %% Utility & Helpers
    subgraph "Utility & Helpers"
        UTIL1["FloatingScreenUtils"]:::utils
        UTIL2["ImageUtils"]:::utils
        UTIL3["UIUtils"]:::utils
        UTIL4["WebUtils"]:::utils
    end

    %% Resources & Assets
    subgraph "Resources & Assets"
        RES1["nya.bundle"]:::resources
        RES2["manifest.json"]:::resources
    end

    %% Relationships
    %% Initialization and Dependency Injection Flow
    PLUGIN -->|"invokes"| INSTALLER1
    PLUGIN -->|"invokes"| INSTALLER2
    PLUGIN -->|"invokes"| INSTALLER3
    INSTALLER1 -->|"injects"| CONFIG
    INSTALLER1 -->|"injects"| MANAGER

    %% Configuration feeding into Managers and Entries
    CONFIG -->|"provides"| ENTRY1
    CONFIG -->|"provides"| ENTRY2
    CONFIG -->|"provides"| ENTRY3
    CONFIG -->|"fetchesEndpoints"| MANAGER

    %% UI Interaction Flow
    FLOW -->|"updatesSettings"| MANAGER
    VIEWCTRL -->|"triggers"| COMP2
    VIEWS -->|"displays"| COMP2

    %% Core Functionalities interacting with Utils
    COMP1 -->|"adjustsFloatingScreen"| UTIL1
    COMP2 -->|"updatesUI"| UTIL3
    MANAGER -->|"callsWebOps"| UTIL4
    MANAGER -->|"processesImages"| UTIL2

    %% UI Components interaction with Core Functionalities
    VIEWCTRL -->|"triggersImageFetch"| MANAGER

    %% Click Events
    click PLUGIN "https://github.com/sirspam/nya/blob/main/Nya/Plugin.cs"
    click INSTALLER1 "https://github.com/sirspam/nya/blob/main/Nya/Installers/NyaAppInstaller.cs"
    click INSTALLER2 "https://github.com/sirspam/nya/blob/main/Nya/Installers/NyaGameInstaller.cs"
    click INSTALLER3 "https://github.com/sirspam/nya/blob/main/Nya/Installers/NyaMenuInstaller.cs"
    click CONFIG "https://github.com/sirspam/nya/tree/main/Nya/Configuration"
    click MANAGER "https://github.com/sirspam/nya/blob/main/Nya/Managers/ImageSourcesManager.cs"
    click ENTRY1 "https://github.com/sirspam/nya/blob/main/Nya/Entries/CommentedImageSourcesEntries.cs"
    click ENTRY2 "https://github.com/sirspam/nya/blob/main/Nya/Entries/ImageSourceEntry.cs"
    click ENTRY3 "https://github.com/sirspam/nya/blob/main/Nya/Entries/NyaImageInfo.cs"
    click FLOW "https://github.com/sirspam/nya/blob/main/Nya/UI/FlowCoordinators/NyaSettingsFlowCoordinator.cs"
    click VIEWCTRL "https://github.com/sirspam/nya/tree/main/Nya/UI/ViewControllers"
    click VIEWS "https://github.com/sirspam/nya/tree/main/Nya/UI/Views"
    click COMP1 "https://github.com/sirspam/nya/blob/main/Nya/Components/NyaGameplaySetupTabActiveHandler.cs"
    click COMP2 "https://github.com/sirspam/nya/blob/main/Nya/Components/NyaSettingsClickableImage.cs"
    click PATCH "https://github.com/sirspam/nya/blob/main/Nya/AffinityPatches/GoodBoyPatch.cs"
    click UTIL1 "https://github.com/sirspam/nya/blob/main/Nya/Utils/FloatingScreenUtils.cs"
    click UTIL2 "https://github.com/sirspam/nya/blob/main/Nya/Utils/ImageUtils.cs"
    click UTIL3 "https://github.com/sirspam/nya/blob/main/Nya/Utils/UIUtils.cs"
    click UTIL4 "https://github.com/sirspam/nya/blob/main/Nya/Utils/WebUtils.cs"
    click RES1 "https://github.com/sirspam/nya/blob/main/Nya/Resources/nya.bundle"
    click RES2 "https://github.com/sirspam/nya/blob/main/Nya/manifest.json"

    %% Styles
    classDef plugin fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef installers fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef config fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef managers fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef entries fill:#FFDEAD,stroke:#333,stroke-width:2px;
    classDef ui fill:#DDA0DD,stroke:#333,stroke-width:2px;
    classDef components fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef utils fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef resources fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
