# gasmith/deckard architecture

> Architecture diagram of the GitHub repository gasmith/deckard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gasmith/deckard
- Repository: https://github.com/gasmith/deckard

## Overview

##### Main Components

a) Core Engine Layer:
- Base components from src/french.rs (French card system) and src/deck.rs
- Use a solid foundation block to represent these core components

b) Game Implementation Layer:
- Above the core engine
- Center around src/euchre/ as the primary game implementation
- Subdivide into key modules:
- Game State (game.rs, round.rs, trick.rs)
- Card Logic (card.rs)
- Player System (player/)
- Action System (action.rs)

c) Player Interface Layer:
- Split into two parallel components:
- Console Player (player/console.rs)
- Robot Player (player/robot.rs)
- How they implement the player interface

d) Terminal UI System:
- This as a top-level component
- Components from src/euchre/tui/
- Subdivide into:
- Main Arena (arena.rs)
- Game Information Display (info.rs, scoreboard.rs)
- Hand Display (hand.rs)
- History Browser (history/)

e) Logging System:
- As a cross-cutting concern
- Round/log/ components
- Tree-structured format

- Blue: Data flow
- Green: User input
- Orange: Game state changes
- Purple: Logging operations

##### Additional Elements

- Notes about key bindings near relevant components
- Configuration flow from args.rs
- GitHub workflow integration points

##### Technical Details to Highlight

- Rust-specific architecture patterns
- Error handling system (error.rs)
- State machine patterns in the game logic
- Component interfaces and trait implementations

##### Future Extensibility

- Placeholder connections for:
- Additional game implementations
- HTTP/JS frontend
- Analysis/coaching systems

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef core fill:#2b6cb0,stroke:#1a4971,color:white
    classDef game fill:#38a169,stroke:#2f855a,color:white
    classDef player fill:#d97706,stroke:#b45309,color:white
    classDef ui fill:#7e22ce,stroke:#6b21a8,color:white
    classDef history fill:#eab308,stroke:#a16207,color:black
    classDef structure fill:#64748b,stroke:#475569,color:white

    %% Core Engine Layer
    subgraph CoreEngine
        French["French Card System"]:::core
        Deck["Deck Management"]:::core
    end

    %% Game Implementation Layer
    subgraph GameImpl
        GameState["Game State"]:::game
        RoundMgmt["Round Management"]:::game
        CardLogic["Card Logic"]:::game
        ActionSys["Action System"]:::game
        TrickMgmt["Trick Management"]:::game
    end

    %% Player Interface Layer
    subgraph Players
        PlayerBase["Player Base System"]:::player
        Console["Console Player"]:::player
        Robot["Robot Player"]:::player
    end

    %% Terminal UI System
    subgraph TerminalUI
        TUIController["Main TUI Controller"]:::ui
        Arena["Arena Display"]:::ui
        HandDisp["Hand Display"]:::ui
        Score["Scoreboard"]:::ui
        ActionUI["Action Interface"]:::ui
        InfoDisp["Information Display"]:::ui
    end

    %% History System
    subgraph History
        HistoryBrowser["History Browser"]:::history
        TreeLog["Tree-structured Log"]:::history
        RoundLog["Round Logging"]:::history
        LogBase["Log Base System"]:::history
    end

    %% Game Structure
    subgraph Structure
        SeatMgmt["Seat Management"]:::structure
        ErrorHandle["Error Handling"]:::structure
        MainGame["Main Game Module"]:::structure
    end

    %% Relationships
    French --> Deck
    Deck --> GameState
    GameState --> RoundMgmt
    RoundMgmt --> TrickMgmt
    CardLogic --> TrickMgmt
    ActionSys --> GameState
    
    PlayerBase --> Console
    PlayerBase --> Robot
    
    TUIController --> Arena
    TUIController --> HandDisp
    TUIController --> Score
    TUIController --> ActionUI
    TUIController --> InfoDisp
    TUIController --> HistoryBrowser
    
    LogBase --> TreeLog
    LogBase --> RoundLog
    RoundLog --> HistoryBrowser
    
    MainGame --> GameState
    MainGame --> SeatMgmt
    ErrorHandle --> MainGame

    %% Click Events
    click French "https://github.com/gasmith/deckard/blob/main/src/french.rs"
    click Deck "https://github.com/gasmith/deckard/blob/main/src/deck.rs"
    click GameState "https://github.com/gasmith/deckard/blob/main/src/euchre/game.rs"
    click RoundMgmt "https://github.com/gasmith/deckard/blob/main/src/euchre/round/base.rs"
    click CardLogic "https://github.com/gasmith/deckard/blob/main/src/euchre/card.rs"
    click ActionSys "https://github.com/gasmith/deckard/blob/main/src/euchre/action.rs"
    click TrickMgmt "https://github.com/gasmith/deckard/blob/main/src/euchre/trick.rs"
    click Console "https://github.com/gasmith/deckard/blob/main/src/euchre/player/console.rs"
    click Robot "https://github.com/gasmith/deckard/blob/main/src/euchre/player/robot.rs"
    click PlayerBase "https://github.com/gasmith/deckard/blob/main/src/euchre/player.rs"
    click Arena "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/arena.rs"
    click HandDisp "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/hand.rs"
    click Score "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/scoreboard.rs"
    click ActionUI "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/action.rs"
    click InfoDisp "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/info.rs"
    click TUIController "https://github.com/gasmith/deckard/blob/main/src/euchre/tui.rs"
    click HistoryBrowser "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/history.rs"
    click TreeLog "https://github.com/gasmith/deckard/blob/main/src/euchre/tui/history/tree.rs"
    click RoundLog "https://github.com/gasmith/deckard/blob/main/src/euchre/round/logging.rs"
    click LogBase "https://github.com/gasmith/deckard/blob/main/src/euchre/round/log.rs"
    click SeatMgmt "https://github.com/gasmith/deckard/blob/main/src/euchre/seat.rs"
    click ErrorHandle "https://github.com/gasmith/deckard/blob/main/src/euchre/error.rs"
    click MainGame "https://github.com/gasmith/deckard/blob/main/src/euchre.rs"

    %% Legend
    classDef legendClass fill:#fff,stroke:#000
    subgraph Legend
        L1["Core Engine"]:::core
        L2["Game Logic"]:::game
        L3["Player Interface"]:::player
        L4["Terminal UI"]:::ui
        L5["History System"]:::history
        L6["Game Structure"]:::structure
    end
```
