# jensbarthel/nnpoker architecture

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

- Interactive diagram: https://gitdiagram.com/jensbarthel/nnpoker
- Repository: https://github.com/jensbarthel/nnpoker

## Overview

##### Project type and purpose
- This is an open-source Kotlin library/application implementing the core logic for Texas Hold ’Em poker (“nnpoker”).
- It provides a domain-driven model of a casino, tables, players, dealers, cards/decks, rounds, pot, community cards and a ranking service.
- It’s packaged as a Gradle project with a small “app” entry point (CasinoApplication) and a suite of unit tests.

##### File structure
- Top-level build:
- build.gradle.kts, gradle.properties, Gradle wrapper under src/poker/gradle
- settings.gradle pulls in the “poker” project
- src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/
- app: CasinoApplication.kt (bootstrap)
- domain/casino: Table, Dealer, Player, BettingParty, TableObserver, TableAuthority, TableNumber
- domain/game: Round, State, Pot, CommunityCards, RankingService
- domain/game/deck: Card, Deck, DeckFactory, Suit, Face
- domain/game/hand: HandRank, HandRanker hierarchy (Compound, Flush, Straight, etc.), HoleCards
- src/poker/src/test: parallel structure of unit tests for each domain component.

##### README
- Very concise: “Kotlin Texas Hold ’Em.” No additional architecture notes; we’ll reverse-engineer from code structure.

##### Detailed separation
- Every major class or interface (Dealer, Table, Player, DeckFactory, RankingService, CompoundRanker, etc.) is a component.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Application Layer
    subgraph "Application Layer"
        CasinoApplication["CasinoApplication"]:::app
    end

    %% Domain Layer
    subgraph "Domain Layer"
        subgraph "Casino Module"
            Dealer["Dealer"]:::casino
            Table["Table"]:::casino
            Player["Player"]:::casino
            BettingParty["BettingParty"]:::casino
            TableObserver["TableObserver"]:::casino
            TableAuthority["TableAuthority"]:::casino
            TableNumber["TableNumber"]:::casino
        end

        subgraph "Game Module"
            Round["Round"]:::game
            State["State"]:::game
            Pot["Pot"]:::game
            CommunityCards["CommunityCards"]:::game
            RankingService["RankingService"]:::game
        end

        subgraph "Deck Module"
            DeckFactory["DeckFactory"]:::deck
            Deck["Deck"]:::deck
            Card["Card"]:::deck
            Suit["Suit"]:::deck
            Face["Face"]:::deck
        end

        subgraph "Hand-Ranking Module"
            HandRank["HandRank"]:::hand
            HandRanker["HandRanker"]:::hand
            CompoundRanker["CompoundRanker"]:::hand
            FlushRanker["FlushRanker"]:::hand
            StraightFlushRanker["StraightFlushRanker"]:::hand
            StraightRanker["StraightRanker"]:::hand
            HighCardRanker["HighCardRanker"]:::hand
            PairingRanker["PairingRanker"]:::hand
            HoleCards["HoleCards"]:::hand
        end
    end

    %% Infrastructure / Build
    subgraph "Infrastructure / Build"
        BuildScript["build.gradle.kts"]:::infra
        Settings["settings.gradle"]:::infra
        Properties["gradle.properties"]:::infra
        Wrapper["gradle-wrapper.properties"]:::infra
    end

    %% Relationships
    CasinoApplication -->|"invokes"| Dealer
    Dealer -->|"manages"| Table
    Dealer -->|"uses"| DeckFactory
    DeckFactory -->|"creates"| Deck
    Deck -->|"deals HoleCards"| HoleCards
    Deck -->|"deals CommunityCards"| CommunityCards
    Round -->|"manages State"| State
    Round -->|"updates Pot"| Pot
    Round -->|"updates CommunityCards"| CommunityCards
    RankingService -->|"uses"| CompoundRanker
    CompoundRanker -->|"delegates to"| FlushRanker
    CompoundRanker -->|"delegates to"| StraightFlushRanker
    CompoundRanker -->|"delegates to"| StraightRanker
    CompoundRanker -->|"delegates to"| HighCardRanker
    CompoundRanker -->|"delegates to"| PairingRanker
    Table -->|"notifies"| TableObserver

    %% Click Events
    click CasinoApplication "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/app/CasinoApplication.kt"
    click Table "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/Table.kt"
    click Dealer "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/Dealer.kt"
    click Player "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/Player.kt"
    click BettingParty "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/BettingParty.kt"
    click TableObserver "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/TableObserver.kt"
    click TableAuthority "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/TableAuthority.kt"
    click TableNumber "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/casino/TableNumber.kt"
    click Round "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/Round.kt"
    click State "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/State.kt"
    click Pot "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/Pot.kt"
    click CommunityCards "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/CommunityCards.kt"
    click RankingService "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/RankingService.kt"
    click Card "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/deck/Card.kt"
    click Deck "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/deck/Deck.kt"
    click DeckFactory "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/deck/DeckFactory.kt"
    click Suit "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/deck/Suit.kt"
    click Face "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/deck/Face.kt"
    click HandRank "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/HandRank.kt"
    click HandRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/HandRanker.kt"
    click CompoundRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/CompoundRanker.kt"
    click FlushRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/FlushRanker.kt"
    click StraightFlushRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/StraightFlushRanker.kt"
    click StraightRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/StraightRanker.kt"
    click HighCardRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/HighCardRanker.kt"
    click PairingRanker "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/PairingRanker.kt"
    click HoleCards "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/src/main/kotlin/com/github/jensbarthel/nnpoker/domain/game/hand/HoleCards.kt"
    click BuildScript "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/build.gradle.kts"
    click Settings "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/settings.gradle"
    click Properties "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/gradle.properties"
    click Wrapper "https://github.com/jensbarthel/nnpoker/blob/master/src/poker/gradle/wrapper/gradle-wrapper.properties"

    %% Styles
    classDef app fill:#add8e6,stroke:#333,stroke-width:1px
    classDef casino fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef game fill:#a0e996,stroke:#333,stroke-width:1px
    classDef deck fill:#f9f29b,stroke:#333,stroke-width:1px
    classDef hand fill:#f2d48b,stroke:#333,stroke-width:1px
    classDef infra fill:#d3d3d3,stroke:#333,stroke-width:1px
```
