# simlmx/chickenroll architecture

> Architecture diagram of the GitHub repository simlmx/chickenroll, 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/simlmx/chickenroll
- Repository: https://github.com/simlmx/chickenroll

## Overview

##### Main Components

A. Frontend Layer (UI Package):
- React Components Structure
- Game Board Components (CantStopBoard)
- Interactive Elements (DiceBoard, Die, MoveButtons)
- Components (ScoreBoard, MoveHistory)
- State Management
- Utility Functions

B. Game Logic Layer (Game Package):
- Core Game Rules
- Math/Probability Calculations
- Game State Management
- Constants and Types

**┌─────────────────────────┐      ┌─────────────────────────┐**
- UI Layer        │ ←──→ │      Game Layer         │
- (React Frontend)     │      │    (Game Logic Core)    │
- ┘      └─────────────────────────┘

##### Important Elements to Highlight

A. UI Package:
- Component hierarchy starting from CantStopBoard
- Event handling flow through MoveButtons
- State management through selectors
- Visual component relationship (Board → Mountain → Die)

B. Game Package:
- Math/probability calculations flow
- Game rules implementation
- Type system and constants
- Test coverage

##### Build process flow

Remember to indicate that this is a standalone web application, with the game logic being independent of the UI implementation, allowing for potential future UI changes or alternative implementations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Main Application"
        UI["UI Layer"]
        Game["Game Layer"]
        UI <--> Game
    end

    subgraph "UI Layer Components"
        Board["CantStopBoard"]:::ui
        DiceBoard["DiceBoard"]:::ui
        Die["Die"]:::ui
        MoveBtn["MoveButtons"]:::ui
        Score["ScoreBoard"]:::ui
        History["MoveHistory"]:::ui
        Mountain["Mountain"]:::ui
        Chicken["Chicken"]:::ui
        Icons["Icons"]:::ui
        InGameIcons["InGame Icons"]:::ui
        Rules["Game Rules"]:::ui
        
        Board --> DiceBoard
        Board --> Mountain
        Board --> MoveBtn
        Board --> Score
        Board --> History
        Board --> Chicken
        DiceBoard --> Die
        Board --> Icons
        Board --> InGameIcons
        Board --> Rules
    end

    subgraph "UI State Management"
        StateUtils["State Utilities"]:::state
        Selectors["Selectors"]:::state
        Profiler["Profiler"]:::util
        
        StateUtils --> Selectors
        StateUtils --> Profiler
    end

    subgraph "Game Logic Core"
        CoreLogic["Core Game Logic"]:::game
        MathCalc["Math Calculations"]:::game
        Probs["Probability Engine"]:::game
        GameConst["Game Constants"]:::game
        GameTypes["Game Types"]:::game
        UITypes["UI Types"]:::game
        
        CoreLogic --> MathCalc
        MathCalc --> Probs
        CoreLogic --> GameConst
        CoreLogic --> GameTypes
        UI --> UITypes
    end

    subgraph "Build System"
        GameBuild["Game Build Config"]:::build
        UIBuild["UI Build Config"]:::build
        
        Game --> GameBuild
        UI --> UIBuild
    end

    %% Click Events
    click Board "https://github.com/simlmx/chickenroll/blob/main/ui/src/CantStopBoard.tsx"
    click DiceBoard "https://github.com/simlmx/chickenroll/blob/main/ui/src/DiceBoard.tsx"
    click Die "https://github.com/simlmx/chickenroll/blob/main/ui/src/Die.tsx"
    click MoveBtn "https://github.com/simlmx/chickenroll/blob/main/ui/src/MoveButtons.tsx"
    click Score "https://github.com/simlmx/chickenroll/blob/main/ui/src/ScoreBoard.tsx"
    click History "https://github.com/simlmx/chickenroll/blob/main/ui/src/MoveHistory.tsx"
    click Mountain "https://github.com/simlmx/chickenroll/blob/main/ui/src/Mountain.tsx"
    click Chicken "https://github.com/simlmx/chickenroll/blob/main/ui/src/Chicken.tsx"
    click Icons "https://github.com/simlmx/chickenroll/blob/main/ui/src/icons.tsx"
    click InGameIcons "https://github.com/simlmx/chickenroll/blob/main/ui/src/InGameIcons.tsx"
    click Selectors "https://github.com/simlmx/chickenroll/blob/main/ui/src/selectors.ts"
    click Profiler "https://github.com/simlmx/chickenroll/blob/main/ui/src/utils/profiler.ts"
    click CoreLogic "https://github.com/simlmx/chickenroll/blob/main/game/src/index.ts"
    click MathCalc "https://github.com/simlmx/chickenroll/blob/main/game/src/math/index.ts"
    click Probs "https://github.com/simlmx/chickenroll/blob/main/game/src/math/probs.ts"
    click GameConst "https://github.com/simlmx/chickenroll/blob/main/game/src/constants.ts"
    click GameTypes "https://github.com/simlmx/chickenroll/blob/main/game/src/types.ts"
    click UITypes "https://github.com/simlmx/chickenroll/blob/main/ui/src/types.ts"
    click GameBuild "https://github.com/simlmx/chickenroll/blob/main/game/rollup.config.js"
    click UIBuild "https://github.com/simlmx/chickenroll/blob/main/ui/rollup.config.js"
    click Rules "https://github.com/simlmx/chickenroll/blob/main/ui/src/Rules.tsx"

    %% Styling
    classDef ui fill:#2374ab
    classDef game fill:#2a9d8f
    classDef state fill:#e9c46a
    classDef util fill:#f4a261
    classDef build fill:#e76f51
```
