# allenpeng0705/envoymesh architecture

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

- Interactive diagram: https://gitdiagram.com/allenpeng0705/envoymesh
- Repository: https://github.com/allenpeng0705/envoymesh

## Overview

EnvoyMesh is a self-hosted, decentralized P2P social and agent mesh: a home node owns identity, policy, AI, and data, while phones act as thin clients. The main workflow is a user action in the Social UI, sent over the home-node service connection, handled locally or dispatched to peers, then returned as chat, content, knowledge, or task results. The README documents the major product branches; sampled source specifically confirms the UI’s WebSocket RPC pattern, RAG indexing/search, and chain-orchestration ownership. Other wiring below reflects documented behavior, not inspected implementation.

Main entry points: [`apps/node/src/node-service-impl.ts`](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-impl.ts) (Node services), [`apps/node/src/node-service-chain-orchestration.ts`](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-chain-orchestration.ts) (Task orchestration), [`apps/node/src/index.ts`](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/index.ts) (Node runtime), [`apps/node/src/mesh-outbound-helper.ts`](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/mesh-outbound-helper.ts) (Mesh transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User clients"]
  node_social["Social UI<br/>[App.tsx]"]
  node_nodeclient["Node service client<br/>[useNodeService.tsx]"]
  node_mobile["EnvoyGo client"]
end

subgraph group_node["Home node"]
  node_nodeentry["Node runtime<br/>[index.ts]"]
  node_services["Node services"]
  node_identity["Identity and trust"]
  node_chat["Chat and calls"]
  node_store[("Local data<br/>[storage-gate.ts]")]
end

subgraph group_mesh["Peer mesh"]
  node_meshtransport["Mesh transport"]
  node_inbound["Inbound handlers"]
  node_peer["Peer node<br/>[index.ts]"]
end

subgraph group_agent["Agent network"]
  node_agentui["Agent interface<br/>[index.ts]"]
  node_openclaw["OpenClaw bridge<br/>[channel.ts]"]
  node_chains["Task orchestration"]
  node_workers["Agent workers"]
end

subgraph group_knowledge["Knowledge and content"]
  node_content["Feed and publishing<br/>[feed-timeline.ts]"]
  node_library["Knowledge libraries<br/>[knowledge-hub.ts]"]
  node_rag["Local RAG<br/>[rag-service.ts]"]
end

node_user(("User"))
node_externalagent(("External agent"))

node_user -->|"uses"| node_social
node_social -->|"invokes RPC"| node_nodeclient
node_mobile -->|"connects thin-client"| node_nodeentry
node_nodeclient -->|"sends WebSocket RPC"| node_nodeentry
node_nodeentry -->|"dispatches"| node_services
node_services -->|"applies trust policy"| node_identity
node_services -->|"handles messaging"| node_chat
node_chat -->|"sends envelopes"| node_meshtransport
node_meshtransport -->|"delivers P2P"| node_peer
node_peer -->|"sends envelopes"| node_inbound
node_inbound -->|"dispatches requests"| node_services
node_services -->|"serves feed and posts"| node_content
node_services -->|"queries knowledge"| node_library
node_library -->|"indexes and searches"| node_rag
node_services -->|"routes agent work"| node_agentui
node_agentui -.->|"bridges built-in agent"| node_openclaw
node_services -->|"starts task chains"| node_chains
node_chains -->|"executes accepted tasks"| node_workers
node_chains -->|"coordinates peers"| node_meshtransport
node_externalagent -.->|"optional integration"| node_agentui
node_services -->|"reads and writes"| node_store
node_rag -->|"persists indexes"| node_store

click node_social "https://github.com/allenpeng0705/envoymesh/blob/main/apps/social/src/App.tsx"
click node_nodeclient "https://github.com/allenpeng0705/envoymesh/blob/main/apps/social/src/hooks/useNodeService.tsx"
click node_mobile "https://github.com/allenpeng0705/envoymesh/tree/main/apps/envoygo"
click node_nodeentry "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/index.ts"
click node_services "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-impl.ts"
click node_identity "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-identity.ts"
click node_chat "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/chat-outbound-deliver.ts"
click node_meshtransport "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/mesh-outbound-helper.ts"
click node_inbound "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/cli-mesh-inbound-chat-room-message.ts"
click node_peer "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/index.ts"
click node_content "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/feed-timeline.ts"
click node_library "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/knowledge-hub.ts"
click node_rag "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/rag-service.ts"
click node_agentui "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/agent-runtime-envoy/index.ts"
click node_openclaw "https://github.com/allenpeng0705/envoymesh/blob/main/OpenClawExtension/src/channel.ts"
click node_chains "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-chain-orchestration.ts"
click node_workers "https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/chain-worker-executor.ts"
click node_store "https://github.com/allenpeng0705/envoymesh/blob/main/packages/local-store/src/storage-gate.ts"

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_social,node_nodeclient,node_mobile,node_user toneBlue
class node_nodeentry,node_services,node_identity,node_chat,node_store toneAmber
class node_meshtransport,node_inbound,node_peer toneMint
class node_agentui,node_openclaw,node_chains,node_workers toneRose
class node_content,node_library,node_rag,node_externalagent toneIndigo
```

## Components

### User clients

- [Social UI](https://github.com/allenpeng0705/envoymesh/blob/main/apps/social/src/App.tsx): `apps/social/src/App.tsx`
- [Node service client](https://github.com/allenpeng0705/envoymesh/blob/main/apps/social/src/hooks/useNodeService.tsx): `apps/social/src/hooks/useNodeService.tsx`
- [EnvoyGo client](https://github.com/allenpeng0705/envoymesh/tree/main/apps/envoygo): `apps/envoygo`

### Home node

- [Node runtime](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/index.ts): `apps/node/src/index.ts`
- [Node services](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-impl.ts): `apps/node/src/node-service-impl.ts`
- [Identity and trust](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-identity.ts): `apps/node/src/node-service-identity.ts`
- [Chat and calls](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/chat-outbound-deliver.ts): `apps/node/src/chat-outbound-deliver.ts`
- [Local data](https://github.com/allenpeng0705/envoymesh/blob/main/packages/local-store/src/storage-gate.ts): `packages/local-store/src/storage-gate.ts`

### Peer mesh

- [Mesh transport](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/mesh-outbound-helper.ts): `apps/node/src/mesh-outbound-helper.ts`
- [Inbound handlers](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/cli-mesh-inbound-chat-room-message.ts): `apps/node/src/cli-mesh-inbound-chat-room-message.ts`
- [Peer node](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/index.ts): `apps/node/src/index.ts`

### Agent network

- [Agent interface](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/agent-runtime-envoy/index.ts): `apps/node/src/agent-runtime-envoy/index.ts`
- [OpenClaw bridge](https://github.com/allenpeng0705/envoymesh/blob/main/OpenClawExtension/src/channel.ts): `OpenClawExtension/src/channel.ts`
- [Task orchestration](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/node-service-chain-orchestration.ts): `apps/node/src/node-service-chain-orchestration.ts`
- [Agent workers](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/chain-worker-executor.ts): `apps/node/src/chain-worker-executor.ts`

### Knowledge and content

- [Feed and publishing](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/feed-timeline.ts): `apps/node/src/feed-timeline.ts`
- [Knowledge libraries](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/knowledge-hub.ts): `apps/node/src/knowledge-hub.ts`
- [Local RAG](https://github.com/allenpeng0705/envoymesh/blob/main/apps/node/src/rag-service.ts): `apps/node/src/rag-service.ts`

### Other components

- **User**
- **External agent**

## Connections

- User → Social UI: uses
- Social UI → Node service client: invokes RPC
- EnvoyGo client → Node runtime: connects thin-client
- Node service client → Node runtime: sends WebSocket RPC
- Node runtime → Node services: dispatches
- Node services → Identity and trust: applies trust policy
- Node services → Chat and calls: handles messaging
- Chat and calls → Mesh transport: sends envelopes
- Mesh transport → Peer node: delivers P2P
- Peer node → Inbound handlers: sends envelopes
- Inbound handlers → Node services: dispatches requests
- Node services → Feed and publishing: serves feed and posts
- Node services → Knowledge libraries: queries knowledge
- Knowledge libraries → Local RAG: indexes and searches
- Node services → Agent interface: routes agent work
- Agent interface → OpenClaw bridge: bridges built-in agent
- Node services → Task orchestration: starts task chains
- Task orchestration → Agent workers: executes accepted tasks
- Task orchestration → Mesh transport: coordinates peers
- External agent → Agent interface: optional integration
- Node services → Local data: reads and writes
- Local RAG → Local data: persists indexes
