# pandorasfox/dms-discord-widget architecture

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

- Interactive diagram: https://gitdiagram.com/pandorasfox/dms-discord-widget
- Repository: https://github.com/pandorasfox/dms-discord-widget

## Overview

This repo is a small DankMaterialShell plugin that adds a Discord voice status widget to DankBar. It is not a standalone app; it plugs into DMS through the plugin system described by `plugin.json` and the QML components.

The architecture has three main parts:
1. **UI widget layer**: `DiscordVoiceWidget.qml`
2. **Settings/configuration layer**: `DiscordVoiceSettings.qml`
3. **Local Python bridge**: `discord_bridge.py`

The **widget layer** is the visible runtime surface in the bar and the popout. It renders Discord voice participants as circular avatars and shows live status indicators for speaking, mute, and deafen states. The widget also acts as the user entry point for authorization and for opening the popout.

The **settings layer** exposes plugin configuration inside DMS Settings. From the README, the only explicit setting is the maximum number of avatars shown in the bar. This implies the widget is designed to adapt its layout based on a user-defined cap rather than showing the full channel roster unbounded.

The **Python bridge** is the backend component that likely handles Discord communication and state synchronization. It requires Python 3.10+, which is important because it means the plugin depends on a local Python runtime rather than only QML/Qt. Its job is to connect to Discord after authorization, track voice participants and speaking state, and expose data/actions back to the QML side.

A key architectural boundary is the **authorization flow**. The user clicks “Authorize Discord,” Discord presents a consent dialog, and once authorized the plugin auto-connects on later launches. This suggests the bridge persists credentials/tokens locally and reuses them to restore state without repeating setup.

Another important boundary is the **IPC command interface**. The plugin registers an IPC target named `discord`, exposing command-style actions such as mute/deafen toggles and a status query. This makes the plugin controllable from outside the widget, so keybinds or compositor bindings can drive Discord voice state independently of the UI.

The **data flow** is likely:
Discord authorization and voice presence data -> Python bridge -> QML widget state -> bar/popout rendering.
In the opposite direction:
UI clicks or IPC calls -> Python bridge -> Discord mute/deafen actions.

The **runtime model** is local and event-driven. There is no evidence of a remote service hosted by the repo itself; instead it integrates with Discord and DMS on the user’s machine. The architecture therefore centers on local state propagation and UI synchronization rather than networked backend services.

The repo’s **integration surface with DankMaterialShell** is the plugin mechanism: the manifest plus QML files allow DMS to discover the plugin, present it in the plugin browser, and mount the widget/settings UI into the shell. The manual install path in the README reinforces that this is a drop-in plugin directory under the DMS plugins path.

For an architecture diagram, the clearest boxes are:
- **DankMaterialShell / DankBar**
- **Discord Voice widget UI (QML)**
- **Discord Voice settings UI (QML)**
- **Python Discord bridge**
- **Discord API / OAuth consent**
- **DMS IPC callers** for mute/deafen/status commands

The main boundaries to show are UI vs bridge, local plugin vs Discord network service, and interactive widget controls vs external IPC control.

Main entry points: [`discord_bridge.py`](https://github.com/pandorasfox/dms-discord-widget/blob/master/discord_bridge.py) (Discord bridge), [`DiscordVoiceWidget.qml`](https://github.com/pandorasfox/dms-discord-widget/blob/master/DiscordVoiceWidget.qml) (Voice widget), [`plugin.json`](https://github.com/pandorasfox/dms-discord-widget/blob/master/plugin.json) (Plugin manifest), [`DiscordVoiceSettings.qml`](https://github.com/pandorasfox/dms-discord-widget/blob/master/DiscordVoiceSettings.qml) (Settings panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_shell["DMS integration"]
  node_node_dms["DankMaterialShell<br/>host shell"]
  node_node_manifest["Plugin manifest<br/>plugin metadata<br/>[plugin.json]"]
end

subgraph group_group_ui["QML UI"]
  node_node_widget["Voice widget<br/>QML widget"]
  node_node_settings["Settings panel<br/>QML settings"]
end

subgraph group_group_backend["Local backend"]
  node_node_bridge["Discord bridge<br/>Python backend<br/>[discord_bridge.py]"]
end

subgraph group_group_external["External systems"]
  node_node_auth(("Authorize flow<br/>oauth handshake"))
  node_node_discord["Discord<br/>api/service"]
  node_node_ipc(("IPC callers<br/>external control"))
end

node_node_dms -->|"discovers"| node_node_manifest
node_node_manifest -->|"mounts"| node_node_widget
node_node_manifest -->|"registers"| node_node_settings
node_node_widget -->|"reads state"| node_node_bridge
node_node_widget -->|"sends actions"| node_node_bridge
node_node_settings -->|"configures"| node_node_widget
node_node_bridge -->|"requests consent"| node_node_auth
node_node_auth -->|"grants access"| node_node_discord
node_node_bridge -->|"syncs voice"| node_node_discord
node_node_ipc -->|"commands"| node_node_bridge
node_node_bridge -.->|"exposes target"| node_node_ipc
node_node_bridge -->|"publishes updates"| node_node_widget

click node_node_manifest "https://github.com/pandorasfox/dms-discord-widget/blob/master/plugin.json"
click node_node_widget "https://github.com/pandorasfox/dms-discord-widget/blob/master/DiscordVoiceWidget.qml"
click node_node_settings "https://github.com/pandorasfox/dms-discord-widget/blob/master/DiscordVoiceSettings.qml"
click node_node_bridge "https://github.com/pandorasfox/dms-discord-widget/blob/master/discord_bridge.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_node_dms,node_node_manifest toneBlue
class node_node_widget,node_node_settings toneAmber
class node_node_bridge toneMint
class node_node_auth,node_node_discord,node_node_ipc toneRose
```

## Components

### DMS integration

Plugin discovery and mounting inside DankMaterialShell / DankBar.

- **DankMaterialShell**: host shell · The host environment that loads the plugin, renders the bar widget, and mounts settings UI.
- [Plugin manifest](https://github.com/pandorasfox/dms-discord-widget/blob/master/plugin.json): plugin metadata · Declares the plugin to DMS and wires the package into the shell. · `plugin.json`

### QML UI

Visible widget and settings surfaces implemented in QML.

- [Voice widget](https://github.com/pandorasfox/dms-discord-widget/blob/master/DiscordVoiceWidget.qml): QML widget · Bar and popout UI that shows Discord voice participants and live speaking/mute/deafen status. · `DiscordVoiceWidget.qml`
- [Settings panel](https://github.com/pandorasfox/dms-discord-widget/blob/master/DiscordVoiceSettings.qml): QML settings · Configuration UI exposed in DMS Settings, including the avatar display cap. · `DiscordVoiceSettings.qml`

### Local backend

Python bridge that manages Discord state and actions.

- [Discord bridge](https://github.com/pandorasfox/dms-discord-widget/blob/master/discord_bridge.py): Python backend · Local Python runtime that connects to Discord, syncs voice presence, and performs state-changing actions. · `discord_bridge.py`

### External systems

Discord and other local callers outside the plugin UI.

- **Authorize flow**: oauth handshake · User consent path used to grant the plugin access and establish a reusable local connection state.
- **Discord**: api/service · Discord voice and authorization endpoints consumed by the bridge.
- **IPC callers**: external control · Keybinds or other local automation that invoke discord commands outside the widget.

## Connections

- DankMaterialShell → Plugin manifest: discovers · DMS loads the plugin through its manifest.
- Plugin manifest → Voice widget: mounts · The manifest exposes the widget surface to the shell.
- Plugin manifest → Settings panel: registers · The manifest exposes the settings surface to DMS Settings.
- Voice widget → Discord bridge: reads state · The QML widget consumes participant and status data from the Python bridge.
- Voice widget → Discord bridge: sends actions · Widget controls trigger authorization and voice-state actions through the bridge.
- Settings panel → Voice widget: configures · Settings adjust widget behavior such as avatar limits.
- Discord bridge → Authorize flow: requests consent · The bridge initiates the Discord authorization flow.
- Authorize flow → Discord: grants access · User consent enables the plugin to talk to Discord.
- Discord bridge → Discord: syncs voice · The bridge tracks voice participants and speaking state from Discord.
- IPC callers → Discord bridge: commands · External IPC target actions invoke mute, deafen, and status operations.
- Discord bridge → IPC callers: exposes target · The bridge provides the discord IPC command surface.
- Discord bridge → Voice widget: publishes updates · Backend state changes are reflected back into the visible widget.
