# ppzxc/strand architecture

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

- Interactive diagram: https://gitdiagram.com/ppzxc/strand
- Repository: https://github.com/ppzxc/strand

## Overview

Strand is a Java library for multiplexing concurrent requests and responses over long-lived server connections. Its user workflow is to configure a client or server, establish a connection, submit requests, dispatch incoming requests to handlers, and observe results; the shared core endpoint handles protocol state and framing. NIO provides TCP/TLS, while Netty provides TCP/WebSocket. Resource limits, result observation, authentication, and shutdown are supporting capabilities. Relationships are limited to README statements and shown source references; some transport-to-core wiring is therefore left unverified.

Main entry points: [`strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java`](https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java) (NIO Engine), [`strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java`](https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java) (Netty Engine), [`strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java`](https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java) (Protocol Endpoint), [`strand-api/src/main/java/io/github/ppzxc/strand/api/Request.java`](https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Request.java) (Requests and Limits)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_api_types["Requests and Limits<br/>[Request.java]"]
  node_extensions["Request Extensions<br/>[Extensions.java]"]
  node_results["Results and Observation"]
  node_resources["Resource Budgets<br/>[Resource.java]"]
end

subgraph group_protocol["Protocol Core"]
  node_endpoint["Protocol Endpoint<br/>[Endpoint.java]"]
  node_events["Protocol Events<br/>[Event.java]"]
  node_outbound["Outbound Messages"]
end

subgraph group_nio["NIO Transport"]
  node_nio_client["NIO Client"]
  node_nio_conn["NIO Connection"]
  node_nio_engine["NIO Engine"]
  node_nio_server["NIO Server"]
  node_nio_tcp["TCP and TLS<br/>[TcpPassage.java]"]
end

subgraph group_netty["Netty Transport"]
  node_netty_client["Netty Client"]
  node_netty_conn["Netty Connection"]
  node_netty_engine["Netty Engine"]
  node_netty_server["Netty Server"]
  node_netty_wire["TCP and WebSocket<br/>[WireFactory.java]"]
end

node_user(("Library User"))

node_user -->|"configures"| node_nio_client
node_user -->|"configures"| node_netty_client
node_nio_client -->|"creates"| node_nio_conn
node_nio_client -->|"starts"| node_nio_engine
node_netty_client -->|"creates"| node_netty_conn
node_netty_client -->|"starts"| node_netty_engine
node_nio_engine -->|"uses"| node_api_types
node_nio_engine -->|"accounts"| node_resources
node_nio_engine -->|"completes"| node_results
node_netty_engine -->|"uses"| node_api_types
node_netty_engine -->|"accounts"| node_resources
node_netty_engine -->|"completes"| node_results
node_endpoint -->|"emits"| node_events
node_endpoint -->|"queues"| node_outbound
node_nio_engine -.->|"drives"| node_endpoint
node_netty_engine -.->|"drives"| node_endpoint
node_nio_conn -.->|"uses"| node_nio_tcp
node_netty_conn -.->|"uses"| node_netty_wire
node_user -->|"submits"| node_api_types
node_api_types -.->|"encodes"| node_extensions

click node_api_types "https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Request.java"
click node_extensions "https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Extensions.java"
click node_results "https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/ResultCompletion.java"
click node_resources "https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Resource.java"
click node_endpoint "https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java"
click node_events "https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Event.java"
click node_outbound "https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/OutboundMessage.java"
click node_nio_client "https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandClient.java"
click node_nio_conn "https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandConnection.java"
click node_nio_engine "https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java"
click node_nio_server "https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandServer.java"
click node_nio_tcp "https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/internal/TcpPassage.java"
click node_netty_client "https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandClient.java"
click node_netty_conn "https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandConnection.java"
click node_netty_engine "https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java"
click node_netty_server "https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandServer.java"
click node_netty_wire "https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/internal/WireFactory.java"

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_api_types,node_extensions,node_results,node_resources,node_user toneBlue
class node_endpoint,node_events,node_outbound toneAmber
class node_nio_client,node_nio_conn,node_nio_engine,node_nio_server,node_nio_tcp toneMint
class node_netty_client,node_netty_conn,node_netty_engine,node_netty_server,node_netty_wire toneRose
```

## Components

### Public API

- [Requests and Limits](https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Request.java): `strand-api/src/main/java/io/github/ppzxc/strand/api/Request.java`
- [Request Extensions](https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Extensions.java): `strand-api/src/main/java/io/github/ppzxc/strand/api/Extensions.java`
- [Results and Observation](https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/ResultCompletion.java): `strand-api/src/main/java/io/github/ppzxc/strand/api/ResultCompletion.java`
- [Resource Budgets](https://github.com/ppzxc/strand/blob/main/strand-api/src/main/java/io/github/ppzxc/strand/api/Resource.java): `strand-api/src/main/java/io/github/ppzxc/strand/api/Resource.java`

### Protocol Core

- [Protocol Endpoint](https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java): `strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java`
- [Protocol Events](https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Event.java): `strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Event.java`
- [Outbound Messages](https://github.com/ppzxc/strand/blob/main/strand-core/src/main/java/io/github/ppzxc/strand/core/internal/OutboundMessage.java): `strand-core/src/main/java/io/github/ppzxc/strand/core/internal/OutboundMessage.java`

### NIO Transport

- [NIO Client](https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandClient.java): `strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandClient.java`
- [NIO Connection](https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandConnection.java): `strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandConnection.java`
- [NIO Engine](https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java): `strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java`
- [NIO Server](https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandServer.java): `strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandServer.java`
- [TCP and TLS](https://github.com/ppzxc/strand/blob/main/strand-nio/src/main/java/io/github/ppzxc/strand/nio/internal/TcpPassage.java): `strand-nio/src/main/java/io/github/ppzxc/strand/nio/internal/TcpPassage.java`

### Netty Transport

- [Netty Client](https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandClient.java): `strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandClient.java`
- [Netty Connection](https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandConnection.java): `strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandConnection.java`
- [Netty Engine](https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java): `strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java`
- [Netty Server](https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandServer.java): `strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandServer.java`
- [TCP and WebSocket](https://github.com/ppzxc/strand/blob/main/strand-netty/src/main/java/io/github/ppzxc/strand/netty/internal/WireFactory.java): `strand-netty/src/main/java/io/github/ppzxc/strand/netty/internal/WireFactory.java`

### Other components

- **Library User**

## Connections

- Library User → NIO Client: configures (evidence: `README.md`)
- Library User → Netty Client: configures (evidence: `README.md`)
- NIO Client → NIO Connection: creates (evidence: `strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandClient.java`)
- NIO Client → NIO Engine: starts (evidence: `strand-nio/src/main/java/io/github/ppzxc/strand/nio/NioStrandClient.java`)
- Netty Client → Netty Connection: creates (evidence: `strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandClient.java`)
- Netty Client → Netty Engine: starts (evidence: `strand-netty/src/main/java/io/github/ppzxc/strand/netty/NettyStrandClient.java`)
- NIO Engine → Requests and Limits: uses (evidence: `strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java`)
- NIO Engine → Resource Budgets: accounts (evidence: `strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java`)
- NIO Engine → Results and Observation: completes (evidence: `strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java`)
- Netty Engine → Requests and Limits: uses (evidence: `strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java`)
- Netty Engine → Resource Budgets: accounts (evidence: `strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java`)
- Netty Engine → Results and Observation: completes (evidence: `strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java`)
- Protocol Endpoint → Protocol Events: emits (evidence: `strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java`)
- Protocol Endpoint → Outbound Messages: queues (evidence: `strand-core/src/main/java/io/github/ppzxc/strand/core/internal/Endpoint.java`)
- NIO Engine → Protocol Endpoint: drives (evidence: `strand-nio/src/main/java/io/github/ppzxc/strand/nio/ConnectionEngine.java`)
- Netty Engine → Protocol Endpoint: drives (evidence: `strand-netty/src/main/java/io/github/ppzxc/strand/netty/ConnectionEngine.java`)
- NIO Connection → TCP and TLS: uses
- Netty Connection → TCP and WebSocket: uses
- Library User → Requests and Limits: submits (evidence: `README.md`)
- Requests and Limits → Request Extensions: encodes (evidence: `strand-api/src/main/java/io/github/ppzxc/strand/api/Request.java`)
