# raphaeltarita/skullgame-common architecture

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

- Interactive diagram: https://gitdiagram.com/raphaeltarita/skullgame-common
- Repository: https://github.com/raphaeltarita/skullgame-common

## Overview

##### Main Components

a) Core Library Components:
- Common Module (Central component)
- Authentication System
- Game State Management
- Move System
- Condition System

b) Platform Targets (as supported implementations):
- JVM Target
- JS Target (Browser & NodeJS)
- WASM Target (Browser & NodeJS)
- Native Targets (Various platforms)

**┌─ Platform Targets Layer ─────────────────────────┐**
- [JVM]  [JS]  [WASM]  [Native Implementations]  │
- ┬───────────────────────────────┘

**┌─ Core Library Layer ──────────────────────────────┐**
- ┌─ Game Logic ─────────────────────────────────┐ │
- Moves System                              │ │
- State Management                          │ │
- ┘ │
- ┌─ Common Infrastructure ───────────────────────┐ │
- Authentication                            │ │
- Conditions System                         │ │
- ┘ │
- ┘

##### Specific Component Details

a) Authentication Components:
- LoginCredentials
- TokenHolder

b) Game State Components:
- GameState
- PlayerGame
- PlayerInfo
- Card
- TurnMode

c) Moves System:
- Various move types (Bid, Lay, Guess, etc.)
- Move outcomes
- Round management

d) Condition System:
- Boolean conditions
- Signal conditions
- Rendezvous conditions
- Conflated conditions

##### Important Relationships

- How the common code is shared across all platform targets
- Relationship between game state and moves
- Condition system's interaction with game state management
- Authentication flow integration

##### Implementation Notes

- The library's role as a shared component between server and clients
- Platform-agnostic nature of the core components
- Clear separation between game logic and infrastructure components
- Extensibility points for different platforms

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef platform fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef auth fill:#FFA500,stroke:#333,stroke-width:2px
    classDef game fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef infra fill:#FFE4B5,stroke:#333,stroke-width:2px

    %% Platform Layer
    subgraph Platforms
        JVM["JVM Target"]:::platform
        JS["JS Target"]:::platform
        WASM["WASM Target"]:::platform
        Native["Native Targets"]:::platform
    end

    %% Core Library Layer
    CommonModule["Common Module"]:::core
    click CommonModule "https://github.com/RaphaelTarita/skullgame-common/tree/main/src/commonMain/kotlin/com/rtarita/skull/common"

    %% Authentication Components
    subgraph Auth
        AuthSystem["Authentication System"]:::auth
        click AuthSystem "https://github.com/RaphaelTarita/skullgame-common/tree/main/src/commonMain/kotlin/com/rtarita/skull/common/auth"
        LoginCred["Login Credentials"]:::auth
        click LoginCred "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/auth/LoginCredentials.kt"
        TokenH["Token Holder"]:::auth
        click TokenH "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/auth/TokenHolder.kt"
    end

    %% Game State Components
    subgraph GameState
        StateSystem["Game State Management"]:::game
        click StateSystem "https://github.com/RaphaelTarita/skullgame-common/tree/main/src/commonMain/kotlin/com/rtarita/skull/common/state"
        GState["Game State"]:::game
        click GState "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/state/GameState.kt"
        PGame["Player Game"]:::game
        click PGame "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/state/PlayerGame.kt"
        PInfo["Player Info"]:::game
        click PInfo "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/state/PlayerInfo.kt"
        Card["Card"]:::game
        click Card "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/state/Card.kt"
        TMode["Turn Mode"]:::game
        click TMode "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/state/TurnMode.kt"
    end

    %% Move System
    subgraph Moves
        MoveSystem["Move System"]:::game
        click MoveSystem "https://github.com/RaphaelTarita/skullgame-common/tree/main/src/commonMain/kotlin/com/rtarita/skull/common/moves"
        Move["Move"]:::game
        click Move "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/moves/Move.kt"
        Bid["Bid"]:::game
        click Bid "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/moves/Bid.kt"
        Lay["Lay"]:::game
        click Lay "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/moves/Lay.kt"
        Guess["Guess"]:::game
        click Guess "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/moves/Guess.kt"
        MOutcome["Move Outcome"]:::game
        click MOutcome "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/moves/MoveOutcome.kt"
    end

    %% Condition System
    subgraph Conditions
        CondSystem["Condition System"]:::infra
        click CondSystem "https://github.com/RaphaelTarita/skullgame-common/tree/main/src/commonMain/kotlin/com/rtarita/skull/common/condition"
        Condition["Condition"]:::infra
        click Condition "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/condition/Condition.kt"
        BoolCond["Boolean Condition"]:::infra
        click BoolCond "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/condition/BooleanCondition.kt"
        SigCond["Signal Condition"]:::infra
        click SigCond "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/condition/SignalCondition.kt"
        RenCond["Rendezvous Condition"]:::infra
        click RenCond "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/condition/RendezvousCondition.kt"
        ConCond["Conflated Condition"]:::infra
        click ConCond "https://github.com/RaphaelTarita/skullgame-common/blob/main/src/commonMain/kotlin/com/rtarita/skull/common/condition/ConflatedCondition.kt"
    end

    %% Relationships
    JVM & JS & WASM & Native --> CommonModule
    CommonModule --> AuthSystem & StateSystem & MoveSystem & CondSystem
    AuthSystem --> LoginCred & TokenH
    StateSystem --> GState & PGame & PInfo & Card & TMode
    MoveSystem --> Move & Bid & Lay & Guess & MOutcome
    CondSystem --> Condition & BoolCond & SigCond & RenCond & ConCond
    
    %% Legend
    subgraph Legend
        L1["Platform Components"]:::platform
        L2["Core Components"]:::core
        L3["Authentication Components"]:::auth
        L4["Game Components"]:::game
        L5["Infrastructure Components"]:::infra
    end
```
