# 3kh0/left-4-dead-2 architecture

> Architecture diagram of the GitHub repository 3kh0/left-4-dead-2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/3kh0/left-4-dead-2
- Repository: https://github.com/3kh0/left-4-dead-2

## Overview

This is an archival Left 4 Dead 2 / Source engine development tree, not a standalone service. Its main product workflow is gameplay running across client, server, and shared game code, supported by engine networking, rendering, audio, and scripting. The README names the gameplay capabilities but does not document their runtime call sequence, so those links are shown as unverified. Sampled source confirms specific ragdoll, voice-audio, post-processing shader, and texture-management responsibilities; other subsystem boundaries are inferred from the README and tree rather than inspected implementation.

Main entry points: [`engine/client.cpp`](https://github.com/3kh0/left-4-dead-2/blob/main/engine/client.cpp) (Client runtime), [`engine/baseserver.cpp`](https://github.com/3kh0/left-4-dead-2/blob/main/engine/baseserver.cpp) (Server runtime), [`game/shared/terror/terrorragdollmanager.cpp`](https://github.com/3kh0/left-4-dead-2/blob/main/game/shared/terror/terrorragdollmanager.cpp) (Ragdoll lifecycle), [`engine/audio/private/voice_sound_engine_interface.cpp`](https://github.com/3kh0/left-4-dead-2/blob/main/engine/audio/private/voice_sound_engine_interface.cpp) (Audio and voice)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["L4D2 gameplay"]
  node_player["Players and survivors"]
  node_bots["Survivor bots"]
  node_infected["Infected and Witch"]
  node_modes["Game modes and HUD"]
  node_ragdolls["Ragdoll lifecycle"]
end

subgraph group_engine["Source engine"]
  node_client["Client runtime<br/>[client.cpp]"]
  node_server["Server runtime<br/>[baseserver.cpp]"]
  node_network["Engine networking<br/>[net_chan.cpp]"]
  node_scripting["Engine scripting"]
end

subgraph group_media["Rendering and audio"]
  node_rendering["Rendering engine<br/>[gl_rmain.cpp]"]
  node_postfx["Post-processing shader"]
  node_textures["Texture manager<br/>[texturemanager.cpp]"]
  node_audio["Audio and voice"]
end

subgraph group_interfaces["Shared interfaces"]
  node_filesystem["Filesystem interface<br/>[filesystem.h]"]
  node_soundapi["Sound interface<br/>[sound.h]"]
  node_materialconfig["Material configuration"]
  node_math["Math library<br/>[mathlib.h]"]
  node_profiling["Runtime profiling<br/>[vprof.h]"]
end

node_player -.->|"runs in"| node_client
node_bots -.->|"runs in"| node_server
node_infected -.->|"runs in"| node_server
node_modes -.->|"supports"| node_player
node_ragdolls -.->|"updates"| node_client
node_ragdolls -.->|"updates"| node_server
node_client -.->|"uses"| node_network
node_server -.->|"uses"| node_network
node_audio -->|"implements"| node_soundapi
node_audio -->|"uses"| node_filesystem
node_postfx -.->|"draws"| node_rendering
node_textures -->|"reads assets"| node_filesystem
node_rendering -.->|"uses settings"| node_materialconfig
node_ragdolls -->|"profiles"| node_profiling
node_ragdolls -->|"manages entities"| node_player
node_client -.->|"uses"| node_audio
node_client -.->|"uses"| node_rendering
node_client -.->|"hosts"| node_scripting
node_server -.->|"hosts"| node_scripting

click node_player "https://github.com/3kh0/left-4-dead-2/tree/main/game"
click node_bots "https://github.com/3kh0/left-4-dead-2/tree/main/game"
click node_infected "https://github.com/3kh0/left-4-dead-2/tree/main/game"
click node_modes "https://github.com/3kh0/left-4-dead-2/tree/main/game"
click node_ragdolls "https://github.com/3kh0/left-4-dead-2/blob/main/game/shared/terror/terrorragdollmanager.cpp"
click node_client "https://github.com/3kh0/left-4-dead-2/blob/main/engine/client.cpp"
click node_server "https://github.com/3kh0/left-4-dead-2/blob/main/engine/baseserver.cpp"
click node_network "https://github.com/3kh0/left-4-dead-2/blob/main/engine/net_chan.cpp"
click node_scripting "https://github.com/3kh0/left-4-dead-2/tree/main/engine"
click node_filesystem "https://github.com/3kh0/left-4-dead-2/blob/main/public/filesystem.h"
click node_soundapi "https://github.com/3kh0/left-4-dead-2/blob/main/engine/audio/public/sound.h"
click node_materialconfig "https://github.com/3kh0/left-4-dead-2/blob/main/public/materialsystem/materialsystem_config.h"
click node_rendering "https://github.com/3kh0/left-4-dead-2/blob/main/engine/gl_rmain.cpp"
click node_postfx "https://github.com/3kh0/left-4-dead-2/blob/main/materialsystem/stdshaders/engine_post_dx9.cpp"
click node_textures "https://github.com/3kh0/left-4-dead-2/blob/main/materialsystem/texturemanager.cpp"
click node_audio "https://github.com/3kh0/left-4-dead-2/blob/main/engine/audio/private/voice_sound_engine_interface.cpp"
click node_math "https://github.com/3kh0/left-4-dead-2/blob/main/public/mathlib/mathlib.h"
click node_profiling "https://github.com/3kh0/left-4-dead-2/blob/main/public/tier0/vprof.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_player,node_bots,node_infected,node_modes,node_ragdolls toneBlue
class node_client,node_server,node_network,node_scripting toneAmber
class node_rendering,node_postfx,node_textures,node_audio toneMint
class node_filesystem,node_soundapi,node_materialconfig,node_math,node_profiling toneRose
```

## Components

### L4D2 gameplay

- [Players and survivors](https://github.com/3kh0/left-4-dead-2/tree/main/game): `game`
- [Survivor bots](https://github.com/3kh0/left-4-dead-2/tree/main/game): `game`
- [Infected and Witch](https://github.com/3kh0/left-4-dead-2/tree/main/game): `game`
- [Game modes and HUD](https://github.com/3kh0/left-4-dead-2/tree/main/game): `game`
- [Ragdoll lifecycle](https://github.com/3kh0/left-4-dead-2/blob/main/game/shared/terror/terrorragdollmanager.cpp): `game/shared/terror/terrorragdollmanager.cpp`

### Source engine

- [Client runtime](https://github.com/3kh0/left-4-dead-2/blob/main/engine/client.cpp): `engine/client.cpp`
- [Server runtime](https://github.com/3kh0/left-4-dead-2/blob/main/engine/baseserver.cpp): `engine/baseserver.cpp`
- [Engine networking](https://github.com/3kh0/left-4-dead-2/blob/main/engine/net_chan.cpp): `engine/net_chan.cpp`
- [Engine scripting](https://github.com/3kh0/left-4-dead-2/tree/main/engine): `engine`

### Rendering and audio

- [Rendering engine](https://github.com/3kh0/left-4-dead-2/blob/main/engine/gl_rmain.cpp): `engine/gl_rmain.cpp`
- [Post-processing shader](https://github.com/3kh0/left-4-dead-2/blob/main/materialsystem/stdshaders/engine_post_dx9.cpp): `materialsystem/stdshaders/engine_post_dx9.cpp`
- [Texture manager](https://github.com/3kh0/left-4-dead-2/blob/main/materialsystem/texturemanager.cpp): `materialsystem/texturemanager.cpp`
- [Audio and voice](https://github.com/3kh0/left-4-dead-2/blob/main/engine/audio/private/voice_sound_engine_interface.cpp): `engine/audio/private/voice_sound_engine_interface.cpp`

### Shared interfaces

- [Filesystem interface](https://github.com/3kh0/left-4-dead-2/blob/main/public/filesystem.h): `public/filesystem.h`
- [Sound interface](https://github.com/3kh0/left-4-dead-2/blob/main/engine/audio/public/sound.h): `engine/audio/public/sound.h`
- [Material configuration](https://github.com/3kh0/left-4-dead-2/blob/main/public/materialsystem/materialsystem_config.h): `public/materialsystem/materialsystem_config.h`
- [Math library](https://github.com/3kh0/left-4-dead-2/blob/main/public/mathlib/mathlib.h): `public/mathlib/mathlib.h`
- [Runtime profiling](https://github.com/3kh0/left-4-dead-2/blob/main/public/tier0/vprof.h): `public/tier0/vprof.h`

## Connections

- Players and survivors → Client runtime: runs in
- Survivor bots → Server runtime: runs in
- Infected and Witch → Server runtime: runs in
- Game modes and HUD → Players and survivors: supports
- Ragdoll lifecycle → Client runtime: updates
- Ragdoll lifecycle → Server runtime: updates
- Client runtime → Engine networking: uses
- Server runtime → Engine networking: uses
- Audio and voice → Sound interface: implements (evidence: `engine/audio/private/voice_sound_engine_interface.cpp`)
- Audio and voice → Filesystem interface: uses
- Post-processing shader → Rendering engine: draws
- Texture manager → Filesystem interface: reads assets (evidence: `materialsystem/texturemanager.cpp`)
- Rendering engine → Material configuration: uses settings
- Ragdoll lifecycle → Runtime profiling: profiles (evidence: `game/shared/terror/terrorragdollmanager.cpp`)
- Ragdoll lifecycle → Players and survivors: manages entities (evidence: `game/shared/terror/terrorragdollmanager.cpp`)
- Client runtime → Audio and voice: uses
- Client runtime → Rendering engine: uses
- Client runtime → Engine scripting: hosts
- Server runtime → Engine scripting: hosts
