# urayushjain/fusion architecture

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

- Interactive diagram: https://gitdiagram.com/urayushjain/fusion
- Repository: https://github.com/urayushjain/fusion

## Overview

##### Component Breakdown

UI Layer (Top):
- It to a style.css component showing the styling relationship
- UI elements like:
- Game Grid
- Score Display
- Reset Button
- Game Status Messages

Game Logic Layer (Middle):
- Game State Manager
- Tile Movement Controller
- Collision Detection System
- Score Calculator
- Animation Controller

Browser Storage Layer (Bottom):
- Local Storage component for saving game state/scores

##### Interaction Flows
- User Input → Game Logic
- Game Logic → UI Updates
- Game State → Storage
- User interactions (e.g., green)
- Data flow (e.g., blue)
- State updates (e.g., orange)

##### Specific Components

Game Logic Components:
- Input Handler
- Keyboard Events
- Touch Events (for mobile)

- Game Core
- Grid Management
- Tile Generation
- Merge Logic
- Win/Lose Conditions

- Animation System
- Movement Animations
- Merge Animations

##### Technical Details to Highlight
- Event-driven architecture for handling user inputs
- State management for game grid
- Animation system for smooth transitions
- Responsive design implementation

##### Design Patterns to Emphasize
- Observer Pattern for UI updates
- State Pattern for game state management
- Command Pattern for handling moves

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef ui fill:#a8d1f0,stroke:#2c89c4,stroke-width:2px
    classDef logic fill:#b8e0b8,stroke:#2d8f2d,stroke-width:2px
    classDef input fill:#ffe599,stroke:#f1c232,stroke-width:2px
    classDef storage fill:#d5a6bd,stroke:#8e3b63,stroke-width:2px
    classDef critical fill:#f4cccc,stroke:#cc0000,stroke-width:2px

    %% UI Layer
    subgraph UI
        HTML["index.html"]
        CSS["style.css"]
        Grid["Game Grid"]:::ui
        Score["Score Display"]:::ui
        Reset["Reset Button"]:::ui
        Status["Game Status Messages"]:::ui
    end

    %% Game Logic Layer
    subgraph Logic
        App["app.js"]:::logic
        StateManager["Game State Manager"]:::logic
        MoveController["Tile Movement Controller"]:::logic
        CollisionSystem["Collision Detection System"]:::logic
        ScoreCalc["Score Calculator"]:::logic
        AnimationCtrl["Animation Controller"]:::logic
        
        subgraph InputHandling["Input Handler"]
            Keyboard["Keyboard Events"]:::input
            Touch["Touch Events"]:::input
        end
        
        subgraph GameCore["Game Core"]
            GridMgmt["Grid Management"]:::logic
            TileGen["Tile Generation"]:::logic
            MergeLogic["Merge Logic"]:::logic
            GameConditions["Win/Lose Conditions"]:::critical
        end
    end

    %% Storage Layer
    subgraph Storage
        LocalStorage["Local Storage"]:::storage
    end

    %% Connections
    HTML --> CSS
    HTML --> Grid
    HTML --> Score
    HTML --> Reset
    HTML --> Status
    
    Keyboard --> App
    Touch --> App
    
    App --> StateManager
    App --> MoveController
    App --> CollisionSystem
    App --> ScoreCalc
    App --> AnimationCtrl
    
    StateManager --> GameCore
    MoveController --> AnimationCtrl
    CollisionSystem --> MergeLogic
    ScoreCalc --> Score
    
    GameCore --> Grid
    StateManager --> LocalStorage
    
    %% Click events
    click HTML "https://github.com/URAYUSHJAIN/Fusion/blob/main/index.html"
    click CSS "https://github.com/URAYUSHJAIN/Fusion/blob/main/style.css"
    click App "https://github.com/URAYUSHJAIN/Fusion/blob/main/app.js"
    click Docs "https://github.com/URAYUSHJAIN/Fusion/blob/main/README.md"

    %% Legend
    subgraph Legend
        UI_Component["UI Component"]:::ui
        Logic_Component["Logic Component"]:::logic
        Input_Component["Input Component"]:::input
        Storage_Component["Storage Component"]:::storage
        Critical_Component["Critical Component"]:::critical
    end
```
