# devscord-team/watchman architecture

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

- Interactive diagram: https://gitdiagram.com/devscord-team/watchman
- Repository: https://github.com/devscord-team/watchman

## Overview

Watchman is a Discord moderation and server-management bot built on Devscord.DiscordFramework. A Discord message enters the framework’s middleware and router, reaches a Watchman controller or command, then domain operations can query or change persisted server data; responses and moderation actions return through Discord integration services. The tree also shows distinct capabilities for spam protection, muting, warnings, configuration, roles, custom commands, help, and event responses. Source samples chiefly establish database-backed query behavior; links among unsampled controllers, handlers, and services are shown only at the subsystem level.

Main entry points: [`Watchman.Discord/Areas`](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas) (Feature controllers), [`Watchman.Cqrs/QueryBus.cs`](https://github.com/devscord-team/watchman/blob/master/Watchman.Cqrs/QueryBus.cs) (Query bus), [`Devscord.DiscordFramework/Integration/Services/DiscordClient.cs`](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Integration/Services/DiscordClient.cs) (Discord API), [`Watchman.Discord/Areas/Muting`](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Muting) (Muting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Discord runtime"]
  node_bot["Watchman bot<br/>[WatchmanBot.cs]"]
  node_framework["Discord framework<br/>[Workflow.cs]"]
  node_middleware["Message middleware"]
  node_router["Command router<br/>[Router.cs]"]
  node_commandservice["Command service"]
end

subgraph group_features["Bot features"]
  node_controllers["Feature controllers<br/>[Areas]"]
  node_antispam["Spam protection<br/>[AntiSpam]"]
  node_muting["Muting<br/>[Muting]"]
  node_warns["Warnings<br/>[Warns]"]
  node_admin["Administration<br/>[Administration]"]
  node_configuration["Configuration<br/>[Configurations]"]
  node_customcommands["Custom commands<br/>[CustomCommands]"]
  node_help["Help<br/>[Help]"]
  node_responses["Custom responses<br/>[Responses]"]
  node_messaging["Messaging and users<br/>[Messaging]"]
end

subgraph group_domain["Domain and CQRS"]
  node_commandbus["Command bus<br/>[CommandBus.cs]"]
  node_querybus["Query bus<br/>[QueryBus.cs]"]
  node_handlers["Domain handlers"]
end

subgraph group_integrations["External integration"]
  node_mongostore[("Mongo session store")]
  node_discordapi["Discord API<br/>[DiscordClient.cs]"]
  node_discordservices["Discord services<br/>[MessagesService.cs]"]
end

node_discord(("Discord users"))

node_discord -->|"sends events"| node_discordapi
node_discordapi -->|"delivers events"| node_framework
node_framework -->|"runs pipeline"| node_middleware
node_middleware -->|"passes context"| node_router
node_router -->|"dispatches commands"| node_commandservice
node_commandservice -->|"invokes handlers"| node_controllers
node_controllers -->|"routes protection"| node_antispam
node_controllers -->|"routes mute actions"| node_muting
node_controllers -->|"routes warning actions"| node_warns
node_controllers -->|"routes administration"| node_admin
node_controllers -->|"routes settings"| node_configuration
node_controllers -->|"routes commands"| node_customcommands
node_controllers -->|"routes help"| node_help
node_controllers -->|"routes response actions"| node_responses
node_controllers -->|"routes messaging"| node_messaging
node_antispam -->|"queries protection data"| node_querybus
node_muting -->|"dispatches mute operations"| node_commandbus
node_muting -->|"queries mute events"| node_querybus
node_warns -->|"queries warnings"| node_querybus
node_configuration -->|"queries settings"| node_querybus
node_admin -->|"dispatches role changes"| node_commandbus
node_customcommands -->|"queries commands"| node_querybus
node_help -->|"queries help data"| node_querybus
node_responses -->|"queries responses"| node_querybus
node_commandbus -->|"dispatches commands"| node_handlers
node_querybus -->|"dispatches queries"| node_handlers
node_handlers -->|"reads and writes"| node_mongostore
node_messaging -->|"sends messages"| node_discordservices
node_discordservices -->|"uses client"| node_discordapi
node_discordapi -->|"sends responses"| node_discord

click node_bot "https://github.com/devscord-team/watchman/blob/master/Watchman.Discord/WatchmanBot.cs"
click node_framework "https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Workflow.cs"
click node_middleware "https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Middlewares/MiddlewaresRunner.cs"
click node_router "https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Routing/Router.cs"
click node_commandservice "https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Commands/Services/BotCommandsService.cs"
click node_controllers "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas"
click node_antispam "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/AntiSpam"
click node_muting "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Muting"
click node_warns "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Warns"
click node_admin "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Administration"
click node_configuration "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Configurations"
click node_customcommands "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/CustomCommands"
click node_help "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Help"
click node_responses "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Responses"
click node_messaging "https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Messaging"
click node_commandbus "https://github.com/devscord-team/watchman/blob/master/Watchman.Cqrs/CommandBus.cs"
click node_querybus "https://github.com/devscord-team/watchman/blob/master/Watchman.Cqrs/QueryBus.cs"
click node_handlers "https://github.com/devscord-team/watchman/tree/master/Watchman.DomainModel"
click node_discordapi "https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Integration/Services/DiscordClient.cs"
click node_discordservices "https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Services/MessagesService.cs"

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_bot,node_framework,node_middleware,node_router,node_commandservice,node_discord toneBlue
class node_controllers,node_antispam,node_muting,node_warns,node_admin,node_configuration,node_customcommands,node_help,node_responses,node_messaging toneAmber
class node_commandbus,node_querybus,node_handlers toneMint
class node_mongostore,node_discordapi,node_discordservices toneRose
```

## Components

### Discord runtime

- [Watchman bot](https://github.com/devscord-team/watchman/blob/master/Watchman.Discord/WatchmanBot.cs): `Watchman.Discord/WatchmanBot.cs`
- [Discord framework](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Workflow.cs): `Devscord.DiscordFramework/Workflow.cs`
- [Message middleware](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Middlewares/MiddlewaresRunner.cs): `Devscord.DiscordFramework/Middlewares/MiddlewaresRunner.cs`
- [Command router](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Routing/Router.cs): `Devscord.DiscordFramework/Routing/Router.cs`
- [Command service](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Commands/Services/BotCommandsService.cs): `Devscord.DiscordFramework/Commands/Services/BotCommandsService.cs`

### Bot features

- [Feature controllers](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas): `Watchman.Discord/Areas`
- [Spam protection](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/AntiSpam): `Watchman.Discord/Areas/AntiSpam`
- [Muting](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Muting): `Watchman.Discord/Areas/Muting`
- [Warnings](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Warns): `Watchman.Discord/Areas/Warns`
- [Administration](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Administration): `Watchman.Discord/Areas/Administration`
- [Configuration](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Configurations): `Watchman.Discord/Areas/Configurations`
- [Custom commands](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/CustomCommands): `Watchman.Discord/Areas/CustomCommands`
- [Help](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Help): `Watchman.Discord/Areas/Help`
- [Custom responses](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Responses): `Watchman.Discord/Areas/Responses`
- [Messaging and users](https://github.com/devscord-team/watchman/tree/master/Watchman.Discord/Areas/Messaging): `Watchman.Discord/Areas/Messaging`

### Domain and CQRS

- [Command bus](https://github.com/devscord-team/watchman/blob/master/Watchman.Cqrs/CommandBus.cs): `Watchman.Cqrs/CommandBus.cs`
- [Query bus](https://github.com/devscord-team/watchman/blob/master/Watchman.Cqrs/QueryBus.cs): `Watchman.Cqrs/QueryBus.cs`
- [Domain handlers](https://github.com/devscord-team/watchman/tree/master/Watchman.DomainModel): `Watchman.DomainModel`

### External integration

- **Mongo session store**
- [Discord API](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Integration/Services/DiscordClient.cs): `Devscord.DiscordFramework/Integration/Services/DiscordClient.cs`
- [Discord services](https://github.com/devscord-team/watchman/blob/master/Devscord.DiscordFramework/Services/MessagesService.cs): `Devscord.DiscordFramework/Services/MessagesService.cs`

### Other components

- **Discord users**

## Connections

- Discord users → Discord API: sends events
- Discord API → Discord framework: delivers events
- Discord framework → Message middleware: runs pipeline
- Message middleware → Command router: passes context
- Command router → Command service: dispatches commands
- Command service → Feature controllers: invokes handlers
- Feature controllers → Spam protection: routes protection
- Feature controllers → Muting: routes mute actions
- Feature controllers → Warnings: routes warning actions
- Feature controllers → Administration: routes administration
- Feature controllers → Configuration: routes settings
- Feature controllers → Custom commands: routes commands
- Feature controllers → Help: routes help
- Feature controllers → Custom responses: routes response actions
- Feature controllers → Messaging and users: routes messaging
- Spam protection → Query bus: queries protection data
- Muting → Command bus: dispatches mute operations
- Muting → Query bus: queries mute events
- Warnings → Query bus: queries warnings
- Configuration → Query bus: queries settings
- Administration → Command bus: dispatches role changes
- Custom commands → Query bus: queries commands
- Help → Query bus: queries help data
- Custom responses → Query bus: queries responses
- Command bus → Domain handlers: dispatches commands
- Query bus → Domain handlers: dispatches queries
- Domain handlers → Mongo session store: reads and writes
- Messaging and users → Discord services: sends messages
- Discord services → Discord API: uses client
- Discord API → Discord users: sends responses
