# lila-kuhlt/mister-x architecture

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

- Interactive diagram: https://gitdiagram.com/lila-kuhlt/mister-x
- Repository: https://github.com/lila-kuhlt/mister-x

## Overview

##### Main System Components
The project consists of three main crates/packages:
- liberica: Frontend application (React/TypeScript)
- robusta: Backend server (Rust)
- trias: API integration library (Rust)

A. Core Components Layout:

##### Frontend Layer (Liberica)
- Sub-components:
- UI Components (React)
- Integration
- WebSocket Client
- Game State Management
- Internationalization (i18n)

##### Backend Layer (Robusta)
- Sub-components:
- WebSocket Server
- Game Logic Handler
- Public Transport Integration
- Route Management

##### External Services Layer
- Public Transport Data Flow

B. Component Relationships:

##### Data flow indicators for
- Real-time game state updates
- Player movements
- Public transport information

Use these visual elements:
- Blue containers for frontend components
- Green containers for backend components
- Yellow containers for external services
- Red highlights for critical game logic paths

Key Architectural Aspects to Highlight:

##### Real-time Communication
- WebSocket connection between frontend and backend
- How game state updates flow

##### Integration
- Connection between map component and transport data
- Route visualization system

##### Data Flow
- Public transport data from TRIAS API
- Game state management
- Player location updates

##### Configuration Elements
- Environment variables
- API tokens
- Transport system configuration

Technical Stack Indicators:

Frontend:
- React/TypeScript
- Tailwind CSS
- WebSocket Client
- Components

Backend:
- Rust Server
- WebSocket Server
- TRIAS API Integration
- Route Management

- Component types
- Communication protocols
- Data flow directions
- Environment configurations

Level of Detail:
- Keep high-level architecture visible
- Critical paths for game functionality
- Configuration points
- Extensibility points for different transport systems

Remember to add notes about:
- Port configurations
- API endpoint requirements
- Regional transport system adaptability
- Development vs. Production setup differences

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend["Frontend Layer (Liberica)"]
        UI["UI Components"]:::frontend
        Map["Map Integration"]:::frontend
        WSClient["WebSocket Client"]:::frontend
        GameState["Game State Management"]:::frontend
        i18n["Internationalization"]:::frontend
        
        subgraph Pages["Game Pages"]
            Admin["Admin Interface"]:::frontend
            Team["Team Creation"]:::frontend
            Game["Game Interface"]:::frontend
            Replay["Replay"]:::frontend
        end
        
        API["API Integration"]:::frontend
        Schema["Data Schema"]:::frontend
    end

    subgraph Backend["Backend Layer (Robusta)"]
        WSServer["WebSocket Server"]:::backend
        GameLogic["Game Logic Handler"]:::backend
        Transport["Public Transport Integration"]:::backend
        Routes["Route Management"]:::backend
    end

    subgraph External["External Services"]
        TRIAS["TRIAS API"]:::external
        subgraph TriasLib["TRIAS Integration Library"]
            Location["Location Services"]:::external
            TripInfo["Trip Information"]:::external
        end
    end

    %% Relationships
    WSClient <--> WSServer
    GameState --> WSClient
    UI --> Map
    UI --> GameState
    UI --> i18n
    
    WSServer --> GameLogic
    GameLogic --> Transport
    Transport --> Routes
    
    Transport --> TRIAS
    TRIAS --> Location
    TRIAS --> TripInfo
    
    API --> WSClient
    Schema --> API

    %% Click Events
    click UI "https://github.com/Lila-Kuhlt/mister-x/tree/main/liberica/src/components"
    click Map "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/components/map/Map.tsx"
    click WSClient "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/lib/websockets.ts"
    click GameState "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/page/Game.tsx"
    click i18n "https://github.com/Lila-Kuhlt/mister-x/tree/main/liberica/src/i18n"
    click Admin "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/page/Admin.tsx"
    click Team "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/page/CreateTeam.tsx"
    click Game "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/page/Game.tsx"
    click Replay "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/page/Replay.tsx"
    click API "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/lib/api.ts"
    click Schema "https://github.com/Lila-Kuhlt/mister-x/blob/main/liberica/src/lib/schema.ts"
    click WSServer "https://github.com/Lila-Kuhlt/mister-x/blob/main/robusta/src/ws_message.rs"
    click Transport "https://github.com/Lila-Kuhlt/mister-x/blob/main/robusta/src/kvv.rs"
    click Routes "https://github.com/Lila-Kuhlt/mister-x/blob/main/robusta/data/route_curves.csv"
    click TRIAS "https://github.com/Lila-Kuhlt/mister-x/blob/main/trias/src/lib.rs"
    click Location "https://github.com/Lila-Kuhlt/mister-x/blob/main/trias/src/location_information.rs"
    click TripInfo "https://github.com/Lila-Kuhlt/mister-x/blob/main/trias/src/trip_info.rs"

    %% Styles
    classDef frontend fill:#3b82f6,color:#fff
    classDef backend fill:#22c55e,color:#fff
    classDef external fill:#eab308,color:#000
    
    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Component"]:::backend
        External_L["External Service"]:::external
    end
```
