# hanlull/animepartygame-server architecture

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

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

## Overview

AnimeParty Game Server is a Go reimplementation of the AstralParty game backend. A client bootstraps through HTTP, authenticates, then uses the framed game protocol to reach gateway handlers; those handlers serve lobby, rooms, battles, and persistent game features. The README documents SQLite persistence, loaded game configuration, hot-update delivery, and an interactive operator console. The source index includes only selected server files, so links for unsampled feature handlers are based on documented capabilities and layout, not inspected implementation details.

Main entry points: [`Server/internal/gateway/handlers.go`](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/handlers.go) (Command handlers), [`Server/internal/db/store.go`](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/db/store.go) (SQLite persistence), [`Server/internal/gateway/server.go`](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/server.go) (TCP gateway), [`Server/main.go`](https://github.com/hanlull/animepartygame-server/blob/main/Server/main.go) (Startup wiring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server runtime"]
  node_main["Startup wiring<br/>[main.go]"]
  node_gateway["TCP gateway<br/>[server.go]"]
  node_handlers["Command handlers<br/>[handlers.go]"]
end

subgraph group_connection["Client connection"]
  node_protocol["Wire schema<br/>[AstralParty.proto]"]
  node_bootstrap["HTTP bootstrap<br/>[web_config.go]"]
  node_hotupdate["Hot-update serving<br/>[hotupdate_files.go]"]
  node_auth["Account authentication<br/>[web_auth.go]"]
  node_smtp["Email codes<br/>[smtp.go]"]
end

subgraph group_gameplay["Game features"]
  node_game["Battle engine<br/>[engine.go]"]
  node_rooms["Rooms and matchmaking<br/>[room_lifecycle.go]"]
  node_settlement["Battle settlement<br/>[room_finish.go]"]
  node_campaign["Single-player campaign<br/>[single_campaign.go]"]
  node_social["Guilds and friends<br/>[guilds.go]"]
  node_economy["Inventory and shop<br/>[land_shop.go]"]
  node_progress["Tasks and passes<br/>[tasks.go]"]
end

subgraph group_persistence["Data and configuration"]
  node_db[("SQLite persistence<br/>[store.go]")]
  node_config["Gameplay configuration<br/>[store.go]"]
end

subgraph group_operations["Operator tools"]
  node_console["Interactive console<br/>[console.go]"]
  node_consolecommands["Operator commands<br/>[console_exec.go]"]
end

node_client(("Game client"))
node_operator(("Server operator"))

node_client -->|"requests bootstrap"| node_bootstrap
node_client -->|"fetches bundles"| node_hotupdate
node_client -->|"authenticates"| node_auth
node_client -->|"opens game socket"| node_gateway
node_protocol -->|"defines messages"| node_gateway
node_gateway -->|"dispatches commands"| node_handlers
node_auth -->|"sends login codes"| node_smtp
node_main -->|"starts listener"| node_gateway
node_main -->|"starts HTTP"| node_bootstrap
node_main -->|"loads tables"| node_config
node_handlers -->|"handles room actions"| node_rooms
node_handlers -->|"runs battle logic"| node_game
node_handlers -->|"serves campaign"| node_campaign
node_handlers -->|"serves social features"| node_social
node_handlers -->|"serves economy"| node_economy
node_handlers -->|"serves progression"| node_progress
node_rooms -->|"finishes battles"| node_settlement
node_settlement -->|"persists results"| node_db
node_rooms -->|"persists room state"| node_db
node_campaign -->|"stores progress"| node_db
node_social -->|"stores guild data"| node_db
node_economy -->|"stores player data"| node_db
node_progress -->|"stores progress"| node_db
node_operator -->|"enters commands"| node_console
node_console -->|"dispatches commands"| node_consolecommands
node_consolecommands -->|"changes player data"| node_db

click node_main "https://github.com/hanlull/animepartygame-server/blob/main/Server/main.go"
click node_gateway "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/server.go"
click node_handlers "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/handlers.go"
click node_protocol "https://github.com/hanlull/animepartygame-server/blob/main/proto/AstralParty.proto"
click node_bootstrap "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/web_config.go"
click node_hotupdate "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/hotupdate_files.go"
click node_auth "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/auth/web_auth.go"
click node_smtp "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/auth/smtp.go"
click node_game "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/game/engine.go"
click node_rooms "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/room_lifecycle.go"
click node_settlement "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/room_finish.go"
click node_campaign "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/single_campaign.go"
click node_social "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/guilds.go"
click node_economy "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/land_shop.go"
click node_progress "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/tasks.go"
click node_db "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/db/store.go"
click node_config "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gdconf/store.go"
click node_console "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/console/console.go"
click node_consolecommands "https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/console_exec.go"

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,node_gateway,node_handlers,node_client toneBlue
class node_protocol,node_bootstrap,node_hotupdate,node_auth,node_smtp toneAmber
class node_game,node_rooms,node_settlement,node_campaign,node_social,node_economy,node_progress,node_operator toneMint
class node_db,node_config toneRose
class node_console,node_consolecommands toneIndigo
```

## Components

### Server runtime

- [Startup wiring](https://github.com/hanlull/animepartygame-server/blob/main/Server/main.go): `Server/main.go`
- [TCP gateway](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/server.go): `Server/internal/gateway/server.go`
- [Command handlers](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/handlers.go): `Server/internal/gateway/handlers.go`

### Client connection

- [Wire schema](https://github.com/hanlull/animepartygame-server/blob/main/proto/AstralParty.proto): `proto/AstralParty.proto`
- [HTTP bootstrap](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/web_config.go): `Server/internal/gateway/web_config.go`
- [Hot-update serving](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/hotupdate_files.go): `Server/internal/gateway/hotupdate_files.go`
- [Account authentication](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/auth/web_auth.go): `Server/internal/auth/web_auth.go`
- [Email codes](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/auth/smtp.go): `Server/internal/auth/smtp.go`

### Game features

- [Battle engine](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/game/engine.go): `Server/internal/game/engine.go`
- [Rooms and matchmaking](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/room_lifecycle.go): `Server/internal/gateway/room_lifecycle.go`
- [Battle settlement](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/room_finish.go): `Server/internal/gateway/room_finish.go`
- [Single-player campaign](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/single_campaign.go): `Server/internal/gateway/single_campaign.go`
- [Guilds and friends](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/guilds.go): `Server/internal/gateway/guilds.go`
- [Inventory and shop](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/land_shop.go): `Server/internal/gateway/land_shop.go`
- [Tasks and passes](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/tasks.go): `Server/internal/gateway/tasks.go`

### Data and configuration

- [SQLite persistence](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/db/store.go): `Server/internal/db/store.go`
- [Gameplay configuration](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gdconf/store.go): `Server/internal/gdconf/store.go`

### Operator tools

- [Interactive console](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/console/console.go): `Server/internal/console/console.go`
- [Operator commands](https://github.com/hanlull/animepartygame-server/blob/main/Server/internal/gateway/console_exec.go): `Server/internal/gateway/console_exec.go`

### Other components

- **Game client**
- **Server operator**

## Connections

- Game client → HTTP bootstrap: requests bootstrap (evidence: `README.md`)
- Game client → Hot-update serving: fetches bundles (evidence: `README.md`)
- Game client → Account authentication: authenticates (evidence: `README.md`)
- Game client → TCP gateway: opens game socket (evidence: `README.md`)
- Wire schema → TCP gateway: defines messages (evidence: `README.md`)
- TCP gateway → Command handlers: dispatches commands (evidence: `README.md`)
- Account authentication → Email codes: sends login codes (evidence: `README.md`)
- Startup wiring → TCP gateway: starts listener (evidence: `README.md`)
- Startup wiring → HTTP bootstrap: starts HTTP (evidence: `README.md`)
- Startup wiring → Gameplay configuration: loads tables (evidence: `README.md`)
- Command handlers → Rooms and matchmaking: handles room actions (evidence: `README.md`)
- Command handlers → Battle engine: runs battle logic (evidence: `README.md`)
- Command handlers → Single-player campaign: serves campaign (evidence: `README.md`)
- Command handlers → Guilds and friends: serves social features (evidence: `README.md`)
- Command handlers → Inventory and shop: serves economy (evidence: `README.md`)
- Command handlers → Tasks and passes: serves progression (evidence: `README.md`)
- Rooms and matchmaking → Battle settlement: finishes battles (evidence: `README.md`)
- Battle settlement → SQLite persistence: persists results (evidence: `README.md`)
- Rooms and matchmaking → SQLite persistence: persists room state (evidence: `README.md`)
- Single-player campaign → SQLite persistence: stores progress (evidence: `README.md`)
- Guilds and friends → SQLite persistence: stores guild data (evidence: `README.md`)
- Inventory and shop → SQLite persistence: stores player data (evidence: `README.md`)
- Tasks and passes → SQLite persistence: stores progress (evidence: `README.md`)
- Server operator → Interactive console: enters commands (evidence: `README.md`)
- Interactive console → Operator commands: dispatches commands (evidence: `README.md`)
- Operator commands → SQLite persistence: changes player data (evidence: `README.md`)
