# finorak/answer-protocol architecture

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

- Interactive diagram: https://gitdiagram.com/finorak/answer-protocol
- Repository: https://github.com/finorak/answer-protocol

## Overview

This is a text-based multiplayer dungeon game with a TCP server, CLI and SDL GUI clients, and a JSON-defined world. The main workflow is client connection and command submission, server-side validation and world interaction, then responses or events shown to players. Major domain stages include world loading/validation, movement and combat, quests, chat, and groups. The GUI adds connection, environment, inventory, and protocol views. Source excerpts show some wiring; README statements support documented capabilities where implementation excerpts are unavailable.

Main entry points: [`server/main.c`](https://github.com/finorak/answer-protocol/blob/main/server/main.c) (TCP server), [`parser/parser_utils.c`](https://github.com/finorak/answer-protocol/blob/main/parser/parser_utils.c) (World initialization), [`gui/Server.cpp`](https://github.com/finorak/answer-protocol/blob/main/gui/Server.cpp) (GUI server link), [`server/execution`](https://github.com/finorak/answer-protocol/tree/main/server/execution) (Game commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Player clients"]
  node_cli["CLI client<br/>[main.c]"]
end

subgraph group_server["Server runtime"]
  node_server_runtime["TCP server<br/>[main.c]"]
  node_validation["Command validation<br/>[val_exec.c]"]
  node_command_handlers["Game commands"]
  node_player_groups["Player and group management"]
end

subgraph group_world["World data"]
  node_world_parser["World initialization<br/>[parser_utils.c]"]
  node_world_extractors["World entity extraction"]
  node_world_validation["World validation"]
  node_world_state[("In-memory world<br/>[world.h]")]
end

subgraph group_gui["GUI experience"]
  node_gui_app["GUI application<br/>[main.cpp]"]
  node_connection["Connection page<br/>[Connect.cpp]"]
  node_gui_network["GUI server link<br/>[Server.cpp]"]
  node_environment["World interface<br/>[Environment.cpp]"]
  node_gui_views["Inventory and protocol"]
  node_ui_components["UI components"]
end

node_player(("Player"))
node_world_file["World JSON"]
node_game_server(("Game server"))

node_player -->|"uses"| node_cli
node_player -->|"uses"| node_gui_app
node_cli -->|"connects to"| node_game_server
node_gui_app -->|"opens"| node_connection
node_connection -->|"connects through"| node_gui_network
node_gui_network -->|"sends requests"| node_game_server
node_gui_network -->|"dispatches events"| node_gui_views
node_environment -->|"requests actions"| node_gui_network
node_environment -->|"renders with"| node_ui_components
node_gui_app -->|"shows"| node_environment
node_game_server -->|"reaches"| node_server_runtime
node_server_runtime -->|"initializes"| node_world_parser
node_server_runtime -->|"validates commands"| node_validation
node_server_runtime -->|"dispatches commands"| node_command_handlers
node_command_handlers -.->|"acts on"| node_world_state
node_server_runtime -->|"manages players"| node_player_groups
node_world_parser -->|"uses extractors"| node_world_extractors
node_world_parser -->|"validates world"| node_world_validation
node_world_parser -->|"loads"| node_world_file
node_world_parser -->|"populates"| node_world_state
node_server_runtime -->|"updates during play"| node_world_state
node_command_handlers -->|"supports group actions"| node_player_groups

click node_cli "https://github.com/finorak/answer-protocol/blob/main/client/main.c"
click node_gui_app "https://github.com/finorak/answer-protocol/blob/main/gui/main.cpp"
click node_connection "https://github.com/finorak/answer-protocol/blob/main/gui/components/page/Connect.cpp"
click node_gui_network "https://github.com/finorak/answer-protocol/blob/main/gui/Server.cpp"
click node_environment "https://github.com/finorak/answer-protocol/blob/main/gui/components/features/Environment.cpp"
click node_gui_views "https://github.com/finorak/answer-protocol/tree/main/gui/components/features"
click node_ui_components "https://github.com/finorak/answer-protocol/tree/main/gui/components/basic"
click node_server_runtime "https://github.com/finorak/answer-protocol/blob/main/server/main.c"
click node_validation "https://github.com/finorak/answer-protocol/blob/main/server/val_exec.c"
click node_command_handlers "https://github.com/finorak/answer-protocol/tree/main/server/execution"
click node_player_groups "https://github.com/finorak/answer-protocol/tree/main/server/tools"
click node_world_parser "https://github.com/finorak/answer-protocol/blob/main/parser/parser_utils.c"
click node_world_extractors "https://github.com/finorak/answer-protocol/tree/main/parser/data_extractor"
click node_world_validation "https://github.com/finorak/answer-protocol/tree/main/parser/data_validator"
click node_world_state "https://github.com/finorak/answer-protocol/blob/main/includes/world.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_cli toneBlue
class node_server_runtime,node_validation,node_command_handlers,node_player_groups toneAmber
class node_world_parser,node_world_extractors,node_world_validation,node_world_state,node_game_server toneMint
class node_gui_app,node_connection,node_gui_network,node_environment,node_gui_views,node_ui_components toneRose
class node_player,node_world_file toneIndigo
```

## Components

### Player clients

- [CLI client](https://github.com/finorak/answer-protocol/blob/main/client/main.c): `client/main.c`

### Server runtime

- [TCP server](https://github.com/finorak/answer-protocol/blob/main/server/main.c): `server/main.c`
- [Command validation](https://github.com/finorak/answer-protocol/blob/main/server/val_exec.c): `server/val_exec.c`
- [Game commands](https://github.com/finorak/answer-protocol/tree/main/server/execution): `server/execution`
- [Player and group management](https://github.com/finorak/answer-protocol/tree/main/server/tools): `server/tools`

### World data

- [World initialization](https://github.com/finorak/answer-protocol/blob/main/parser/parser_utils.c): `parser/parser_utils.c`
- [World entity extraction](https://github.com/finorak/answer-protocol/tree/main/parser/data_extractor): `parser/data_extractor`
- [World validation](https://github.com/finorak/answer-protocol/tree/main/parser/data_validator): `parser/data_validator`
- [In-memory world](https://github.com/finorak/answer-protocol/blob/main/includes/world.h): `includes/world.h`

### GUI experience

- [GUI application](https://github.com/finorak/answer-protocol/blob/main/gui/main.cpp): `gui/main.cpp`
- [Connection page](https://github.com/finorak/answer-protocol/blob/main/gui/components/page/Connect.cpp): `gui/components/page/Connect.cpp`
- [GUI server link](https://github.com/finorak/answer-protocol/blob/main/gui/Server.cpp): `gui/Server.cpp`
- [World interface](https://github.com/finorak/answer-protocol/blob/main/gui/components/features/Environment.cpp): `gui/components/features/Environment.cpp`
- [Inventory and protocol](https://github.com/finorak/answer-protocol/tree/main/gui/components/features): `gui/components/features`
- [UI components](https://github.com/finorak/answer-protocol/tree/main/gui/components/basic): `gui/components/basic`

### Other components

- **Player**
- **World JSON**
- **Game server**

## Connections

- Player → CLI client: uses (evidence: `README.md`)
- Player → GUI application: uses (evidence: `README.md`)
- CLI client → Game server: connects to (evidence: `README.md`)
- GUI application → Connection page: opens (evidence: `gui/main.cpp`)
- Connection page → GUI server link: connects through (evidence: `gui/components/page/Connect.cpp`)
- GUI server link → Game server: sends requests (evidence: `README.md`)
- GUI server link → Inventory and protocol: dispatches events (evidence: `gui/Server.cpp`)
- World interface → GUI server link: requests actions (evidence: `gui/components/features/Environment.cpp`)
- World interface → UI components: renders with (evidence: `gui/components/features/Environment.cpp`)
- GUI application → World interface: shows
- Game server → TCP server: reaches (evidence: `README.md`)
- TCP server → World initialization: initializes (evidence: `server/main.c`)
- TCP server → Command validation: validates commands (evidence: `server/main.c`)
- TCP server → Game commands: dispatches commands (evidence: `README.md`)
- Game commands → In-memory world: acts on
- TCP server → Player and group management: manages players (evidence: `server/main.c`)
- World initialization → World entity extraction: uses extractors (evidence: `parser/parser_utils.c`)
- World initialization → World validation: validates world
- World initialization → World JSON: loads
- World initialization → In-memory world: populates
- TCP server → In-memory world: updates during play (evidence: `server/main.c`)
- Game commands → Player and group management: supports group actions (evidence: `README.md`)
