# boardzilla/boardzilla-core architecture

> Architecture diagram of the GitHub repository boardzilla/boardzilla-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boardzilla/boardzilla-core
- Repository: https://github.com/boardzilla/boardzilla-core

## Overview

##### Main Components

A. Core Engine Layer
- Game Management System (src/game-manager.ts)
- Game Creation System (src/game-creator.ts)
- Flow Control System (src/flow/*)
- Action Management (src/action/*)

B. Board Management Layer
- Grid Systems (hex, square, fixed)
- Space Management
- Piece Management
- Element Collections
- Stack Management

C. Player Management Layer
- Player Collections
- Player State Management

D. UI Layer
- React Components
- Game UI Components
- Setup Interface
- Debug Tools
- Asset Management

E. Component Library
- Reusable Game Components (d6, flippable)
- Asset Management for Components

**┌─────────────────────────────────────────────┐**
- UI Layer                    │
- ┤
- Component Library               │
- ┤
- Core Engine Layer              │
- ┬───────────────┬────────────┤
- Board      │    Player     │    Flow    │
- Management   │  Management   │  Control   │
- ┴───────────────┴────────────┘

##### Key Relationships

- How the Core Engine coordinates with Board, Player, and Flow Control systems
- Event flow from user actions through the system
- Demonstrate state management and persistence paths

##### Technical Details

- TypeScript integration
- React component structure
- Build system (esbuild)
- Test framework integration
- Asset handling pipeline

##### Specific Implementation Notes

- Relationship between action selection and game flow
- How the grid systems (hex, square, fixed) interact
- Demonstrate the component lifecycle
- Debug tools integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef board fill:#f1c40f,stroke:#f39c12,color:black
    classDef player fill:#9b59b6,stroke:#8e44ad,color:white
    classDef flow fill:#e67e22,stroke:#d35400,color:white
    classDef component fill:#95a5a6,stroke:#7f8c8d,color:white

    %% UI Layer
    subgraph UI
        MainUI["Main UI"]:::ui
        GameUI["Game UI Components"]:::ui
        SetupUI["Setup Interface"]:::ui
        DebugTools["Debug Tools"]:::ui
        AssetMgmt["Asset Management"]:::ui
        Store["Store"]:::ui
        Queue["Queue Management"]:::ui
        Render["Render System"]:::ui
    end

    %% Component Library
    subgraph Components
        D6["D6 Component"]:::component
        Flippable["Flippable Component"]:::component
    end

    %% Core Engine Layer
    subgraph CoreEngine
        GameMgr["Game Manager"]:::core
        GameCreator["Game Creator"]:::core
        FlowControl["Flow Control"]:::core
        ActionMgmt["Action Management"]:::core
    end

    %% Board Management Layer
    subgraph BoardMgmt
        GridSystems["Grid Systems"]:::board
        SpaceMgmt["Space Management"]:::board
        PieceMgmt["Piece Management"]:::board
        ElementColl["Element Collections"]:::board
        StackMgmt["Stack Management"]:::board
    end

    %% Player Management Layer
    subgraph PlayerMgmt
        PlayerColl["Player Collections"]:::player
        PlayerState["Player State Management"]:::player
    end

    %% Relationships
    MainUI --> Store
    Store --> Queue
    Queue --> Render
    GameUI --> Store
    SetupUI --> GameCreator
    DebugTools --> GameMgr

    GameMgr --> FlowControl
    GameMgr --> ActionMgmt
    GameCreator --> BoardMgmt
    GameCreator --> PlayerMgmt

    FlowControl --> BoardMgmt
    FlowControl --> PlayerMgmt
    ActionMgmt --> BoardMgmt

    Components --> GameUI
    AssetMgmt --> Components

    %% Click events
    click MainUI "https://github.com/boardzilla/boardzilla-core/blob/main/src/ui/Main.tsx"
    click GameUI "https://github.com/boardzilla/boardzilla-core/tree/main/src/ui/game/components"
    click SetupUI "https://github.com/boardzilla/boardzilla-core/blob/main/src/ui/setup/Setup.tsx"
    click DebugTools "https://github.com/boardzilla/boardzilla-core/blob/main/src/ui/game/components/Debug.tsx"
    click AssetMgmt "https://github.com/boardzilla/boardzilla-core/tree/main/src/ui/assets"
    click Store "https://github.com/boardzilla/boardzilla-core/blob/main/src/ui/store.ts"
    click Queue "https://github.com/boardzilla/boardzilla-core/blob/main/src/ui/queue.ts"
    click Render "https://github.com/boardzilla/boardzilla-core/blob/main/src/ui/render.ts"
    click D6 "https://github.com/boardzilla/boardzilla-core/tree/main/src/components/d6"
    click Flippable "https://github.com/boardzilla/boardzilla-core/tree/main/src/components/flippable"
    click GameMgr "https://github.com/boardzilla/boardzilla-core/blob/main/src/game-manager.ts"
    click GameCreator "https://github.com/boardzilla/boardzilla-core/blob/main/src/game-creator.ts"
    click FlowControl "https://github.com/boardzilla/boardzilla-core/tree/main/src/flow"
    click ActionMgmt "https://github.com/boardzilla/boardzilla-core/tree/main/src/action"
    click GridSystems "https://github.com/boardzilla/boardzilla-core/blob/main/src/board/hex-grid.ts"
    click SpaceMgmt "https://github.com/boardzilla/boardzilla-core/blob/main/src/board/space.ts"
    click PieceMgmt "https://github.com/boardzilla/boardzilla-core/blob/main/src/board/piece.ts"
    click ElementColl "https://github.com/boardzilla/boardzilla-core/blob/main/src/board/element-collection.ts"
    click StackMgmt "https://github.com/boardzilla/boardzilla-core/blob/main/src/board/stack.ts"
    click PlayerColl "https://github.com/boardzilla/boardzilla-core/blob/main/src/player/collection.ts"
    click PlayerState "https://github.com/boardzilla/boardzilla-core/blob/main/src/player/player.ts"
```
