# fwgs/xash3d architecture

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

- Interactive diagram: https://gitdiagram.com/fwgs/xash3d
- Repository: https://github.com/fwgs/xash3d

## Overview

Xash3D FWGS is a cross-platform Gold Source-compatible game engine. Its main user-facing workflow is running a compatible game or mod: the engine loads game assets and game-DLL interfaces, then runs client/server simulation and presents graphics, audio, and input. The tree also shows networking, shared movement physics, platform backends, and a Win32 compatibility loader. Major client features include rendering, sound, input, menus, and cinematics. Several subsystem links are based on documented capabilities or header references rather than sampled call sites; those uncertain links are dashed.

Main entry points: [`engine/client/cl_main.c`](https://github.com/fwgs/xash3d/blob/master/engine/client/cl_main.c) (Client session), [`engine/common/host.c`](https://github.com/fwgs/xash3d/blob/master/engine/common/host.c) (Host lifecycle), [`engine/common/filesystem.c`](https://github.com/fwgs/xash3d/blob/master/engine/common/filesystem.c) (Game files), [`engine/server/sv_frame.c`](https://github.com/fwgs/xash3d/blob/master/engine/server/sv_frame.c) (Server simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Engine runtime"]
  node_host["Host lifecycle<br/>[host.c]"]
  node_filesystem["Game files<br/>[filesystem.c]"]
  node_models["Models and maps<br/>[model.c]"]
  node_store[("Asset storage<br/>[filesystem.c]")]
end

subgraph group_simulation["Game simulation"]
  node_server["Server simulation<br/>[sv_frame.c]"]
  node_gameapi["Game DLL interface<br/>[eiface.h]"]
  node_movement["Shared movement<br/>[pm_defs.h]"]
  node_network["Network protocol<br/>[network.c]"]
  node_serverclient["Client handling<br/>[sv_client.c]"]
end

subgraph group_client["Client experience"]
  node_client["Client session<br/>[cl_main.c]"]
  node_clientnet["Client networking<br/>[cl_parse.c]"]
  node_input["Input controls<br/>[input.c]"]
  node_renderer["World renderer<br/>[gl_rmain.c]"]
  node_fragments["Entity fragments<br/>[gl_refrag.c]"]
  node_sound["Audio playback<br/>[s_main.c]"]
  node_menus["Menus and UI<br/>[cl_menu.c]"]
  node_cinematics["Cinematics<br/>[cl_video.c]"]
end

subgraph group_platform["Platform and compatibility"]
  node_launcher["Game launcher<br/>[xash.c]"]
  node_platform["Platform backends<br/>[events.c]"]
  node_compat["Win32 emulation<br/>[win32.c]"]
end

node_player(("Player"))
node_game["Game or mod"]

node_player -.->|"starts game"| node_launcher
node_launcher -.->|"starts runtime"| node_host
node_game -.->|"provides assets"| node_filesystem
node_host -.->|"uses files"| node_filesystem
node_filesystem -->|"reads assets"| node_store
node_host -.->|"runs client"| node_client
node_host -.->|"runs server"| node_server
node_server -.->|"dispatches callbacks"| node_gameapi
node_serverclient -.->|"encodes messages"| node_network
node_server -.->|"simulates movement"| node_movement
node_client -.->|"receives updates"| node_clientnet
node_clientnet -.->|"decodes protocol"| node_network
node_client -.->|"collects input"| node_input
node_client -.->|"renders frames"| node_renderer
node_renderer -->|"uses fragments"| node_fragments
node_client -.->|"plays audio"| node_sound
node_client -.->|"shows menus"| node_menus
node_client -->|"plays videos"| node_cinematics
node_platform -.->|"supplies events"| node_input
node_game -.->|"uses compatibility"| node_compat
node_compat -.->|"loads game libraries"| node_launcher
node_models -.->|"loads model data"| node_filesystem
node_renderer -.->|"displays world"| node_models

click node_launcher "https://github.com/fwgs/xash3d/blob/master/game_launch/xash.c"
click node_host "https://github.com/fwgs/xash3d/blob/master/engine/common/host.c"
click node_filesystem "https://github.com/fwgs/xash3d/blob/master/engine/common/filesystem.c"
click node_models "https://github.com/fwgs/xash3d/blob/master/engine/common/model.c"
click node_server "https://github.com/fwgs/xash3d/blob/master/engine/server/sv_frame.c"
click node_gameapi "https://github.com/fwgs/xash3d/blob/master/engine/eiface.h"
click node_movement "https://github.com/fwgs/xash3d/blob/master/pm_shared/pm_defs.h"
click node_network "https://github.com/fwgs/xash3d/blob/master/engine/common/network.c"
click node_serverclient "https://github.com/fwgs/xash3d/blob/master/engine/server/sv_client.c"
click node_client "https://github.com/fwgs/xash3d/blob/master/engine/client/cl_main.c"
click node_clientnet "https://github.com/fwgs/xash3d/blob/master/engine/client/cl_parse.c"
click node_input "https://github.com/fwgs/xash3d/blob/master/engine/client/input.c"
click node_renderer "https://github.com/fwgs/xash3d/blob/master/engine/client/gl_rmain.c"
click node_fragments "https://github.com/fwgs/xash3d/blob/master/engine/client/gl_refrag.c"
click node_sound "https://github.com/fwgs/xash3d/blob/master/engine/client/s_main.c"
click node_menus "https://github.com/fwgs/xash3d/blob/master/engine/client/cl_menu.c"
click node_cinematics "https://github.com/fwgs/xash3d/blob/master/engine/client/cl_video.c"
click node_platform "https://github.com/fwgs/xash3d/blob/master/engine/platform/sdl/events.c"
click node_compat "https://github.com/fwgs/xash3d/blob/master/loader/win32.c"
click node_store "https://github.com/fwgs/xash3d/blob/master/engine/common/filesystem.c"

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_filesystem,node_models,node_store toneBlue
class node_server,node_gameapi,node_movement,node_network,node_serverclient toneAmber
class node_client,node_clientnet,node_input,node_renderer,node_fragments,node_sound,node_menus,node_cinematics toneMint
class node_launcher,node_platform,node_compat toneRose
class node_player,node_game toneIndigo
```

## Components

### Engine runtime

- [Host lifecycle](https://github.com/fwgs/xash3d/blob/master/engine/common/host.c): `engine/common/host.c`
- [Game files](https://github.com/fwgs/xash3d/blob/master/engine/common/filesystem.c): `engine/common/filesystem.c`
- [Models and maps](https://github.com/fwgs/xash3d/blob/master/engine/common/model.c): `engine/common/model.c`
- [Asset storage](https://github.com/fwgs/xash3d/blob/master/engine/common/filesystem.c): `engine/common/filesystem.c`

### Game simulation

- [Server simulation](https://github.com/fwgs/xash3d/blob/master/engine/server/sv_frame.c): `engine/server/sv_frame.c`
- [Game DLL interface](https://github.com/fwgs/xash3d/blob/master/engine/eiface.h): `engine/eiface.h`
- [Shared movement](https://github.com/fwgs/xash3d/blob/master/pm_shared/pm_defs.h): `pm_shared/pm_defs.h`
- [Network protocol](https://github.com/fwgs/xash3d/blob/master/engine/common/network.c): `engine/common/network.c`
- [Client handling](https://github.com/fwgs/xash3d/blob/master/engine/server/sv_client.c): `engine/server/sv_client.c`

### Client experience

- [Client session](https://github.com/fwgs/xash3d/blob/master/engine/client/cl_main.c): `engine/client/cl_main.c`
- [Client networking](https://github.com/fwgs/xash3d/blob/master/engine/client/cl_parse.c): `engine/client/cl_parse.c`
- [Input controls](https://github.com/fwgs/xash3d/blob/master/engine/client/input.c): `engine/client/input.c`
- [World renderer](https://github.com/fwgs/xash3d/blob/master/engine/client/gl_rmain.c): `engine/client/gl_rmain.c`
- [Entity fragments](https://github.com/fwgs/xash3d/blob/master/engine/client/gl_refrag.c): `engine/client/gl_refrag.c`
- [Audio playback](https://github.com/fwgs/xash3d/blob/master/engine/client/s_main.c): `engine/client/s_main.c`
- [Menus and UI](https://github.com/fwgs/xash3d/blob/master/engine/client/cl_menu.c): `engine/client/cl_menu.c`
- [Cinematics](https://github.com/fwgs/xash3d/blob/master/engine/client/cl_video.c): `engine/client/cl_video.c`

### Platform and compatibility

- [Game launcher](https://github.com/fwgs/xash3d/blob/master/game_launch/xash.c): `game_launch/xash.c`
- [Platform backends](https://github.com/fwgs/xash3d/blob/master/engine/platform/sdl/events.c): `engine/platform/sdl/events.c`
- [Win32 emulation](https://github.com/fwgs/xash3d/blob/master/loader/win32.c): `loader/win32.c`

### Other components

- **Player**
- **Game or mod**

## Connections

- Player → Game launcher: starts game
- Game launcher → Host lifecycle: starts runtime
- Game or mod → Game files: provides assets
- Host lifecycle → Game files: uses files
- Game files → Asset storage: reads assets
- Host lifecycle → Client session: runs client
- Host lifecycle → Server simulation: runs server
- Server simulation → Game DLL interface: dispatches callbacks
- Client handling → Network protocol: encodes messages (evidence: `engine/server/sv_client.c`)
- Server simulation → Shared movement: simulates movement
- Client session → Client networking: receives updates
- Client networking → Network protocol: decodes protocol
- Client session → Input controls: collects input
- Client session → World renderer: renders frames
- World renderer → Entity fragments: uses fragments (evidence: `engine/client/gl_refrag.c`)
- Client session → Audio playback: plays audio
- Client session → Menus and UI: shows menus
- Client session → Cinematics: plays videos
- Platform backends → Input controls: supplies events
- Game or mod → Win32 emulation: uses compatibility
- Win32 emulation → Game launcher: loads game libraries (evidence: `game_launch/xash.c`)
- Models and maps → Game files: loads model data
- World renderer → Models and maps: displays world
