# novack/dbeditor architecture

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

- Interactive diagram: https://gitdiagram.com/novack/dbeditor
- Repository: https://github.com/novack/dbeditor

## Overview

##### Project type and purpose
- Type: Unity Editor extension / plugin
- Purpose: Provide a custom Editor window (“DBEditor”) inside the Unity Editor that displays and organizes ScriptableObject assets in a flexible tree hierarchy, with toolbar actions and an integrated inspector for editing.

##### File structure
- Top level:
– Assets/… contains the plugin source, resources, example/test data
– Packages/… contains this as a Unity Package (com.unity.package-manager-ui appears in tree but main code lives under Assets)
– ProjectSettings/… and UnityPackageManager/… are Unity boilerplate

- Key subfolders under Assets:
– Assets/Editor: entry points (menu items, windows)
– Assets/Plugins/Editor/TreeView: reusable TreeView framework and example code
– Assets/Sources/ConfigManager: core “ConfigManager” service, its attributes, inspectors, property drawers, and Editor UI for config
– Assets/Resources: JSON config (BillingMode.json)
– Assets/Test Data: sample ScriptableObject assets & types

##### README
- Confirms the tool is an Editor window for organizing ScriptableObjects
- Managed by a ScriptableObject asset that lists hierarchies and types

- Unity Editor Host (Unity.exe)
- DBEditor Window (custom EditorWindow)
- TreeView Framework (Plugins/Editor/TreeView)
- ConfigManager Service (loads/manages ScriptableObject config)
- ScriptableObject Assets (persistent data store)
- Inspector Panel (uses Custom Property Drawers)
- Resources Loader (reads BillingMode.json)

- Unity Editor Host → instantiates DBEditor Window via menu command
- DBEditor Window → queries ConfigManager to load hierarchy definitions
- ConfigManager → reads ScriptableObject config asset(s) & JSON resources
- DBEditor Window → passes data to TreeView Framework → renders tree nodes
- User selection in TreeView → triggers Inspector Panel → uses Custom Property Drawers → modifies ScriptableObject Asset → back to ConfigManager to persist changes

c. Architectural patterns / principles
- MVC-like separation:
– Model = ScriptableObject assets & config data
– View = DBEditor Window + TreeView + Inspector
– Controller/Service = ConfigManager, TreeViewControllers in examples
- Plugin modularization:
– TreeView lives under Plugins/Editor for reuse
– ConfigManager encapsulates config logic, with Custom Attributes & Drawers to keep UI decoupled
- Unity Package structure: leverages Unity’s ScriptableObject and EditorWindow APIs

d. Key technologies & libraries
- C# Editor scripting (EditorWindow, ScriptableObject, Attributes)
- UnityEditor.IMGUI / UIElements via TreeView plugin
- Custom Attributes & PropertyDrawers for runtime metadata
- JSON resource for auxiliary config
- Unity Package metadata under Packages/

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraphs and components
    subgraph "Unity Editor Host"
        Editor["Unity Editor Host\n(Unity.exe)"]:::host
    end

    subgraph "Menu & Entry Point"
        MenuReg["Menu Registration\nBuiltInResourcesWindow"]:::ui
    end

    subgraph "UI Layer"
        DBEditor["DBEditor Window"]:::ui
        TreeViewCtrl["DBEditor TreeView Controller"]:::ui
        Inspector["Inspector Panel"]:::ui
    end

    subgraph "Service Layer"
        ConfigService["ConfigManager Service"]:::service
        ConfigAsset["ScriptableObject Config Asset"]:::data
        CMConfig["CMConfig Logic"]:::service
        CustomAttrs["Custom Attributes"]:::service
    end

    subgraph "Plugin Framework"
        TreeModel["TreeDataModel"]:::plugin
        TreeExamples["TreeView Examples"]:::plugin
    end

    subgraph "Property Drawers & Inspectors"
        PropDrawers["Property Drawers"]:::service
        CustomInsp["Custom Inspectors"]:::service
    end

    subgraph "Data Layer"
        SOAssets["ScriptableObject Assets"]:::data
        JSONRes["JSON Resource Loader"]:::data
    end

    %% Connections
    Editor -->|initializes via menu| MenuReg
    MenuReg -->|opens| DBEditor
    DBEditor -->|loads definitions| ConfigService
    ConfigService -->|reads asset| ConfigAsset
    ConfigService -->|executes logic| CMConfig
    ConfigService -->|uses metadata| CustomAttrs
    ConfigService -->|loads JSON| JSONRes
    DBEditor -->|creates tree| TreeViewCtrl
    TreeViewCtrl -->|uses framework| TreeModel
    TreeViewCtrl -->|examples| TreeExamples
    DBEditor -->|displays| Inspector
    Inspector -->|uses drawers| PropDrawers
    Inspector -->|uses inspectors| CustomInsp
    Inspector -->|edits| SOAssets
    SOAssets -->|persist changes| ConfigService
    DBEditor -->|passes data| TreeModel

    %% Click Events
    click DBEditor "https://github.com/novack/dbeditor/blob/main/Assets/Sources/ConfigManager/Editor/_ConfigManager/DBEditorWindow.cs"
    click TreeViewCtrl "https://github.com/novack/dbeditor/blob/main/Assets/Sources/ConfigManager/Editor/_ConfigManager/DBEditorTreeView.cs"
    click ConfigAsset "https://github.com/novack/dbeditor/blob/main/Assets/Sources/ConfigManager/Config/DBEditor Config.asset"
    click CMConfig "https://github.com/novack/dbeditor/blob/main/Assets/Sources/ConfigManager/Editor/_ConfigManager/CMConfig.cs"
    click CustomAttrs "https://github.com/novack/dbeditor/tree/main/Assets/Sources/ConfigManager/Custom Attributes/"
    click PropDrawers "https://github.com/novack/dbeditor/tree/main/Assets/Sources/ConfigManager/Editor/PropertyDrawers/"
    click CustomInsp "https://github.com/novack/dbeditor/blob/main/Assets/Sources/ConfigManager/Editor/CustomInspectors/EditorButton.cs"
    click TreeModel "https://github.com/novack/dbeditor/blob/main/Assets/Plugins/Editor/TreeView/TreeDataModel/TreeModel.cs"
    click TreeExamples "https://github.com/novack/dbeditor/tree/main/Assets/Plugins/Editor/TreeView/TreeViewExamples/"
    click SOAssets "https://github.com/novack/dbeditor/tree/main/Assets/Test Data/"
    click JSONRes "https://github.com/novack/dbeditor/blob/main/Assets/Resources/BillingMode.json"
    click MenuReg "https://github.com/novack/dbeditor/blob/main/Assets/Editor/BuiltInResourcesWindow.cs"

    %% Styles
    classDef host fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef plugin fill:#D3D3D3,stroke:#333,stroke-width:1px
```
