# emre-emiroglu/hmmodelviewcontroller architecture

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

- Interactive diagram: https://gitdiagram.com/emre-emiroglu/hmmodelviewcontroller
- Repository: https://github.com/emre-emiroglu/hmmodelviewcontroller

## Overview

##### Project type and purpose
- This is a Unity-compatible UPM package providing a generic Model-View-Controller framework, augmented with a Mediator layer, to help Unity developers cleanly separate data, UI, and logic. It ships as a standalone library (see package.json, asmdef files) and comes with EditMode and PlayMode tests.

##### File structure
Top level
- package.json / README.md / LICENSE.md / CHANGELOG.md → defines the UPM package metadata
- Runtime/CodeCatGames.HMModelViewController.Runtime.asmdef → Unity assembly definition for runtime code
- Tests/EditMode/*.asmdef and Tests/PlayMode/*.asmdef → assemblies for unit and play mode tests
Runtime folder
- Interfaces: IModel<TSettings>, IView, IMediator<TModel,TSettings,TView>, IController<TModel,TSettings,TView>
- Base classes: Model<TSettings>, View, Mediator<TModel,TSettings,TView>, Controller<TModel,TSettings,TView>
- Concrete wiring (Controller.cs, Mediator.cs, Model.cs, View.cs) implement the generic contracts
Tests folder
- EditMode tests verify model/view/controller behavior in the editor
- PlayMode tests verify runtime interactions

##### Key insights from the README
- Core patterns: MVC + Mediator
- Extensibility via generic interfaces
- Usage: developers subclass Model, View, Mediator, Controller to implement application-specific logic

##### Elements
- Interfaces (e.g., light blue rectangles)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UPM Package Metadata
    subgraph "UPM Package Metadata"
        direction TB
        pkgJSON["package.json"]:::metadata
        readme["README.md"]:::metadata
        license["LICENSE.md"]:::metadata
        changelog["CHANGELOG.md"]:::metadata
    end

    %% Runtime Assembly
    subgraph "Runtime Assembly (CodeCatGames.HMModelViewController.Runtime)" 
        direction TB
        asmdef["Runtime/CodeCatGames.HMModelViewController.Runtime.asmdef"]:::asmdef

        subgraph "Interfaces" 
            direction TB
            IModel["IModel<TSettings>"]:::interface
            IView["IView"]:::interface
            IMediator["IMediator<TModel,TSettings,TView>"]:::interface
            IController["IController<TModel,TSettings,TView>"]:::interface
        end

        subgraph "Base Classes"
            direction TB
            ModelBase["Model<TSettings>"]:::baseclass
            ViewBase["View"]:::baseclass
            MediatorBase["Mediator<TModel,TSettings,TView>"]:::baseclass
            ControllerBase["Controller<TModel,TSettings,TView>"]:::baseclass
        end
    end

    %% Client Code Extensibility
    subgraph "Client Code (Game-specific Subclasses)"
        direction TB
        MySettings["MySettings"]:::subclass
        MyModel["MyModel"]:::subclass
        MyView["MyView"]:::subclass
        MyMediator["MyMediator"]:::subclass
        MyControllerOne["MyControllerOne"]:::subclass
        MyControllerTwo["MyControllerTwo"]:::subclass
    end

    %% Test Assemblies
    subgraph "Tests"
        direction TB
        subgraph "EditMode Tests"
            direction TB
            editAsmdef["CodeCatGames.HMModelViewController.Tests.EditMode.asmdef"]:::test
            editTests["ModelViewControllerEditModeTests.cs"]:::test
        end
        subgraph "PlayMode Tests"
            direction TB
            playAsmdef["CodeCatGames.HMModelViewController.Tests.PlayMode.asmdef"]:::test
            playTests["ModelViewControllerPlayModeTests.cs"]:::test
        end
    end

    %% Relationships within Runtime
    ControllerBase -->|"LoadData()/SaveData()"| ModelBase
    ModelBase -->|"OnDataChanged()"| MediatorBase
    MediatorBase -->|"Show()/Hide()"| ViewBase
    ViewBase -->|"UIEvent()"| MediatorBase
    MediatorBase -->|"Execute()"| ControllerBase

    %% Client Code extends Runtime
    MyModel -->|implements| IModel
    MyModel -->|inherits| ModelBase
    MyView -->|implements| IView
    MyView -->|inherits| ViewBase
    MyMediator -->|implements| IMediator
    MyMediator -->|inherits| MediatorBase
    MyControllerOne -->|implements| IController
    MyControllerOne -->|inherits| ControllerBase
    MyControllerTwo -->|implements| IController
    MyControllerTwo -->|inherits| ControllerBase

    %% Tests reference Runtime
    editAsmdef -->|references| asmdef
    editTests -->|runs against| asmdef
    playAsmdef -->|references| asmdef
    playTests -->|runs against| asmdef

    %% Click Events
    click pkgJSON "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/package.json"
    click readme "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/README.md"
    click license "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/LICENSE.md"
    click changelog "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/CHANGELOG.md"
    click asmdef "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/CodeCatGames.HMModelViewController.Runtime.asmdef"
    click IModel "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/IModel.cs"
    click IView "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/IView.cs"
    click IMediator "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/IMediator.cs"
    click IController "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/IController.cs"
    click ModelBase "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/Model.cs"
    click ViewBase "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/View.cs"
    click MediatorBase "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/Mediator.cs"
    click ControllerBase "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Runtime/Controller.cs"
    click editAsmdef "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Tests/EditMode/CodeCatGames.HMModelViewController.Tests.EditMode.asmdef"
    click editTests "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Tests/EditMode/ModelViewControllerEditModeTests.cs"
    click playAsmdef "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Tests/PlayMode/CodeCatGames.HMModelViewController.Tests.PlayMode.asmdef"
    click playTests "https://github.com/emre-emiroglu/hmmodelviewcontroller/blob/main/Tests/PlayMode/ModelViewControllerPlayModeTests.cs"

    %% Styles
    classDef metadata fill:#D4C5E2,stroke:#7E57C2,color:#000,stroke-width:1px;
    classDef asmdef fill:#E8F0FE,stroke:#1967D2,color:#000,stroke-width:1px;
    classDef interface fill:#BBDEFB,stroke:#1E88E5,color:#000,stroke-width:1px;
    classDef baseclass fill:#90CAF9,stroke:#1565C0,color:#000,stroke-width:1px,stroke-dasharray: 5 5;
    classDef subclass fill:#C8E6C9,stroke:#388E3C,color:#000,stroke-width:1px;
    classDef test fill:#E0E0E0,stroke:#757575,color:#000,stroke-width:1px;
```
