# rivoraecosystem/riven architecture

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

- Interactive diagram: https://gitdiagram.com/rivoraecosystem/riven
- Repository: https://github.com/rivoraecosystem/riven

## Overview

Riven is a Python HTTP/3 server with RCP as its native application interface and ASGI compatibility. Its principal workflow configures an application and TLS/listening options, starts the server, handles HTTP/3 requests through application-facing streams, and returns responses over QUIC. The repository also includes lifespan management and optional WebTransport sessions and streams. Evidence is limited to the README, source index references, and sampled excerpts; unsampled implementation details are not inferred.

Main entry points: [`riven/protocol_h3/_protocol.py`](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_protocol.py) (HTTP/3 protocol adapter), [`riven/server.py`](https://github.com/rivoraecosystem/riven/blob/main/riven/server.py) (Server and shutdown), [`riven/protocol_h3/_session_wt.py`](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_session_wt.py) (WebTransport session), [`riven/_config.py`](https://github.com/rivoraecosystem/riven/blob/main/riven/_config.py) (Server configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and lifecycle"]
  node_cli["CLI and runner<br/>[main.py]"]
  node_config["Server configuration<br/>[_config.py]"]
  node_server["Server and shutdown<br/>[server.py]"]
  node_lifespan["App lifespan<br/>[lifespan.py]"]
end

subgraph group_http3["HTTP/3 handling"]
  node_h3protocol["HTTP/3 protocol adapter<br/>[_protocol.py]"]
  node_h3app["HTTP application stream<br/>[_stream_h3.py]"]
  node_h3facade["HTTP/3 protocol helpers<br/>[h3_protocol.py]"]
  node_connection["Connection utilities"]
  node_h3events["Protocol events<br/>[events.py]"]
end

subgraph group_webtransport["WebTransport"]
  node_wtcapsules["WebTransport capsules<br/>[capsules.py]"]
  node_wtsession["WebTransport session<br/>[_session_wt.py]"]
  node_wtstream["WebTransport streams<br/>[_stream_wt.py]"]
end

subgraph group_support["Runtime support"]
  node_errors["Protocol errors<br/>[error.py]"]
  node_exceptions["Runtime exceptions<br/>[exceptions.py]"]
  node_loop["Event loop selection<br/>[auto.py]"]
  node_logging["Logging and colors<br/>[colors.py]"]
end

node_operator(("Server operator"))
node_application["RCP or ASGI app"]

node_operator -->|"configures and starts"| node_cli
node_cli -->|"builds"| node_config
node_cli -->|"starts"| node_server
node_server -->|"reads settings"| node_config
node_server -->|"creates protocol"| node_h3protocol
node_server -->|"manages lifecycle"| node_lifespan
node_config -->|"loads app"| node_application
node_config -->|"selects loop"| node_loop
node_lifespan -->|"loads app settings"| node_config
node_lifespan -->|"dispatches lifespan"| node_application
node_h3protocol -->|"dispatches streams"| node_h3app
node_h3app -->|"invokes app"| node_application
node_h3app -->|"sends response data"| node_h3protocol
node_h3protocol -->|"uses helpers"| node_connection
node_h3protocol -->|"uses protocol helpers"| node_h3facade
node_h3protocol -->|"dispatches sessions"| node_wtsession
node_wtsession -->|"creates streams"| node_wtstream
node_wtstream -->|"uses session state"| node_wtsession
node_wtsession -->|"uses capsules"| node_wtcapsules
node_h3facade -->|"uses capsules"| node_wtcapsules
node_h3protocol -->|"raises protocol errors"| node_exceptions
node_wtsession -->|"uses error codes"| node_errors
node_server -->|"formats startup logs"| node_logging

click node_cli "https://github.com/rivoraecosystem/riven/blob/main/riven/main.py"
click node_config "https://github.com/rivoraecosystem/riven/blob/main/riven/_config.py"
click node_server "https://github.com/rivoraecosystem/riven/blob/main/riven/server.py"
click node_lifespan "https://github.com/rivoraecosystem/riven/blob/main/riven/lifespan/lifespan.py"
click node_h3protocol "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_protocol.py"
click node_h3app "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_stream_h3.py"
click node_h3facade "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/h3_protocol.py"
click node_connection "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_connection_utils.py"
click node_h3events "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/events.py"
click node_wtcapsules "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/capsules.py"
click node_wtsession "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_session_wt.py"
click node_wtstream "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_stream_wt.py"
click node_errors "https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/error.py"
click node_exceptions "https://github.com/rivoraecosystem/riven/blob/main/riven/exceptions/exceptions.py"
click node_loop "https://github.com/rivoraecosystem/riven/blob/main/riven/loop/auto.py"
click node_logging "https://github.com/rivoraecosystem/riven/blob/main/riven/logger/colors.py"

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_cli,node_config,node_server,node_lifespan toneBlue
class node_h3protocol,node_h3app,node_h3facade,node_connection,node_h3events toneAmber
class node_wtcapsules,node_wtsession,node_wtstream,node_operator toneMint
class node_errors,node_exceptions,node_loop,node_logging toneRose
class node_application toneIndigo
```

## Components

### Startup and lifecycle

- [CLI and runner](https://github.com/rivoraecosystem/riven/blob/main/riven/main.py): `riven/main.py`
- [Server configuration](https://github.com/rivoraecosystem/riven/blob/main/riven/_config.py): `riven/_config.py`
- [Server and shutdown](https://github.com/rivoraecosystem/riven/blob/main/riven/server.py): `riven/server.py`
- [App lifespan](https://github.com/rivoraecosystem/riven/blob/main/riven/lifespan/lifespan.py): `riven/lifespan/lifespan.py`

### HTTP/3 handling

- [HTTP/3 protocol adapter](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_protocol.py): `riven/protocol_h3/_protocol.py`
- [HTTP application stream](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_stream_h3.py): `riven/protocol_h3/_stream_h3.py`
- [HTTP/3 protocol helpers](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/h3_protocol.py): `riven/protocol_h3/h3_protocol.py`
- [Connection utilities](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_connection_utils.py): `riven/protocol_h3/_connection_utils.py`
- [Protocol events](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/events.py): `riven/protocol_h3/events.py`

### WebTransport

- [WebTransport capsules](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/capsules.py): `riven/protocol_h3/capsules.py`
- [WebTransport session](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_session_wt.py): `riven/protocol_h3/_session_wt.py`
- [WebTransport streams](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/_stream_wt.py): `riven/protocol_h3/_stream_wt.py`

### Runtime support

- [Protocol errors](https://github.com/rivoraecosystem/riven/blob/main/riven/protocol_h3/error.py): `riven/protocol_h3/error.py`
- [Runtime exceptions](https://github.com/rivoraecosystem/riven/blob/main/riven/exceptions/exceptions.py): `riven/exceptions/exceptions.py`
- [Event loop selection](https://github.com/rivoraecosystem/riven/blob/main/riven/loop/auto.py): `riven/loop/auto.py`
- [Logging and colors](https://github.com/rivoraecosystem/riven/blob/main/riven/logger/colors.py): `riven/logger/colors.py`

### Other components

- **Server operator**
- **RCP or ASGI app**

## Connections

- Server operator → CLI and runner: configures and starts (evidence: `README.md`)
- CLI and runner → Server configuration: builds (evidence: `riven/main.py`)
- CLI and runner → Server and shutdown: starts (evidence: `riven/main.py`)
- Server and shutdown → Server configuration: reads settings (evidence: `riven/server.py`)
- Server and shutdown → HTTP/3 protocol adapter: creates protocol (evidence: `riven/server.py`)
- Server and shutdown → App lifespan: manages lifecycle (evidence: `riven/server.py`)
- Server configuration → RCP or ASGI app: loads app (evidence: `riven/_config.py`)
- Server configuration → Event loop selection: selects loop (evidence: `riven/_config.py`)
- App lifespan → Server configuration: loads app settings (evidence: `riven/lifespan/lifespan.py`)
- App lifespan → RCP or ASGI app: dispatches lifespan (evidence: `riven/lifespan/lifespan.py`)
- HTTP/3 protocol adapter → HTTP application stream: dispatches streams (evidence: `riven/protocol_h3/_protocol.py`)
- HTTP application stream → RCP or ASGI app: invokes app (evidence: `riven/protocol_h3/_stream_h3.py`)
- HTTP application stream → HTTP/3 protocol adapter: sends response data (evidence: `riven/protocol_h3/_stream_h3.py`)
- HTTP/3 protocol adapter → Connection utilities: uses helpers (evidence: `riven/protocol_h3/_stream_h3.py`)
- HTTP/3 protocol adapter → HTTP/3 protocol helpers: uses protocol helpers (evidence: `riven/protocol_h3/_protocol.py`)
- HTTP/3 protocol adapter → WebTransport session: dispatches sessions (evidence: `riven/protocol_h3/_protocol.py`)
- WebTransport session → WebTransport streams: creates streams (evidence: `riven/protocol_h3/_session_wt.py`)
- WebTransport streams → WebTransport session: uses session state (evidence: `riven/protocol_h3/_stream_wt.py`)
- WebTransport session → WebTransport capsules: uses capsules (evidence: `riven/protocol_h3/_session_wt.py`)
- HTTP/3 protocol helpers → WebTransport capsules: uses capsules (evidence: `riven/protocol_h3/h3_protocol.py`)
- HTTP/3 protocol adapter → Runtime exceptions: raises protocol errors (evidence: `riven/protocol_h3/_protocol.py`)
- WebTransport session → Protocol errors: uses error codes (evidence: `riven/protocol_h3/_session_wt.py`)
- Server and shutdown → Logging and colors: formats startup logs (evidence: `riven/server.py`)
