# mjsalerno/unobot architecture

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

- Interactive diagram: https://gitdiagram.com/mjsalerno/unobot
- Repository: https://github.com/mjsalerno/unobot

## Overview

- IRC Server <--> IRC Interface Layer <--> Game Engine <--> Card Management
- <--> Player Management
- <--> Score System

- AI System --> Game Engine
- Score System --> File System

##### Specific Implementation Details

Create subsections showing:
- Card representation and deck management
- Player state and turn management
- Score tracking and persistence
- AI decision making process

##### Important Notes
- Configuration loading flow at startup
- Where game rules are enforced (Rules class)
- Points of extension (especially for AI and scoring)
- Test coverage indicators

Key Architectural Patterns to Highlight:
- Command pattern for IRC commands
- Observer pattern for game state changes
- Strategy pattern for AI behavior
- Factory pattern for card creation

This system design should help developers understand both the high-level architecture and the specific implementation details of the UnoBot project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        IRC["IRC Server"]:::external
        FS["File System"]:::external
    end

    subgraph Interface
        UnoBot["UnoBot"]:::interface
        UnoAIBot["UnoAIBot"]:::interface
        Messenger["Message Handler"]:::interface
    end

    subgraph Core
        Engine["Game Engine"]:::core
        Rules["Game Rules"]:::core
        OpValid["Operation Validator"]:::core
        Config["Configuration"]:::config
    end

    subgraph Players
        PList["Player List"]:::players
        Player["Player"]:::players
        CAList["Circular Array List"]:::players
    end

    subgraph Cards
        Deck["Deck"]:::cards
        Card["Card"]:::cards
    end

    subgraph Scoring
        Score["Score Board"]:::scoring
        SCard["Score Card"]:::scoring
    end

    subgraph AI
        UnoAI["UNO AI"]:::ai
        AIHand["AI Hand Comparator"]:::ai
    end

    %% Connections
    IRC <--> UnoBot
    IRC <--> UnoAIBot
    UnoBot --> Messenger
    UnoAIBot --> Messenger
    Messenger --> Engine
    Engine --> Rules
    Engine --> OpValid
    Engine --> Config
    Engine --> PList
    PList --> Player
    PList --> CAList
    Engine --> Deck
    Deck --> Card
    Engine --> Score
    Score --> SCard
    Score --> FS
    UnoAI --> Engine
    UnoAI --> AIHand

    %% Click Events
    click UnoBot "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/UnoBot.java"
    click UnoAIBot "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/UnoAIBot.java"
    click Engine "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/UnoEngine.java"
    click Player "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/Player.java"
    click PList "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/PlayerList.java"
    click Card "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/Card.java"
    click Deck "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/Deck.java"
    click Score "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/score/ScoreBoard2.java"
    click SCard "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/score/ScoreCard.java"
    click UnoAI "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/UnoAI.java"
    click AIHand "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/AIHandComparator.java"
    click Config "https://github.com/mjsalerno/UnoBot/blob/master/config.ini"
    click OpValid "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/opers/OperValidator.java"
    click Rules "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/Rules.java"
    click CAList "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/CircularArrayList.java"
    click Messenger "https://github.com/mjsalerno/UnoBot/blob/master/src/main/java/com/mjsalerno/unobot/Messenger.java"

    %% Styling
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef interface fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef players fill:#FFD700,stroke:#333,stroke-width:2px
    classDef cards fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef scoring fill:#FFD700,stroke:#333,stroke-width:2px
    classDef ai fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:2px
```
