# wechaty/grpc architecture

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

- Interactive diagram: https://gitdiagram.com/wechaty/grpc
- Repository: https://github.com/wechaty/grpc

## Overview

Wechaty gRPC defines the Puppet RPC contract and exposes it through a Node.js package, with client libraries available for several other languages. A consumer uses the exported package and its protocol, generated message types, and stream helpers to interact with a Puppet service. The schema covers lifecycle and events as well as contact, friendship, messaging, room, tag, and file-transfer operations. The repository also exposes OpenAPI data and Google protobuf wrappers. Polyglot bindings are documented capabilities, but their generated runtime implementations are not sampled here; links to them reflect the README’s description of stub generation, not inspected call paths.

Main entry points: [`proto/wechaty/puppet.proto`](https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet.proto) (Puppet RPC), [`src/mod.ts`](https://github.com/wechaty/grpc/blob/main/src/mod.ts) (Node exports), [`src/cjs.ts`](https://github.com/wechaty/grpc/blob/main/src/cjs.ts) (Generated JS assets), [`src/proto.ts`](https://github.com/wechaty/grpc/blob/main/src/proto.ts) (Proto loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["RPC contract"]
  node_puppet["Puppet RPC<br/>[puppet.proto]"]
  node_base["Lifecycle and events<br/>[base.proto]"]
  node_contacts["Contacts and friendship<br/>[contact.proto]"]
  node_messages["Messages and media<br/>[message.proto]"]
  node_rooms["Rooms and members<br/>[room.proto]"]
  node_other_rpc["Other RPC domains"]
end

subgraph group_node["Node package"]
  node_node_exports["Node exports<br/>[mod.ts]"]
  node_schema_loader["Proto loader<br/>[proto.ts]"]
  node_openapi_loader["OpenAPI loader<br/>[openapi.ts]"]
  node_runtime_config["Version config<br/>[config.ts]"]
  node_package_metadata["Package metadata<br/>[package-json.ts]"]
  node_cjs_assets["Generated JS assets<br/>[cjs.ts]"]
  node_root_helper["Code root helper<br/>[code-root.cjs]"]
  node_google_types["Google protobuf types<br/>[google.ts]"]
  node_chunk_streams["Chunk transforms"]
  node_commonjs_clients["CommonJS support"]
end

subgraph group_clients["Language clients"]
  node_python_client["Python client"]
  node_go_client["Go client"]
  node_java_client["Java client"]
  node_php_client["PHP client"]
  node_csharp_client["C&#35; client<br/>[Wechaty.Grpc]"]
end

node_consumer(("API consumer"))

node_consumer -->|"imports"| node_node_exports
node_node_exports -->|"exports"| node_schema_loader
node_node_exports -->|"exports"| node_openapi_loader
node_node_exports -->|"imports"| node_cjs_assets
node_node_exports -->|"imports"| node_runtime_config
node_node_exports -->|"exports"| node_google_types
node_node_exports -->|"exports"| node_chunk_streams
node_schema_loader -->|"imports"| node_cjs_assets
node_schema_loader -->|"reads"| node_puppet
node_openapi_loader -->|"imports"| node_cjs_assets
node_openapi_loader -->|"uses type"| node_runtime_config
node_runtime_config -->|"reads"| node_package_metadata
node_cjs_assets -->|"imports"| node_root_helper
node_puppet -.->|"generates stubs"| node_commonjs_clients
node_puppet -.->|"generates stubs"| node_python_client
node_puppet -.->|"generates stubs"| node_go_client
node_puppet -.->|"generates stubs"| node_java_client
node_puppet -.->|"generates stubs"| node_php_client
node_puppet -.->|"generates stubs"| node_csharp_client

click node_puppet "https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet.proto"
click node_base "https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/base.proto"
click node_contacts "https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/contact.proto"
click node_messages "https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/message.proto"
click node_rooms "https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/room.proto"
click node_other_rpc "https://github.com/wechaty/grpc/tree/main/proto/wechaty/puppet"
click node_node_exports "https://github.com/wechaty/grpc/blob/main/src/mod.ts"
click node_schema_loader "https://github.com/wechaty/grpc/blob/main/src/proto.ts"
click node_openapi_loader "https://github.com/wechaty/grpc/blob/main/src/openapi.ts"
click node_runtime_config "https://github.com/wechaty/grpc/blob/main/src/config.ts"
click node_package_metadata "https://github.com/wechaty/grpc/blob/main/src/package-json.ts"
click node_cjs_assets "https://github.com/wechaty/grpc/blob/main/src/cjs.ts"
click node_root_helper "https://github.com/wechaty/grpc/blob/main/commonjs/code-root.cjs"
click node_google_types "https://github.com/wechaty/grpc/blob/main/src/google.ts"
click node_chunk_streams "https://github.com/wechaty/grpc/blob/main/src/chunk-transformer.ts"
click node_commonjs_clients "https://github.com/wechaty/grpc/tree/main/commonjs"
click node_python_client "https://github.com/wechaty/grpc/tree/main/polyglot/python"
click node_go_client "https://github.com/wechaty/grpc/tree/main/polyglot/go"
click node_java_client "https://github.com/wechaty/grpc/tree/main/polyglot/java"
click node_php_client "https://github.com/wechaty/grpc/tree/main/polyglot/php"
click node_csharp_client "https://github.com/wechaty/grpc/tree/main/polyglot/csharp/Wechaty.Grpc"

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_puppet,node_base,node_contacts,node_messages,node_rooms,node_other_rpc toneBlue
class node_node_exports,node_schema_loader,node_openapi_loader,node_runtime_config,node_package_metadata,node_cjs_assets,node_root_helper,node_google_types,node_chunk_streams,node_commonjs_clients toneAmber
class node_python_client,node_go_client,node_java_client,node_php_client,node_csharp_client,node_consumer toneMint
```

## Components

### RPC contract

- [Puppet RPC](https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet.proto): `proto/wechaty/puppet.proto`
- [Lifecycle and events](https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/base.proto): `proto/wechaty/puppet/base.proto`
- [Contacts and friendship](https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/contact.proto): `proto/wechaty/puppet/contact.proto`
- [Messages and media](https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/message.proto): `proto/wechaty/puppet/message.proto`
- [Rooms and members](https://github.com/wechaty/grpc/blob/main/proto/wechaty/puppet/room.proto): `proto/wechaty/puppet/room.proto`
- [Other RPC domains](https://github.com/wechaty/grpc/tree/main/proto/wechaty/puppet): `proto/wechaty/puppet`

### Node package

- [Node exports](https://github.com/wechaty/grpc/blob/main/src/mod.ts): `src/mod.ts`
- [Proto loader](https://github.com/wechaty/grpc/blob/main/src/proto.ts): `src/proto.ts`
- [OpenAPI loader](https://github.com/wechaty/grpc/blob/main/src/openapi.ts): `src/openapi.ts`
- [Version config](https://github.com/wechaty/grpc/blob/main/src/config.ts): `src/config.ts`
- [Package metadata](https://github.com/wechaty/grpc/blob/main/src/package-json.ts): `src/package-json.ts`
- [Generated JS assets](https://github.com/wechaty/grpc/blob/main/src/cjs.ts): `src/cjs.ts`
- [Code root helper](https://github.com/wechaty/grpc/blob/main/commonjs/code-root.cjs): `commonjs/code-root.cjs`
- [Google protobuf types](https://github.com/wechaty/grpc/blob/main/src/google.ts): `src/google.ts`
- [Chunk transforms](https://github.com/wechaty/grpc/blob/main/src/chunk-transformer.ts): `src/chunk-transformer.ts`
- [CommonJS support](https://github.com/wechaty/grpc/tree/main/commonjs): `commonjs`

### Language clients

- [Python client](https://github.com/wechaty/grpc/tree/main/polyglot/python): `polyglot/python`
- [Go client](https://github.com/wechaty/grpc/tree/main/polyglot/go): `polyglot/go`
- [Java client](https://github.com/wechaty/grpc/tree/main/polyglot/java): `polyglot/java`
- [PHP client](https://github.com/wechaty/grpc/tree/main/polyglot/php): `polyglot/php`
- [C# client](https://github.com/wechaty/grpc/tree/main/polyglot/csharp/Wechaty.Grpc): `polyglot/csharp/Wechaty.Grpc`

### Other components

- **API consumer**

## Connections

- API consumer → Node exports: imports (evidence: `README.md`)
- Node exports → Proto loader: exports (evidence: `src/mod.ts`)
- Node exports → OpenAPI loader: exports (evidence: `src/mod.ts`)
- Node exports → Generated JS assets: imports (evidence: `src/mod.ts`)
- Node exports → Version config: imports (evidence: `src/mod.ts`)
- Node exports → Google protobuf types: exports (evidence: `src/mod.ts`)
- Node exports → Chunk transforms: exports (evidence: `src/mod.ts`)
- Proto loader → Generated JS assets: imports (evidence: `src/proto.ts`)
- Proto loader → Puppet RPC: reads (evidence: `src/proto.ts`)
- OpenAPI loader → Generated JS assets: imports (evidence: `src/openapi.ts`)
- OpenAPI loader → Version config: uses type (evidence: `src/openapi.ts`)
- Version config → Package metadata: reads (evidence: `src/config.ts`)
- Generated JS assets → Code root helper: imports (evidence: `src/cjs.ts`)
- Puppet RPC → CommonJS support: generates stubs (evidence: `README.md`)
- Puppet RPC → Python client: generates stubs (evidence: `README.md`)
- Puppet RPC → Go client: generates stubs (evidence: `README.md`)
- Puppet RPC → Java client: generates stubs (evidence: `README.md`)
- Puppet RPC → PHP client: generates stubs (evidence: `README.md`)
- Puppet RPC → C# client: generates stubs (evidence: `README.md`)
