# nayandas69/discord-role-guardian architecture

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

- Interactive diagram: https://gitdiagram.com/nayandas69/discord-role-guardian
- Repository: https://github.com/nayandas69/discord-role-guardian

## Overview

Role Guardian is a multi-server Discord bot: administrators configure community features through slash commands, members use role and ticket interactions, and event handlers carry out those actions while persisting configuration. Its main stages are command registration and dispatch, feature setup, member/interaction event handling, and scheduled or lifecycle actions. The file-backed storage and activity manager are shared internal services. Some feature handlers are documented in the README but were not sampled, so their runtime links are omitted where source evidence is unavailable.

Main entry points: [`src/index.js`](https://github.com/nayandas69/discord-role-guardian/blob/main/src/index.js) (Bot entry point), [`src/data/storage.js`](https://github.com/nayandas69/discord-role-guardian/blob/main/src/data/storage.js) (Persistent configuration), [`src/utils/commandRegistry.js`](https://github.com/nayandas69/discord-role-guardian/blob/main/src/utils/commandRegistry.js) (Command registry), [`src/handlers/interactionHandler.js`](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/interactionHandler.js) (Interaction dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Bot entry point<br/>[index.js]"]
  node_registry["Command registry<br/>[commandRegistry.js]"]
  node_interactions["Interaction dispatch"]
  node_health["Health endpoint<br/>[index.js]"]
end

subgraph group_commands["Slash commands"]
  node_role_setup["Role setup commands"]
  node_welcome_setup["Welcome and leave setup"]
  node_level_setup["Level commands"]
  node_schedule_setup["Schedule commands<br/>[scheduleMessage.js]"]
  node_ticket_setup["Ticket setup<br/>[setupTicket.js]"]
end

subgraph group_features["Community features"]
  node_roles["Reaction and button roles<br/>[reactionRoles.js]"]
  node_button_roles["Button role handler<br/>[buttonRoles.js]"]
  node_members["Member lifecycle<br/>[memberEvents.js]"]
  node_leveling["Leveling system<br/>[levelingSystem.js]"]
  node_tickets["Ticket lifecycle<br/>[ticketSystem.js]"]
  node_scheduled["Scheduled messages"]
end

subgraph group_services["Shared services"]
  node_storage[("Persistent configuration<br/>[storage.js]")]
  node_activity["Activity status<br/>[activityManager.js]"]
end

node_admin(("Server admin"))
node_member(("Server member"))
node_discord(("Discord platform"))

node_entry -->|"registers commands"| node_registry
node_entry -->|"dispatches interactions"| node_interactions
node_entry -->|"sets up events"| node_roles
node_entry -->|"sets up events"| node_members
node_entry -->|"starts system"| node_leveling
node_entry -->|"cancels timers"| node_scheduled
node_entry -->|"starts rotation"| node_activity
node_entry -->|"loads configuration"| node_storage
node_entry -->|"serves health checks"| node_health
node_registry -->|"registers slash commands"| node_discord
node_registry -->|"registers commands"| node_role_setup
node_registry -->|"registers commands"| node_welcome_setup
node_registry -->|"registers commands"| node_level_setup
node_registry -->|"registers commands"| node_schedule_setup
node_registry -->|"registers commands"| node_ticket_setup
node_admin -.->|"issues commands"| node_interactions
node_member -.->|"uses bot interactions"| node_interactions
node_interactions -->|"dispatches button roles"| node_button_roles
node_interactions -->|"dispatches ticket actions"| node_tickets
node_interactions -->|"sets temporary status"| node_activity
node_ticket_setup -->|"saves configuration"| node_storage
node_ticket_setup -->|"creates panel"| node_tickets
node_schedule_setup -->|"saves schedule"| node_storage
node_schedule_setup -->|"signals new schedule"| node_scheduled
node_tickets -->|"persists ticket data"| node_storage
node_scheduled -->|"reads and removes schedules"| node_storage
node_button_roles -->|"reads role configuration"| node_storage
node_roles -->|"uses role configuration"| node_storage
node_members -->|"uses member data"| node_storage
node_leveling -->|"uses XP data"| node_storage
node_tickets -.->|"creates ticket channels"| node_discord
node_scheduled -.->|"sends announcements"| node_discord
node_roles -.->|"assigns member roles"| node_discord
node_members -.->|"welcomes and farewells"| node_discord
node_leveling -.->|"awards XP and roles"| node_discord

click node_entry "https://github.com/nayandas69/discord-role-guardian/blob/main/src/index.js"
click node_registry "https://github.com/nayandas69/discord-role-guardian/blob/main/src/utils/commandRegistry.js"
click node_interactions "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/interactionHandler.js"
click node_role_setup "https://github.com/nayandas69/discord-role-guardian/tree/main/src/commands"
click node_welcome_setup "https://github.com/nayandas69/discord-role-guardian/tree/main/src/commands"
click node_level_setup "https://github.com/nayandas69/discord-role-guardian/tree/main/src/commands"
click node_schedule_setup "https://github.com/nayandas69/discord-role-guardian/blob/main/src/commands/scheduleMessage.js"
click node_ticket_setup "https://github.com/nayandas69/discord-role-guardian/blob/main/src/commands/setupTicket.js"
click node_roles "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/reactionRoles.js"
click node_button_roles "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/buttonRoles.js"
click node_members "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/memberEvents.js"
click node_leveling "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/levelingSystem.js"
click node_tickets "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/ticketSystem.js"
click node_scheduled "https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/scheduledMessages.js"
click node_storage "https://github.com/nayandas69/discord-role-guardian/blob/main/src/data/storage.js"
click node_activity "https://github.com/nayandas69/discord-role-guardian/blob/main/src/utils/activityManager.js"
click node_health "https://github.com/nayandas69/discord-role-guardian/blob/main/src/index.js"

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_entry,node_registry,node_interactions,node_health toneBlue
class node_role_setup,node_welcome_setup,node_level_setup,node_schedule_setup,node_ticket_setup toneAmber
class node_roles,node_button_roles,node_members,node_leveling,node_tickets,node_scheduled,node_admin,node_member toneMint
class node_storage,node_activity toneRose
class node_discord toneIndigo
```

## Components

### Bot runtime

- [Bot entry point](https://github.com/nayandas69/discord-role-guardian/blob/main/src/index.js): `src/index.js`
- [Command registry](https://github.com/nayandas69/discord-role-guardian/blob/main/src/utils/commandRegistry.js): `src/utils/commandRegistry.js`
- [Interaction dispatch](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/interactionHandler.js): `src/handlers/interactionHandler.js`
- [Health endpoint](https://github.com/nayandas69/discord-role-guardian/blob/main/src/index.js): `src/index.js`

### Slash commands

- [Role setup commands](https://github.com/nayandas69/discord-role-guardian/tree/main/src/commands): `src/commands`
- [Welcome and leave setup](https://github.com/nayandas69/discord-role-guardian/tree/main/src/commands): `src/commands`
- [Level commands](https://github.com/nayandas69/discord-role-guardian/tree/main/src/commands): `src/commands`
- [Schedule commands](https://github.com/nayandas69/discord-role-guardian/blob/main/src/commands/scheduleMessage.js): `src/commands/scheduleMessage.js`
- [Ticket setup](https://github.com/nayandas69/discord-role-guardian/blob/main/src/commands/setupTicket.js): `src/commands/setupTicket.js`

### Community features

- [Reaction and button roles](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/reactionRoles.js): `src/handlers/reactionRoles.js`
- [Button role handler](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/buttonRoles.js): `src/handlers/buttonRoles.js`
- [Member lifecycle](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/memberEvents.js): `src/handlers/memberEvents.js`
- [Leveling system](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/levelingSystem.js): `src/handlers/levelingSystem.js`
- [Ticket lifecycle](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/ticketSystem.js): `src/handlers/ticketSystem.js`
- [Scheduled messages](https://github.com/nayandas69/discord-role-guardian/blob/main/src/handlers/scheduledMessages.js): `src/handlers/scheduledMessages.js`

### Shared services

- [Persistent configuration](https://github.com/nayandas69/discord-role-guardian/blob/main/src/data/storage.js): `src/data/storage.js`
- [Activity status](https://github.com/nayandas69/discord-role-guardian/blob/main/src/utils/activityManager.js): `src/utils/activityManager.js`

### Other components

- **Server admin**
- **Server member**
- **Discord platform**

## Connections

- Bot entry point → Command registry: registers commands (evidence: `src/index.js`)
- Bot entry point → Interaction dispatch: dispatches interactions (evidence: `src/index.js`)
- Bot entry point → Reaction and button roles: sets up events (evidence: `src/index.js`)
- Bot entry point → Member lifecycle: sets up events (evidence: `src/index.js`)
- Bot entry point → Leveling system: starts system (evidence: `src/index.js`)
- Bot entry point → Scheduled messages: cancels timers (evidence: `src/index.js`)
- Bot entry point → Activity status: starts rotation (evidence: `src/index.js`)
- Bot entry point → Persistent configuration: loads configuration (evidence: `src/index.js`)
- Bot entry point → Health endpoint: serves health checks (evidence: `src/index.js`)
- Command registry → Discord platform: registers slash commands (evidence: `src/utils/commandRegistry.js`)
- Command registry → Role setup commands: registers commands (evidence: `src/utils/commandRegistry.js`)
- Command registry → Welcome and leave setup: registers commands (evidence: `src/utils/commandRegistry.js`)
- Command registry → Level commands: registers commands (evidence: `src/utils/commandRegistry.js`)
- Command registry → Schedule commands: registers commands (evidence: `src/utils/commandRegistry.js`)
- Command registry → Ticket setup: registers commands (evidence: `src/utils/commandRegistry.js`)
- Server admin → Interaction dispatch: issues commands (evidence: `README.md`)
- Server member → Interaction dispatch: uses bot interactions (evidence: `README.md`)
- Interaction dispatch → Button role handler: dispatches button roles (evidence: `src/handlers/interactionHandler.js`)
- Interaction dispatch → Ticket lifecycle: dispatches ticket actions (evidence: `src/handlers/interactionHandler.js`)
- Interaction dispatch → Activity status: sets temporary status (evidence: `src/handlers/interactionHandler.js`)
- Ticket setup → Persistent configuration: saves configuration (evidence: `src/commands/setupTicket.js`)
- Ticket setup → Ticket lifecycle: creates panel (evidence: `src/commands/setupTicket.js`)
- Schedule commands → Persistent configuration: saves schedule (evidence: `src/commands/scheduleMessage.js`)
- Schedule commands → Scheduled messages: signals new schedule (evidence: `src/commands/scheduleMessage.js`)
- Ticket lifecycle → Persistent configuration: persists ticket data (evidence: `src/handlers/ticketSystem.js`)
- Scheduled messages → Persistent configuration: reads and removes schedules (evidence: `src/handlers/scheduledMessages.js`)
- Button role handler → Persistent configuration: reads role configuration (evidence: `src/handlers/buttonRoles.js`)
- Reaction and button roles → Persistent configuration: uses role configuration (evidence: `src/handlers/reactionRoles.js`)
- Member lifecycle → Persistent configuration: uses member data (evidence: `src/handlers/memberEvents.js`)
- Leveling system → Persistent configuration: uses XP data (evidence: `src/handlers/levelingSystem.js`)
- Ticket lifecycle → Discord platform: creates ticket channels
- Scheduled messages → Discord platform: sends announcements
- Reaction and button roles → Discord platform: assigns member roles (evidence: `README.md`)
- Member lifecycle → Discord platform: welcomes and farewells (evidence: `README.md`)
- Leveling system → Discord platform: awards XP and roles (evidence: `README.md`)
