# spelunkern/shaiya-core architecture

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

- Interactive diagram: https://gitdiagram.com/spelunkern/shaiya-core
- Repository: https://github.com/spelunkern/shaiya-core

## Overview

Shaiya Core is a C++ patching framework for the Shaiya client and official game, database-agent, and login services. The principal workflow is a player using the patched Game.exe, with client hooks and UI features, while server hooks extend gameplay and exchange data with login/database services. Configuration controls runtime behavior; shared packet definitions describe cross-module data. The README documents the product boundaries and capabilities; sampled entry points show hook registration, but most feature implementations and inter-service routing were not inspected, so those links are omitted.

Main entry points: [`sdev-client/src/main.cpp`](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/main.cpp) (Client hook entry), [`sdev/src/main.cpp`](https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/main.cpp) (Server hook entry), [`sdev-client/src/imgui_layer.cpp`](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/imgui_layer.cpp) (ImGui overlay), [`sdev-client/src/packet.cpp`](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/packet.cpp) (Client packets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client features"]
  node_client_entry["Client hook entry<br/>[main.cpp]"]
  node_client_ui["ImGui overlay<br/>[imgui_layer.cpp]"]
  node_client_chat["Custom chat<br/>[custom_chat.cpp]"]
  node_client_packet["Client packets<br/>[packet.cpp]"]
  node_client_quality["Client QoL hooks<br/>[quick_slot.cpp]"]
  node_discord["Discord RPC<br/>[discord_rpc.cpp]"]
end

subgraph group_game["Game service"]
  node_game_entry["Server hook entry<br/>[main.cpp]"]
  node_gameplay_packets["Gameplay packets"]
  node_world["World processing<br/>[world_thread.cpp]"]
  node_game_user["User state<br/>[CUser.h]"]
  node_config["Server configuration<br/>[Configuration.cpp]"]
end

subgraph group_services["Login and database"]
  node_login_entry["Login hooks<br/>[main.cpp]"]
  node_login_security["GM login security<br/>[gm_security.cpp]"]
  node_db_entry["Database hooks<br/>[main.cpp]"]
  node_db_characters["Character persistence<br/>[character_list.cpp]"]
  node_db_pool["Database pool<br/>[SDatabasePool.h]"]
end

subgraph group_shared["Shared runtime"]
  node_shared_packets["Packet definitions<br/>[0800.h]"]
  node_shared_gmp["GMP arithmetic<br/>[mini-gmp.c]"]
  node_imgui["ImGui runtime<br/>[imgui.cpp]"]
end

node_player(("Player"))

node_player -.->|"uses patched client"| node_client_entry
node_client_entry -->|"registers hooks"| node_client_ui
node_client_entry -->|"registers hooks"| node_client_packet
node_client_entry -->|"registers hooks"| node_client_quality
node_client_entry -->|"initializes RPC"| node_discord
node_client_ui -.->|"renders with"| node_imgui
node_game_entry -->|"loads settings"| node_config
node_game_entry -->|"initializes state"| node_game_user
node_game_entry -->|"registers hooks"| node_gameplay_packets
node_game_entry -->|"registers hook"| node_world
node_login_entry -->|"checks login"| node_login_security
node_db_entry -->|"registers hook"| node_db_characters
node_db_pool -.->|"provides connections"| node_db_characters
node_gameplay_packets -.->|"uses definitions"| node_shared_packets
node_client_packet -.->|"uses definitions"| node_shared_packets

click node_client_entry "https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/main.cpp"
click node_client_ui "https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/imgui_layer.cpp"
click node_client_chat "https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/custom_chat.cpp"
click node_client_packet "https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/packet.cpp"
click node_client_quality "https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/quick_slot.cpp"
click node_discord "https://github.com/spelunkern/shaiya-core/blob/main/external/discord-rpc/src/discord_rpc.cpp"
click node_game_entry "https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/main.cpp"
click node_gameplay_packets "https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/packet_character.cpp"
click node_world "https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/world_thread.cpp"
click node_game_user "https://github.com/spelunkern/shaiya-core/blob/main/sdev/include/shaiya/CUser.h"
click node_config "https://github.com/spelunkern/shaiya-core/blob/main/sdev/include/shaiya/Configuration.cpp"
click node_login_entry "https://github.com/spelunkern/shaiya-core/blob/main/sdev-login/src/main.cpp"
click node_login_security "https://github.com/spelunkern/shaiya-core/blob/main/sdev-login/src/gm_security.cpp"
click node_db_entry "https://github.com/spelunkern/shaiya-core/blob/main/sdev-db/src/main.cpp"
click node_db_characters "https://github.com/spelunkern/shaiya-core/blob/main/sdev-db/src/character_list.cpp"
click node_db_pool "https://github.com/spelunkern/shaiya-core/blob/main/sdev-db/include/shaiya/SDatabasePool.h"
click node_shared_packets "https://github.com/spelunkern/shaiya-core/blob/main/shaiya/include/network/game/incoming/0800.h"
click node_shared_gmp "https://github.com/spelunkern/shaiya-core/blob/main/mini-gmp/mini-gmp.c"
click node_imgui "https://github.com/spelunkern/shaiya-core/blob/main/external/imgui/imgui.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_client_entry,node_client_ui,node_client_chat,node_client_packet,node_client_quality,node_discord toneBlue
class node_game_entry,node_gameplay_packets,node_world,node_game_user,node_config toneAmber
class node_login_entry,node_login_security,node_db_entry,node_db_characters,node_db_pool toneMint
class node_shared_packets,node_shared_gmp,node_imgui toneRose
class node_player toneIndigo
```

## Components

### Client features

- [Client hook entry](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/main.cpp): `sdev-client/src/main.cpp`
- [ImGui overlay](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/imgui_layer.cpp): `sdev-client/src/imgui_layer.cpp`
- [Custom chat](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/custom_chat.cpp): `sdev-client/src/custom_chat.cpp`
- [Client packets](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/packet.cpp): `sdev-client/src/packet.cpp`
- [Client QoL hooks](https://github.com/spelunkern/shaiya-core/blob/main/sdev-client/src/quick_slot.cpp): `sdev-client/src/quick_slot.cpp`
- [Discord RPC](https://github.com/spelunkern/shaiya-core/blob/main/external/discord-rpc/src/discord_rpc.cpp): `external/discord-rpc/src/discord_rpc.cpp`

### Game service

- [Server hook entry](https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/main.cpp): `sdev/src/main.cpp`
- [Gameplay packets](https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/packet_character.cpp): `sdev/src/packet_character.cpp`
- [World processing](https://github.com/spelunkern/shaiya-core/blob/main/sdev/src/world_thread.cpp): `sdev/src/world_thread.cpp`
- [User state](https://github.com/spelunkern/shaiya-core/blob/main/sdev/include/shaiya/CUser.h): `sdev/include/shaiya/CUser.h`
- [Server configuration](https://github.com/spelunkern/shaiya-core/blob/main/sdev/include/shaiya/Configuration.cpp): `sdev/include/shaiya/Configuration.cpp`

### Login and database

- [Login hooks](https://github.com/spelunkern/shaiya-core/blob/main/sdev-login/src/main.cpp): `sdev-login/src/main.cpp`
- [GM login security](https://github.com/spelunkern/shaiya-core/blob/main/sdev-login/src/gm_security.cpp): `sdev-login/src/gm_security.cpp`
- [Database hooks](https://github.com/spelunkern/shaiya-core/blob/main/sdev-db/src/main.cpp): `sdev-db/src/main.cpp`
- [Character persistence](https://github.com/spelunkern/shaiya-core/blob/main/sdev-db/src/character_list.cpp): `sdev-db/src/character_list.cpp`
- [Database pool](https://github.com/spelunkern/shaiya-core/blob/main/sdev-db/include/shaiya/SDatabasePool.h): `sdev-db/include/shaiya/SDatabasePool.h`

### Shared runtime

- [Packet definitions](https://github.com/spelunkern/shaiya-core/blob/main/shaiya/include/network/game/incoming/0800.h): `shaiya/include/network/game/incoming/0800.h`
- [GMP arithmetic](https://github.com/spelunkern/shaiya-core/blob/main/mini-gmp/mini-gmp.c): `mini-gmp/mini-gmp.c`
- [ImGui runtime](https://github.com/spelunkern/shaiya-core/blob/main/external/imgui/imgui.cpp): `external/imgui/imgui.cpp`

### Other components

- **Player**

## Connections

- Player → Client hook entry: uses patched client
- Client hook entry → ImGui overlay: registers hooks (evidence: `sdev-client/src/main.cpp`)
- Client hook entry → Client packets: registers hooks (evidence: `sdev-client/src/main.cpp`)
- Client hook entry → Client QoL hooks: registers hooks (evidence: `sdev-client/src/main.cpp`)
- Client hook entry → Discord RPC: initializes RPC (evidence: `sdev-client/src/main.cpp`)
- ImGui overlay → ImGui runtime: renders with
- Server hook entry → Server configuration: loads settings (evidence: `sdev/src/main.cpp`)
- Server hook entry → User state: initializes state (evidence: `sdev/src/main.cpp`)
- Server hook entry → Gameplay packets: registers hooks (evidence: `sdev/src/main.cpp`)
- Server hook entry → World processing: registers hook (evidence: `sdev/src/main.cpp`)
- Login hooks → GM login security: checks login (evidence: `sdev-login/src/main.cpp`)
- Database hooks → Character persistence: registers hook (evidence: `sdev-db/src/main.cpp`)
- Database pool → Character persistence: provides connections
- Gameplay packets → Packet definitions: uses definitions
- Client packets → Packet definitions: uses definitions
