# jcpsimmons/poker architecture

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

## Overview

##### Main Components

a. Client Components (Left Side):
- UI Module (from ui/*.go files)
- Components
- Connections
- Utils
- Multiple client instances to indicate multi-user support

b. Server Component (Right Side):
- WebSocket Server (from server/server.go)
- Message Handler (from messaging/messaging.go)
- Port 8080 notation

c. Communication Layer (Middle):
- WebSocket connections (ws:// or wss://)
- Optional NgRok tunnel for external access

##### Component Relationships

- Bidirectional WebSocket communication between clients and server
- Message flow through the system
- Host client's special control capabilities
- Optional NgRok tunnel routing

##### Specific Implementation Details

**🔷 Client Component**
**🔶 Server Component**
**↔️ WebSocket Communication**
**🔐 Host Controls**

**[Client Layer]**
- ↕️ WebSocket (ws:// or wss://)
**[Optional NgRok Layer]**
- ↕️ WebSocket
**[Server Layer]**

##### Important Notes

- Lightweight nature of the application
- Types package (types/types.go) as a shared component between client and server
- Port configuration (8080 default)
- Both local network and internet-facing deployment options
- Messaging protocol flow

##### Technical Details to Highlight

- WebSocket-based real-time communication
- Terminal-based user interface
- Host/Client role separation
- Message passing system
- State management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Layer"
        direction TB
        C1["Client TUI Instance 1"]:::client
        C2["Client TUI Instance 2 (Host)"]:::hostclient
        C3["Client TUI Instance 3"]:::client
        
        subgraph "TUI Components"
            direction TB
            UI["UI Core"]:::client
            UICOMP["UI Components"]:::client
            UICON["UI Connections"]:::client
            UIUTIL["UI Utilities"]:::client
            
            UI --> UICOMP
            UI --> UICON
            UI --> UIUTIL
        end
        
        C1 --> TUI
        C2 --> TUI
        C3 --> TUI
    end
    
    subgraph "Communication Layer"
        WS["WebSocket Protocol (ws:// or wss://)"]:::comm
        NG["NgRok Tunnel (Optional)"]:::ngrok
    end
    
    subgraph "Server Layer"
        direction TB
        SRV["WebSocket Server\nPort: 8080"]:::server
        MSG["Message Handler"]:::server
        TYPES["Shared Types"]:::shared
        
        SRV --> MSG
        SRV --> TYPES
        MSG --> TYPES
    end
    
    C1 --> WS
    C2 --> WS
    C3 --> WS
    WS --> NG
    NG --> SRV
    WS --> SRV
    
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef hostclient fill:#f1c40f,stroke:#f39c12,color:black
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef comm fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef ngrok fill:#9b59b6,stroke:#8e44ad,color:white
    classDef shared fill:#e74c3c,stroke:#c0392b,color:white
    
    click UI "https://github.com/jcpsimmons/poker/blob/master/ui/ui.go"
    click UICOMP "https://github.com/jcpsimmons/poker/blob/master/ui/components.go"
    click UICON "https://github.com/jcpsimmons/poker/blob/master/ui/connections.go"
    click UIUTIL "https://github.com/jcpsimmons/poker/blob/master/ui/utils.go"
    click SRV "https://github.com/jcpsimmons/poker/blob/master/server/server.go"
    click MSG "https://github.com/jcpsimmons/poker/blob/master/messaging/messaging.go"
    click TYPES "https://github.com/jcpsimmons/poker/blob/master/types/types.go"
    
    %% Legend
    subgraph Legend
        L1["Client Component"]:::client
        L2["Host Client"]:::hostclient
        L3["Server Component"]:::server
        L4["Communication"]:::comm
        L5["NgRok Tunnel"]:::ngrok
        L6["Shared Component"]:::shared
    end
```
