# ypatel2022/chess-bot architecture

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

- Interactive diagram: https://gitdiagram.com/ypatel2022/chess-bot
- Repository: https://github.com/ypatel2022/chess-bot

## Overview

##### Main Components

a) Core Game Components:
- Game Manager Layer
- Chess Engine (AI Component)
- Board Management System
- UI System
- Input Management System

b) Asset Management:
- Piece Management System
- Resource Management
- Scene Management

##### Specific Implementation Details

- How BoardGenerator interacts with Piece prefabs
- How ChessEngine interfaces with the main Chess.cs controller
- How UIManager handles user input and game state display
- Resource loading paths for chess pieces (Black/White prefabs)

##### Technical Specifications

- Unity Version (2021.3.16+)
- Key dependencies
- Asset organization structure

##### Data Flow Indicators

How data flows between:
- User input → Game Logic → AI Engine
- Game State → UI Updates
- AI Decisions → Board State Changes

- Presentation Layer (UI/Input)
- Game Logic Layer (Chess rules/Board management)
- AI Layer (Move calculation/Board evaluation)

Remember to:
- Use consistent symbols throughout
- Notes for important architectural decisions
- Both runtime and design-time relationships

This structure will effectively communicate how the chess bot's components interact while maintaining a clear separation of concerns between the game logic, AI, and presentation layers.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef ai fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef resource fill:#FFD700,stroke:#333,stroke-width:2px
    classDef system fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% UI Layer
    subgraph Presentation_Layer
        MenuManager["Menu Manager"]:::ui
        UIManager["UI Manager"]:::ui
        DragPiece["Drag & Drop Handler"]:::ui
    end

    %% Game Logic Layer
    subgraph Game_Logic_Layer
        Chess["Chess Controller"]:::core
        BoardGenerator["Board Generator"]:::core
        Piece["Piece Manager"]:::core
        BoardSquare["Board Square"]:::core
    end

    %% AI Layer
    subgraph AI_Layer
        ChessEngine["Chess Engine"]:::ai
        BoardEval["Board Evaluation"]:::ai
        MoveGen["Move Generation"]:::ai
    end

    %% Resource Management
    subgraph Resource_Management
        BlackPieces["Black Pieces"]:::resource
        WhitePieces["White Pieces"]:::resource
        BoardTiles["Board Tiles"]:::resource
        PieceTextures["Piece Textures"]:::resource
        UIElements["UI Elements"]:::resource
    end

    %% Scene Management
    subgraph Scene_Management
        MainMenu["Main Menu Scene"]:::system
        MainGame["Main Game Scene"]:::system
    end

    %% Relationships
    MenuManager --> MainMenu
    MenuManager --> MainGame
    UIManager --> Chess
    Chess --> BoardGenerator
    Chess --> ChessEngine
    BoardGenerator --> Piece
    BoardGenerator --> BoardSquare
    Piece --> DragPiece
    ChessEngine --> BoardEval
    ChessEngine --> MoveGen
    BoardGenerator --> BlackPieces
    BoardGenerator --> WhitePieces
    BoardGenerator --> BoardTiles
    UIManager --> UIElements
    Piece --> PieceTextures

    %% Click Events
    click MenuManager "https://github.com/ypatel2022/chess-bot/blob/main/Assets/MenuManager.cs"
    click UIManager "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/UIManager.cs"
    click Chess "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/Chess.cs"
    click BoardGenerator "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/BoardGenerator.cs"
    click Piece "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/Piece.cs"
    click DragPiece "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/DragPiece.cs"
    click BoardSquare "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/BoardSquare.cs"
    click ChessEngine "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scripts/ChessEngine.cs"
    click BlackPieces "https://github.com/ypatel2022/chess-bot/tree/main/Assets/Resources/Black/"
    click WhitePieces "https://github.com/ypatel2022/chess-bot/tree/main/Assets/Resources/White/"
    click BoardTiles "https://github.com/ypatel2022/chess-bot/tree/main/Assets/Prefabs/"
    click MainMenu "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scenes/Main Menu.unity"
    click MainGame "https://github.com/ypatel2022/chess-bot/blob/main/Assets/Scenes/Main.unity"
    click PieceTextures "https://github.com/ypatel2022/chess-bot/tree/main/Assets/Textures/PNGs/"
    click UIElements "https://github.com/ypatel2022/chess-bot/tree/main/Assets/TextMesh Pro/"
```
