# siladu/poker architecture

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

- Interactive diagram: https://gitdiagram.com/siladu/poker
- Repository: https://github.com/siladu/poker

## Overview

##### Project Overview
- This is a Java-based project built with Gradle. It implements a Poker game simulation with core classes focused on game mechanics such as cards, decks, hands, rounds, and overall game statistics.
- The README points out that the hand winning rules are derived from external websites, suggesting that the game logic follows standard poker rules.

##### Main Components
- Application Entry Point: Represented by Application.java; this is likely where the program starts and orchestrates game flow.
- Core Domain Objects:
- Card.java: Models individual cards.
- Deck.java: Represents a full set of cards and contains operations for shuffling and dealing.
- Hand.java: Represents a player’s hand and is involved in determining hand value.
- Round.java: Represents a single round of poker with its own game mechanics.
- Game.java: Likely coordinates the entire game process (dealing, turns, rules, etc.).
- Statistics.java: Handles tracking of game statistics which may include wins, losses, or hand rankings.
- Supporting Files:
- playstyles.txt: Contains information on play styles or possibly configuration for gameplay strategies.
- Testing Components:
- Located in the src/test directory, covering DeckTest.java, HandComparisonTest.java, HandTest.java, and RoundTest.java that verify the logic accuracy of the core components.

##### Relationships and Interactions
- The Application component initializes and invokes the Game component.
- The Game component coordinates actions with the Deck, Card, Hand, and Round classes to simulate a round of poker.
- The Hand and Round classes interact to determine winners based on the rules provided in the README.
- The Statistics class aggregates data from game rounds and hands.
- Test classes are designed to invoke and validate logic within these components, ensuring consistency in how the game mechanics work.

##### Architectural Patterns and Design Principles
- The project follows a modular design by breaking down the game logic into individual, cohesive classes.
- There is a separation of concerns: different classes handle specific aspects of the game (card management, game state, hand ranking, and statistical reporting).
- Although not explicitly shown in the file structure, the use of Gradle indicates that dependency management and build configuration are handled externally.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Main Application Flow"
        A["Application: Entry Point"]:::application
        G["Game: Coordinates game mechanics"]:::domain
        C["Card: Models an individual card"]:::domain
        D["Deck: Manages card ordering and dealing"]:::domain
        H["Hand: Represents a player's hand"]:::domain
        R["Round: Represents a single poker round"]:::domain
        S["Statistics: Aggregates game data"]:::supporting
        X["External Data: playstyles.txt (Game configuration)"]:::supporting

        A -->|"initializes"| G
        G -->|"uses"| C
        G -->|"uses"| D
        G -->|"uses"| H
        G -->|"uses"| R
        H -->|"updates"| S
        R -->|"reports"| S
        G -->|"reads"| X
    end

    subgraph "Testing Suite"
        T["Tests (DeckTest, HandTest, HandComparisonTest, RoundTest)"]:::tests
    end

    %% Indicate that tests validate core components
    T ---|"validates"| D
    T ---|"validates"| H
    T ---|"validates"| R

    %% Click events for main components
    click A "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Application.java"
    click G "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Game.java"
    click C "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Card.java"
    click D "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Deck.java"
    click H "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Hand.java"
    click R "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Round.java"
    click S "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/Statistics.java"
    click X "https://github.com/siladu/poker/blob/master/src/main/java/com/simondudley/poker/playstyles.txt"
    click T "https://github.com/siladu/poker/tree/master/src/test/java/com/simondudley/poker/"

    %% Styles
    classDef application fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef domain fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef supporting fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef tests fill:#FFB6C1,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5;
```
