# slackapi/node-slack-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/slackapi/node-slack-sdk
- Repository: https://github.com/slackapi/node-slack-sdk

## Overview

1. This repository is a monorepo for the Node Slack SDK, organized as several publishable packages under `packages/`. Each package has its own `package.json`, source, tests, and TypeDoc config, so the main architectural boundary is by Slack API surface rather than by deployment tier.

2. The core product packages map directly to Slack communication modes:
   - `@slack/web-api` for HTTPS/REST calls to Slack’s Web API
   - `@slack/socket-mode` for receiving events over Slack’s WebSocket-based Socket Mode
   - `@slack/rtm-api` for the legacy RTM WebSocket API
   - `@slack/oauth` for installation and token exchange flows
   - `@slack/webhook` for outgoing message delivery via incoming webhooks

3. `@slack/web-api` is the largest subsystem and is the main outbound data plane. It exposes `WebClient`, which routes method calls into Slack API requests, handles retries and error typing, and includes special paths for file upload and chat streaming. Its `src/types/request` and `src/types/response` trees define the request/response shape for the many Slack methods, while `src/methods.ts` and generated type files provide the method surface.

4. `@slack/socket-mode` and `@slack/rtm-api` are the inbound real-time subsystems. Both manage long-lived WebSocket connections to Slack, but Socket Mode is the newer event delivery mechanism while RTM is the older chat/event stream. These packages encapsulate connection lifecycle, message acking/reply behavior, and recoverable vs unrecoverable connection errors.

5. `@slack/oauth` handles app installation and authorization as a stateful flow. It includes installation and state stores, support for file-backed or in-memory persistence, install URL generation, callback handling, and HTML rendering for install routes. The main data flow is: install request -> state generation/store -> Slack authorization redirect -> callback validation -> token/installation persistence.

6. `@slack/webhook` is the simplest boundary: it sends a single payload to a Slack-provided webhook URL over HTTP. It is intentionally narrow and stateless compared with the other packages.

7. `@slack/types` is the shared schema layer. It contains the canonical TypeScript models for blocks, events, messages, views, chunks, and other Slack payloads. The rest of the SDK depends on these types to keep API surfaces consistent across packages and to centralize Slack object definitions.

8. `@slack/logger` is a small cross-cutting utility package. It standardizes logging interfaces and log levels used by the client packages, rather than introducing a heavyweight shared runtime or framework.

9. `packages/cli-test` and `packages/cli-hooks` are support tooling rather than end-user SDK surfaces. `cli-test` provides a programmable CLI test harness and command wrappers, while `cli-hooks` supplies local hooks/doctor/start helpers for package development and validation.

10. The repository includes live validation infrastructure in `prod-server-integration-tests/`. That area contains Slack app manifests, scripts, and end-to-end tests that exercise the published packages against real Slack servers, so it serves as the architecture’s external-system verification layer.

11. `examples/` shows how the packages are composed in real applications, with examples for Socket Mode and OpenID Connect. `docs/english/` is the published documentation tree, including API reference, migration guides, and getting-started material, which reflects the package boundaries exposed to consumers.

12. Tooling and automation are part of the repo’s operational architecture: TypeScript is the primary implementation language, Node v18+ is the runtime baseline, Biome handles code style, and GitHub Actions drive CI, dependency updates, release, and issue triage. The `scripts/` directory also contains code generation for the Web API type surface, which is important because much of the SDK’s method and type coverage is generated rather than handwritten.

Main entry points: [`packages/web-api`](https://github.com/slackapi/node-slack-sdk/tree/main/packages/web-api) (Web API), [`packages/socket-mode`](https://github.com/slackapi/node-slack-sdk/tree/main/packages/socket-mode) (Socket Mode), [`docs/english`](https://github.com/slackapi/node-slack-sdk/tree/main/docs/english) (Docs), [`packages/types`](https://github.com/slackapi/node-slack-sdk/tree/main/packages/types) (Types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_packages["Packages"]
  node_web_api["Web API<br/>client package"]
  node_web_client["WebClient<br/>API client<br/>[WebClient.ts]"]
  node_web_methods["Methods<br/>method surface<br/>[methods.ts]"]
  node_web_types["Req/Resp types<br/>schema trees"]
  node_socket_mode["Socket Mode<br/>realtime package"]
  node_socket_client["SocketModeClient<br/>ws client"]
  node_rtm_api["RTM API<br/>legacy realtime package"]
  node_rtm_client["RTMClient<br/>ws client<br/>[RTMClient.ts]"]
  node_oauth["OAuth<br/>auth package"]
  node_install_provider["InstallProvider<br/>oauth flow"]
  node_webhook["Webhook<br/>delivery package"]
  node_incoming_webhook["IncomingWebhook<br/>http sender<br/>[IncomingWebhook.ts]"]
  node_types["Types<br/>shared schema"]
  node_logger["Logger<br/>shared utility"]
end

subgraph group_grp_tooling["Tooling"]
  node_examples["Examples<br/>sample apps"]
  node_prod_tests["Prod tests<br/>live integration"]
  node_scripts["Scripts<br/>build automation"]
  node_docs["Docs<br/>documentation"]
end

node_root["Node Slack SDK<br/>monorepo"]

node_root -->|"contains"| node_web_api
node_root -->|"contains"| node_socket_mode
node_root -->|"contains"| node_rtm_api
node_root -->|"contains"| node_oauth
node_root -->|"contains"| node_webhook
node_root -->|"contains"| node_types
node_root -->|"contains"| node_logger
node_web_api -->|"implements"| node_web_client
node_web_api -->|"defines"| node_web_methods
node_web_api -->|"shapes"| node_web_types
node_web_api -->|"depends on"| node_types
node_web_api -->|"uses"| node_logger
node_socket_mode -->|"implements"| node_socket_client
node_socket_mode -->|"depends on"| node_types
node_socket_mode -->|"uses"| node_logger
node_rtm_api -->|"implements"| node_rtm_client
node_rtm_api -->|"depends on"| node_types
node_rtm_api -->|"uses"| node_logger
node_oauth -->|"implements"| node_install_provider
node_oauth -->|"depends on"| node_types
node_oauth -->|"uses"| node_logger
node_webhook -->|"implements"| node_incoming_webhook
node_webhook -->|"uses"| node_logger
node_examples -->|"shows"| node_socket_mode
node_examples -->|"shows"| node_oauth
node_prod_tests -->|"verifies"| node_web_api
node_prod_tests -->|"verifies"| node_socket_mode
node_scripts -->|"generates"| node_web_api
node_scripts -->|"generates"| node_types
node_docs -->|"documents"| node_web_api
node_docs -->|"documents"| node_socket_mode
node_docs -->|"documents"| node_rtm_api
node_docs -->|"documents"| node_oauth
node_docs -->|"documents"| node_webhook
node_docs -->|"documents"| node_types

click node_web_api "https://github.com/slackapi/node-slack-sdk/tree/main/packages/web-api"
click node_web_client "https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/WebClient.ts"
click node_web_methods "https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/methods.ts"
click node_web_types "https://github.com/slackapi/node-slack-sdk/tree/main/packages/web-api/src/types"
click node_socket_mode "https://github.com/slackapi/node-slack-sdk/tree/main/packages/socket-mode"
click node_socket_client "https://github.com/slackapi/node-slack-sdk/blob/main/packages/socket-mode/src/SocketModeClient.ts"
click node_rtm_api "https://github.com/slackapi/node-slack-sdk/tree/main/packages/rtm-api"
click node_rtm_client "https://github.com/slackapi/node-slack-sdk/blob/main/packages/rtm-api/src/RTMClient.ts"
click node_oauth "https://github.com/slackapi/node-slack-sdk/tree/main/packages/oauth"
click node_install_provider "https://github.com/slackapi/node-slack-sdk/blob/main/packages/oauth/src/install-provider.ts"
click node_webhook "https://github.com/slackapi/node-slack-sdk/tree/main/packages/webhook"
click node_incoming_webhook "https://github.com/slackapi/node-slack-sdk/blob/main/packages/webhook/src/IncomingWebhook.ts"
click node_types "https://github.com/slackapi/node-slack-sdk/tree/main/packages/types"
click node_logger "https://github.com/slackapi/node-slack-sdk/tree/main/packages/logger"
click node_examples "https://github.com/slackapi/node-slack-sdk/tree/main/examples"
click node_prod_tests "https://github.com/slackapi/node-slack-sdk/tree/main/prod-server-integration-tests"
click node_scripts "https://github.com/slackapi/node-slack-sdk/tree/main/scripts"
click node_docs "https://github.com/slackapi/node-slack-sdk/tree/main/docs/english"

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_web_api,node_web_client,node_web_methods,node_web_types,node_socket_mode,node_socket_client,node_rtm_api,node_rtm_client,node_oauth,node_install_provider,node_webhook,node_incoming_webhook,node_types,node_logger toneBlue
class node_examples,node_prod_tests,node_scripts,node_docs toneAmber
class node_root toneNeutral
```

## Components

### Packages

Publishable SDK packages and shared libraries.

- [Web API](https://github.com/slackapi/node-slack-sdk/tree/main/packages/web-api): client package · Primary outbound Slack API client over HTTPS. · `packages/web-api`
- [WebClient](https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/WebClient.ts): API client · Routes Slack method calls, retries, errors, uploads, and chat streaming. · `packages/web-api/src/WebClient.ts`
- [Methods](https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/methods.ts): method surface · Method surface and generated call signatures. · `packages/web-api/src/methods.ts`
- [Req/Resp types](https://github.com/slackapi/node-slack-sdk/tree/main/packages/web-api/src/types): schema trees · Request and response type trees for Slack Web API methods. · `packages/web-api/src/types`
- [Socket Mode](https://github.com/slackapi/node-slack-sdk/tree/main/packages/socket-mode): realtime package · Newer inbound event delivery over Slack WebSockets. · `packages/socket-mode`
- [SocketModeClient](https://github.com/slackapi/node-slack-sdk/blob/main/packages/socket-mode/src/SocketModeClient.ts): ws client · Manages Socket Mode connection lifecycle, acking, and recoverable errors. · `packages/socket-mode/src/SocketModeClient.ts`
- [RTM API](https://github.com/slackapi/node-slack-sdk/tree/main/packages/rtm-api): legacy realtime package · Legacy real-time Slack chat/event stream over WebSockets. · `packages/rtm-api`
- [RTMClient](https://github.com/slackapi/node-slack-sdk/blob/main/packages/rtm-api/src/RTMClient.ts): ws client · Manages RTM connection lifecycle, replies, and connection errors. · `packages/rtm-api/src/RTMClient.ts`
- [OAuth](https://github.com/slackapi/node-slack-sdk/tree/main/packages/oauth): auth package · Installation, authorization, state, and token exchange flow. · `packages/oauth`
- [InstallProvider](https://github.com/slackapi/node-slack-sdk/blob/main/packages/oauth/src/install-provider.ts): oauth flow · Generates install URLs, handles callbacks, validates state, and persists installations. · `packages/oauth/src/install-provider.ts`
- [Webhook](https://github.com/slackapi/node-slack-sdk/tree/main/packages/webhook): delivery package · Sends a single payload to a Slack incoming webhook URL. · `packages/webhook`
- [IncomingWebhook](https://github.com/slackapi/node-slack-sdk/blob/main/packages/webhook/src/IncomingWebhook.ts): http sender · Narrow stateless HTTP sender for incoming webhooks. · `packages/webhook/src/IncomingWebhook.ts`
- [Types](https://github.com/slackapi/node-slack-sdk/tree/main/packages/types): shared schema · Canonical Slack payload models shared across packages. · `packages/types`
- [Logger](https://github.com/slackapi/node-slack-sdk/tree/main/packages/logger): shared utility · Shared logging interface and log levels used by client packages. · `packages/logger`

### Tooling

Repo automation, docs, examples, and validation.

- [Examples](https://github.com/slackapi/node-slack-sdk/tree/main/examples): sample apps · Reference apps demonstrating package composition. · `examples`
- [Prod tests](https://github.com/slackapi/node-slack-sdk/tree/main/prod-server-integration-tests): live integration · End-to-end validation against real Slack servers and manifests. · `prod-server-integration-tests`
- [Scripts](https://github.com/slackapi/node-slack-sdk/tree/main/scripts): build automation · Code generation and release/build automation, including Web API type generation. · `scripts`
- [Docs](https://github.com/slackapi/node-slack-sdk/tree/main/docs/english): documentation · Published documentation tree aligned to the package boundaries. · `docs/english`

### Other components

- **Node Slack SDK**: monorepo · Top-level monorepo for the Slack SDK packages.

## Connections

- Node Slack SDK → Web API: contains
- Node Slack SDK → Socket Mode: contains
- Node Slack SDK → RTM API: contains
- Node Slack SDK → OAuth: contains
- Node Slack SDK → Webhook: contains
- Node Slack SDK → Types: contains
- Node Slack SDK → Logger: contains
- Web API → WebClient: implements
- Web API → Methods: defines
- Web API → Req/Resp types: shapes
- Web API → Types: depends on
- Web API → Logger: uses
- Socket Mode → SocketModeClient: implements
- Socket Mode → Types: depends on
- Socket Mode → Logger: uses
- RTM API → RTMClient: implements
- RTM API → Types: depends on
- RTM API → Logger: uses
- OAuth → InstallProvider: implements
- OAuth → Types: depends on
- OAuth → Logger: uses
- Webhook → IncomingWebhook: implements
- Webhook → Logger: uses
- Examples → Socket Mode: shows
- Examples → OAuth: shows
- Prod tests → Web API: verifies
- Prod tests → Socket Mode: verifies
- Scripts → Web API: generates
- Scripts → Types: generates
- Docs → Web API: documents
- Docs → Socket Mode: documents
- Docs → RTM API: documents
- Docs → OAuth: documents
- Docs → Webhook: documents
- Docs → Types: documents
