# dico-api/dico architecture

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

- Interactive diagram: https://gitdiagram.com/dico-api/dico
- Repository: https://github.com/dico-api/dico

## Overview

dico is a Python Discord API wrapper. In the API-only workflow, a caller uses APIClient to invoke an endpoint; the client delegates HTTP work and converts responses into Discord models. The gateway workflow connects Client to Discord’s gateway, dispatches events to registered handlers, and can establish voice connections. The model layer covers Discord entities, permissions, gateway payloads, and interactions. README documents API-only and interaction support; source excerpts are partial, so unsampled subsystem links are omitted where their runtime wiring is not evidenced.

Main entry points: [`dico/model/channel.py`](https://github.com/dico-api/dico/blob/master/dico/model/channel.py) (Channels and messages), [`dico/api.py`](https://github.com/dico-api/dico/blob/master/dico/api.py) (API client), [`dico/model/guild.py`](https://github.com/dico-api/dico/blob/master/dico/model/guild.py) (Guilds and events), [`dico/base/model.py`](https://github.com/dico-api/dico/blob/master/dico/base/model.py) (Model base)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API requests"]
  node_api_client["API client<br/>[api.py]"]
end

subgraph group_gateway["Gateway events"]
  node_client["Gateway client<br/>[client.py]"]
  node_gateway_ws["Gateway websocket<br/>[websocket.py]"]
  node_event_handlers["Event handlers<br/>[handler.py]"]
end

subgraph group_models["Discord models"]
  node_gateway_models["Gateway payloads<br/>[gateway.py]"]
  node_events["Event models<br/>[event.py]"]
  node_interactions["Interactions<br/>[interactions.py]"]
  node_channels["Channels and messages<br/>[channel.py]"]
  node_guilds["Guilds and events<br/>[guild.py]"]
  node_users["Users and roles<br/>[user.py]"]
  node_permissions["Permissions<br/>[permission.py]"]
  node_base_models["Model base<br/>[model.py]"]
  node_snowflakes["Snowflake IDs<br/>[snowflake.py]"]
end

subgraph group_voice["Voice"]
  node_voice_client["Voice client<br/>[client.py]"]
  node_voice_ws["Voice websocket<br/>[websocket.py]"]
  node_voice_codec["Opus codec<br/>[opus.py]"]
end

subgraph group_transport["Transport"]
  node_http_base["HTTP interface<br/>[http.py]"]
  node_http_sync["Requests transport<br/>[request.py]"]
  node_http_async["Async transport<br/>[async_http.py]"]
  node_http_rate["HTTP rate limits<br/>[ratelimit.py]"]
end

node_caller(("Application"))
node_discord_api(("Discord API"))

node_caller -->|"calls endpoints"| node_api_client
node_api_client -->|"delegates requests"| node_http_base
node_http_sync -->|"implements"| node_http_base
node_http_async -->|"implements"| node_http_base
node_http_async -->|"uses limits"| node_http_rate
node_http_base -.->|"sends requests"| node_discord_api
node_api_client -->|"creates responses"| node_channels
node_api_client -->|"creates responses"| node_guilds
node_client -->|"uses API"| node_api_client
node_client -->|"connects"| node_gateway_ws
node_gateway_ws -->|"dispatches events"| node_event_handlers
node_gateway_ws -->|"uses transport"| node_http_async
node_gateway_ws -->|"uses payloads"| node_gateway_models
node_event_handlers -->|"dispatches model events"| node_events
node_client -->|"connects voice"| node_voice_client
node_voice_client -->|"uses websocket"| node_voice_ws
node_voice_client -->|"encodes audio"| node_voice_codec
node_voice_ws -->|"uses codec"| node_voice_codec
node_events -->|"references entities"| node_channels
node_events -->|"references entities"| node_guilds
node_events -->|"references interactions"| node_interactions
node_channels -->|"references guilds"| node_guilds
node_channels -->|"uses permissions"| node_permissions
node_users -->|"uses channels"| node_channels
node_guilds -->|"uses channels"| node_channels
node_channels -->|"inherits model base"| node_base_models
node_guilds -->|"inherits model base"| node_base_models
node_users -->|"inherits model base"| node_base_models
node_permissions -->|"inherits model base"| node_base_models
node_base_models -->|"uses IDs"| node_snowflakes

click node_api_client "https://github.com/dico-api/dico/blob/master/dico/api.py"
click node_http_base "https://github.com/dico-api/dico/blob/master/dico/base/http.py"
click node_http_sync "https://github.com/dico-api/dico/blob/master/dico/http/request.py"
click node_http_async "https://github.com/dico-api/dico/blob/master/dico/http/async_http.py"
click node_http_rate "https://github.com/dico-api/dico/blob/master/dico/http/ratelimit.py"
click node_client "https://github.com/dico-api/dico/blob/master/dico/client.py"
click node_gateway_ws "https://github.com/dico-api/dico/blob/master/dico/ws/websocket.py"
click node_event_handlers "https://github.com/dico-api/dico/blob/master/dico/handler.py"
click node_gateway_models "https://github.com/dico-api/dico/blob/master/dico/model/gateway.py"
click node_events "https://github.com/dico-api/dico/blob/master/dico/model/event.py"
click node_interactions "https://github.com/dico-api/dico/blob/master/dico/model/interactions/interactions.py"
click node_channels "https://github.com/dico-api/dico/blob/master/dico/model/channel.py"
click node_guilds "https://github.com/dico-api/dico/blob/master/dico/model/guild.py"
click node_users "https://github.com/dico-api/dico/blob/master/dico/model/user.py"
click node_permissions "https://github.com/dico-api/dico/blob/master/dico/model/permission.py"
click node_base_models "https://github.com/dico-api/dico/blob/master/dico/base/model.py"
click node_snowflakes "https://github.com/dico-api/dico/blob/master/dico/model/snowflake.py"
click node_voice_client "https://github.com/dico-api/dico/blob/master/dico/voice/client.py"
click node_voice_ws "https://github.com/dico-api/dico/blob/master/dico/voice/websocket.py"
click node_voice_codec "https://github.com/dico-api/dico/blob/master/dico/voice/opus.py"

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_api_client toneBlue
class node_client,node_gateway_ws,node_event_handlers toneAmber
class node_gateway_models,node_events,node_interactions,node_channels,node_guilds,node_users,node_permissions,node_base_models,node_snowflakes,node_discord_api toneMint
class node_voice_client,node_voice_ws,node_voice_codec toneRose
class node_http_base,node_http_sync,node_http_async,node_http_rate,node_caller toneIndigo
```

## Components

### API requests

- [API client](https://github.com/dico-api/dico/blob/master/dico/api.py): `dico/api.py`

### Gateway events

- [Gateway client](https://github.com/dico-api/dico/blob/master/dico/client.py): `dico/client.py`
- [Gateway websocket](https://github.com/dico-api/dico/blob/master/dico/ws/websocket.py): `dico/ws/websocket.py`
- [Event handlers](https://github.com/dico-api/dico/blob/master/dico/handler.py): `dico/handler.py`

### Discord models

- [Gateway payloads](https://github.com/dico-api/dico/blob/master/dico/model/gateway.py): `dico/model/gateway.py`
- [Event models](https://github.com/dico-api/dico/blob/master/dico/model/event.py): `dico/model/event.py`
- [Interactions](https://github.com/dico-api/dico/blob/master/dico/model/interactions/interactions.py): `dico/model/interactions/interactions.py`
- [Channels and messages](https://github.com/dico-api/dico/blob/master/dico/model/channel.py): `dico/model/channel.py`
- [Guilds and events](https://github.com/dico-api/dico/blob/master/dico/model/guild.py): `dico/model/guild.py`
- [Users and roles](https://github.com/dico-api/dico/blob/master/dico/model/user.py): `dico/model/user.py`
- [Permissions](https://github.com/dico-api/dico/blob/master/dico/model/permission.py): `dico/model/permission.py`
- [Model base](https://github.com/dico-api/dico/blob/master/dico/base/model.py): `dico/base/model.py`
- [Snowflake IDs](https://github.com/dico-api/dico/blob/master/dico/model/snowflake.py): `dico/model/snowflake.py`

### Voice

- [Voice client](https://github.com/dico-api/dico/blob/master/dico/voice/client.py): `dico/voice/client.py`
- [Voice websocket](https://github.com/dico-api/dico/blob/master/dico/voice/websocket.py): `dico/voice/websocket.py`
- [Opus codec](https://github.com/dico-api/dico/blob/master/dico/voice/opus.py): `dico/voice/opus.py`

### Transport

- [HTTP interface](https://github.com/dico-api/dico/blob/master/dico/base/http.py): `dico/base/http.py`
- [Requests transport](https://github.com/dico-api/dico/blob/master/dico/http/request.py): `dico/http/request.py`
- [Async transport](https://github.com/dico-api/dico/blob/master/dico/http/async_http.py): `dico/http/async_http.py`
- [HTTP rate limits](https://github.com/dico-api/dico/blob/master/dico/http/ratelimit.py): `dico/http/ratelimit.py`

### Other components

- **Application**
- **Discord API**

## Connections

- Application → API client: calls endpoints
- API client → HTTP interface: delegates requests (evidence: `dico/api.py`)
- Requests transport → HTTP interface: implements (evidence: `dico/http/request.py`)
- Async transport → HTTP interface: implements (evidence: `dico/http/async_http.py`)
- Async transport → HTTP rate limits: uses limits (evidence: `dico/http/async_http.py`)
- HTTP interface → Discord API: sends requests
- API client → Channels and messages: creates responses (evidence: `dico/api.py`)
- API client → Guilds and events: creates responses (evidence: `dico/api.py`)
- Gateway client → API client: uses API (evidence: `dico/client.py`)
- Gateway client → Gateway websocket: connects (evidence: `dico/client.py`)
- Gateway websocket → Event handlers: dispatches events (evidence: `dico/ws/websocket.py`)
- Gateway websocket → Async transport: uses transport (evidence: `dico/ws/websocket.py`)
- Gateway websocket → Gateway payloads: uses payloads (evidence: `dico/ws/websocket.py`)
- Event handlers → Event models: dispatches model events (evidence: `dico/handler.py`)
- Gateway client → Voice client: connects voice (evidence: `dico/client.py`)
- Voice client → Voice websocket: uses websocket (evidence: `dico/voice/client.py`)
- Voice client → Opus codec: encodes audio (evidence: `dico/voice/client.py`)
- Voice websocket → Opus codec: uses codec (evidence: `dico/voice/websocket.py`)
- Event models → Channels and messages: references entities (evidence: `dico/model/event.py`)
- Event models → Guilds and events: references entities (evidence: `dico/model/event.py`)
- Event models → Interactions: references interactions (evidence: `dico/model/event.py`)
- Channels and messages → Guilds and events: references guilds (evidence: `dico/model/channel.py`)
- Channels and messages → Permissions: uses permissions (evidence: `dico/model/channel.py`)
- Users and roles → Channels and messages: uses channels (evidence: `dico/model/user.py`)
- Guilds and events → Channels and messages: uses channels (evidence: `dico/model/guild.py`)
- Channels and messages → Model base: inherits model base (evidence: `dico/model/channel.py`)
- Guilds and events → Model base: inherits model base (evidence: `dico/model/guild.py`)
- Users and roles → Model base: inherits model base (evidence: `dico/model/user.py`)
- Permissions → Model base: inherits model base (evidence: `dico/model/permission.py`)
- Model base → Snowflake IDs: uses IDs (evidence: `dico/base/model.py`)
