# kienmai262/burgeon architecture

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

- Interactive diagram: https://gitdiagram.com/kienmai262/burgeon
- Repository: https://github.com/kienmai262/burgeon

## Overview

##### Main Components
- Game Controller – A central component (GameController.cs) likely orchestrates game state, initialization, and high-level logic.
- Player System – Found under the “Player” directory (with MoveController, Player, SoundPlayer, etc.), which handles user input, movement, and actions.
- Animal & Farm Management – In the “Animal” folder you have scripts for AI movement and specific classes for barns and farm animals (e.g., BarnChicken, BarnCow) that are responsible for animal behavior and management.
- Inventory & Item System – Two key folders (“Inventory” and “Item”) include logic for inventory management, UI elements, and the handling of numerous item assets (such as fruits, vegetables, eggs, etc.).
- Shop and Transaction Systems – The “Shop” and “Transaction” directories manage trade, buying/selling logic, and possibly online transactions which might also interact with player inventory.
- Tree & Seed System – The “Tree” folder (including subdirectories for “Seed”) provides functionality for planting, growing, and managing crops or trees, a common feature in farming games.
- Friend & Social Interaction – Under “Friend”, components manage chat, notes, or friend list mechanisms.
- Online Multiplayer/Networking – The “Photon” directory indicates use of the Photon framework for establishing connections, creating or joining rooms, and managing multiplayer aspects.
- Other Supporting Features – These include components for camera behavior (CameraFollow), game settings (SettingManager), lighting control (LightManager), user interface screens (Menu), state management (State), and persistent data (SaveData).

##### Relationships and Interactions
- The Game Controller acts as the core hub that interacts with and directs various subsystems.
- Player components interact heavily with the Inventory, Shop, and Animal/Tree systems as users engage in farm activities.
- The Inventory and Item systems interact not only to display and manage game items but also feed data into and from the Shop and Transaction systems.
- The Shop and Transaction systems exchange data with both the Inventory (for selling and buying items) and potentially a backend system through Photon (for online multiplayer components).
- Photon-based components likely manage the online networking aspect that ties in friend interactions and possibly multiplayer trade sessions.
- SaveData components work across subsystems to persist game state (e.g., player progress, inventory, settings) ensuring that state information is stored and restored appropriately.
- UI components (found in several directories—InventoryUI, MenuController, OrderUI, ItemUI, etc.) mediate user interactions, and so they should be clearly connected to their related systems.

##### Architectural Patterns and Design Principles
- The highly modular structure indicates a component-based design (a core Unity pattern), where gameplay elements are separated into distinct systems.
- The use of external libraries like Photon shows reliance on established frameworks for networking, so denote “External Services” for Photon.
- Separation of concerns: each subsystem focuses on a specific aspect of game functionality (e.g., animal management is completely separate from the inventory system).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Game Logic
    subgraph "Core Game Logic"
        GC["Game Controller"]:::core
    end

    %% Gameplay Systems
    subgraph "Gameplay Systems"
        %% Player System
        subgraph "Player System"
            P["Player"]:::player
            MT["MoveController"]:::player
            SP["SoundPlayer"]:::player
        end

        %% Animal & Farm Management
        subgraph "Animal & Farm Management"
            AIM["AIMove"]:::animal
            Barn["Barn"]:::animal
            BC["BarnChicken"]:::animal
            BCo["BarnCow"]:::animal
            Chick["Chicken"]:::animal
            Cow["Cow"]:::animal
        end

        %% Inventory & Item System
        subgraph "Inventory & Item System"
            Inv["Inventory"]:::inventory
            InvCtrl["InventoryController"]:::inventory
            InvUI["InventoryUI"]:::inventory
            Item["Item"]:::inventory
            ItemData["ItemData"]:::inventory
        end

        %% Shop and Transaction Systems
        subgraph "Shop and Transaction Systems"
            ShopUI["ShopUI"]:::shop
            ClickItemShop["ClickItemShop"]:::shop
            ClickItemSell["ClickItemSell"]:::shop
            InvSellOnline["InventorySellOnline"]:::shop
            TradeMgr["TradeManager"]:::shop
            ClickItemTrad["ClickItemTrad"]:::shop
        end

        %% Tree & Seed System
        subgraph "Tree & Seed System"
            ActiveTree["ActiveTreeAndField"]:::tree
            FruitTree["FruitTree"]:::tree
            Berries["Berries"]:::tree
            Seed["Seed"]:::tree
            SeedUI["SeedUI"]:::tree
            ClickHandler["ClickHandler"]:::tree
            SelectUI["SelectUI"]:::tree
        end

        %% Friend & Social Interaction
        subgraph "Friend & Social Interaction"
            ChatNote["ChatAndNoteManager"]:::friend
            FriendMgr["FriendManager"]:::friend
        end

        %% Supporting Features
        subgraph "Supporting Features"
            Camera["CameraFollow"]:::support
            Setting["SettingManager"]:::support
            Light["LightManager"]:::support
            MenuCtrl["MenuController"]:::support
            StateMgr["StateManager"]:::support
            ClickIcon["ClickIcon"]:::support
            SwitchIcon["SwitchIcon"]:::support
            SaveDataLogin["LoginData"]:::data
            ReadWrite["ReadWriteData"]:::data
            SaveDataJSON["SaveData.json"]:::data
        end
    end

    %% Networking & Services
    subgraph "Networking & Services"
        Photon1["ConnectToSever"]:::network
        Photon2["CreateAndJoinRoom"]:::network
    end

    %% Connections from Core Game Controller to Systems
    GC -->|"init"| P
    GC -->|"init"| AIM
    GC -->|"init"| Inv
    GC -->|"init"| ShopUI
    GC -->|"init"| ActiveTree
    GC -->|"init"| ChatNote
    GC -->|"init"| Camera
    GC -->|"init"| Setting
    GC -->|"init"| SaveDataLogin

    %% Player interactions
    P -->|"action"| InvUI
    P -->|"action"| InvCtrl
    P -->|"action"| Camera
    P -->|"interact"| ShopUI

    %% Inventory interactions
    InvUI -->|"update"| InvCtrl
    InvCtrl -->|"sync"| SaveDataLogin

    %% Shop interactions
    ShopUI -->|"sell_item"| ClickItemSell
    ShopUI -->|"buy_item"| ClickItemShop
    ClickItemTrad -->|"trade"| TradeMgr

    %% Tree & Seed interactions
    ActiveTree -->|"grow"| Seed
    Seed -->|"UI_update"| SeedUI
    SeedUI -->|"select"| SelectUI

    %% Networking interactions
    Photon1 -->|"network"| Photon2
    Photon2 -->|"lobby"| ChatNote
    Photon2 -->|"lobby"| ShopUI

    %% Friend interactions
    FriendMgr -->|"manage"| ChatNote

    %% State management interactions
    StateMgr -->|"handle"| ClickIcon
    StateMgr -->|"handle"| SwitchIcon

    %% Click Events
    click GC "https://github.com/kienmai262/burgeon/blob/main/GameController.cs"
    click P "https://github.com/kienmai262/burgeon/blob/main/Player/Player.cs"
    click MT "https://github.com/kienmai262/burgeon/blob/main/Player/MoveController.cs"
    click SP "https://github.com/kienmai262/burgeon/blob/main/Player/SoundPlayer.cs"
    click AIM "https://github.com/kienmai262/burgeon/blob/main/Animal/AIMove.cs"
    click Barn "https://github.com/kienmai262/burgeon/blob/main/Animal/Barn.cs"
    click BC "https://github.com/kienmai262/burgeon/blob/main/Animal/BarnChicken.cs"
    click BCo "https://github.com/kienmai262/burgeon/blob/main/Animal/BarnCow.cs"
    click Chick "https://github.com/kienmai262/burgeon/blob/main/Animal/Chicken.cs"
    click Cow "https://github.com/kienmai262/burgeon/blob/main/Animal/Cow.cs"
    click Inv "https://github.com/kienmai262/burgeon/blob/main/Inventory/Inventory.cs"
    click InvCtrl "https://github.com/kienmai262/burgeon/blob/main/Inventory/InventoryController.cs"
    click InvUI "https://github.com/kienmai262/burgeon/blob/main/Inventory/InventoryUI.cs"
    click Item "https://github.com/kienmai262/burgeon/blob/main/Item/Item.cs"
    click ItemData "https://github.com/kienmai262/burgeon/tree/main/Item/ItemData"
    click ShopUI "https://github.com/kienmai262/burgeon/blob/main/Shop/ShopUI.cs"
    click ClickItemShop "https://github.com/kienmai262/burgeon/blob/main/Shop/ClickItemShop.cs"
    click ClickItemSell "https://github.com/kienmai262/burgeon/blob/main/Shop/ClickItemSell.cs"
    click InvSellOnline "https://github.com/kienmai262/burgeon/blob/main/Shop/InventorySellOnline.cs"
    click TradeMgr "https://github.com/kienmai262/burgeon/blob/main/Transaction/TradeManager.cs"
    click ClickItemTrad "https://github.com/kienmai262/burgeon/blob/main/Transaction/ClickItemTrad.cs"
    click ActiveTree "https://github.com/kienmai262/burgeon/blob/main/Tree/ActiveTreeAndField.cs"
    click FruitTree "https://github.com/kienmai262/burgeon/blob/main/Tree/FruitTree.cs"
    click Berries "https://github.com/kienmai262/burgeon/blob/main/Tree/Berries.cs"
    click Seed "https://github.com/kienmai262/burgeon/blob/main/Tree/Seed/Seed.cs"
    click SeedUI "https://github.com/kienmai262/burgeon/blob/main/Tree/Seed/SeedUI.cs"
    click ClickHandler "https://github.com/kienmai262/burgeon/blob/main/Tree/Seed/ClickHandler.cs"
    click SelectUI "https://github.com/kienmai262/burgeon/blob/main/Tree/Seed/SelectUI.cs"
    click ChatNote "https://github.com/kienmai262/burgeon/blob/main/Friend/ChatAndNoteManager.cs"
    click FriendMgr "https://github.com/kienmai262/burgeon/blob/main/Friend/FriendManager.cs"
    click Photon1 "https://github.com/kienmai262/burgeon/blob/main/Photon/ConnectToSever.cs"
    click Photon2 "https://github.com/kienmai262/burgeon/blob/main/Photon/CreateAndJoinRoom.cs"
    click Camera "https://github.com/kienmai262/burgeon/blob/main/CameraFollow.cs"
    click Setting "https://github.com/kienmai262/burgeon/blob/main/SettingManager.cs"
    click Light "https://github.com/kienmai262/burgeon/blob/main/LightManager.cs"
    click MenuCtrl "https://github.com/kienmai262/burgeon/blob/main/Menu/MenuController.cs"
    click StateMgr "https://github.com/kienmai262/burgeon/blob/main/State/StateManager.cs"
    click ClickIcon "https://github.com/kienmai262/burgeon/blob/main/State/ClickIcon.cs"
    click SwitchIcon "https://github.com/kienmai262/burgeon/blob/main/State/SwitchIcon.cs"
    click SaveDataLogin "https://github.com/kienmai262/burgeon/blob/main/SaveData/LoginData.cs"
    click ReadWrite "https://github.com/kienmai262/burgeon/blob/main/SaveData/ReadWriteData.cs"
    click SaveDataJSON "https://github.com/kienmai262/burgeon/blob/main/SaveData/SaveData.json"

    %% Styles
    classDef core fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef player fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef animal fill:#D5F5E3,stroke:#28B463,stroke-width:2px;
    classDef inventory fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef shop fill:#FDEBD0,stroke:#E67E22,stroke-width:2px;
    classDef tree fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef friend fill:#F9E79F,stroke:#F39C12,stroke-width:2px;
    classDef network fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
    classDef support fill:#E8F8F5,stroke:#1ABC9C,stroke-width:2px;
    classDef data fill:#F5EEF8,stroke:#9B59B6,stroke-width:2px;
```
