# daksh7011/troy architecture

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

- Interactive diagram: https://gitdiagram.com/daksh7011/troy
- Repository: https://github.com/daksh7011/troy

## Overview

Troy is a Kotlin Discord bot whose main workflow is Discord events and commands entering through the bot runtime, then producing server interactions or moderation actions. Commands cover entertainment, utilities, moderation, configuration and age-restricted content; moderation and guild settings use repositories backed by MongoDB. The README also documents phishing protection and broad command capabilities. Several command implementations are unsampled, so their internal calls and integrations are not inferred; those branches are represented at their source directories.

Main entry points: [`src/main/kotlin/troy/core/Troy.kt`](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/core/Troy.kt) (Bot setup), [`src/main/kotlin/troy/App.kt`](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/App.kt) (Event handlers), [`src/main/kotlin/troy/commands/mod/Warn.kt`](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Warn.kt) (Warning workflow), [`src/main/kotlin/troy/data/repository`](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/data/repository) (Data repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_app["Event handlers<br/>[App.kt]"]
  node_bot["Bot setup<br/>[Troy.kt]"]
end

subgraph group_commands["Discord commands"]
  node_fun["Fun commands"]
  node_dictionary["Dictionary lookup<br/>[Dictionary.kt]"]
  node_urban["Urban dictionary<br/>[UrbanDictionary.kt]"]
  node_doggo["Doggo command<br/>[Doggo.kt]"]
  node_poll["Poll command<br/>[Poll.kt]"]
  node_misc["Utility commands"]
  node_steam["Steam lookup<br/>[Steam.kt]"]
  node_config["Guild configuration"]
  node_moderation["Moderation commands"]
  node_warn["Warning workflow<br/>[Warn.kt]"]
  node_ban["Ban command<br/>[Ban.kt]"]
  node_kick["Kick command<br/>[Kick.kt]"]
  node_nsfw["Age-restricted commands"]
end

subgraph group_safety["Safety and presence"]
  node_phishing["Phishing protection"]
  node_presence["Presence rotation<br/>[PresenceManager.kt]"]
end

subgraph group_data["Persistence"]
  node_repositories["Data repositories"]
  node_guild_repo["Guild settings"]
  node_warning_repo["Warning records"]
  node_ban_repo["Ban records"]
  node_kick_repo["Kick records"]
end

node_discord(("Discord users"))
node_discord_api["Discord API"]
node_mongo[("MongoDB")]
node_owl_api["OwlDict API"]

node_discord -->|"sends events"| node_app
node_app -->|"creates runtime"| node_bot
node_bot -->|"registers commands"| node_fun
node_bot -->|"registers commands"| node_misc
node_bot -->|"registers commands"| node_moderation
node_bot -->|"registers commands"| node_nsfw
node_bot -->|"registers commands"| node_config
node_app -->|"fetches domains"| node_phishing
node_app -->|"sets presence"| node_presence
node_app -->|"initializes guilds"| node_guild_repo
node_bot -->|"loads modules"| node_repositories
node_dictionary -->|"requests definitions"| node_owl_api
node_warn -->|"records warnings"| node_warning_repo
node_warn -->|"reads policy"| node_guild_repo
node_warn -->|"records automatic bans"| node_ban_repo
node_warn -->|"records automatic kicks"| node_kick_repo
node_ban -->|"records bans"| node_ban_repo
node_kick -->|"records kicks"| node_kick_repo
node_repositories -.->|"persists records"| node_mongo
node_discord_api -.->|"hosts commands"| node_fun
node_discord_api -.->|"hosts commands"| node_moderation

click node_app "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/App.kt"
click node_bot "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/core/Troy.kt"
click node_fun "https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/funstuff"
click node_dictionary "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/Dictionary.kt"
click node_urban "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt"
click node_doggo "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/Doggo.kt"
click node_poll "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/Poll.kt"
click node_misc "https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/misc"
click node_steam "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/misc/Steam.kt"
click node_config "https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/config"
click node_moderation "https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/mod"
click node_warn "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Warn.kt"
click node_ban "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Ban.kt"
click node_kick "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Kick.kt"
click node_nsfw "https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/nsfw"
click node_phishing "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/utils/PhishingDomainsHelper.kt"
click node_presence "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/utils/PresenceManager.kt"
click node_repositories "https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/data/repository"
click node_guild_repo "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/GlobalGuildRepository.kt"
click node_warning_repo "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/WarningLogsRepository.kt"
click node_ban_repo "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/BanLogsRepository.kt"
click node_kick_repo "https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/KickLogsRepository.kt"

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_app,node_bot,node_discord toneBlue
class node_fun,node_dictionary,node_urban,node_doggo,node_poll,node_misc,node_steam,node_config,node_moderation,node_warn,node_ban,node_kick,node_nsfw,node_mongo toneAmber
class node_phishing,node_presence,node_discord_api,node_owl_api toneMint
class node_repositories,node_guild_repo,node_warning_repo,node_ban_repo,node_kick_repo toneRose
```

## Components

### Bot runtime

- [Event handlers](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/App.kt): `src/main/kotlin/troy/App.kt`
- [Bot setup](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/core/Troy.kt): `src/main/kotlin/troy/core/Troy.kt`

### Discord commands

- [Fun commands](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/funstuff): `src/main/kotlin/troy/commands/funstuff`
- [Dictionary lookup](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/Dictionary.kt): `src/main/kotlin/troy/commands/funstuff/Dictionary.kt`
- [Urban dictionary](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt): `src/main/kotlin/troy/commands/funstuff/UrbanDictionary.kt`
- [Doggo command](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/Doggo.kt): `src/main/kotlin/troy/commands/funstuff/Doggo.kt`
- [Poll command](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/funstuff/Poll.kt): `src/main/kotlin/troy/commands/funstuff/Poll.kt`
- [Utility commands](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/misc): `src/main/kotlin/troy/commands/misc`
- [Steam lookup](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/misc/Steam.kt): `src/main/kotlin/troy/commands/misc/Steam.kt`
- [Guild configuration](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/config): `src/main/kotlin/troy/commands/config`
- [Moderation commands](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/mod): `src/main/kotlin/troy/commands/mod`
- [Warning workflow](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Warn.kt): `src/main/kotlin/troy/commands/mod/Warn.kt`
- [Ban command](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Ban.kt): `src/main/kotlin/troy/commands/mod/Ban.kt`
- [Kick command](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/commands/mod/Kick.kt): `src/main/kotlin/troy/commands/mod/Kick.kt`
- [Age-restricted commands](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/commands/nsfw): `src/main/kotlin/troy/commands/nsfw`

### Safety and presence

- [Phishing protection](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/utils/PhishingDomainsHelper.kt): `src/main/kotlin/troy/utils/PhishingDomainsHelper.kt`
- [Presence rotation](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/utils/PresenceManager.kt): `src/main/kotlin/troy/utils/PresenceManager.kt`

### Persistence

- [Data repositories](https://github.com/daksh7011/troy/tree/develop/src/main/kotlin/troy/data/repository): `src/main/kotlin/troy/data/repository`
- [Guild settings](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/GlobalGuildRepository.kt): `src/main/kotlin/troy/data/repository/GlobalGuildRepository.kt`
- [Warning records](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/WarningLogsRepository.kt): `src/main/kotlin/troy/data/repository/WarningLogsRepository.kt`
- [Ban records](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/BanLogsRepository.kt): `src/main/kotlin/troy/data/repository/BanLogsRepository.kt`
- [Kick records](https://github.com/daksh7011/troy/blob/develop/src/main/kotlin/troy/data/repository/KickLogsRepository.kt): `src/main/kotlin/troy/data/repository/KickLogsRepository.kt`

### Other components

- **Discord users**
- **Discord API**
- **MongoDB**
- **OwlDict API**

## Connections

- Discord users → Event handlers: sends events (evidence: `src/main/kotlin/troy/App.kt`)
- Event handlers → Bot setup: creates runtime (evidence: `src/main/kotlin/troy/App.kt`)
- Bot setup → Fun commands: registers commands (evidence: `src/main/kotlin/troy/core/Troy.kt`)
- Bot setup → Utility commands: registers commands (evidence: `src/main/kotlin/troy/core/Troy.kt`)
- Bot setup → Moderation commands: registers commands (evidence: `src/main/kotlin/troy/core/Troy.kt`)
- Bot setup → Age-restricted commands: registers commands (evidence: `src/main/kotlin/troy/core/Troy.kt`)
- Bot setup → Guild configuration: registers commands (evidence: `src/main/kotlin/troy/core/Troy.kt`)
- Event handlers → Phishing protection: fetches domains (evidence: `src/main/kotlin/troy/App.kt`)
- Event handlers → Presence rotation: sets presence (evidence: `src/main/kotlin/troy/App.kt`)
- Event handlers → Guild settings: initializes guilds (evidence: `src/main/kotlin/troy/App.kt`)
- Bot setup → Data repositories: loads modules (evidence: `src/main/kotlin/troy/core/Troy.kt`)
- Dictionary lookup → OwlDict API: requests definitions (evidence: `src/main/kotlin/troy/commands/funstuff/Dictionary.kt`)
- Warning workflow → Warning records: records warnings (evidence: `src/main/kotlin/troy/commands/mod/Warn.kt`)
- Warning workflow → Guild settings: reads policy (evidence: `src/main/kotlin/troy/commands/mod/Warn.kt`)
- Warning workflow → Ban records: records automatic bans (evidence: `src/main/kotlin/troy/commands/mod/Warn.kt`)
- Warning workflow → Kick records: records automatic kicks (evidence: `src/main/kotlin/troy/commands/mod/Warn.kt`)
- Ban command → Ban records: records bans (evidence: `src/main/kotlin/troy/commands/mod/Ban.kt`)
- Kick command → Kick records: records kicks (evidence: `src/main/kotlin/troy/commands/mod/Kick.kt`)
- Data repositories → MongoDB: persists records
- Discord API → Fun commands: hosts commands
- Discord API → Moderation commands: hosts commands
