# ghostzragon/coffe-pack-clone architecture

> Architecture diagram of the GitHub repository ghostzragon/coffe-pack-clone, 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/ghostzragon/coffe-pack-clone
- Repository: https://github.com/ghostzragon/coffe-pack-clone

## Overview

##### Main Components
- Game Engine & Scene Management: Represent the Unity runtime environment—the Scenes folder and ProjectSettings. Highlight scenes such as “Grid”, “Level”, “SampleScene” that initialize the game.
- Core Gameplay Systems:
– Level Manager & Grid Manager: These are the heart of gameplay logic (located in Assets/Scripts/Core) that control level generation and grid behavior.
– Drag & Drop System & Merge System: Modules that manage user item interactions and merging of elements.
– Dynamic Difficulty: Identify the component that selects items on the fly based on game state.
– Quest/Challenge System: Under Scripts/Core/Quest.
- Game State Manager: Based on the state pattern implementation (found in Assets/Scripts/Game State) that controls overall transitions (MainMenuState, GameplayState, GameResultState, etc.)
- UI and Presentation Layer: Modules under Scripts/UI plus the prefabs for various screens (Main Menu, Gameplay UI, Level selection, Star results, etc.). Also include TextMeshPro for text rendering.
- Level Editor & Data Import: The Level Editor functionality and CSV importer for custom maps (Assets/Scripts/Ultis/CSVImport.cs) as well as related ScriptableObjects for level configurations.
- External Tools/Plugins:
– Odin Inspector (under Assets/Plugins/Sirenix) for extended editor functionality.
– TextMesh Pro for advanced UI text.

##### Relationships and Interactions
– Input Controllers send events to the Game State Manager.
– Game State Manager triggers core systems (Level Manager, Grid Manager) based on current state.
– Core systems update both the UI (via event calls to UI controllers) and internal game data.
– Level Editor reads CSV data and produces ScriptableObject–based level configurations that feed into Level Manager.
– The dynamic difficulty system modifies the parameters of the Level Manager and inventory/quest systems in real time.
- Feedback paths where user actions on the UI (through drag & drop) alter the grid, which in turn notifies UI components (like animations in the UI or score updates).

##### Architectural Patterns and Design Principles
- State Pattern: Emphasize that the game’s state transitions (for example, from Main Menu to Gameplay and then to Game Result) are encapsulated in separate state classes.
- Component-Based Design: Each game object in Unity has attached MonoBehaviours (from the various “Scripts” subfolders) that follow clear separation of concerns.
- Data-Driven Configuration: Use of ScriptableObjects and CSV files to allow easy modification of level maps, quest parameters, and UI settings.
- Separation between Presentation (UI prefabs, animations) and Core Game Logic (management scripts).

##### Final Advice
- Do not hesitate to split complex modules into sub-components if necessary (for instance, showing a separate flow for input handling on mobile vs. PC).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine/Scene Layer
    subgraph "Engine/Scene Layer"
        A1["Grid Scene"]:::engine
        A2["Level Scene"]:::engine
        A3["Sample Scene"]:::engine
        A4["Project Settings"]:::engine
    end

    %% Core Gameplay Systems
    subgraph "Core Gameplay Systems"
        B1["Level Manager"]:::core
        B2["Grid Manager"]:::core
        B3["Drag & Drop System"]:::core
        B4["Merge System"]:::core
        B5["Quest System"]:::core
        B6["Dynamic Difficulty System"]:::core
    end

    %% Game State Manager
    subgraph "Game State Manager"
        C1["Game State Manager"]:::state
    end

    %% UI Layer
    subgraph "UI Layer"
        D1["UI Controllers & Prefabs"]:::ui
    end

    %% Data & Level Configuration
    subgraph "Data & Level Configuration"
        E1["CSV Importer & Level Editor"]:::data
        E2["Scriptable Objects (Level Config)"]:::data
    end

    %% External Plugins
    subgraph "External Plugins"
        F1["Odin Inspector"]:::external
        F2["TextMesh Pro Plugin"]:::external
    end

    %% Relationships and Data Flow
    A1 --> C1
    A2 --> C1
    A3 --> C1
    A4 --> C1

    D1 --> C1

    C1 -->|"triggers"| B1
    C1 -->|"triggers"| B2
    C1 -->|"triggers"| B3
    C1 -->|"triggers"| B4
    C1 -->|"triggers"| B6

    B6 -->|"modifies"| B1
    B6 -->|"modifies"| B5

    B1 -->|"updates"| D1
    B2 -->|"updates"| D1
    B3 -->|"sends events"| D1

    E1 -->|"feeds data"| B1
    E2 -->|"feeds config"| B1

    F1 -->|"enhances"| D1
    F2 -->|"renders text for"| D1

    %% Click Events for Component Mappings
    click A1 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scenes/Grid/Grid.unity"
    click A2 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scenes/Level.unity"
    click A3 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scenes/SampleScene.unity"
    click A4 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/ProjectSettings/ProjectVersion.txt"
    
    click B1 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scripts/Core/Level/LevelManager.cs"
    click B2 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scripts/Core/GridManager.cs"
    click B3 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scripts/Core/DragDropSystem.cs"
    click B4 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scripts/Core/MergeSystem.cs"
    click B5 "https://github.com/ghostzragon/coffe-pack-clone/tree/main/Assets/Scripts/Core/Quest"
    
    click C1 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scripts/Game State/GameStateManager.cs"
    
    click D1 "https://github.com/ghostzragon/coffe-pack-clone/tree/main/Assets/Scripts/UI"
    
    click E1 "https://github.com/ghostzragon/coffe-pack-clone/blob/main/Assets/Scripts/Ultis/CSVImport.cs"
    click E2 "https://github.com/ghostzragon/coffe-pack-clone/tree/main/Assets/ScriptableObjects/Resources/Level"
    
    click F1 "https://github.com/ghostzragon/coffe-pack-clone/tree/main/Assets/Plugins/Sirenix"
    click F2 "https://github.com/ghostzragon/coffe-pack-clone/tree/main/Assets/TextMesh Pro"
    
    %% Styles
    classDef engine fill:#FFC107,stroke:#000,stroke-width:2px,color:#000;
    classDef core fill:#8BC34A,stroke:#000,stroke-width:2px,color:#000;
    classDef state fill:#03A9F4,stroke:#000,stroke-width:2px,color:#000;
    classDef ui fill:#E91E63,stroke:#000,stroke-width:2px,color:#000;
    classDef data fill:#9C27B0,stroke:#000,stroke-width:2px,color:#fff;
    classDef external fill:#00BCD4,stroke:#000,stroke-width:2px,color:#000;
```
