# theeussx/wardizitto architecture

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

- Interactive diagram: https://gitdiagram.com/theeussx/wardizitto
- Repository: https://github.com/theeussx/wardizitto

## Overview

Wardizitto v2 is a modular Discord bot for community administration, moderation, economy, and social features. Its principal workflow starts with a Discord interaction or message, routes it through command/component handling and access controls, then invokes a feature handler that performs its domain work and, where applicable, uses database or external-service infrastructure. The README documents this layered flow and the feature set; unsampled feature implementations are represented by their existing module directories. Their specific call paths are not inferred where excerpts do not show them.

Main entry points: [`src/application/wardizitto-application.ts`](https://github.com/theeussx/wardizitto/blob/main/src/application/wardizitto-application.ts) (Application wiring), [`src/presentation/discord/handlers/interaction-router.ts`](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/interaction-router.ts) (Interaction router), [`src/application/ports/database.ts`](https://github.com/theeussx/wardizitto/blob/main/src/application/ports/database.ts) (Database port), [`src/presentation/discord/client/wardizitto-client.ts`](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/client/wardizitto-client.ts) (Discord client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and Discord"]
  node_main["Composition root<br/>[main.ts]"]
  node_application["Application wiring"]
  node_client["Discord client"]
  node_events["Event registration<br/>[register-events.ts]"]
  node_interaction_router["Interaction router"]
  node_message_router["Message router<br/>[message-router.ts]"]
  node_prefix_handler["Prefix handler"]
  node_command_registry["Command registry"]
  node_component_registry["Component registry"]
  node_lifecycle["Discord lifecycle"]
  node_registration["Command registration"]
end

subgraph group_controls["Application controls"]
  node_permission["Permission service"]
  node_rate_limiter["Rate limiting<br/>[rate-limiter.ts]"]
  node_metrics["Metrics service<br/>[metrics-service.ts]"]
end

subgraph group_features["Bot features"]
  node_economy["Economy features"]
  node_economy_service["Economy service<br/>[economy-service.ts]"]
  node_social["Social features"]
  node_marriage_service["Marriage service"]
  node_moderation["Moderation features"]
  node_tickets["Ticket features"]
  node_verification["Verification"]
  node_utilities["Utilities and reports"]
  node_fun["Games and fun"]
  node_administration["Administration"]
  node_owner_features["Owner commands"]
end

subgraph group_infra["Infrastructure and persistence"]
  node_database_port["Database port<br/>[database.ts]"]
  node_mysql[("MySQL database<br/>[mysql-database.ts]")]
  node_migrations["Migration runner"]
  node_legacy_db["Legacy database access<br/>[legacy.ts]"]
  node_afk_repository["AFK repository<br/>[afk-repository.ts]"]
  node_custom_permissions["Custom permissions"]
  node_cache["TTL cache<br/>[ttl-cache.ts]"]
  node_http_client["Safe HTTP client"]
end

subgraph group_core["Core services"]
end

node_discord_users(("Discord users"))

node_discord_users -->|"send interactions"| node_interaction_router
node_discord_users -->|"send messages"| node_message_router
node_main -->|"creates"| node_application
node_main -->|"configures"| node_mysql
node_main -.->|"starts"| node_client
node_application -->|"uses"| node_database_port
node_application -->|"wires"| node_permission
node_application -->|"wires"| node_rate_limiter
node_application -->|"wires"| node_economy_service
node_application -->|"wires"| node_marriage_service
node_application -->|"runs"| node_migrations
node_events -->|"registers on"| node_client
node_events -->|"routes events"| node_interaction_router
node_events -->|"routes events"| node_message_router
node_events -->|"registers events"| node_lifecycle
node_interaction_router -->|"reads commands and services"| node_client
node_interaction_router -->|"resolves components"| node_component_registry
node_interaction_router -->|"authorizes commands"| node_permission
node_interaction_router -->|"limits requests"| node_rate_limiter
node_interaction_router -->|"records duration"| node_metrics
node_message_router -->|"reads commands"| node_client
node_message_router -->|"delegates"| node_prefix_handler
node_client -->|"holds commands"| node_command_registry
node_lifecycle -->|"registers commands"| node_registration
node_economy_service -->|"reads and updates"| node_database_port
node_marriage_service -->|"reads and updates"| node_database_port
node_mysql -->|"implements"| node_database_port
node_migrations -->|"queries"| node_database_port
node_legacy_db -->|"uses"| node_database_port
node_afk_repository -->|"queries"| node_database_port
node_afk_repository -->|"caches entries"| node_cache
node_custom_permissions -->|"queries"| node_database_port
node_custom_permissions -->|"caches permissions"| node_cache
node_permission -->|"checks permissions"| node_custom_permissions
node_utilities -.->|"uses VirusTotal optionally"| node_http_client
node_moderation -.->|"moderates members"| node_discord_users
node_tickets -.->|"serves ticket workflows"| node_discord_users
node_verification -.->|"verifies members"| node_discord_users
node_economy -.->|"provides economy commands"| node_discord_users
node_social -.->|"provides social features"| node_discord_users
node_fun -.->|"provides games"| node_discord_users
node_administration -.->|"provides administration"| node_discord_users
node_owner_features -.->|"provides owner tools"| node_discord_users

click node_main "https://github.com/theeussx/wardizitto/blob/main/src/main.ts"
click node_application "https://github.com/theeussx/wardizitto/blob/main/src/application/wardizitto-application.ts"
click node_client "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/client/wardizitto-client.ts"
click node_events "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/register-events.ts"
click node_interaction_router "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/interaction-router.ts"
click node_message_router "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/message-router.ts"
click node_prefix_handler "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/prefix-command-handler.ts"
click node_command_registry "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/registries/command-registry.ts"
click node_component_registry "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/registries/component-registry.ts"
click node_lifecycle "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/services/discord-lifecycle-service.ts"
click node_registration "https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/services/command-registration-service.ts"
click node_permission "https://github.com/theeussx/wardizitto/blob/main/src/application/services/permission-service.ts"
click node_rate_limiter "https://github.com/theeussx/wardizitto/blob/main/src/application/services/rate-limiter.ts"
click node_metrics "https://github.com/theeussx/wardizitto/blob/main/src/application/services/metrics-service.ts"
click node_economy "https://github.com/theeussx/wardizitto/tree/main/src/modules/economy"
click node_economy_service "https://github.com/theeussx/wardizitto/blob/main/src/modules/economy/application/economy-service.ts"
click node_social "https://github.com/theeussx/wardizitto/tree/main/src/modules/social"
click node_marriage_service "https://github.com/theeussx/wardizitto/blob/main/src/modules/social/application/marriage-service.ts"
click node_moderation "https://github.com/theeussx/wardizitto/tree/main/src/modules/moderation"
click node_tickets "https://github.com/theeussx/wardizitto/tree/main/src/modules/tickets"
click node_verification "https://github.com/theeussx/wardizitto/tree/main/src/modules/verification"
click node_utilities "https://github.com/theeussx/wardizitto/tree/main/src/modules/utilities"
click node_fun "https://github.com/theeussx/wardizitto/tree/main/src/modules/fun"
click node_administration "https://github.com/theeussx/wardizitto/tree/main/src/modules/administration"
click node_owner_features "https://github.com/theeussx/wardizitto/tree/main/src/modules/owner"
click node_database_port "https://github.com/theeussx/wardizitto/blob/main/src/application/ports/database.ts"
click node_mysql "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/database/mysql-database.ts"
click node_migrations "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/database/migration-runner.ts"
click node_legacy_db "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/database/legacy.ts"
click node_afk_repository "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/repositories/afk-repository.ts"
click node_custom_permissions "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/repositories/custom-permission-repository.ts"
click node_cache "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/cache/ttl-cache.ts"
click node_http_client "https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/http/safe-http-client.ts"

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_main,node_application,node_client,node_events,node_interaction_router,node_message_router,node_prefix_handler,node_command_registry,node_component_registry,node_lifecycle,node_registration,node_discord_users toneBlue
class node_permission,node_rate_limiter,node_metrics toneAmber
class node_economy,node_economy_service,node_social,node_marriage_service,node_moderation,node_tickets,node_verification,node_utilities,node_fun,node_administration,node_owner_features toneMint
class node_database_port,node_mysql,node_migrations,node_legacy_db,node_afk_repository,node_custom_permissions,node_cache,node_http_client toneRose
```

## Components

### Runtime and Discord

- [Composition root](https://github.com/theeussx/wardizitto/blob/main/src/main.ts): `src/main.ts`
- [Application wiring](https://github.com/theeussx/wardizitto/blob/main/src/application/wardizitto-application.ts): `src/application/wardizitto-application.ts`
- [Discord client](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/client/wardizitto-client.ts): `src/presentation/discord/client/wardizitto-client.ts`
- [Event registration](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/register-events.ts): `src/presentation/discord/register-events.ts`
- [Interaction router](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/interaction-router.ts): `src/presentation/discord/handlers/interaction-router.ts`
- [Message router](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/message-router.ts): `src/presentation/discord/handlers/message-router.ts`
- [Prefix handler](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/handlers/prefix-command-handler.ts): `src/presentation/discord/handlers/prefix-command-handler.ts`
- [Command registry](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/registries/command-registry.ts): `src/presentation/discord/registries/command-registry.ts`
- [Component registry](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/registries/component-registry.ts): `src/presentation/discord/registries/component-registry.ts`
- [Discord lifecycle](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/services/discord-lifecycle-service.ts): `src/presentation/discord/services/discord-lifecycle-service.ts`
- [Command registration](https://github.com/theeussx/wardizitto/blob/main/src/presentation/discord/services/command-registration-service.ts): `src/presentation/discord/services/command-registration-service.ts`

### Application controls

- [Permission service](https://github.com/theeussx/wardizitto/blob/main/src/application/services/permission-service.ts): `src/application/services/permission-service.ts`
- [Rate limiting](https://github.com/theeussx/wardizitto/blob/main/src/application/services/rate-limiter.ts): `src/application/services/rate-limiter.ts`
- [Metrics service](https://github.com/theeussx/wardizitto/blob/main/src/application/services/metrics-service.ts): `src/application/services/metrics-service.ts`

### Bot features

- [Economy features](https://github.com/theeussx/wardizitto/tree/main/src/modules/economy): `src/modules/economy`
- [Economy service](https://github.com/theeussx/wardizitto/blob/main/src/modules/economy/application/economy-service.ts): `src/modules/economy/application/economy-service.ts`
- [Social features](https://github.com/theeussx/wardizitto/tree/main/src/modules/social): `src/modules/social`
- [Marriage service](https://github.com/theeussx/wardizitto/blob/main/src/modules/social/application/marriage-service.ts): `src/modules/social/application/marriage-service.ts`
- [Moderation features](https://github.com/theeussx/wardizitto/tree/main/src/modules/moderation): `src/modules/moderation`
- [Ticket features](https://github.com/theeussx/wardizitto/tree/main/src/modules/tickets): `src/modules/tickets`
- [Verification](https://github.com/theeussx/wardizitto/tree/main/src/modules/verification): `src/modules/verification`
- [Utilities and reports](https://github.com/theeussx/wardizitto/tree/main/src/modules/utilities): `src/modules/utilities`
- [Games and fun](https://github.com/theeussx/wardizitto/tree/main/src/modules/fun): `src/modules/fun`
- [Administration](https://github.com/theeussx/wardizitto/tree/main/src/modules/administration): `src/modules/administration`
- [Owner commands](https://github.com/theeussx/wardizitto/tree/main/src/modules/owner): `src/modules/owner`

### Infrastructure and persistence

- [Database port](https://github.com/theeussx/wardizitto/blob/main/src/application/ports/database.ts): `src/application/ports/database.ts`
- [MySQL database](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/database/mysql-database.ts): `src/infrastructure/database/mysql-database.ts`
- [Migration runner](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/database/migration-runner.ts): `src/infrastructure/database/migration-runner.ts`
- [Legacy database access](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/database/legacy.ts): `src/infrastructure/database/legacy.ts`
- [AFK repository](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/repositories/afk-repository.ts): `src/infrastructure/repositories/afk-repository.ts`
- [Custom permissions](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/repositories/custom-permission-repository.ts): `src/infrastructure/repositories/custom-permission-repository.ts`
- [TTL cache](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/cache/ttl-cache.ts): `src/infrastructure/cache/ttl-cache.ts`
- [Safe HTTP client](https://github.com/theeussx/wardizitto/blob/main/src/infrastructure/http/safe-http-client.ts): `src/infrastructure/http/safe-http-client.ts`

### Other components

- **Discord users**

## Connections

- Discord users → Interaction router: send interactions
- Discord users → Message router: send messages
- Composition root → Application wiring: creates (evidence: `src/main.ts`)
- Composition root → MySQL database: configures (evidence: `src/main.ts`)
- Composition root → Discord client: starts
- Application wiring → Database port: uses (evidence: `src/application/wardizitto-application.ts`)
- Application wiring → Permission service: wires (evidence: `src/application/wardizitto-application.ts`)
- Application wiring → Rate limiting: wires (evidence: `src/application/wardizitto-application.ts`)
- Application wiring → Economy service: wires (evidence: `src/application/wardizitto-application.ts`)
- Application wiring → Marriage service: wires (evidence: `src/application/wardizitto-application.ts`)
- Application wiring → Migration runner: runs (evidence: `src/application/wardizitto-application.ts`)
- Event registration → Discord client: registers on (evidence: `src/presentation/discord/register-events.ts`)
- Event registration → Interaction router: routes events (evidence: `src/presentation/discord/register-events.ts`)
- Event registration → Message router: routes events (evidence: `src/presentation/discord/register-events.ts`)
- Event registration → Discord lifecycle: registers events (evidence: `src/presentation/discord/register-events.ts`)
- Interaction router → Discord client: reads commands and services (evidence: `src/presentation/discord/handlers/interaction-router.ts`)
- Interaction router → Component registry: resolves components (evidence: `src/presentation/discord/handlers/interaction-router.ts`)
- Interaction router → Permission service: authorizes commands (evidence: `src/presentation/discord/handlers/interaction-router.ts`)
- Interaction router → Rate limiting: limits requests (evidence: `src/presentation/discord/handlers/interaction-router.ts`)
- Interaction router → Metrics service: records duration (evidence: `src/presentation/discord/handlers/interaction-router.ts`)
- Message router → Discord client: reads commands (evidence: `src/presentation/discord/handlers/message-router.ts`)
- Message router → Prefix handler: delegates (evidence: `src/presentation/discord/handlers/message-router.ts`)
- Discord client → Command registry: holds commands (evidence: `src/presentation/discord/registries/command-registry.ts`)
- Discord lifecycle → Command registration: registers commands (evidence: `src/presentation/discord/services/discord-lifecycle-service.ts`)
- Economy service → Database port: reads and updates (evidence: `src/modules/economy/application/economy-service.ts`)
- Marriage service → Database port: reads and updates (evidence: `src/modules/social/application/marriage-service.ts`)
- MySQL database → Database port: implements (evidence: `src/infrastructure/database/mysql-database.ts`)
- Migration runner → Database port: queries (evidence: `src/infrastructure/database/migration-runner.ts`)
- Legacy database access → Database port: uses (evidence: `src/infrastructure/database/legacy.ts`)
- AFK repository → Database port: queries (evidence: `src/infrastructure/repositories/afk-repository.ts`)
- AFK repository → TTL cache: caches entries (evidence: `src/infrastructure/repositories/afk-repository.ts`)
- Custom permissions → Database port: queries (evidence: `src/infrastructure/repositories/custom-permission-repository.ts`)
- Custom permissions → TTL cache: caches permissions (evidence: `src/infrastructure/repositories/custom-permission-repository.ts`)
- Permission service → Custom permissions: checks permissions (evidence: `src/application/services/permission-service.ts`)
- Utilities and reports → Safe HTTP client: uses VirusTotal optionally
- Moderation features → Discord users: moderates members
- Ticket features → Discord users: serves ticket workflows
- Verification → Discord users: verifies members
- Economy features → Discord users: provides economy commands
- Social features → Discord users: provides social features
- Games and fun → Discord users: provides games
- Administration → Discord users: provides administration
- Owner commands → Discord users: provides owner tools
