# xreveres/libwt architecture

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

- Interactive diagram: https://gitdiagram.com/xreveres/libwt
- Repository: https://github.com/xreveres/libwt

## Overview

libwt is a Linux C++ WebTransport datagram server, with an optional Node.js API. The main workflow is a client connecting over QUIC/HTTP/3, the server handling a WebTransport CONNECT request and admission decision, then exposing an accepted session for datagram exchange. The graph includes the documented Node.js event path, certificate rotation, and statistics. Some internal protocol dispatch details are not established by the sampled excerpts, so those links are omitted rather than inferred.

Main entry points: [`include/libwt/Server.hpp`](https://github.com/xreveres/libwt/blob/master/include/libwt/Server.hpp) (C++ Server API), [`src/Server.cpp`](https://github.com/xreveres/libwt/blob/master/src/Server.cpp) (Server Lifecycle), [`src/Connection.cpp`](https://github.com/xreveres/libwt/blob/master/src/Connection.cpp) (QUIC Connection), [`bindings/node/addon.cpp`](https://github.com/xreveres/libwt/blob/master/bindings/node/addon.cpp) (Node Native Addon)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Application APIs"]
  node_server_api["C++ Server API<br/>[Server.hpp]"]
  node_session["Datagram Session<br/>[Connection.cpp]"]
end

subgraph group_runtime["Server Runtime"]
  node_server_runtime["Server Lifecycle<br/>[Server.cpp]"]
  node_listener["QUIC Listener<br/>[Server.cpp]"]
  node_connection["QUIC Connection<br/>[Connection.cpp]"]
end

subgraph group_protocol["HTTP3 Protocol"]
  node_h3_processing["HTTP3 Processing<br/>[Http3Protocol.cpp]"]
  node_protocol_helpers["HTTP3 Utilities<br/>[Http3Utils.cpp]"]
  node_protocol_defs["Protocol Definitions<br/>[Http3Utils.hpp]"]
  node_qpack["QPACK Header Decode<br/>[QpackUtils.cpp]"]
end

subgraph group_node["Node.js Binding"]
  node_node_api["Node.js API<br/>[index.js]"]
  node_node_addon["Node Native Addon<br/>[addon.cpp]"]
end

subgraph group_observability["Statistics"]
  node_server_stats[("Server Counters<br/>[Statistics.hpp]")]
  node_public_stats["Statistics API<br/>[Statistics.hpp]"]
end

node_client(("WebTransport Client"))
node_cpp_app(("C++ Application"))

node_client -->|"connects over QUIC"| node_listener
node_cpp_app -->|"configures"| node_server_api
node_server_api -->|"starts server"| node_server_runtime
node_server_runtime -->|"starts listener"| node_listener
node_listener -->|"creates connection"| node_connection
node_connection -->|"opens session"| node_session
node_client -->|"sends CONNECT"| node_h3_processing
node_cpp_app -->|"exchanges datagrams"| node_session
node_node_api -->|"calls native methods"| node_node_addon
node_node_addon -->|"creates native server"| node_server_api
node_server_api -->|"returns statistics"| node_public_stats
node_server_runtime -->|"snapshots counters"| node_server_stats

click node_server_api "https://github.com/xreveres/libwt/blob/master/include/libwt/Server.hpp"
click node_server_runtime "https://github.com/xreveres/libwt/blob/master/src/Server.cpp"
click node_listener "https://github.com/xreveres/libwt/blob/master/src/Server.cpp"
click node_connection "https://github.com/xreveres/libwt/blob/master/src/Connection.cpp"
click node_session "https://github.com/xreveres/libwt/blob/master/src/Connection.cpp"
click node_h3_processing "https://github.com/xreveres/libwt/blob/master/src/Http3Protocol.cpp"
click node_protocol_helpers "https://github.com/xreveres/libwt/blob/master/src/Http3Utils.cpp"
click node_protocol_defs "https://github.com/xreveres/libwt/blob/master/src/Http3Utils.hpp"
click node_qpack "https://github.com/xreveres/libwt/blob/master/src/QpackUtils.cpp"
click node_node_api "https://github.com/xreveres/libwt/blob/master/bindings/node/index.js"
click node_node_addon "https://github.com/xreveres/libwt/blob/master/bindings/node/addon.cpp"
click node_server_stats "https://github.com/xreveres/libwt/blob/master/src/Statistics.hpp"
click node_public_stats "https://github.com/xreveres/libwt/blob/master/include/libwt/Statistics.hpp"

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_server_api,node_session,node_client toneBlue
class node_server_runtime,node_listener,node_connection toneAmber
class node_h3_processing,node_protocol_helpers,node_protocol_defs,node_qpack toneMint
class node_node_api,node_node_addon toneRose
class node_server_stats,node_public_stats,node_cpp_app toneIndigo
```

## Components

### Application APIs

- [C++ Server API](https://github.com/xreveres/libwt/blob/master/include/libwt/Server.hpp): `include/libwt/Server.hpp`
- [Datagram Session](https://github.com/xreveres/libwt/blob/master/src/Connection.cpp): `src/Connection.cpp`

### Server Runtime

- [Server Lifecycle](https://github.com/xreveres/libwt/blob/master/src/Server.cpp): `src/Server.cpp`
- [QUIC Listener](https://github.com/xreveres/libwt/blob/master/src/Server.cpp): `src/Server.cpp`
- [QUIC Connection](https://github.com/xreveres/libwt/blob/master/src/Connection.cpp): `src/Connection.cpp`

### HTTP3 Protocol

- [HTTP3 Processing](https://github.com/xreveres/libwt/blob/master/src/Http3Protocol.cpp): `src/Http3Protocol.cpp`
- [HTTP3 Utilities](https://github.com/xreveres/libwt/blob/master/src/Http3Utils.cpp): `src/Http3Utils.cpp`
- [Protocol Definitions](https://github.com/xreveres/libwt/blob/master/src/Http3Utils.hpp): `src/Http3Utils.hpp`
- [QPACK Header Decode](https://github.com/xreveres/libwt/blob/master/src/QpackUtils.cpp): `src/QpackUtils.cpp`

### Node.js Binding

- [Node.js API](https://github.com/xreveres/libwt/blob/master/bindings/node/index.js): `bindings/node/index.js`
- [Node Native Addon](https://github.com/xreveres/libwt/blob/master/bindings/node/addon.cpp): `bindings/node/addon.cpp`

### Statistics

- [Server Counters](https://github.com/xreveres/libwt/blob/master/src/Statistics.hpp): `src/Statistics.hpp`
- [Statistics API](https://github.com/xreveres/libwt/blob/master/include/libwt/Statistics.hpp): `include/libwt/Statistics.hpp`

### Other components

- **WebTransport Client**
- **C++ Application**

## Connections

- WebTransport Client → QUIC Listener: connects over QUIC (evidence: `README.md`)
- C++ Application → C++ Server API: configures (evidence: `README.md`)
- C++ Server API → Server Lifecycle: starts server (evidence: `src/Server.cpp`)
- Server Lifecycle → QUIC Listener: starts listener (evidence: `src/Server.cpp`)
- QUIC Listener → QUIC Connection: creates connection (evidence: `src/Server.cpp`)
- QUIC Connection → Datagram Session: opens session (evidence: `src/Connection.cpp`)
- WebTransport Client → HTTP3 Processing: sends CONNECT (evidence: `README.md`)
- C++ Application → Datagram Session: exchanges datagrams (evidence: `README.md`)
- Node.js API → Node Native Addon: calls native methods (evidence: `bindings/node/index.js`)
- Node Native Addon → C++ Server API: creates native server (evidence: `bindings/node/addon.cpp`)
- C++ Server API → Statistics API: returns statistics (evidence: `include/libwt/Server.hpp`)
- Server Lifecycle → Server Counters: snapshots counters (evidence: `src/Server.cpp`)
