# larksuite/oapi-sdk-go architecture

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

- Interactive diagram: https://gitdiagram.com/larksuite/oapi-sdk-go
- Repository: https://github.com/larksuite/oapi-sdk-go

## Overview

This is the Feishu OpenPlatform Go server SDK: developers use a configured client to call typed APIs, manage credentials, and handle events; optional modules add WebSocket chat and one-click app registration. The graph preserves broad API domains and the README’s additional product capabilities. Sampled source confirms client request delegation, token caching, and WebSocket receive behavior; unsampled feature wiring is limited to documented relationships.

Main entry points: [`core/apireq.go`](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/apireq.go) (HTTP request core), [`channel/channel.go`](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/channel.go) (Channel listener), [`client.go`](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/client.go) (SDK client), [`service`](https://github.com/larksuite/oapi-sdk-go/tree/v3_main/service) (Typed API domains)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client and auth"]
  node_client["SDK client<br/>[client.go]"]
  node_request["HTTP request core<br/>[apireq.go]"]
  node_tokens["Token manager<br/>[tokenmanager.go]"]
  node_cache[("Token cache<br/>[cache.go]")]
  node_ticket["App ticket manager"]
end

subgraph group_apis["Platform APIs"]
  node_api_domains["Typed API domains"]
end

subgraph group_events["Events and callbacks"]
  node_event_dispatch["Event dispatcher"]
  node_callbacks["Card callbacks"]
end

subgraph group_channel["Channel messaging"]
  node_ws_client["WebSocket client<br/>[client.go]"]
  node_channel["Channel listener<br/>[channel.go]"]
  node_normalize["Message normalization<br/>[parser.go]"]
  node_pipeline["Chat batching<br/>[chat_pipeline.go]"]
  node_outbound["Outbound messaging<br/>[send.go]"]
end

subgraph group_addons["Optional workflows"]
  node_registration["App registration<br/>[registration.go]"]
end

node_developer(("SDK developer"))
node_platform(("Feishu platform"))
node_api_platform(("Open platform APIs"))
node_ws_platform(("WebSocket service"))

node_developer -->|"configures"| node_client
node_developer -->|"calls APIs"| node_api_domains
node_client -->|"initializes"| node_api_domains
node_client -->|"delegates requests"| node_request
node_request -->|"gets access token"| node_tokens
node_tokens -->|"reads and writes"| node_cache
node_request -->|"sends HTTP requests"| node_api_platform
node_api_domains -->|"issues API requests"| node_request
node_api_platform -->|"returns responses"| node_request
node_platform -->|"delivers events"| node_event_dispatch
node_developer -->|"registers handlers"| node_event_dispatch
node_developer -->|"handles callbacks"| node_callbacks
node_platform -->|"delivers callbacks"| node_callbacks
node_developer -->|"starts listener"| node_channel
node_channel -->|"uses transport"| node_ws_client
node_ws_client -->|"connects and receives"| node_ws_platform
node_channel -->|"normalizes messages"| node_normalize
node_channel -->|"batches messages"| node_pipeline
node_developer -->|"sends replies"| node_outbound
node_outbound -->|"uses API client"| node_client
node_developer -->|"starts registration"| node_registration
node_registration -->|"requests authorization"| node_platform
node_developer -.->|"uses ticket flow"| node_ticket
node_event_dispatch -.->|"stores app tickets"| node_ticket

click node_client "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/client.go"
click node_request "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/apireq.go"
click node_tokens "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/tokenmanager.go"
click node_cache "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/cache.go"
click node_api_domains "https://github.com/larksuite/oapi-sdk-go/tree/v3_main/service"
click node_event_dispatch "https://github.com/larksuite/oapi-sdk-go/tree/v3_main/event/dispatcher"
click node_callbacks "https://github.com/larksuite/oapi-sdk-go/tree/v3_main/event/dispatcher/callback"
click node_ws_client "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/ws/client.go"
click node_channel "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/channel.go"
click node_normalize "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/normalize/parser.go"
click node_pipeline "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/pipeline/chat_pipeline.go"
click node_outbound "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/send.go"
click node_registration "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/scene/registration/registration.go"
click node_ticket "https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/appticketmanager.go"

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_client,node_request,node_tokens,node_cache,node_ticket toneBlue
class node_api_domains toneAmber
class node_event_dispatch,node_callbacks,node_api_platform toneMint
class node_ws_client,node_channel,node_normalize,node_pipeline,node_outbound toneRose
class node_registration,node_developer,node_platform,node_ws_platform toneIndigo
```

## Components

### Client and auth

- [SDK client](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/client.go): `client.go`
- [HTTP request core](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/apireq.go): `core/apireq.go`
- [Token manager](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/tokenmanager.go): `core/tokenmanager.go`
- [Token cache](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/cache.go): `core/cache.go`
- [App ticket manager](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/core/appticketmanager.go): `core/appticketmanager.go`

### Platform APIs

- [Typed API domains](https://github.com/larksuite/oapi-sdk-go/tree/v3_main/service): `service`

### Events and callbacks

- [Event dispatcher](https://github.com/larksuite/oapi-sdk-go/tree/v3_main/event/dispatcher): `event/dispatcher`
- [Card callbacks](https://github.com/larksuite/oapi-sdk-go/tree/v3_main/event/dispatcher/callback): `event/dispatcher/callback`

### Channel messaging

- [WebSocket client](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/ws/client.go): `ws/client.go`
- [Channel listener](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/channel.go): `channel/channel.go`
- [Message normalization](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/normalize/parser.go): `channel/normalize/parser.go`
- [Chat batching](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/pipeline/chat_pipeline.go): `channel/pipeline/chat_pipeline.go`
- [Outbound messaging](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/channel/send.go): `channel/send.go`

### Optional workflows

- [App registration](https://github.com/larksuite/oapi-sdk-go/blob/v3_main/scene/registration/registration.go): `scene/registration/registration.go`

### Other components

- **SDK developer**
- **Feishu platform**
- **Open platform APIs**
- **WebSocket service**

## Connections

- SDK developer → SDK client: configures
- SDK developer → Typed API domains: calls APIs
- SDK client → Typed API domains: initializes
- SDK client → HTTP request core: delegates requests
- HTTP request core → Token manager: gets access token
- Token manager → Token cache: reads and writes
- HTTP request core → Open platform APIs: sends HTTP requests
- Typed API domains → HTTP request core: issues API requests
- Open platform APIs → HTTP request core: returns responses
- Feishu platform → Event dispatcher: delivers events
- SDK developer → Event dispatcher: registers handlers
- SDK developer → Card callbacks: handles callbacks
- Feishu platform → Card callbacks: delivers callbacks
- SDK developer → Channel listener: starts listener
- Channel listener → WebSocket client: uses transport
- WebSocket client → WebSocket service: connects and receives
- Channel listener → Message normalization: normalizes messages
- Channel listener → Chat batching: batches messages
- SDK developer → Outbound messaging: sends replies
- Outbound messaging → SDK client: uses API client
- SDK developer → App registration: starts registration
- App registration → Feishu platform: requests authorization
- SDK developer → App ticket manager: uses ticket flow
- Event dispatcher → App ticket manager: stores app tickets
