# 0x676e67/rnet architecture

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

- Interactive diagram: https://gitdiagram.com/0x676e67/rnet
- Repository: https://github.com/0x676e67/rnet

## Overview

#### Purpose and Entry Points
`wreq` is a Python-native HTTP client implemented by a Rust extension, targeting high-fidelity TLS, HTTP/2, and browser/device protocol emulation. Public Python imports and API façades live in `python/wreq/__init__.py` and modules such as `python/wreq/wreq.py` and `python/wreq/blocking.py`. The Rust extension is rooted at `src/lib.rs`; packaging/build integration is defined by `pyproject.toml` and `Cargo.toml`.

#### Python API Layer
The package exposes asynchronous and blocking clients, request/response types, and configuration domains (cookies, DNS, proxy, TLS, redirects, headers, HTTP/1 and HTTP/2). Python modules are likely thin bindings around Rust-exported types rather than an independent transport implementation.
Paths: `python/wreq/wreq.py`, `python/wreq/blocking.py`, `python/wreq/http2.py`.

#### Client Request Pipeline
The central client subsystem constructs requests, applies parameters/query/body encoding, dispatches network work, and exposes typed responses. Request bodies support plain streams plus form, JSON, and multipart formats; response handling includes HTTP payloads, extension methods, and WebSocket upgrades.
Paths: `src/client.rs`, `src/client/req.rs`, `src/client/body/`, `src/client/resp.rs`.

#### Transport and Protocol Boundary
HTTP protocol behavior is separated into core HTTP abstractions and explicit HTTP/1 and HTTP/2 modules. This is the boundary where protocol signatures/settings and connection behavior are material, including pooling, transfer streaming, trailers, decompression, and WebSocket response paths.
Paths: `src/http.rs`, `src/http1.rs`, `src/http2.rs`.

#### Identity, TLS, and Emulation
High-fidelity client identity is an architectural focus: emulation profiles configure browser-like TLS and HTTP/2 behavior rather than merely replaying JA3/JA4 strings. TLS integrates BoringSSL, supports certificate authorities, mutual TLS identities, certificate stores, and key logging.
Paths: `src/emulate.rs`, `src/tls.rs`, `src/tls/identity.rs`, `src/tls/store.rs`.

#### Stateful Request Policy
Cross-request state and routing policies are modular: cookie storage, redirect handling, proxy selection/rotation, DNS behavior, header preservation/control, and errors are distinct subsystems consumed by the client pipeline.
Paths: `src/cookie.rs`, `src/redirect.rs`, `src/proxy.rs`, `src/dns.rs`, `src/header.rs`.

#### Runtime, Concurrency, and Delivery
Async usage is designed for Python `asyncio`; a separate blocking client provides synchronous access. Rust-side no-GIL support indicates compatibility with Python free-threaded execution. Builds produce Python wheels through Maturin, require Rust plus BoringSSL tooling, and target Linux, macOS, Windows, and Android.
Paths: `src/client/nogil.rs`, `pyproject.toml`, `Cargo.toml`, `.github/workflows/ci.yml`.

Main entry points: [`src/client.rs`](https://github.com/0x676e67/rnet/blob/main/src/client.rs) (Client orchestration), [`src/lib.rs`](https://github.com/0x676e67/rnet/blob/main/src/lib.rs) (Rust extension entry), [`src/tls.rs`](https://github.com/0x676e67/rnet/blob/main/src/tls.rs) (TLS integration), [`src/http.rs`](https://github.com/0x676e67/rnet/blob/main/src/http.rs) (HTTP abstractions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python API"]
  node_python_async["Async API façade<br/>Python module<br/>[wreq.py]"]
  node_python_blocking["Blocking API façade<br/>Python module<br/>[blocking.py]"]
  node_python_http2["Python HTTP/2 API<br/>Python module<br/>[http2.py]"]
end

subgraph group_client["Rust Client Pipeline"]
  node_rust_extension{{"Rust extension entry<br/>PyO3 extension<br/>[lib.rs]"}}
  node_client["Client orchestration<br/>Rust client<br/>[client.rs]"]
  node_request["Request construction<br/>request pipeline<br/>[req.rs]"]
  node_body["Request bodies<br/>body encoding<br/>[body.rs]"]
  node_response["Response handling<br/>response pipeline<br/>[resp.rs]"]
end

subgraph group_transport["Protocol &amp; Identity"]
  node_http_core["HTTP abstractions<br/>protocol core<br/>[http.rs]"]
  node_http1["HTTP/1 transport<br/>protocol implementation<br/>[http1.rs]"]
  node_http2["HTTP/2 transport<br/>protocol implementation<br/>[http2.rs]"]
  node_emulation["Browser emulation<br/>identity profiles<br/>[emulate.rs]"]
  node_tls["TLS integration<br/>BoringSSL transport<br/>[tls.rs]"]
  node_tls_identity["TLS identities<br/>certificate identity<br/>[identity.rs]"]
  node_tls_store[("Certificate store<br/>certificate storage<br/>[store.rs]")]
end

subgraph group_policy["Request Policy"]
  node_cookies[("Cookie storage<br/>state policy<br/>[cookie.rs]")]
  node_routing["Redirects, proxy &amp; DNS<br/>routing policy<br/>[proxy.rs]"]
  node_headers["Header control<br/>request policy<br/>[header.rs]"]
end

subgraph group_delivery["Runtime &amp; Delivery"]
  node_nogil["Free-threaded support<br/>concurrency bridge<br/>[nogil.rs]"]
  node_packaging["Maturin packaging<br/>build metadata<br/>[pyproject.toml]"]
  node_cargo["Rust &amp; BoringSSL build<br/>Cargo manifest<br/>[Cargo.toml]"]
  node_ci["Cross-platform CI<br/>delivery pipeline<br/>[ci.yml]"]
end

node_python_async -->|"calls"| node_rust_extension
node_python_blocking -->|"calls"| node_rust_extension
node_python_http2 -->|"binds"| node_rust_extension
node_rust_extension -->|"exports"| node_client
node_client -->|"builds"| node_request
node_request -->|"encodes"| node_body
node_client -->|"returns"| node_response
node_client -->|"dispatches through"| node_http_core
node_http_core -->|"selects"| node_http1
node_http_core -->|"selects"| node_http2
node_emulation -->|"configures"| node_http2
node_emulation -->|"configures"| node_tls
node_http1 -->|"secures with"| node_tls
node_http2 -->|"secures with"| node_tls
node_tls -->|"uses"| node_tls_identity
node_tls -->|"reads"| node_tls_store
node_client -->|"maintains"| node_cookies
node_client -->|"applies"| node_routing
node_client -->|"applies"| node_headers
node_rust_extension -.->|"supports"| node_nogil
node_packaging -->|"builds"| node_cargo
node_ci -->|"produces wheels"| node_packaging

click node_python_async "https://github.com/0x676e67/rnet/blob/main/python/wreq/wreq.py"
click node_python_blocking "https://github.com/0x676e67/rnet/blob/main/python/wreq/blocking.py"
click node_python_http2 "https://github.com/0x676e67/rnet/blob/main/python/wreq/http2.py"
click node_rust_extension "https://github.com/0x676e67/rnet/blob/main/src/lib.rs"
click node_client "https://github.com/0x676e67/rnet/blob/main/src/client.rs"
click node_request "https://github.com/0x676e67/rnet/blob/main/src/client/req.rs"
click node_body "https://github.com/0x676e67/rnet/blob/main/src/client/body.rs"
click node_response "https://github.com/0x676e67/rnet/blob/main/src/client/resp.rs"
click node_http_core "https://github.com/0x676e67/rnet/blob/main/src/http.rs"
click node_http1 "https://github.com/0x676e67/rnet/blob/main/src/http1.rs"
click node_http2 "https://github.com/0x676e67/rnet/blob/main/src/http2.rs"
click node_emulation "https://github.com/0x676e67/rnet/blob/main/src/emulate.rs"
click node_tls "https://github.com/0x676e67/rnet/blob/main/src/tls.rs"
click node_tls_identity "https://github.com/0x676e67/rnet/blob/main/src/tls/identity.rs"
click node_tls_store "https://github.com/0x676e67/rnet/blob/main/src/tls/store.rs"
click node_cookies "https://github.com/0x676e67/rnet/blob/main/src/cookie.rs"
click node_routing "https://github.com/0x676e67/rnet/blob/main/src/proxy.rs"
click node_headers "https://github.com/0x676e67/rnet/blob/main/src/header.rs"
click node_nogil "https://github.com/0x676e67/rnet/blob/main/src/client/nogil.rs"
click node_packaging "https://github.com/0x676e67/rnet/blob/main/pyproject.toml"
click node_cargo "https://github.com/0x676e67/rnet/blob/main/Cargo.toml"
click node_ci "https://github.com/0x676e67/rnet/blob/main/.github/workflows/ci.yml"

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_python_async,node_python_blocking,node_python_http2 toneBlue
class node_rust_extension,node_client,node_request,node_body,node_response toneAmber
class node_http_core,node_http1,node_http2,node_emulation,node_tls,node_tls_identity,node_tls_store toneMint
class node_cookies,node_routing,node_headers toneRose
class node_nogil,node_packaging,node_cargo,node_ci toneIndigo
```

## Components

### Python API

- [Async API façade](https://github.com/0x676e67/rnet/blob/main/python/wreq/wreq.py): Python module · Public asyncio-oriented client bindings. · `python/wreq/wreq.py`
- [Blocking API façade](https://github.com/0x676e67/rnet/blob/main/python/wreq/blocking.py): Python module · Synchronous client access. · `python/wreq/blocking.py`
- [Python HTTP/2 API](https://github.com/0x676e67/rnet/blob/main/python/wreq/http2.py): Python module · `python/wreq/http2.py`

### Rust Client Pipeline

- [Rust extension entry](https://github.com/0x676e67/rnet/blob/main/src/lib.rs): PyO3 extension · Exports Rust functionality to the Python package. · `src/lib.rs`
- [Client orchestration](https://github.com/0x676e67/rnet/blob/main/src/client.rs): Rust client · Constructs and dispatches requests and exposes responses. · `src/client.rs`
- [Request construction](https://github.com/0x676e67/rnet/blob/main/src/client/req.rs): request pipeline · Applies parameters, query encoding, and request setup. · `src/client/req.rs`
- [Request bodies](https://github.com/0x676e67/rnet/blob/main/src/client/body.rs): body encoding · Streams plain, form, JSON, and multipart payloads. · `src/client/body.rs`
- [Response handling](https://github.com/0x676e67/rnet/blob/main/src/client/resp.rs): response pipeline · Handles payloads, extension methods, and WebSocket upgrades. · `src/client/resp.rs`

### Protocol & Identity

- [HTTP abstractions](https://github.com/0x676e67/rnet/blob/main/src/http.rs): protocol core · Shared HTTP request, response, and connection abstractions. · `src/http.rs`
- [HTTP/1 transport](https://github.com/0x676e67/rnet/blob/main/src/http1.rs): protocol implementation · Supports streaming, trailers, and decompression behavior. · `src/http1.rs`
- [HTTP/2 transport](https://github.com/0x676e67/rnet/blob/main/src/http2.rs): protocol implementation · Applies HTTP/2 settings and connection behavior. · `src/http2.rs`
- [Browser emulation](https://github.com/0x676e67/rnet/blob/main/src/emulate.rs): identity profiles · Configures browser-like TLS and HTTP/2 behavior. · `src/emulate.rs`
- [TLS integration](https://github.com/0x676e67/rnet/blob/main/src/tls.rs): BoringSSL transport · Handles TLS, certificate authorities, mutual TLS, and key logging. · `src/tls.rs`
- [TLS identities](https://github.com/0x676e67/rnet/blob/main/src/tls/identity.rs): certificate identity · `src/tls/identity.rs`
- [Certificate store](https://github.com/0x676e67/rnet/blob/main/src/tls/store.rs): certificate storage · `src/tls/store.rs`

### Request Policy

- [Cookie storage](https://github.com/0x676e67/rnet/blob/main/src/cookie.rs): state policy · `src/cookie.rs`
- [Redirects, proxy & DNS](https://github.com/0x676e67/rnet/blob/main/src/proxy.rs): routing policy · Selects routes and governs redirect behavior. · `src/proxy.rs`
- [Header control](https://github.com/0x676e67/rnet/blob/main/src/header.rs): request policy · Preserves and controls request headers. · `src/header.rs`

### Runtime & Delivery

- [Free-threaded support](https://github.com/0x676e67/rnet/blob/main/src/client/nogil.rs): concurrency bridge · Supports no-GIL Python execution. · `src/client/nogil.rs`
- [Maturin packaging](https://github.com/0x676e67/rnet/blob/main/pyproject.toml): build metadata · Builds Rust extension wheels for supported platforms. · `pyproject.toml`
- [Rust & BoringSSL build](https://github.com/0x676e67/rnet/blob/main/Cargo.toml): Cargo manifest · Defines Rust dependencies and native build integration. · `Cargo.toml`
- [Cross-platform CI](https://github.com/0x676e67/rnet/blob/main/.github/workflows/ci.yml): delivery pipeline · Builds and validates target platform artifacts. · `.github/workflows/ci.yml`

## Connections

- Async API façade → Rust extension entry: calls
- Blocking API façade → Rust extension entry: calls
- Python HTTP/2 API → Rust extension entry: binds
- Rust extension entry → Client orchestration: exports
- Client orchestration → Request construction: builds
- Request construction → Request bodies: encodes
- Client orchestration → Response handling: returns
- Client orchestration → HTTP abstractions: dispatches through
- HTTP abstractions → HTTP/1 transport: selects
- HTTP abstractions → HTTP/2 transport: selects
- Browser emulation → HTTP/2 transport: configures
- Browser emulation → TLS integration: configures
- HTTP/1 transport → TLS integration: secures with
- HTTP/2 transport → TLS integration: secures with
- TLS integration → TLS identities: uses
- TLS integration → Certificate store: reads
- Client orchestration → Cookie storage: maintains
- Client orchestration → Redirects, proxy & DNS: applies
- Client orchestration → Header control: applies
- Rust extension entry → Free-threaded support: supports
- Maturin packaging → Rust & BoringSSL build: builds
- Cross-platform CI → Maturin packaging: produces wheels
