# ollrogge/bango architecture

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

- Interactive diagram: https://gitdiagram.com/ollrogge/bango
- Repository: https://github.com/ollrogge/bango

## Overview

Bango is a C++ KalOnline MMORPG server emulator, split into a player-facing MainServer and a database-facing DBServer. The principal workflow accepts a game-client connection, routes account and character requests through the DB protocol, loads player state, and serves gameplay over the client socket. Gameplay spans player actions and properties, inventory/items, party interactions, and the map’s NPC and monster world. The README documents these capabilities; some implementation details are not sampled, so the graph omits uncertain internal wiring rather than inferring it.

Main entry points: [`MainServer/GameCharacter/CPlayer.cpp`](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CPlayer.cpp) (Player state), [`MainServer/CClient.cpp`](https://github.com/ollrogge/bango/blob/devel/MainServer/CClient.cpp) (Client session), [`DBServer/Socket/CMainSocket.cpp`](https://github.com/ollrogge/bango/blob/devel/DBServer/Socket/CMainSocket.cpp) (DB protocol server), [`MainServer/Map/CMap.cpp`](https://github.com/ollrogge/bango/blob/devel/MainServer/Map/CMap.cpp) (Map and zones)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_session["Client sessions"]
  node_main_socket["Client socket<br/>[CClientSocket.cpp]"]
  node_client["Client session<br/>[CClient.cpp]"]
  node_main_server["Session registry<br/>[CServer.cpp]"]
end

subgraph group_persistence["Account persistence"]
  node_db_client["DB protocol client<br/>[CDBSocket.cpp]"]
  node_db_socket["DB protocol server<br/>[CMainSocket.cpp]"]
  node_accounts["Account handling<br/>[CAccount.cpp]"]
  node_database["Connection pool<br/>[CDatabase.cpp]"]
end

subgraph group_gameplay["Player gameplay"]
  node_player["Player state<br/>[CPlayer.cpp]"]
  node_character["Character base<br/>[CCharacter.cpp]"]
  node_items["Inventory items<br/>[CItem.cpp]"]
  node_party["Party play<br/>[CParty.cpp]"]
end

subgraph group_world["World simulation"]
  node_map["Map and zones<br/>[CMap.cpp]"]
  node_tile["World tiles<br/>[CTile.cpp]"]
  node_npc["NPC services<br/>[CNPC.cpp]"]
  node_monster["Monster AI<br/>[CMonster.cpp]"]
  node_drops["Item drops<br/>[CItemDrop.cpp]"]
end

subgraph group_shared["Shared services"]
  node_macro_db["Game data macros<br/>[CMacroDB.cpp]"]
  node_config["Server configuration<br/>[CConfig.cpp]"]
end

node_game_client(("Game client"))
node_mysql[("MySQL database")]

node_game_client -->|"sends packets"| node_main_socket
node_main_socket -->|"dispatches packets"| node_client
node_main_socket -->|"registers sessions"| node_main_server
node_client -->|"sends responses"| node_game_client
node_client -->|"forwards account requests"| node_db_client
node_db_client -->|"sends DB packets"| node_db_socket
node_db_socket -->|"handles accounts"| node_accounts
node_db_socket -->|"executes queries"| node_database
node_database -->|"reads and writes"| node_mysql
node_db_socket -->|"returns results"| node_db_client
node_db_client -->|"delivers results"| node_client
node_client -->|"creates and routes"| node_player
node_player -->|"inherits behavior"| node_character
node_player -->|"manages inventory"| node_items
node_player -->|"handles party actions"| node_party
node_player -->|"updates world position"| node_map
node_map -->|"uses tiles"| node_tile
node_map -->|"loads NPCs"| node_npc
node_map -->|"tracks monsters"| node_monster
node_monster -->|"uses character behavior"| node_character
node_monster -.->|"creates drops"| node_drops
node_player -->|"uses game data"| node_macro_db
node_npc -->|"uses game data"| node_macro_db
node_monster -->|"uses game data"| node_macro_db
node_config -->|"configures listener"| node_main_socket
node_config -->|"configures connection"| node_database

click node_main_socket "https://github.com/ollrogge/bango/blob/devel/MainServer/Socket/CClientSocket.cpp"
click node_client "https://github.com/ollrogge/bango/blob/devel/MainServer/CClient.cpp"
click node_main_server "https://github.com/ollrogge/bango/blob/devel/MainServer/CServer.cpp"
click node_db_client "https://github.com/ollrogge/bango/blob/devel/MainServer/Socket/CDBSocket.cpp"
click node_db_socket "https://github.com/ollrogge/bango/blob/devel/DBServer/Socket/CMainSocket.cpp"
click node_accounts "https://github.com/ollrogge/bango/blob/devel/DBServer/CAccount.cpp"
click node_database "https://github.com/ollrogge/bango/blob/devel/DBServer/Database/CDatabase.cpp"
click node_player "https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CPlayer.cpp"
click node_character "https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CCharacter.cpp"
click node_items "https://github.com/ollrogge/bango/blob/devel/MainServer/Item/CItem.cpp"
click node_party "https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CParty.cpp"
click node_map "https://github.com/ollrogge/bango/blob/devel/MainServer/Map/CMap.cpp"
click node_tile "https://github.com/ollrogge/bango/blob/devel/MainServer/Map/CTile.cpp"
click node_npc "https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CNPC.cpp"
click node_monster "https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CMonster.cpp"
click node_drops "https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CItemDrop.cpp"
click node_macro_db "https://github.com/ollrogge/bango/blob/devel/MainServer/Macro/CMacroDB.cpp"
click node_config "https://github.com/ollrogge/bango/blob/devel/include/Config/CConfig.cpp"

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_main_socket,node_client,node_main_server,node_game_client toneBlue
class node_db_client,node_db_socket,node_accounts,node_database,node_mysql toneAmber
class node_player,node_character,node_items,node_party toneMint
class node_map,node_tile,node_npc,node_monster,node_drops toneRose
class node_macro_db,node_config toneIndigo
```

## Components

### Client sessions

- [Client socket](https://github.com/ollrogge/bango/blob/devel/MainServer/Socket/CClientSocket.cpp): `MainServer/Socket/CClientSocket.cpp`
- [Client session](https://github.com/ollrogge/bango/blob/devel/MainServer/CClient.cpp): `MainServer/CClient.cpp`
- [Session registry](https://github.com/ollrogge/bango/blob/devel/MainServer/CServer.cpp): `MainServer/CServer.cpp`

### Account persistence

- [DB protocol client](https://github.com/ollrogge/bango/blob/devel/MainServer/Socket/CDBSocket.cpp): `MainServer/Socket/CDBSocket.cpp`
- [DB protocol server](https://github.com/ollrogge/bango/blob/devel/DBServer/Socket/CMainSocket.cpp): `DBServer/Socket/CMainSocket.cpp`
- [Account handling](https://github.com/ollrogge/bango/blob/devel/DBServer/CAccount.cpp): `DBServer/CAccount.cpp`
- [Connection pool](https://github.com/ollrogge/bango/blob/devel/DBServer/Database/CDatabase.cpp): `DBServer/Database/CDatabase.cpp`

### Player gameplay

- [Player state](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CPlayer.cpp): `MainServer/GameCharacter/CPlayer.cpp`
- [Character base](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CCharacter.cpp): `MainServer/GameCharacter/CCharacter.cpp`
- [Inventory items](https://github.com/ollrogge/bango/blob/devel/MainServer/Item/CItem.cpp): `MainServer/Item/CItem.cpp`
- [Party play](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CParty.cpp): `MainServer/GameCharacter/CParty.cpp`

### World simulation

- [Map and zones](https://github.com/ollrogge/bango/blob/devel/MainServer/Map/CMap.cpp): `MainServer/Map/CMap.cpp`
- [World tiles](https://github.com/ollrogge/bango/blob/devel/MainServer/Map/CTile.cpp): `MainServer/Map/CTile.cpp`
- [NPC services](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CNPC.cpp): `MainServer/GameCharacter/CNPC.cpp`
- [Monster AI](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CMonster.cpp): `MainServer/GameCharacter/CMonster.cpp`
- [Item drops](https://github.com/ollrogge/bango/blob/devel/MainServer/GameCharacter/CItemDrop.cpp): `MainServer/GameCharacter/CItemDrop.cpp`

### Shared services

- [Game data macros](https://github.com/ollrogge/bango/blob/devel/MainServer/Macro/CMacroDB.cpp): `MainServer/Macro/CMacroDB.cpp`
- [Server configuration](https://github.com/ollrogge/bango/blob/devel/include/Config/CConfig.cpp): `include/Config/CConfig.cpp`

### Other components

- **Game client**
- **MySQL database**

## Connections

- Game client → Client socket: sends packets
- Client socket → Client session: dispatches packets
- Client socket → Session registry: registers sessions
- Client session → Game client: sends responses
- Client session → DB protocol client: forwards account requests
- DB protocol client → DB protocol server: sends DB packets
- DB protocol server → Account handling: handles accounts
- DB protocol server → Connection pool: executes queries
- Connection pool → MySQL database: reads and writes
- DB protocol server → DB protocol client: returns results
- DB protocol client → Client session: delivers results
- Client session → Player state: creates and routes
- Player state → Character base: inherits behavior
- Player state → Inventory items: manages inventory
- Player state → Party play: handles party actions
- Player state → Map and zones: updates world position
- Map and zones → World tiles: uses tiles
- Map and zones → NPC services: loads NPCs
- Map and zones → Monster AI: tracks monsters
- Monster AI → Character base: uses character behavior
- Monster AI → Item drops: creates drops
- Player state → Game data macros: uses game data
- NPC services → Game data macros: uses game data
- Monster AI → Game data macros: uses game data
- Server configuration → Client socket: configures listener
- Server configuration → Connection pool: configures connection
