# charmedbaryon/commonlibsse-ng architecture

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

- Interactive diagram: https://gitdiagram.com/charmedbaryon/commonlibsse-ng
- Repository: https://github.com/charmedbaryon/commonlibsse-ng

## Overview

#### Purpose and Consumption

CommonLibSSE NG is a Windows C++20 static library for building SKSE plugins against reverse-engineered Skyrim engine APIs. Consumers link it through CMake or install it via Vcpkg/Conan; it is not an executable or web application. Primary public entry surfaces are the aggregate game API, SKSE integration, and relocation API: `include/RE/Skyrim.h`, `include/SKSE/SKSE.h`, `include/REL/REL.h`.

#### Build, Packaging, and Plugin Entry Generation

CMake is the canonical build integration and provides `add_commonlibsse_plugin`, which generates compatible SKSE plugin declarations and links the library. Package metadata supports Conan and Vcpkg; CI validates target combinations. Key paths: `CMakeLists.txt`, `cmake/CommonLibSSE.cmake`, `conanfile.py`.

#### Runtime Targeting and Relocation Boundary

The core portability boundary resolves IDs, offsets, module versions, and relocated executable symbols at runtime. It permits one DLL to adapt across Skyrim SE, AE (including ABI/layout differences), and VR, while callers must probe availability before using runtime-specific APIs. This layer bridges compiled plugin code to the loaded Skyrim process and Address Library data: `include/REL/Relocation.h`, `src/REL/Module.cpp`, `include/RE/Offsets.h`.

#### Reverse-Engineered Engine Model

`RE` exposes C++ declarations and selected implementations for Skyrim’s in-process object model: forms, actors, world state, effects, quests, inventory, and engine managers. It is organized alphabetically rather than by strict subsystem; headers define ABI-facing layouts/interfaces and source files supply callable wrappers or implementations. Representative roots: `include/RE/Skyrim.h`, `include/RE/T/TESForm.h`, `include/RE/A/Actor.h`.

#### UI, Input, and Scaleform Interop

The library represents both native UI message/menu machinery and Scaleform/GFx movie APIs. Plugins can interact with engine menus and UI queues, while Flash ActionScript CLIK assets document the UI-side control/delegate contract. The important crossing is native game/SKSE code → UI messages or GFx delegates → Flash movie behavior. Paths: `include/RE/U/UIMessageQueue.h`, `include/RE/G/GFxMovieView.h`, `Flash/AS2/CLIK/gfx/io/GameDelegate.as`.

#### SKSE Plugin Services

The `SKSE` layer wraps plugin-facing services: API initialization, event registration, serialization/messaging interfaces, input mapping, logging, translations, IAT hooks, and executable trampolines. It is the supported plugin-to-SKSE boundary; hooks and registration objects ultimately operate inside the Skyrim runtime. Paths: `include/SKSE/API.h`, `include/SKSE/Interfaces.h`, `src/SKSE/Trampoline.cpp`.

#### Engine Integration Domains

Several engine-facing domains share the relocation/ABI foundation: Papyrus VM and native bindings; rendering/scene graph; Havok physics/behavior; and DirectX/Win32 platform declarations. These are interfaces to game-owned systems, not standalone implementations. Paths: `include/RE/S/SkyrimVM.h`, `include/RE/N/NiAVObject.h`, `include/RE/H/hkpWorld.h`.

#### Runtimes and External Dependencies

Build/runtime target is x86_64 Windows using MSVC ABI (Clang is supported in compatibility mode); Ninja/CMake drive builds. Runtime deployment requires SKSE64 plus the SE/AE or VR Address Library. Build dependencies include rapidcsv and spdlog, reflected by dependency/build manifests: `vcpkg.json`, `CMakePresets.json`, `include/SKSE/Logger.h`.

Main entry points: [`include/REL/Relocation.h`](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/REL/Relocation.h) (Runtime Relocation), [`include/SKSE/Interfaces.h`](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/SKSE/Interfaces.h) (SKSE Services), [`include/RE/U/UIMessageQueue.h`](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/U/UIMessageQueue.h) (Native UI & GFx), [`cmake/CommonLibSSE.cmake`](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/cmake/CommonLibSSE.cmake) (CMake Integration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build &amp; Distribution"]
  node_cmake["CMake Integration<br/>build integration<br/>[CommonLibSSE.cmake]"]
  node_build_root["CMake Build<br/>build manifest<br/>[CMakeLists.txt]"]
  node_packages["Conan / Vcpkg<br/>package metadata<br/>[conanfile.py]"]
end

subgraph group_public["Public Plugin APIs"]
  node_commonlib["CommonLibSSE NG<br/>C++20 static library"]
  node_skyrim_api["RE Aggregate API<br/>public header<br/>[Skyrim.h]"]
  node_skse_api["SKSE Integration API<br/>public header<br/>[SKSE.h]"]
  node_rel_api["Relocation API<br/>public header<br/>[REL.h]"]
end

subgraph group_engine["Engine Interop"]
  node_engine_model["RE Engine Object Model<br/>ABI declarations<br/>[TESForm.h]"]
  node_engine_offsets["Engine Offsets<br/>runtime offsets<br/>[Offsets.h]"]
  node_ui["Native UI &amp; GFx<br/>UI interop<br/>[UIMessageQueue.h]"]
  node_flash["Flash CLIK Contract<br/>ActionScript delegate<br/>[GameDelegate.as]"]
  node_integration_domains["VM, Scene &amp; Physics APIs<br/>engine interfaces<br/>[SkyrimVM.h]"]
end

subgraph group_runtime["Runtime Boundaries"]
  node_skse_services["SKSE Services<br/>plugin service layer<br/>[Interfaces.h]"]
  node_trampoline["Executable Trampolines<br/>hook implementation<br/>[Trampoline.cpp]"]
  node_relocation["Runtime Relocation<br/>portability boundary<br/>[Relocation.h]"]
  node_module["Loaded Module Detection<br/>runtime implementation<br/>[Module.cpp]"]
end

node_plugin["SKSE Plugin Consumer"]
node_skse_runtime["SKSE64 Runtime<br/>external runtime"]
node_address_library[("Address Library<br/>external runtime data")]
node_skyrim["Loaded Skyrim Process<br/>external game runtime"]

node_build_root -->|"includes"| node_cmake
node_cmake -->|"builds / links"| node_commonlib
node_packages -->|"distributes"| node_commonlib
node_plugin -->|"uses"| node_cmake
node_plugin -->|"links"| node_commonlib
node_commonlib -->|"exports"| node_skyrim_api
node_commonlib -->|"exports"| node_skse_api
node_commonlib -->|"exports"| node_rel_api
node_skse_api -->|"provides"| node_skse_services
node_skse_services -->|"uses"| node_trampoline
node_skse_services -->|"integrates with"| node_skse_runtime
node_rel_api -->|"provides"| node_relocation
node_relocation -->|"detects"| node_module
node_relocation -->|"resolves through"| node_address_library
node_relocation -->|"applies"| node_engine_offsets
node_relocation -->|"binds symbols in"| node_skyrim
node_skyrim_api -->|"aggregates"| node_engine_model
node_engine_model -->|"requires ABI bindings"| node_relocation
node_integration_domains -->|"uses"| node_relocation
node_ui -->|"uses"| node_relocation
node_ui -->|"delegates to"| node_flash
node_skse_services -->|"sends UI work to"| node_ui

click node_cmake "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/cmake/CommonLibSSE.cmake"
click node_build_root "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/CMakeLists.txt"
click node_packages "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/conanfile.py"
click node_skyrim_api "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/Skyrim.h"
click node_skse_api "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/SKSE/SKSE.h"
click node_rel_api "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/REL/REL.h"
click node_skse_services "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/SKSE/Interfaces.h"
click node_trampoline "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/src/SKSE/Trampoline.cpp"
click node_relocation "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/REL/Relocation.h"
click node_module "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/src/REL/Module.cpp"
click node_engine_model "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/T/TESForm.h"
click node_engine_offsets "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/Offsets.h"
click node_ui "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/U/UIMessageQueue.h"
click node_flash "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/Flash/AS2/CLIK/gfx/io/GameDelegate.as"
click node_integration_domains "https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/S/SkyrimVM.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_cmake,node_build_root,node_packages toneBlue
class node_commonlib,node_skyrim_api,node_skse_api,node_rel_api toneAmber
class node_engine_model,node_engine_offsets,node_ui,node_flash,node_integration_domains toneMint
class node_skse_services,node_trampoline,node_relocation,node_module toneRose
class node_plugin,node_skse_runtime,node_address_library,node_skyrim toneNeutral
```

## Components

### Build & Distribution

- [CMake Integration](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/cmake/CommonLibSSE.cmake): build integration · Defines plugin setup and library linkage. · `cmake/CommonLibSSE.cmake`
- [CMake Build](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/CMakeLists.txt): build manifest · `CMakeLists.txt`
- [Conan / Vcpkg](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/conanfile.py): package metadata · `conanfile.py`

### Public Plugin APIs

- **CommonLibSSE NG**: C++20 static library · ABI-facing library for SKSE plugins.
- [RE Aggregate API](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/Skyrim.h): public header · `include/RE/Skyrim.h`
- [SKSE Integration API](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/SKSE/SKSE.h): public header · `include/SKSE/SKSE.h`
- [Relocation API](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/REL/REL.h): public header · `include/REL/REL.h`

### Engine Interop

- [RE Engine Object Model](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/T/TESForm.h): ABI declarations · Game-owned forms, actors, world state, effects, quests, and managers. · `include/RE/T/TESForm.h`
- [Engine Offsets](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/Offsets.h): runtime offsets · `include/RE/Offsets.h`
- [Native UI & GFx](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/U/UIMessageQueue.h): UI interop · Native menus and Scaleform movie APIs. · `include/RE/U/UIMessageQueue.h`
- [Flash CLIK Contract](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/Flash/AS2/CLIK/gfx/io/GameDelegate.as): ActionScript delegate · UI-side movie control and delegate contract. · `Flash/AS2/CLIK/gfx/io/GameDelegate.as`
- [VM, Scene & Physics APIs](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/RE/S/SkyrimVM.h): engine interfaces · Papyrus, rendering, scene graph, and Havok interfaces. · `include/RE/S/SkyrimVM.h`

### Runtime Boundaries

- [SKSE Services](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/SKSE/Interfaces.h): plugin service layer · Initialization, events, serialization, messaging, hooks, and trampolines. · `include/SKSE/Interfaces.h`
- [Executable Trampolines](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/src/SKSE/Trampoline.cpp): hook implementation · `src/SKSE/Trampoline.cpp`
- [Runtime Relocation](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/include/REL/Relocation.h): portability boundary · Resolves IDs, offsets, versions, and executable symbols. · `include/REL/Relocation.h`
- [Loaded Module Detection](https://github.com/charmedbaryon/commonlibsse-ng/blob/main/src/REL/Module.cpp): runtime implementation · Selects the active Skyrim runtime module. · `src/REL/Module.cpp`

### Other components

- **SKSE Plugin Consumer**: consumer · Consumer plugin links the static library.
- **SKSE64 Runtime**: external runtime
- **Address Library**: external runtime data · SE/AE or VR relocation data.
- **Loaded Skyrim Process**: external game runtime · SE, AE, or VR executable process.

## Connections

- CMake Build → CMake Integration: includes
- CMake Integration → CommonLibSSE NG: builds / links
- Conan / Vcpkg → CommonLibSSE NG: distributes
- SKSE Plugin Consumer → CMake Integration: uses
- SKSE Plugin Consumer → CommonLibSSE NG: links
- CommonLibSSE NG → RE Aggregate API: exports
- CommonLibSSE NG → SKSE Integration API: exports
- CommonLibSSE NG → Relocation API: exports
- SKSE Integration API → SKSE Services: provides
- SKSE Services → Executable Trampolines: uses
- SKSE Services → SKSE64 Runtime: integrates with
- Relocation API → Runtime Relocation: provides
- Runtime Relocation → Loaded Module Detection: detects
- Runtime Relocation → Address Library: resolves through
- Runtime Relocation → Engine Offsets: applies
- Runtime Relocation → Loaded Skyrim Process: binds symbols in
- RE Aggregate API → RE Engine Object Model: aggregates
- RE Engine Object Model → Runtime Relocation: requires ABI bindings
- VM, Scene & Physics APIs → Runtime Relocation: uses
- Native UI & GFx → Runtime Relocation: uses
- Native UI & GFx → Flash CLIK Contract: delegates to
- SKSE Services → Native UI & GFx: sends UI work to
