# morketh/server architecture

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

- Interactive diagram: https://gitdiagram.com/morketh/server
- Repository: https://github.com/morketh/server

## Overview

MaNGOS Three is a Cataclysm 4.3.4 World of Warcraft server. Its main workflow separates realm login from the world server: clients authenticate and select a realm, then interact with the world through session handlers that query game data and return protocol packets. The world daemon starts the master runtime; shared database services and game-data storage support that runtime. The README establishes the product scope, while sampled sources show startup, query handling, storage, and VMap internals; unsampled gameplay links are left unasserted.

Main entry points: [`src/mangosd`](https://github.com/morketh/server/tree/master/src/mangosd) (World runtime), [`src/game/QueryHandler.cpp`](https://github.com/morketh/server/blob/master/src/game/QueryHandler.cpp) (Protocol queries), [`src/realmd/Main.cpp`](https://github.com/morketh/server/blob/master/src/realmd/Main.cpp) (Realm daemon), [`src/shared/Database/DatabaseEnv.h`](https://github.com/morketh/server/blob/master/src/shared/Database/DatabaseEnv.h) (Database services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_realm["Realm access"]
  node_realm_main["Realm daemon<br/>[Main.cpp]"]
  node_realm_auth["Login protocol"]
  node_realm_list["Realm directory"]
end

subgraph group_world["World runtime"]
  node_world_main["World daemon<br/>[Main.cpp]"]
  node_world_master["World runtime"]
  node_session["Game sessions"]
  node_query["Protocol queries<br/>[QueryHandler.cpp]"]
  node_battleground["Battlegrounds"]
  node_pools["Spawn pools<br/>[PoolManager.cpp]"]
  node_scripts["Script bindings<br/>[ScriptMgr.cpp]"]
  node_client_packets["Game packets<br/>[WorldPacket.h]"]
end

subgraph group_data["Game data"]
  node_object_mgr["Object catalog<br/>[ObjectMgr.h]"]
  node_sql_storage[("SQL data cache<br/>[SQLStorage.h]")]
  node_sql_loader["SQL storage loader<br/>[SQLStorageImpl.h]"]
  node_database[("Database services<br/>[DatabaseEnv.h]")]
end

subgraph group_spatial["Spatial services"]
  node_vmap["Collision manager<br/>[VMapManager2.cpp]"]
  node_navmesh["Navigation queries"]
end

node_client(("WoW client"))

node_client -.->|"authenticates"| node_realm_auth
node_realm_main -->|"initializes"| node_realm_list
node_realm_main -->|"connects login DB"| node_database
node_realm_main -.->|"starts listener"| node_realm_auth
node_client -.->|"plays through"| node_session
node_world_main -->|"runs"| node_world_master
node_query -->|"looks up objects"| node_object_mgr
node_query -->|"queries data"| node_database
node_query -->|"builds responses"| node_client_packets
node_session -.->|"dispatches handlers"| node_query
node_sql_loader -->|"loads rows"| node_database
node_sql_loader -->|"fills records"| node_sql_storage
node_object_mgr -.->|"uses cached data"| node_sql_storage
node_world_master -.->|"hosts gameplay"| node_battleground
node_world_master -.->|"hosts gameplay"| node_pools
node_world_master -.->|"hosts scripting"| node_scripts
node_world_master -.->|"uses collision"| node_vmap
node_vmap -.->|"uses navigation"| node_navmesh

click node_realm_main "https://github.com/morketh/server/blob/master/src/realmd/Main.cpp"
click node_realm_auth "https://github.com/morketh/server/tree/master/src/realmd"
click node_realm_list "https://github.com/morketh/server/tree/master/src/realmd"
click node_world_main "https://github.com/morketh/server/blob/master/src/mangosd/Main.cpp"
click node_world_master "https://github.com/morketh/server/tree/master/src/mangosd"
click node_session "https://github.com/morketh/server/tree/master/src/game"
click node_query "https://github.com/morketh/server/blob/master/src/game/QueryHandler.cpp"
click node_battleground "https://github.com/morketh/server/blob/master/src/game/BattleGround/BattleGroundHandler.cpp"
click node_pools "https://github.com/morketh/server/blob/master/src/game/PoolManager.cpp"
click node_scripts "https://github.com/morketh/server/blob/master/src/bindings/universal/ScriptMgr.cpp"
click node_object_mgr "https://github.com/morketh/server/blob/master/src/game/ObjectMgr.h"
click node_sql_storage "https://github.com/morketh/server/blob/master/src/shared/Database/SQLStorage.h"
click node_sql_loader "https://github.com/morketh/server/blob/master/src/shared/Database/SQLStorageImpl.h"
click node_database "https://github.com/morketh/server/blob/master/src/shared/Database/DatabaseEnv.h"
click node_vmap "https://github.com/morketh/server/blob/master/src/game/vmap/VMapManager2.cpp"
click node_navmesh "https://github.com/morketh/server/blob/master/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp"
click node_client_packets "https://github.com/morketh/server/blob/master/src/shared/WorldPacket.h"

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_realm_main,node_realm_auth,node_realm_list,node_client toneBlue
class node_world_main,node_world_master,node_session,node_query,node_battleground,node_pools,node_scripts,node_client_packets toneAmber
class node_object_mgr,node_sql_storage,node_sql_loader,node_database toneMint
class node_vmap,node_navmesh toneRose
```

## Components

### Realm access

- [Realm daemon](https://github.com/morketh/server/blob/master/src/realmd/Main.cpp): `src/realmd/Main.cpp`
- [Login protocol](https://github.com/morketh/server/tree/master/src/realmd): `src/realmd`
- [Realm directory](https://github.com/morketh/server/tree/master/src/realmd): `src/realmd`

### World runtime

- [World daemon](https://github.com/morketh/server/blob/master/src/mangosd/Main.cpp): `src/mangosd/Main.cpp`
- [World runtime](https://github.com/morketh/server/tree/master/src/mangosd): `src/mangosd`
- [Game sessions](https://github.com/morketh/server/tree/master/src/game): `src/game`
- [Protocol queries](https://github.com/morketh/server/blob/master/src/game/QueryHandler.cpp): `src/game/QueryHandler.cpp`
- [Battlegrounds](https://github.com/morketh/server/blob/master/src/game/BattleGround/BattleGroundHandler.cpp): `src/game/BattleGround/BattleGroundHandler.cpp`
- [Spawn pools](https://github.com/morketh/server/blob/master/src/game/PoolManager.cpp): `src/game/PoolManager.cpp`
- [Script bindings](https://github.com/morketh/server/blob/master/src/bindings/universal/ScriptMgr.cpp): `src/bindings/universal/ScriptMgr.cpp`
- [Game packets](https://github.com/morketh/server/blob/master/src/shared/WorldPacket.h): `src/shared/WorldPacket.h`

### Game data

- [Object catalog](https://github.com/morketh/server/blob/master/src/game/ObjectMgr.h): `src/game/ObjectMgr.h`
- [SQL data cache](https://github.com/morketh/server/blob/master/src/shared/Database/SQLStorage.h): `src/shared/Database/SQLStorage.h`
- [SQL storage loader](https://github.com/morketh/server/blob/master/src/shared/Database/SQLStorageImpl.h): `src/shared/Database/SQLStorageImpl.h`
- [Database services](https://github.com/morketh/server/blob/master/src/shared/Database/DatabaseEnv.h): `src/shared/Database/DatabaseEnv.h`

### Spatial services

- [Collision manager](https://github.com/morketh/server/blob/master/src/game/vmap/VMapManager2.cpp): `src/game/vmap/VMapManager2.cpp`
- [Navigation queries](https://github.com/morketh/server/blob/master/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp): `dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp`

### Other components

- **WoW client**

## Connections

- WoW client → Login protocol: authenticates
- Realm daemon → Realm directory: initializes (evidence: `src/realmd/Main.cpp`)
- Realm daemon → Database services: connects login DB (evidence: `src/realmd/Main.cpp`)
- Realm daemon → Login protocol: starts listener (evidence: `src/realmd/Main.cpp`)
- WoW client → Game sessions: plays through
- World daemon → World runtime: runs (evidence: `src/mangosd/Main.cpp`)
- Protocol queries → Object catalog: looks up objects (evidence: `src/game/QueryHandler.cpp`)
- Protocol queries → Database services: queries data (evidence: `src/game/QueryHandler.cpp`)
- Protocol queries → Game packets: builds responses (evidence: `src/game/QueryHandler.cpp`)
- Game sessions → Protocol queries: dispatches handlers (evidence: `src/game/QueryHandler.cpp`)
- SQL storage loader → Database services: loads rows (evidence: `src/shared/Database/SQLStorageImpl.h`)
- SQL storage loader → SQL data cache: fills records (evidence: `src/shared/Database/SQLStorageImpl.h`)
- Object catalog → SQL data cache: uses cached data
- World runtime → Battlegrounds: hosts gameplay
- World runtime → Spawn pools: hosts gameplay
- World runtime → Script bindings: hosts scripting
- World runtime → Collision manager: uses collision
- Collision manager → Navigation queries: uses navigation
