# inn-media/truyn architecture

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

- Interactive diagram: https://gitdiagram.com/inn-media/truyn
- Repository: https://github.com/inn-media/truyn

## Overview

TRUYN is a trust-aware peer network for agent discovery, requests, provider execution, and contextual data exchange. A user configures a node or provider through the CLI; the node client communicates with a relay, which supports discovery and dispatch, while a provider-side adapter host runs configured provider integrations. The repository also exposes A2A/MCP and NLWeb interoperability, semantic context, trust, and multi-language SDKs. Edges are limited to excerpted calls, SOURCE INDEX references, or README-documented capabilities; several large subsystems are represented by their exact directories because their implementation was not sampled.

Main entry points: [`node/client.js`](https://github.com/inn-media/truyn/blob/main/node/client.js) (Node client), [`cli/index.js`](https://github.com/inn-media/truyn/blob/main/cli/index.js) (CLI), [`network/relay/server.js`](https://github.com/inn-media/truyn/blob/main/network/relay/server.js) (Relay and dispatch), [`network/runtime.js`](https://github.com/inn-media/truyn/blob/main/network/runtime.js) (Network runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and APIs"]
  node_cli["CLI<br/>[index.js]"]
  node_nodeclient["Node client<br/>[client.js]"]
  node_httpapi["HTTP API<br/>[server.js]"]
end

subgraph group_network["Network runtime"]
  node_relay["Relay and dispatch<br/>[server.js]"]
  node_runtime["Network runtime<br/>[runtime.js]"]
  node_peerdiscovery["Peer discovery<br/>[peer-discovery.js]"]
  node_quicrpc["QUIC RPC<br/>[quic-rpc.js]"]
  node_p2p["P2P transport<br/>[p2p.js]"]
  node_state[("Persistent state")]
end

subgraph group_trustcontext["Trust and context"]
  node_protocol["Protocol envelopes<br/>[index.js]"]
  node_identity["Node identity<br/>[index.js]"]
  node_trust["Trust services<br/>[index.js]"]
  node_context["Semantic context<br/>[index.js]"]
  node_semanticrouting["Semantic routing"]
end

subgraph group_execution["Provider execution"]
  node_adapterhost["Provider adapter host<br/>[index.js]"]
  node_providerregistry["Provider registry<br/>[index.js]"]
  node_providercore["Provider integrations"]
end

subgraph group_interop["Interoperability and SDKs"]
  node_mcp["MCP server<br/>[server.js]"]
  node_a2a["A2A adapter<br/>[server.js]"]
  node_mcpclient["MCP clients"]
  node_nlweb["NLWeb interoperability"]
  node_sdks["Language SDKs"]
end

node_operator(("User or operator"))

node_operator -->|"runs commands"| node_cli
node_cli -->|"creates node"| node_nodeclient
node_cli -->|"starts relay"| node_relay
node_cli -->|"selects provider"| node_providerregistry
node_cli -->|"configures host"| node_adapterhost
node_cli -.->|"starts API"| node_httpapi
node_cli -.->|"starts MCP"| node_mcp
node_nodeclient -->|"signs and verifies"| node_protocol
node_nodeclient -->|"creates identity"| node_identity
node_nodeclient -->|"sends requests"| node_relay
node_nodeclient -->|"validates selections"| node_context
node_httpapi -->|"routes discovery"| node_nodeclient
node_mcp -->|"routes tool calls"| node_nodeclient
node_relay -->|"verifies envelopes"| node_protocol
node_relay -->|"scores trust"| node_trust
node_relay -->|"retrieves context"| node_context
node_runtime -->|"loads discovery"| node_peerdiscovery
node_runtime -->|"loads RPC"| node_quicrpc
node_runtime -->|"loads transport"| node_p2p
node_runtime -->|"loads persistence"| node_state
node_adapterhost -.->|"executes adapter"| node_providerregistry
node_providerregistry -->|"dispatches provider"| node_providercore
node_a2a -.->|"compatibility profile"| node_mcp
node_mcpclient -.->|"connects to server"| node_mcp
node_nlweb -.->|"composes discovery and ask"| node_nodeclient
node_semanticrouting -.->|"uses context runtime"| node_context
node_sdks -.->|"offers client access"| node_nodeclient

click node_cli "https://github.com/inn-media/truyn/blob/main/cli/index.js"
click node_nodeclient "https://github.com/inn-media/truyn/blob/main/node/client.js"
click node_httpapi "https://github.com/inn-media/truyn/blob/main/adapters/http/server.js"
click node_mcp "https://github.com/inn-media/truyn/blob/main/adapters/mcp/server.js"
click node_protocol "https://github.com/inn-media/truyn/blob/main/core/protocol/index.js"
click node_identity "https://github.com/inn-media/truyn/blob/main/core/identity/index.js"
click node_relay "https://github.com/inn-media/truyn/blob/main/network/relay/server.js"
click node_runtime "https://github.com/inn-media/truyn/blob/main/network/runtime.js"
click node_peerdiscovery "https://github.com/inn-media/truyn/blob/main/network/discovery/peer-discovery.js"
click node_quicrpc "https://github.com/inn-media/truyn/blob/main/network/discovery/quic-rpc.js"
click node_p2p "https://github.com/inn-media/truyn/blob/main/network/transport/p2p.js"
click node_state "https://github.com/inn-media/truyn/blob/main/network/state/persistent-state.js"
click node_trust "https://github.com/inn-media/truyn/blob/main/core/trust/index.js"
click node_context "https://github.com/inn-media/truyn/blob/main/core/context/index.js"
click node_semanticrouting "https://github.com/inn-media/truyn/blob/main/core/context/semantic-router-v2.js"
click node_adapterhost "https://github.com/inn-media/truyn/blob/main/adapters/sdk/index.js"
click node_providerregistry "https://github.com/inn-media/truyn/blob/main/adapters/providers/index.js"
click node_providercore "https://github.com/inn-media/truyn/tree/main/adapters/providers"
click node_a2a "https://github.com/inn-media/truyn/blob/main/adapters/a2a/server.js"
click node_mcpclient "https://github.com/inn-media/truyn/tree/main/adapters/mcp"
click node_nlweb "https://github.com/inn-media/truyn/tree/main/adapters/nlweb"
click node_sdks "https://github.com/inn-media/truyn/tree/main/sdk"

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_nodeclient,node_httpapi,node_operator toneBlue
class node_relay,node_runtime,node_peerdiscovery,node_quicrpc,node_p2p,node_state toneAmber
class node_protocol,node_identity,node_trust,node_context,node_semanticrouting toneMint
class node_adapterhost,node_providerregistry,node_providercore toneRose
class node_mcp,node_a2a,node_mcpclient,node_nlweb,node_sdks toneIndigo
```

## Components

### Entry and APIs

- [CLI](https://github.com/inn-media/truyn/blob/main/cli/index.js): `cli/index.js`
- [Node client](https://github.com/inn-media/truyn/blob/main/node/client.js): `node/client.js`
- [HTTP API](https://github.com/inn-media/truyn/blob/main/adapters/http/server.js): `adapters/http/server.js`

### Network runtime

- [Relay and dispatch](https://github.com/inn-media/truyn/blob/main/network/relay/server.js): `network/relay/server.js`
- [Network runtime](https://github.com/inn-media/truyn/blob/main/network/runtime.js): `network/runtime.js`
- [Peer discovery](https://github.com/inn-media/truyn/blob/main/network/discovery/peer-discovery.js): `network/discovery/peer-discovery.js`
- [QUIC RPC](https://github.com/inn-media/truyn/blob/main/network/discovery/quic-rpc.js): `network/discovery/quic-rpc.js`
- [P2P transport](https://github.com/inn-media/truyn/blob/main/network/transport/p2p.js): `network/transport/p2p.js`
- [Persistent state](https://github.com/inn-media/truyn/blob/main/network/state/persistent-state.js): `network/state/persistent-state.js`

### Trust and context

- [Protocol envelopes](https://github.com/inn-media/truyn/blob/main/core/protocol/index.js): `core/protocol/index.js`
- [Node identity](https://github.com/inn-media/truyn/blob/main/core/identity/index.js): `core/identity/index.js`
- [Trust services](https://github.com/inn-media/truyn/blob/main/core/trust/index.js): `core/trust/index.js`
- [Semantic context](https://github.com/inn-media/truyn/blob/main/core/context/index.js): `core/context/index.js`
- [Semantic routing](https://github.com/inn-media/truyn/blob/main/core/context/semantic-router-v2.js): `core/context/semantic-router-v2.js`

### Provider execution

- [Provider adapter host](https://github.com/inn-media/truyn/blob/main/adapters/sdk/index.js): `adapters/sdk/index.js`
- [Provider registry](https://github.com/inn-media/truyn/blob/main/adapters/providers/index.js): `adapters/providers/index.js`
- [Provider integrations](https://github.com/inn-media/truyn/tree/main/adapters/providers): `adapters/providers`

### Interoperability and SDKs

- [MCP server](https://github.com/inn-media/truyn/blob/main/adapters/mcp/server.js): `adapters/mcp/server.js`
- [A2A adapter](https://github.com/inn-media/truyn/blob/main/adapters/a2a/server.js): `adapters/a2a/server.js`
- [MCP clients](https://github.com/inn-media/truyn/tree/main/adapters/mcp): `adapters/mcp`
- [NLWeb interoperability](https://github.com/inn-media/truyn/tree/main/adapters/nlweb): `adapters/nlweb`
- [Language SDKs](https://github.com/inn-media/truyn/tree/main/sdk): `sdk`

### Other components

- **User or operator**

## Connections

- User or operator → CLI: runs commands
- CLI → Node client: creates node (evidence: `cli/index.js`)
- CLI → Relay and dispatch: starts relay (evidence: `cli/index.js`)
- CLI → Provider registry: selects provider (evidence: `cli/index.js`)
- CLI → Provider adapter host: configures host (evidence: `cli/index.js`)
- CLI → HTTP API: starts API (evidence: `cli/index.js`)
- CLI → MCP server: starts MCP (evidence: `cli/index.js`)
- Node client → Protocol envelopes: signs and verifies (evidence: `node/client.js`)
- Node client → Node identity: creates identity (evidence: `node/client.js`)
- Node client → Relay and dispatch: sends requests (evidence: `node/client.js`)
- Node client → Semantic context: validates selections (evidence: `node/client.js`)
- HTTP API → Node client: routes discovery (evidence: `adapters/http/server.js`)
- MCP server → Node client: routes tool calls (evidence: `adapters/mcp/server.js`)
- Relay and dispatch → Protocol envelopes: verifies envelopes (evidence: `network/relay/server.js`)
- Relay and dispatch → Trust services: scores trust (evidence: `network/relay/server.js`)
- Relay and dispatch → Semantic context: retrieves context (evidence: `network/relay/server.js`)
- Network runtime → Peer discovery: loads discovery (evidence: `network/runtime.js`)
- Network runtime → QUIC RPC: loads RPC (evidence: `network/runtime.js`)
- Network runtime → P2P transport: loads transport (evidence: `network/runtime.js`)
- Network runtime → Persistent state: loads persistence (evidence: `network/runtime.js`)
- Provider adapter host → Provider registry: executes adapter
- Provider registry → Provider integrations: dispatches provider (evidence: `adapters/providers/index.js`)
- A2A adapter → MCP server: compatibility profile
- MCP clients → MCP server: connects to server (evidence: `adapters/mcp/server.js`)
- NLWeb interoperability → Node client: composes discovery and ask
- Semantic routing → Semantic context: uses context runtime (evidence: `core/context/semantic-router-v2.js`)
- Language SDKs → Node client: offers client access
