# jacoders/openjk architecture

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

- Interactive diagram: https://gitdiagram.com/jacoders/openjk
- Repository: https://github.com/jacoders/openjk

## Overview

OpenJK maintains the engine and game runtime for Jedi Academy and Jedi Outcast, preserving compatibility rather than introducing major gameplay changes. The main player loop runs from input through client prediction and game simulation to server snapshots and rendered/audio output; menus, scripted behaviors, and persistence are important adjacent capabilities. The tree also contains distinct single-player, multiplayer, and JK2 implementations. Edges reflect the conventional runtime boundaries visible in module names and the sampled APIs; most subsystem internals were not sampled, so uncertain wiring is omitted.

Main entry points: [`code/client/cl_main.cpp`](https://github.com/jacoders/openjk/blob/master/code/client/cl_main.cpp) (Client Core), [`code/cgame/cg_main.cpp`](https://github.com/jacoders/openjk/blob/master/code/cgame/cg_main.cpp) (Client Game), [`code/game/g_main.cpp`](https://github.com/jacoders/openjk/blob/master/code/game/g_main.cpp) (Game Rules), [`code/qcommon/net_chan.cpp`](https://github.com/jacoders/openjk/blob/master/code/qcommon/net_chan.cpp) (Network Channel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client Runtime"]
  node_input["Input<br/>[cl_input.cpp]"]
  node_clientcore["Client Core<br/>[cl_main.cpp]"]
  node_cgame["Client Game<br/>[cg_main.cpp]"]
  node_ui["Menus UI<br/>[ui_main.cpp]"]
  node_renderer["Renderer<br/>[tr_main.cpp]"]
  node_audio["Audio<br/>[snd_dma.cpp]"]
end

subgraph group_simulation["Game Simulation"]
  node_server["Game Server<br/>[sv_main.cpp]"]
  node_rules["Game Rules<br/>[g_main.cpp]"]
  node_movement["Shared Movement<br/>[bg_pmove.cpp]"]
  node_mpgame["MP Rules<br/>[g_main.c]"]
  node_jk2game["JK2 Rules<br/>[g_main.cpp]"]
end

subgraph group_engine["Engine Services"]
  node_network["Network Channel<br/>[net_chan.cpp]"]
  node_persistence["Save Games<br/>[ojk_saved_game.cpp]"]
end

subgraph group_extensions["Game Capabilities"]
  node_scripts["ICARUS Tasks<br/>[TaskManager.cpp]"]
  node_bots["Bot AI<br/>[be_interface.cpp]"]
end

node_player(("Player"))
node_assets[("Game Installation")]

node_player -->|"provides controls"| node_input
node_input -->|"submits commands"| node_clientcore
node_clientcore -->|"dispatches calls"| node_cgame
node_cgame -->|"predicts movement"| node_movement
node_cgame -->|"submits scene"| node_renderer
node_cgame -->|"starts sounds"| node_audio
node_clientcore -->|"sends messages"| node_network
node_network -->|"delivers messages"| node_server
node_server -->|"invokes game module"| node_rules
node_rules -->|"uses movement"| node_movement
node_server -->|"sends snapshots"| node_network
node_network -->|"delivers snapshots"| node_clientcore
node_clientcore -->|"dispatches UI"| node_ui
node_assets -->|"loads game data"| node_clientcore
node_rules -.->|"runs scripted tasks"| node_scripts
node_rules -.->|"uses save support"| node_persistence
node_mpgame -->|"uses movement"| node_movement
node_jk2game -->|"uses movement"| node_movement
node_mpgame -.->|"uses bot library"| node_bots

click node_input "https://github.com/jacoders/openjk/blob/master/code/client/cl_input.cpp"
click node_clientcore "https://github.com/jacoders/openjk/blob/master/code/client/cl_main.cpp"
click node_cgame "https://github.com/jacoders/openjk/blob/master/code/cgame/cg_main.cpp"
click node_ui "https://github.com/jacoders/openjk/blob/master/code/ui/ui_main.cpp"
click node_renderer "https://github.com/jacoders/openjk/blob/master/code/rd-vanilla/tr_main.cpp"
click node_audio "https://github.com/jacoders/openjk/blob/master/code/client/snd_dma.cpp"
click node_server "https://github.com/jacoders/openjk/blob/master/code/server/sv_main.cpp"
click node_rules "https://github.com/jacoders/openjk/blob/master/code/game/g_main.cpp"
click node_movement "https://github.com/jacoders/openjk/blob/master/code/game/bg_pmove.cpp"
click node_mpgame "https://github.com/jacoders/openjk/blob/master/codemp/game/g_main.c"
click node_jk2game "https://github.com/jacoders/openjk/blob/master/codeJK2/game/g_main.cpp"
click node_network "https://github.com/jacoders/openjk/blob/master/code/qcommon/net_chan.cpp"
click node_persistence "https://github.com/jacoders/openjk/blob/master/code/qcommon/ojk_saved_game.cpp"
click node_scripts "https://github.com/jacoders/openjk/blob/master/code/icarus/TaskManager.cpp"
click node_bots "https://github.com/jacoders/openjk/blob/master/codemp/botlib/be_interface.cpp"

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_input,node_clientcore,node_cgame,node_ui,node_renderer,node_audio toneBlue
class node_server,node_rules,node_movement,node_mpgame,node_jk2game,node_assets toneAmber
class node_network,node_persistence toneMint
class node_scripts,node_bots toneRose
class node_player toneIndigo
```

## Components

### Client Runtime

- [Input](https://github.com/jacoders/openjk/blob/master/code/client/cl_input.cpp): `code/client/cl_input.cpp`
- [Client Core](https://github.com/jacoders/openjk/blob/master/code/client/cl_main.cpp): `code/client/cl_main.cpp`
- [Client Game](https://github.com/jacoders/openjk/blob/master/code/cgame/cg_main.cpp): `code/cgame/cg_main.cpp`
- [Menus UI](https://github.com/jacoders/openjk/blob/master/code/ui/ui_main.cpp): `code/ui/ui_main.cpp`
- [Renderer](https://github.com/jacoders/openjk/blob/master/code/rd-vanilla/tr_main.cpp): `code/rd-vanilla/tr_main.cpp`
- [Audio](https://github.com/jacoders/openjk/blob/master/code/client/snd_dma.cpp): `code/client/snd_dma.cpp`

### Game Simulation

- [Game Server](https://github.com/jacoders/openjk/blob/master/code/server/sv_main.cpp): `code/server/sv_main.cpp`
- [Game Rules](https://github.com/jacoders/openjk/blob/master/code/game/g_main.cpp): `code/game/g_main.cpp`
- [Shared Movement](https://github.com/jacoders/openjk/blob/master/code/game/bg_pmove.cpp): `code/game/bg_pmove.cpp`
- [MP Rules](https://github.com/jacoders/openjk/blob/master/codemp/game/g_main.c): `codemp/game/g_main.c`
- [JK2 Rules](https://github.com/jacoders/openjk/blob/master/codeJK2/game/g_main.cpp): `codeJK2/game/g_main.cpp`

### Engine Services

- [Network Channel](https://github.com/jacoders/openjk/blob/master/code/qcommon/net_chan.cpp): `code/qcommon/net_chan.cpp`
- [Save Games](https://github.com/jacoders/openjk/blob/master/code/qcommon/ojk_saved_game.cpp): `code/qcommon/ojk_saved_game.cpp`

### Game Capabilities

- [ICARUS Tasks](https://github.com/jacoders/openjk/blob/master/code/icarus/TaskManager.cpp): `code/icarus/TaskManager.cpp`
- [Bot AI](https://github.com/jacoders/openjk/blob/master/codemp/botlib/be_interface.cpp): `codemp/botlib/be_interface.cpp`

### Other components

- **Player**
- **Game Installation**

## Connections

- Player → Input: provides controls
- Input → Client Core: submits commands
- Client Core → Client Game: dispatches calls
- Client Game → Shared Movement: predicts movement
- Client Game → Renderer: submits scene
- Client Game → Audio: starts sounds
- Client Core → Network Channel: sends messages
- Network Channel → Game Server: delivers messages
- Game Server → Game Rules: invokes game module
- Game Rules → Shared Movement: uses movement
- Game Server → Network Channel: sends snapshots
- Network Channel → Client Core: delivers snapshots
- Client Core → Menus UI: dispatches UI
- Game Installation → Client Core: loads game data
- Game Rules → ICARUS Tasks: runs scripted tasks
- Game Rules → Save Games: uses save support
- MP Rules → Shared Movement: uses movement
- JK2 Rules → Shared Movement: uses movement
- MP Rules → Bot AI: uses bot library
