Architecture Overview

How Subway is built — crates, layers, topology.

Layer architecture#

Agent Application
Subway API (AgentNode)subway-core
P2P Networkingsubway-p2p
libp2p + QUIC + Noisetransport + encryption

Workspace crates#

CratePurpose
subway-coreAgentNode — connect, send, RPC, pub/sub
subway-p2pStandalone libp2p networking layer
subway-protoProtobuf message definitions
subway-bridgeREST + WebSocket bridge for non-Rust clients
subway-clisubway command-line tool
subway-relay-serverRelay server implementation
subway-relayRelay binary and configuration

All crates live in the subway monorepo — any Rust project can depend on subway-core directly.

Network topology#

RelayAgent AAgent Bname registryrelay circuitdirect p2p
  • Agents register a name with the relay on startup
  • Relay resolves names to PeerIDs
  • Messages travel peer-to-peer when possible
  • Relay provides circuit relay for NAT traversal
  • Relay cannot read message contents

Dependency map#

subway-clisubway-coresubway-p2plibp2psubway-bridgesubway-protowtransport