# supertavor/puniemu architecture

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

- Interactive diagram: https://gitdiagram.com/supertavor/puniemu
- Repository: https://github.com/supertavor/puniemu

## Overview

Puniemu is a C# private-server emulator for Yo-kai Watch Puni Puni. A game client sends encrypted HTTP requests to the ASP.NET host, which dispatches identity, initialization, gameplay, economy, social, and profile operations to request handlers. Handlers use domain managers and cached master data, update account state through UserDataManager, and return encrypted responses. The sampled code confirms PostgreSQL persistence, embedded table caching, gacha registration, and email-based account codes; many handler internals were not sampled, so their detailed links are conservative.

Main entry points: [`Src/Program.cs`](https://github.com/supertavor/puniemu/blob/master/Src/Program.cs) (HTTP Host), [`Src/Server/GameServer/Requests`](https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Requests) (Game Handlers), [`Src/Server/GameServer/Logic`](https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Logic) (Domain Managers), [`Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaPoolManager.cs`](https://github.com/supertavor/puniemu/blob/master/Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaPoolManager.cs) (Gacha Pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime Host"]
  node_host["HTTP Host<br/>[Program.cs]"]
  node_crypto["NHN Encryption<br/>[NHNCrypt.cs]"]
  node_game_handlers["Game Handlers"]
end

subgraph group_identity["Identity Access"]
  node_auth_handlers["Auth Handlers"]
  node_auth_manager["Auth Manager<br/>[AuthManager.cs]"]
  node_l5_handlers["L5ID Handlers"]
  node_smtp{{"SMTP Mail"}}
end

subgraph group_gameplay["Game Domains"]
  node_domain_managers["Domain Managers"]
  node_gacha["Gacha Service<br/>[GachaService.cs]"]
  node_gacha_pool["Gacha Pool"]
end

subgraph group_content["Game Content"]
  node_master_managers["Master Managers"]
  node_game_data["Game Data Cache<br/>[GameDataManager.cs]"]
  node_table_parser["Table Parser<br/>[TableParser.cs]"]
end

subgraph group_storage["State Storage"]
  node_user_data["User Data Manager<br/>[UserDataManager.cs]"]
  node_postgres[("PostgreSQL")]
end

node_player(("Game Client"))

node_player -->|"sends requests"| node_host
node_host -->|"dispatches requests"| node_game_handlers
node_host -->|"dispatches auth"| node_auth_handlers
node_host -->|"dispatches identity"| node_l5_handlers
node_host -->|"uses protocol"| node_crypto
node_host -->|"initializes storage"| node_user_data
node_host -->|"loads configuration"| node_game_data
node_auth_handlers -->|"manages codes"| node_auth_manager
node_auth_manager -.->|"sends codes"| node_smtp
node_game_handlers -->|"decrypts responses"| node_crypto
node_game_handlers -->|"invokes domains"| node_domain_managers
node_game_handlers -->|"executes gacha"| node_gacha
node_gacha -->|"rolls pools"| node_gacha_pool
node_gacha_pool -->|"updates collections"| node_domain_managers
node_gacha_pool -->|"loads pools"| node_game_data
node_domain_managers -->|"uses master rules"| node_master_managers
node_master_managers -->|"reads tables"| node_game_data
node_master_managers -->|"parses tables"| node_table_parser
node_domain_managers -->|"reads writes state"| node_user_data
node_user_data -->|"persists accounts"| node_postgres
node_game_handlers -->|"returns responses"| node_player

click node_host "https://github.com/supertavor/puniemu/blob/master/Src/Program.cs"
click node_crypto "https://github.com/supertavor/puniemu/blob/master/Src/NHNCrypt/Logic/NHNCrypt.cs"
click node_game_handlers "https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Requests"
click node_auth_handlers "https://github.com/supertavor/puniemu/tree/master/Src/Server/CustomAuth/Requests"
click node_auth_manager "https://github.com/supertavor/puniemu/blob/master/Src/Server/CustomAuth/AuthManager.cs"
click node_l5_handlers "https://github.com/supertavor/puniemu/tree/master/Src/Server/L5ID/Requests"
click node_domain_managers "https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Logic"
click node_gacha "https://github.com/supertavor/puniemu/blob/master/Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaService.cs"
click node_gacha_pool "https://github.com/supertavor/puniemu/blob/master/Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaPoolManager.cs"
click node_master_managers "https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Logic/Mst"
click node_game_data "https://github.com/supertavor/puniemu/blob/master/Src/DataManager/Logic/GameDataManager.cs"
click node_table_parser "https://github.com/supertavor/puniemu/blob/master/Src/TableParser/Logic/TableParser.cs"
click node_user_data "https://github.com/supertavor/puniemu/blob/master/Src/UserDataManager/Logic/UserDataManager.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_host,node_crypto,node_game_handlers,node_player toneBlue
class node_auth_handlers,node_auth_manager,node_l5_handlers,node_smtp toneAmber
class node_domain_managers,node_gacha,node_gacha_pool toneMint
class node_master_managers,node_game_data,node_table_parser toneRose
class node_user_data,node_postgres toneIndigo
```

## Components

### Runtime Host

- [HTTP Host](https://github.com/supertavor/puniemu/blob/master/Src/Program.cs): `Src/Program.cs`
- [NHN Encryption](https://github.com/supertavor/puniemu/blob/master/Src/NHNCrypt/Logic/NHNCrypt.cs): `Src/NHNCrypt/Logic/NHNCrypt.cs`
- [Game Handlers](https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Requests): `Src/Server/GameServer/Requests`

### Identity Access

- [Auth Handlers](https://github.com/supertavor/puniemu/tree/master/Src/Server/CustomAuth/Requests): `Src/Server/CustomAuth/Requests`
- [Auth Manager](https://github.com/supertavor/puniemu/blob/master/Src/Server/CustomAuth/AuthManager.cs): `Src/Server/CustomAuth/AuthManager.cs`
- [L5ID Handlers](https://github.com/supertavor/puniemu/tree/master/Src/Server/L5ID/Requests): `Src/Server/L5ID/Requests`
- **SMTP Mail**

### Game Domains

- [Domain Managers](https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Logic): `Src/Server/GameServer/Logic`
- [Gacha Service](https://github.com/supertavor/puniemu/blob/master/Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaService.cs): `Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaService.cs`
- [Gacha Pool](https://github.com/supertavor/puniemu/blob/master/Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaPoolManager.cs): `Src/Server/GameServer/Requests/ExecuteGacha/Logic/GachaPoolManager.cs`

### Game Content

- [Master Managers](https://github.com/supertavor/puniemu/tree/master/Src/Server/GameServer/Logic/Mst): `Src/Server/GameServer/Logic/Mst`
- [Game Data Cache](https://github.com/supertavor/puniemu/blob/master/Src/DataManager/Logic/GameDataManager.cs): `Src/DataManager/Logic/GameDataManager.cs`
- [Table Parser](https://github.com/supertavor/puniemu/blob/master/Src/TableParser/Logic/TableParser.cs): `Src/TableParser/Logic/TableParser.cs`

### State Storage

- [User Data Manager](https://github.com/supertavor/puniemu/blob/master/Src/UserDataManager/Logic/UserDataManager.cs): `Src/UserDataManager/Logic/UserDataManager.cs`
- **PostgreSQL**

### Other components

- **Game Client**

## Connections

- Game Client → HTTP Host: sends requests
- HTTP Host → Game Handlers: dispatches requests
- HTTP Host → Auth Handlers: dispatches auth
- HTTP Host → L5ID Handlers: dispatches identity
- HTTP Host → NHN Encryption: uses protocol
- HTTP Host → User Data Manager: initializes storage
- HTTP Host → Game Data Cache: loads configuration
- Auth Handlers → Auth Manager: manages codes
- Auth Manager → SMTP Mail: sends codes
- Game Handlers → NHN Encryption: decrypts responses
- Game Handlers → Domain Managers: invokes domains
- Game Handlers → Gacha Service: executes gacha
- Gacha Service → Gacha Pool: rolls pools
- Gacha Pool → Domain Managers: updates collections
- Gacha Pool → Game Data Cache: loads pools
- Domain Managers → Master Managers: uses master rules
- Master Managers → Game Data Cache: reads tables
- Master Managers → Table Parser: parses tables
- Domain Managers → User Data Manager: reads writes state
- User Data Manager → PostgreSQL: persists accounts
- Game Handlers → Game Client: returns responses
