# adrior11/roborally architecture

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

- Interactive diagram: https://gitdiagram.com/adrior11/roborally
- Repository: https://github.com/adrior11/roborally

## Overview

##### High-Level Architecture Overview
The system should be represented as a client-server architecture with three main components:
- Server Core
- Client Interface
- Random Bot Implementation

##### Main Components Breakdown

A. Server Core (Primary Component)
- Game Manager Module
- To: TurnManager, GameState
- Relationship with MovementExecutor
- Command System
- Link to CommandRegistry and individual command executors
- Core Game Logic
- Card Management System
- Board Management System
- Player Management System

B. Communication Layer
- TCP Protocol Handler
- Message Serialization System (JSON)
- Server Communication Facade

C. Client Components
- Base Client Interface
- Random Bot Implementation
- Message Handlers

##### Specific Implementation Details

a) Core Game Elements (Green):
- Card System
- Programming Cards
- Damage Cards
- Upgrade Cards
- Shared Deck Management

b) Board Management (Blue):
- Racing Course
- Tile System
- Board Parser
- Position Management

c) Player Management (Yellow):
- Robot Control
- Energy Management
- Programming Register
- Card Management

d) Communication Protocol (Red):
- Message Handlers
- Command System
- Client-Server Protocol

##### Data Flow Representation

- Client-Server Communication Flow
- Game State Updates
- Command Execution Path
- Message Broadcasting

##### Key Design Patterns to Highlight

Patterns with distinct symbols:
- Command Pattern (for game actions)
- Factory Pattern (for card creation)
- Observer Pattern (for game state updates)
- Adapter Pattern (for board management)

##### Implementation Notes

Notes for:
- TCP Protocol Details
- JSON Message Format
- Configuration Options
- Testing Coverage

Remember to emphasize the modular nature of the system, particularly how the command system, card management, and board management can be extended for future enhancements.

This will provide a comprehensive view of the system while maintaining clarity on the core architectural decisions and patterns used in the implementation.

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2b2b2b',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C0000',
    'lineColor': '#F8B229',
    'secondaryColor': '#006100',
    'tertiaryColor': '#0000ff'
  }
}}%%

flowchart TB
    subgraph Server ["Server Core"]
        direction TB
        GM["Game Manager"]
        CS["Command System"]
        CGL["Core Game Logic"]
        
        subgraph GameLogic ["Game Logic Components"]
            direction TB
            CMS["Card Management System"]
            BMS["Board Management System"]
            PMS["Player Management System"]
            ME["Movement Executor"]
            GS["Game State"]
            CR["Command Registry"]
        end
        
        GM --> ME
        GM --> GS
        CS --> CR
        CGL --> CMS
        CGL --> BMS
        CGL --> PMS
    end
    
    subgraph CommLayer ["Communication Layer"]
        direction TB
        TPH["TCP Protocol Handler"]
        MSS["Message Serialization (JSON)"]
        SCF["Server Communication Facade"]
        MH["Message Handlers"]
        
        TPH --> MSS
        MSS --> SCF
        SCF --> MH
    end
    
    subgraph Clients ["Client Components"]
        direction TB
        BCI["Base Client Interface"]
        RBI["Random Bot Implementation"]
        CMH["Client Message Handlers"]
    end
    
    subgraph BoardMgmt ["Board Management"]
        direction TB
        RC["Racing Course"]
        TS["Tile System"]
        BP["Board Parser"]
        PM["Position Management"]
    end
    
    Server <--> CommLayer
    CommLayer <--> Clients
    BMS --- BoardMgmt
    
    classDef default fill:#2b2b2b,stroke:#F8B229,color:#fff
    classDef core fill:#006100,stroke:#F8B229,color:#fff
    classDef comm fill:#7C0000,stroke:#F8B229,color:#fff
    classDef client fill:#0000ff,stroke:#F8B229,color:#fff
    classDef board fill:#4B0082,stroke:#F8B229,color:#fff
    
    class Server,GameLogic core
    class CommLayer,TPH,MSS,SCF,MH comm
    class Clients,BCI,RBI,CMH client
    class BoardMgmt,RC,TS,BP,PM board
    
    click GM "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/core/game/GameManager.java"
    click CS "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/commands/CommandManager.java"
    click CMS "https://github.com/adrior11/roborally/tree/main/src/main/java/com/github/adrior/roborally/core/card/"
    click BMS "https://github.com/adrior11/roborally/tree/main/src/main/java/com/github/adrior/roborally/core/map/"
    click PMS "https://github.com/adrior11/roborally/tree/main/src/main/java/com/github/adrior/roborally/core/player/"
    click ME "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/core/game/MovementExecutor.java"
    click SCF "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/server/ServerCommunicationFacade.java"
    click MH "https://github.com/adrior11/roborally/tree/main/src/main/java/com/github/adrior/roborally/message/handlers/"
    click RC "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/core/map/RacingCourse.java"
    click CR "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/commands/CommandRegistry.java"
    click GS "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/core/game/GameState.java"
    click BCI "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/client/Client.java"
    click RBI "https://github.com/adrior11/roborally/blob/main/src/main/java/com/github/adrior/roborally/random_bot/RandomBot.java"
```
