# hasangergames/suroi architecture

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

- Interactive diagram: https://gitdiagram.com/hasangergames/suroi
- Repository: https://github.com/hasangergames/suroi

## Overview

a. Client ↔ Server Communication
- WebSocket connections
- Game state updates
- Player input
- Packet streaming

b. Internal Systems
- Game object updates
- Physics calculations
- Player interactions
- Asset loading

a. Game Logic
- Player management
- Inventory system
- Combat system
- Generation
- Gas system

b. Asset Pipeline
- Images
- Audio
- Translations
- Data

- Node.js runtime
- PixiJS rendering
- SASS/CSS styling
- Vite build system

##### Specific Implementation Details

- Client-side game loop
- Server-side game loop
- Shared resources
- Network layer

b. Important features:
- Multi-language support
- Plugin system
- Console commands
- Performance monitoring

##### Error handling and fallback systems

- The real-time nature of the game
- Client-server architecture
- Asset management system
- Plugin extensibility
- Multi-language support
- Build and deployment pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        GC[Game Client]
        RE[Rendering Engine]
        IM[Input Manager]
        SM[Sound Manager]
        UM[UI Manager]
        GMC[Game Console]
        AM[Asset Management]
    end

    subgraph Server
        WS[WebSocket Server]
        GM[Game Manager]
        PS[Plugin System]
        AS[Authentication Server]
        MS[Map System]
        PE[Physics Engine]
    end

    subgraph Common
        GO[Game Objects]
        DEF[Definitions]
        PKT[Packet System]
        MU[Math Utilities]
        CON[Constants]
    end

    subgraph GameLogic
        PM[Player Management]
        INV[Inventory System]
        CS[Combat System]
        MG[Map Generation]
        GS[Gas System]
    end

    subgraph External
        NODE[Node.js]
        PIXI[PixiJS]
        SASS[SASS/CSS]
        VITE[Vite]
    end

    %% Connections
    GC --> WS
    WS --> GC
    GM --> WS
    PS --> GM
    MS --> GM
    PE --> GM
    IM --> GC
    SM --> GC
    UM --> GC
    GMC --> GC
    AM --> GC
    RE --> GC

    %% Common Layer Connections
    GO --> GC
    GO --> GM
    DEF --> GC
    DEF --> GM
    PKT --> GC
    PKT --> WS
    MU --> GC
    MU --> GM
    CON --> GC
    CON --> GM

    %% Game Logic Connections
    PM --> GM
    INV --> GM
    CS --> GM
    MG --> MS
    GS --> GM

    %% External Dependencies
    NODE --> WS
    PIXI --> RE
    SASS --> UM
    VITE --> GC

    %% Styling
    classDef client fill:#a8d1f0
    classDef server fill:#90EE90
    classDef common fill:#FFE5B4
    classDef gamelogic fill:#E6E6FA
    classDef external fill:#F0F0F0

    class GC,RE,IM,SM,UM,GMC,AM client
    class WS,GM,PS,AS,MS,PE server
    class GO,DEF,PKT,MU,CON common
    class PM,INV,CS,MG,GS gamelogic
    class NODE,PIXI,SASS,VITE external

    %% Click Events
    click GC "https://github.com/HasangerGames/suroi/blob/master/client/src/scripts/game.ts"
    click IM "https://github.com/HasangerGames/suroi/blob/master/client/src/scripts/managers/inputManager.ts"
    click SM "https://github.com/HasangerGames/suroi/blob/master/client/src/scripts/managers/soundManager.ts"
    click UM "https://github.com/HasangerGames/suroi/blob/master/client/src/scripts/managers/uiManager.ts"
    click GMC "https://github.com/HasangerGames/suroi/blob/master/client/src/scripts/utils/console/gameConsole.ts"
    click AM "https://github.com/HasangerGames/suroi/tree/master/client/public/"
    click WS "https://github.com/HasangerGames/suroi/blob/master/server/src/server.ts"
    click GM "https://github.com/HasangerGames/suroi/blob/master/server/src/gameManager.ts"
    click PS "https://github.com/HasangerGames/suroi/blob/master/server/src/pluginManager.ts"
    click MS "https://github.com/HasangerGames/suroi/blob/master/server/src/map.ts"
    click PE "https://github.com/HasangerGames/suroi/blob/master/server/src/objects/gameObject.ts"
    click GO "https://github.com/HasangerGames/suroi/blob/master/common/src/utils/gameObject.ts"
    click DEF "https://github.com/HasangerGames/suroi/tree/master/common/src/definitions/"
    click PKT "https://github.com/HasangerGames/suroi/tree/master/common/src/packets/"
    click MU "https://github.com/HasangerGames/suroi/blob/master/common/src/utils/math.ts"
    click CON "https://github.com/HasangerGames/suroi/blob/master/common/src/constants.ts"
    click INV "https://github.com/HasangerGames/suroi/tree/master/server/src/inventory/"
    click PKT "https://github.com/HasangerGames/suroi/blob/master/common/src/packets/packetStream.ts"
```
