# bronkoknorb/type-draw-type-game architecture

> Architecture diagram of the GitHub repository bronkoknorb/type-draw-type-game, 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/bronkoknorb/type-draw-type-game
- Repository: https://github.com/bronkoknorb/type-draw-type-game

## Overview

##### Main Components

a) Frontend (React Application)
- User Interface Components
- WebSocket Client
- State Management
- Drawing Tools
- Game Flow Controllers

b) Backend (Spring Boot Server)
- WebSocket Server
- Game Management
- Player State Machine
- Storage System
- REST API Endpoints

c) Persistence Layer
- File System Storage (~/tdt-data)

##### Component Relationships and Architecture

**[Client Layer]**
- ↕️ WebSocket/HTTP
**[Server Layer]**
- ↕️ File I/O
**[Storage Layer]**

##### Detailed Component Breakdown

Frontend Components (tdt-webapp):
- WebSocket Client Connection
- Game State Management
- Drawing Canvas System
- Player Management Interface

Backend Components (tdt-server):
- WebSocket Handler
- Game Manager
- Player State Machine
- Game Rounds Generator
- Story Management

Storage:

##### Interaction Flows

- WebSocket communication between frontend and backend
- Game state updates
- Player actions flow
- Data persistence operations

##### Technical Stack Indicators

Technology labels:
- React/TypeScript (Frontend)
- Spring Boot (Backend)
- WebSocket Protocol
- Docker Container
- File System Storage

##### Additional Elements

- Notes about scaling considerations
- Development vs production paths
- Version/build process flow

##### Specific Implementation Details

- The game's turn-based nature
- Real-time updates via WebSocket
- Player state transitions
- Story chain progression
- Drawing/typing round alternation

##### Deployment Context

Docker container boundary and how it encapsulates both frontend and backend components, with exposed port 8080 mapped to host port 8081.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[User Interface]
        GC[Game Components]:::game
        click GC "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/Game.tsx"
        
        subgraph "UI Components"
            Draw[Draw Component]:::ui
            Type[Type Component]:::ui
            Stories[Stories Component]:::ui
            click Draw "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/Draw.tsx"
            click Type "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/Type.tsx"
            click Stories "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/Stories.tsx"
        end
        
        subgraph "Drawing System"
            Canvas[Draw Canvas]:::draw
            Tools[Draw Tools]:::draw
            Colors[Color Picker]:::draw
            click Canvas "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/DrawCanvas.tsx"
            click Tools "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/DrawTools.tsx"
            click Colors "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/ColorPicker.tsx"
        end
        
        StateManager[State Manager]:::state
        click StateManager "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-webapp/src/model.ts"
        WSClient[WebSocket Client]:::ws
    end
    
    subgraph Server
        WSServer[WebSocket Server]:::ws
        click WSServer "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/WebSocketHandler.java"
        
        subgraph "Game Core"
            GameMgr[Game Manager]:::game
            GameGen[Game Rounds Generator]:::game
            click GameMgr "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/GameManager.java"
            click GameGen "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/GameRoundsGenerator.java"
        end
        
        subgraph "Player States"
            PSM[Player State Machine]:::state
            DS[Draw State]:::state
            TS[Type State]:::state
            SS[Stories State]:::state
            click PSM "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/playerstate/PlayerState.java"
            click DS "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/playerstate/DrawState.java"
            click TS "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/playerstate/TypeState.java"
            click SS "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/playerstate/StoriesState.java"
        end
        
        API[REST API Controller]:::api
        click API "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/Controller.java"
        
        subgraph "Actions"
            Access[Access Action]:::action
            Join[Join Action]:::action
            TypeAct[Type Action]:::action
            click Access "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/actions/AccessAction.java"
            click Join "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/actions/JoinAction.java"
            click TypeAct "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/actions/TypeAction.java"
        end
    end
    
    subgraph Storage
        FileSystem[File System Storage]:::storage
        GameLoader[Game Loader]:::storage
        click GameLoader "https://github.com/Bronkoknorb/type-draw-type-game/blob/master/tdt-server/src/main/java/net/czedik/hermann/tdt/GameLoader.java"
    end
    
    %% Connections
    UI --> GC
    GC --> Draw & Type & Stories
    Draw --> Canvas
    Canvas --> Tools
    Tools --> Colors
    GC --> StateManager
    StateManager --> WSClient
    WSClient <--> WSServer
    WSServer --> GameMgr
    GameMgr --> GameGen
    GameMgr --> PSM
    PSM --> DS & TS & SS
    API --> GameMgr
    GameMgr --> Access & Join & TypeAct
    GameMgr --> GameLoader
    GameLoader --> FileSystem
    
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef game fill:#2ecc71,stroke:#27ae60,color:white
    classDef draw fill:#e74c3c,stroke:#c0392b,color:white
    classDef state fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ws fill:#f1c40f,stroke:#f39c12,color:black
    classDef api fill:#1abc9c,stroke:#16a085,color:white
    classDef action fill:#e67e22,stroke:#d35400,color:white
    classDef storage fill:#34495e,stroke:#2c3e50,color:white
```
