# johnbenjaminmccarthy/reactchess architecture

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

- Interactive diagram: https://gitdiagram.com/johnbenjaminmccarthy/reactchess
- Repository: https://github.com/johnbenjaminmccarthy/reactchess

## Overview

Key Components to Include:

##### Frontend Layer (UI Components)
- Following React components:
- App (main container)
- BoardDisplay (chess board visualization)
- HistoryDisplay (move history)
- PromotionPicker (pawn promotion UI)

##### Game Logic Layer (Core)
- Core components:
- BitBoard (primary state representation)
- BoardState (game state manager)
- Move (move representation)
- MoveTables (pre-computed moves)
- Magic (magic bitboard implementation)
- SquareBitIndex (board position mapping)

##### Data Flow and State Management
- User interactions → UI Components
- UI Components → Game Logic
- Game Logic → State Updates
- State Updates → UI Refresh

Specific Implementation Details:

- [UI Layer]
- ↕
- [Game Logic Layer]
- ↕
- [BitBoard Storage Layer]

##### Special notations for
- Magic BitBoards computation flow
- Move generation pathways
- State update propagation

Architectural Considerations:

##### BitBoard Implementation
- How the 64-bit integer board representations interact
- Pre-computed move tables storage
- Magic bitboard lookup system

##### Component Interaction
- How Move generation affects BoardState
- How HistoryDisplay observes state changes

Technical Details to Include:

##### Technology Stack Indicators
- Kotlin/JS
- React
- BitBoard Implementation
- Magic BitBoard System

##### Performance Optimizations
- Pre-computed move tables
- Magic bitboard lookup paths

##### Notes for
- BitBoard representation
- Magic BitBoard optimization
- Move generation system
- State management flow

Remember to maintain a balance between showing the technical complexity of the BitBoard implementation while keeping the overall architecture clear and understandable at a glance.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#d4e5ff,stroke:#2d6ac7
    classDef core fill:#d4ffdb,stroke:#2d8c3f
    classDef storage fill:#ffe3cc,stroke:#cc6600
    classDef data fill:#f2f2f2,stroke:#666666

    %% UI Layer
    subgraph Frontend
        App["App Component"]
        BoardDisplay["Board Display"]
        HistoryDisplay["History Display"]
        PromotionPicker["Promotion Picker"]
    end

    %% Game Logic Layer
    subgraph GameLogic
        BoardState["Board State Manager"]
        Move["Move Handler"]
        BitBoard["BitBoard System"]
        MoveTables["Move Tables"]
        Magic["Magic BitBoard"]
        SquareBitIndex["Square Bit Index"]
    end

    %% Data Flow
    App --> BoardDisplay
    App --> HistoryDisplay
    App --> PromotionPicker
    
    BoardDisplay --> BitBoard
    BitBoard --> BoardDisplay
    
    BitBoard --> BoardState
    BoardState --> BitBoard
    
    Move --> BoardState
    BoardState --> Move
    
    BitBoard --> Magic
    Magic --> MoveTables
    MoveTables --> Move
    
    SquareBitIndex --> BitBoard
    SquareBitIndex --> MoveTables
    
    BoardState --> HistoryDisplay
    PromotionPicker --> Move

    %% Click Events
    click App "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/App.kt"
    click BoardDisplay "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/BoardDisplay.kt"
    click HistoryDisplay "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/HistoryDisplay.kt"
    click PromotionPicker "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/PromotionPicker.kt"
    click BitBoard "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/BitBoard.kt"
    click BoardState "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/BoardState.kt"
    click Move "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/Move.kt"
    click MoveTables "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/MoveTables.kt"
    click Magic "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/Magic.kt"
    click SquareBitIndex "https://github.com/johnbenjaminmccarthy/ReactChess/blob/master/src/jsMain/kotlin/SquareBitIndex.kt"

    %% Style Applications
    class App,BoardDisplay,HistoryDisplay,PromotionPicker ui
    class BoardState,Move,BitBoard,MoveTables,Magic,SquareBitIndex core

    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        Core["Core Logic"]:::core
        DataFlow["Data Flow"]:::data
    end
```
