# 3kh0/portal-2 architecture

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

- Interactive diagram: https://gitdiagram.com/3kh0/portal-2
- Repository: https://github.com/3kh0/portal-2

## Overview

This is an archival mirror of the Portal 2 / Source engine development tree, not a single standalone utility. The README describes gameplay code divided across client, server and shared layers, alongside engine rendering, networking, audio, particles and scripting. The graph sketches those product areas and key internal interfaces; it is not a verified runtime call sequence. Source excerpts are partial, and many central modules were only indexed, so undocumented connections are omitted.

Main entry points: [`game/client`](https://github.com/3kh0/portal-2/tree/main/game/client) (Client Gameplay), [`engine/cdll_engine_int.cpp`](https://github.com/3kh0/portal-2/blob/main/engine/cdll_engine_int.cpp) (Engine Client API), [`engine/enginetrace.cpp`](https://github.com/3kh0/portal-2/blob/main/engine/enginetrace.cpp) (Collision Tracing), [`engine/gl_model_private.h`](https://github.com/3kh0/portal-2/blob/main/engine/gl_model_private.h) (Rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Gameplay"]
  node_client_game["Client Gameplay"]
  node_shared_game["Shared Gameplay"]
  node_server_game["Server Gameplay"]
end

subgraph group_engine["Engine Runtime"]
  node_engine_client["Engine Client API"]
  node_engine_server["Engine Server<br/>[server.h]"]
  node_collision["Collision Tracing<br/>[enginetrace.cpp]"]
  node_client_classes["Client Class Registry<br/>[client_class.h]"]
  node_networking["Networking<br/>[netmessages.cpp]"]
  node_scripting["Scripting Interfaces<br/>[lua.h]"]
  node_models["Collision Models<br/>[cmodel_engine.h]"]
  node_physics["Physics Interface"]
end

subgraph group_media["Media Systems"]
  node_rendering["Rendering<br/>[gl_model_private.h]"]
  node_post_effects["Post Effects"]
  node_audio["Audio System<br/>[sound.h]"]
  node_voice_audio["Voice Audio"]
  node_particles["Particle Systems<br/>[blobrender.cpp]"]
end

subgraph group_foundation["Shared Foundation"]
  node_math["Math Library<br/>[mathlib.h]"]
  node_platform["Platform Types<br/>[platform.h]"]
  node_threading["Threading<br/>[threadtools.h]"]
  node_profiling["Profiling<br/>[vprof.h]"]
  node_telemetry["Profiling Telemetry<br/>[vprof_telemetry.h]"]
  node_configuration["Console Variables<br/>[convar.h]"]
  node_memory_debug["Memory Debug Hooks<br/>[memdbgon.h]"]
  node_base_types["Base Types<br/>[basetypes.h]"]
  node_debug["Debug Utilities<br/>[dbg.h]"]
end

node_player(("Player"))

node_player -->|"plays"| node_client_game
node_client_game -.->|"uses engine API"| node_engine_client
node_client_game -->|"shares gameplay"| node_shared_game
node_server_game -->|"shares gameplay"| node_shared_game
node_engine_client -->|"queries models"| node_models
node_engine_client -->|"exposes sound"| node_audio
node_engine_client -->|"traces world"| node_collision
node_engine_server -.->|"hosts gameplay"| node_server_game
node_client_classes -->|"registers classes"| node_client_game
node_collision -->|"queries collision"| node_models
node_rendering -.->|"uses shader"| node_post_effects
node_audio -->|"supports voice"| node_voice_audio
node_client_game -.->|"exchanges data"| node_networking
node_rendering -.->|"renders effects"| node_particles
node_physics -.->|"provides physics"| node_collision
node_platform -->|"defines platform types"| node_base_types
node_profiling -->|"uses thread support"| node_threading
node_profiling -->|"includes telemetry"| node_telemetry

click node_client_game "https://github.com/3kh0/portal-2/tree/main/game/client"
click node_shared_game "https://github.com/3kh0/portal-2/tree/main/game/shared"
click node_server_game "https://github.com/3kh0/portal-2/tree/main/game/server"
click node_engine_client "https://github.com/3kh0/portal-2/blob/main/engine/cdll_engine_int.cpp"
click node_engine_server "https://github.com/3kh0/portal-2/blob/main/engine/server.h"
click node_collision "https://github.com/3kh0/portal-2/blob/main/engine/enginetrace.cpp"
click node_client_classes "https://github.com/3kh0/portal-2/blob/main/public/client_class.h"
click node_rendering "https://github.com/3kh0/portal-2/blob/main/engine/gl_model_private.h"
click node_post_effects "https://github.com/3kh0/portal-2/blob/main/materialsystem/stdshaders/engine_post_dx9.cpp"
click node_audio "https://github.com/3kh0/portal-2/blob/main/engine/audio/public/sound.h"
click node_voice_audio "https://github.com/3kh0/portal-2/blob/main/engine/audio/private/voice_sound_engine_interface.cpp"
click node_networking "https://github.com/3kh0/portal-2/blob/main/common/netmessages.cpp"
click node_particles "https://github.com/3kh0/portal-2/blob/main/blobulator/common/blobrender.cpp"
click node_scripting "https://github.com/3kh0/portal-2/blob/main/common/lua.h"
click node_models "https://github.com/3kh0/portal-2/blob/main/engine/cmodel_engine.h"
click node_physics "https://github.com/3kh0/portal-2/blob/main/public/vphysics_interface.h"
click node_math "https://github.com/3kh0/portal-2/blob/main/public/mathlib/mathlib.h"
click node_platform "https://github.com/3kh0/portal-2/blob/main/public/tier0/platform.h"
click node_threading "https://github.com/3kh0/portal-2/blob/main/public/tier0/threadtools.h"
click node_profiling "https://github.com/3kh0/portal-2/blob/main/public/tier0/vprof.h"
click node_telemetry "https://github.com/3kh0/portal-2/blob/main/public/tier0/vprof_telemetry.h"
click node_configuration "https://github.com/3kh0/portal-2/blob/main/public/tier1/convar.h"
click node_memory_debug "https://github.com/3kh0/portal-2/blob/main/public/tier0/memdbgon.h"
click node_base_types "https://github.com/3kh0/portal-2/blob/main/public/tier0/basetypes.h"
click node_debug "https://github.com/3kh0/portal-2/blob/main/public/tier0/dbg.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_client_game,node_shared_game,node_server_game toneBlue
class node_engine_client,node_engine_server,node_collision,node_client_classes,node_networking,node_scripting,node_models,node_physics toneAmber
class node_rendering,node_post_effects,node_audio,node_voice_audio,node_particles toneMint
class node_math,node_platform,node_threading,node_profiling,node_telemetry,node_configuration,node_memory_debug,node_base_types,node_debug toneRose
class node_player toneIndigo
```

## Components

### Gameplay

- [Client Gameplay](https://github.com/3kh0/portal-2/tree/main/game/client): `game/client`
- [Shared Gameplay](https://github.com/3kh0/portal-2/tree/main/game/shared): `game/shared`
- [Server Gameplay](https://github.com/3kh0/portal-2/tree/main/game/server): `game/server`

### Engine Runtime

- [Engine Client API](https://github.com/3kh0/portal-2/blob/main/engine/cdll_engine_int.cpp): `engine/cdll_engine_int.cpp`
- [Engine Server](https://github.com/3kh0/portal-2/blob/main/engine/server.h): `engine/server.h`
- [Collision Tracing](https://github.com/3kh0/portal-2/blob/main/engine/enginetrace.cpp): `engine/enginetrace.cpp`
- [Client Class Registry](https://github.com/3kh0/portal-2/blob/main/public/client_class.h): `public/client_class.h`
- [Networking](https://github.com/3kh0/portal-2/blob/main/common/netmessages.cpp): `common/netmessages.cpp`
- [Scripting Interfaces](https://github.com/3kh0/portal-2/blob/main/common/lua.h): `common/lua.h`
- [Collision Models](https://github.com/3kh0/portal-2/blob/main/engine/cmodel_engine.h): `engine/cmodel_engine.h`
- [Physics Interface](https://github.com/3kh0/portal-2/blob/main/public/vphysics_interface.h): `public/vphysics_interface.h`

### Media Systems

- [Rendering](https://github.com/3kh0/portal-2/blob/main/engine/gl_model_private.h): `engine/gl_model_private.h`
- [Post Effects](https://github.com/3kh0/portal-2/blob/main/materialsystem/stdshaders/engine_post_dx9.cpp): `materialsystem/stdshaders/engine_post_dx9.cpp`
- [Audio System](https://github.com/3kh0/portal-2/blob/main/engine/audio/public/sound.h): `engine/audio/public/sound.h`
- [Voice Audio](https://github.com/3kh0/portal-2/blob/main/engine/audio/private/voice_sound_engine_interface.cpp): `engine/audio/private/voice_sound_engine_interface.cpp`
- [Particle Systems](https://github.com/3kh0/portal-2/blob/main/blobulator/common/blobrender.cpp): `blobulator/common/blobrender.cpp`

### Shared Foundation

- [Math Library](https://github.com/3kh0/portal-2/blob/main/public/mathlib/mathlib.h): `public/mathlib/mathlib.h`
- [Platform Types](https://github.com/3kh0/portal-2/blob/main/public/tier0/platform.h): `public/tier0/platform.h`
- [Threading](https://github.com/3kh0/portal-2/blob/main/public/tier0/threadtools.h): `public/tier0/threadtools.h`
- [Profiling](https://github.com/3kh0/portal-2/blob/main/public/tier0/vprof.h): `public/tier0/vprof.h`
- [Profiling Telemetry](https://github.com/3kh0/portal-2/blob/main/public/tier0/vprof_telemetry.h): `public/tier0/vprof_telemetry.h`
- [Console Variables](https://github.com/3kh0/portal-2/blob/main/public/tier1/convar.h): `public/tier1/convar.h`
- [Memory Debug Hooks](https://github.com/3kh0/portal-2/blob/main/public/tier0/memdbgon.h): `public/tier0/memdbgon.h`
- [Base Types](https://github.com/3kh0/portal-2/blob/main/public/tier0/basetypes.h): `public/tier0/basetypes.h`
- [Debug Utilities](https://github.com/3kh0/portal-2/blob/main/public/tier0/dbg.h): `public/tier0/dbg.h`

### Other components

- **Player**

## Connections

- Player → Client Gameplay: plays
- Client Gameplay → Engine Client API: uses engine API
- Client Gameplay → Shared Gameplay: shares gameplay
- Server Gameplay → Shared Gameplay: shares gameplay
- Engine Client API → Collision Models: queries models (evidence: `engine/cdll_engine_int.cpp`)
- Engine Client API → Audio System: exposes sound (evidence: `engine/cdll_engine_int.cpp`)
- Engine Client API → Collision Tracing: traces world (evidence: `engine/enginetrace.cpp`)
- Engine Server → Server Gameplay: hosts gameplay
- Client Class Registry → Client Gameplay: registers classes (evidence: `public/client_class.h`)
- Collision Tracing → Collision Models: queries collision (evidence: `engine/enginetrace.cpp`)
- Rendering → Post Effects: uses shader
- Audio System → Voice Audio: supports voice
- Client Gameplay → Networking: exchanges data
- Rendering → Particle Systems: renders effects
- Physics Interface → Collision Tracing: provides physics (evidence: `engine/enginetrace.cpp`)
- Platform Types → Base Types: defines platform types (evidence: `engine/audio/private/audio_pch.h`)
- Profiling → Threading: uses thread support (evidence: `public/tier0/vprof.h`)
- Profiling → Profiling Telemetry: includes telemetry (evidence: `public/tier0/vprof.h`)
