# mirbeta/openmir2 architecture

> Architecture diagram of the GitHub repository mirbeta/openmir2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mirbeta/openmir2
- Repository: https://github.com/mirbeta/openmir2

## Overview

OpenMir2 is a multiplayer Legend of Mir 2 server. The documented player flow is login through LoginGate/LoginSrv, character selection through a separate gateway, then game traffic through GameGate to GameSrv. GameSrv hosts the world and gameplay systems; DBSrv provides persistence. The tree contains CloudGate but not a SelGate-named project, so its character-selection role is not assumed. The README establishes service responsibilities and forwarding; sampled excerpts show storage, scripting, magic, and gateway behavior, but do not establish all inter-service wiring.

Main entry points: [`src/M2Server/Player/PlayObject.cs`](https://github.com/mirbeta/openmir2/blob/master/src/M2Server/Player/PlayObject.cs) (World engine), [`src/MapSrv/Pipeline.cs`](https://github.com/mirbeta/openmir2/blob/master/src/MapSrv/Pipeline.cs) (Map pipeline), [`src/LoginGate/AppService.cs`](https://github.com/mirbeta/openmir2/blob/master/src/LoginGate/AppService.cs) (LoginGate), [`src/CloudGate/AppService.cs`](https://github.com/mirbeta/openmir2/blob/master/src/CloudGate/AppService.cs) (CloudGate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateways["Client gateways"]
  node_login_gate["LoginGate<br/>[AppService.cs]"]
  node_character_gate["CloudGate<br/>[AppService.cs]"]
  node_game_gate["GameGate<br/>[AppService.cs]"]
end

subgraph group_identity["Accounts and data"]
  node_login_srv["LoginSrv<br/>[LoginServer.cs]"]
  node_account_store[("Account storage<br/>[AccountStorage.cs]")]
  node_db_srv["DBSrv<br/>[AppService.cs]"]
  node_character_store[("Character storage")]
end

subgraph group_gameplay["Game runtime"]
  node_game_srv["GameSrv<br/>[GameServer.cs]"]
  node_world["World engine<br/>[PlayObject.cs]"]
  node_maps["Map service<br/>[AppService.cs]"]
end

subgraph group_features["Game features"]
  node_magic["Magic system<br/>[MagicManager.cs]"]
  node_scripts["NPC scripts<br/>[ScriptEngine.cs]"]
  node_commands["Game commands<br/>[GameCommand.cs]"]
  node_chat_module["Chat module<br/>[ChatService.cs]"]
  node_market["Market system<br/>[MarketService.cs]"]
  node_robots["Robot system<br/>[RobotProcessor.cs]"]
end

subgraph group_services["Supporting services"]
  node_chat_srv["ChatSrv<br/>[AppService.cs]"]
  node_log_srv["LogDataSrv<br/>[AppService.cs]"]
  node_map_pipe["Map pipeline<br/>[Pipeline.cs]"]
end

node_players(("Game clients"))
node_map_clients(("Map pipe clients"))

node_players -->|"login traffic"| node_login_gate
node_login_gate -->|"forwards login"| node_login_srv
node_login_srv -->|"reads and updates"| node_account_store
node_players -.->|"character traffic"| node_character_gate
node_character_gate -.->|"character requests"| node_db_srv
node_db_srv -.->|"persists characters"| node_character_store
node_players -->|"game traffic"| node_game_gate
node_game_gate -->|"forwards player data"| node_game_srv
node_game_srv -->|"runs world"| node_world
node_world -->|"uses spells"| node_magic
node_world -->|"runs NPC scripts"| node_scripts
node_world -->|"dispatches commands"| node_commands
node_world -.->|"uses chat"| node_chat_module
node_world -.->|"uses market"| node_market
node_world -.->|"runs robots"| node_robots
node_map_clients -->|"connects by pipe"| node_map_pipe
node_map_pipe -->|"reads and replies"| node_map_pipe

click node_login_gate "https://github.com/mirbeta/openmir2/blob/master/src/LoginGate/AppService.cs"
click node_login_srv "https://github.com/mirbeta/openmir2/blob/master/src/LoginSrv/Services/LoginServer.cs"
click node_account_store "https://github.com/mirbeta/openmir2/blob/master/src/LoginSrv/Storage/AccountStorage.cs"
click node_character_gate "https://github.com/mirbeta/openmir2/blob/master/src/CloudGate/AppService.cs"
click node_db_srv "https://github.com/mirbeta/openmir2/blob/master/src/DBSrv/AppService.cs"
click node_character_store "https://github.com/mirbeta/openmir2/blob/master/src/Storeages/DBSvr.Storage.MySQL/PlayDataStorage.Save.cs"
click node_game_gate "https://github.com/mirbeta/openmir2/blob/master/src/GameGate/AppService.cs"
click node_game_srv "https://github.com/mirbeta/openmir2/blob/master/src/GameSrv/GameServer.cs"
click node_world "https://github.com/mirbeta/openmir2/blob/master/src/M2Server/Player/PlayObject.cs"
click node_maps "https://github.com/mirbeta/openmir2/blob/master/src/MapSrv/AppService.cs"
click node_magic "https://github.com/mirbeta/openmir2/blob/master/src/M2Server/Magic/MagicManager.cs"
click node_scripts "https://github.com/mirbeta/openmir2/blob/master/src/Modules/ScriptEngine/ScriptEngine.cs"
click node_commands "https://github.com/mirbeta/openmir2/blob/master/src/Modules/GameCommand/GameCommand.cs"
click node_chat_module "https://github.com/mirbeta/openmir2/blob/master/src/Modules/ChatSystem/ChatService.cs"
click node_market "https://github.com/mirbeta/openmir2/blob/master/src/Modules/MarketSystem/Services/MarketService.cs"
click node_robots "https://github.com/mirbeta/openmir2/blob/master/src/Modules/RobotSystem/RobotProcessor.cs"
click node_chat_srv "https://github.com/mirbeta/openmir2/blob/master/src/ChatSrv/AppService.cs"
click node_log_srv "https://github.com/mirbeta/openmir2/blob/master/src/LogDataSrv/AppService.cs"
click node_map_pipe "https://github.com/mirbeta/openmir2/blob/master/src/MapSrv/Pipeline.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_login_gate,node_character_gate,node_game_gate,node_players,node_map_clients toneBlue
class node_login_srv,node_account_store,node_db_srv,node_character_store toneAmber
class node_game_srv,node_world,node_maps toneMint
class node_magic,node_scripts,node_commands,node_chat_module,node_market,node_robots toneRose
class node_chat_srv,node_log_srv,node_map_pipe toneIndigo
```

## Components

### Client gateways

- [LoginGate](https://github.com/mirbeta/openmir2/blob/master/src/LoginGate/AppService.cs): `src/LoginGate/AppService.cs`
- [CloudGate](https://github.com/mirbeta/openmir2/blob/master/src/CloudGate/AppService.cs): `src/CloudGate/AppService.cs`
- [GameGate](https://github.com/mirbeta/openmir2/blob/master/src/GameGate/AppService.cs): `src/GameGate/AppService.cs`

### Accounts and data

- [LoginSrv](https://github.com/mirbeta/openmir2/blob/master/src/LoginSrv/Services/LoginServer.cs): `src/LoginSrv/Services/LoginServer.cs`
- [Account storage](https://github.com/mirbeta/openmir2/blob/master/src/LoginSrv/Storage/AccountStorage.cs): `src/LoginSrv/Storage/AccountStorage.cs`
- [DBSrv](https://github.com/mirbeta/openmir2/blob/master/src/DBSrv/AppService.cs): `src/DBSrv/AppService.cs`
- [Character storage](https://github.com/mirbeta/openmir2/blob/master/src/Storeages/DBSvr.Storage.MySQL/PlayDataStorage.Save.cs): `src/Storeages/DBSvr.Storage.MySQL/PlayDataStorage.Save.cs`

### Game runtime

- [GameSrv](https://github.com/mirbeta/openmir2/blob/master/src/GameSrv/GameServer.cs): `src/GameSrv/GameServer.cs`
- [World engine](https://github.com/mirbeta/openmir2/blob/master/src/M2Server/Player/PlayObject.cs): `src/M2Server/Player/PlayObject.cs`
- [Map service](https://github.com/mirbeta/openmir2/blob/master/src/MapSrv/AppService.cs): `src/MapSrv/AppService.cs`

### Game features

- [Magic system](https://github.com/mirbeta/openmir2/blob/master/src/M2Server/Magic/MagicManager.cs): `src/M2Server/Magic/MagicManager.cs`
- [NPC scripts](https://github.com/mirbeta/openmir2/blob/master/src/Modules/ScriptEngine/ScriptEngine.cs): `src/Modules/ScriptEngine/ScriptEngine.cs`
- [Game commands](https://github.com/mirbeta/openmir2/blob/master/src/Modules/GameCommand/GameCommand.cs): `src/Modules/GameCommand/GameCommand.cs`
- [Chat module](https://github.com/mirbeta/openmir2/blob/master/src/Modules/ChatSystem/ChatService.cs): `src/Modules/ChatSystem/ChatService.cs`
- [Market system](https://github.com/mirbeta/openmir2/blob/master/src/Modules/MarketSystem/Services/MarketService.cs): `src/Modules/MarketSystem/Services/MarketService.cs`
- [Robot system](https://github.com/mirbeta/openmir2/blob/master/src/Modules/RobotSystem/RobotProcessor.cs): `src/Modules/RobotSystem/RobotProcessor.cs`

### Supporting services

- [ChatSrv](https://github.com/mirbeta/openmir2/blob/master/src/ChatSrv/AppService.cs): `src/ChatSrv/AppService.cs`
- [LogDataSrv](https://github.com/mirbeta/openmir2/blob/master/src/LogDataSrv/AppService.cs): `src/LogDataSrv/AppService.cs`
- [Map pipeline](https://github.com/mirbeta/openmir2/blob/master/src/MapSrv/Pipeline.cs): `src/MapSrv/Pipeline.cs`

### Other components

- **Game clients**
- **Map pipe clients**

## Connections

- Game clients → LoginGate: login traffic
- LoginGate → LoginSrv: forwards login
- LoginSrv → Account storage: reads and updates
- Game clients → CloudGate: character traffic
- CloudGate → DBSrv: character requests
- DBSrv → Character storage: persists characters
- Game clients → GameGate: game traffic
- GameGate → GameSrv: forwards player data
- GameSrv → World engine: runs world
- World engine → Magic system: uses spells
- World engine → NPC scripts: runs NPC scripts
- World engine → Game commands: dispatches commands
- World engine → Chat module: uses chat
- World engine → Market system: uses market
- World engine → Robot system: runs robots
- Map pipe clients → Map pipeline: connects by pipe
- Map pipeline → Map pipeline: reads and replies
