# jevenchy/giveaway architecture

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

- Interactive diagram: https://gitdiagram.com/jevenchy/giveaway
- Repository: https://github.com/jevenchy/giveaway

## Overview

Giveaway is a Discord bot for timed giveaways and first-claim instant drops. Users interact through slash commands, modals, buttons, and select menus; the bot validates entries, persists activity and records, draws or assigns winners, and updates Discord messages with announcements. The graph follows the evidenced interaction dispatch and giveaway-service calls. The README documents scheduler recovery and other capabilities, but some implementation links are not visible in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`src/services/giveawayService.ts`](https://github.com/jevenchy/giveaway/blob/main/src/services/giveawayService.ts) (Giveaway lifecycle), [`src/handlers/interactionHandler.ts`](https://github.com/jevenchy/giveaway/blob/main/src/handlers/interactionHandler.ts) (Interaction dispatch), [`src/handlers/commandHandler.ts`](https://github.com/jevenchy/giveaway/blob/main/src/handlers/commandHandler.ts) (Command dispatch), [`src/services/dropService.ts`](https://github.com/jevenchy/giveaway/blob/main/src/services/dropService.ts) (Drop lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_app["Client and events<br/>[app.ts]"]
  node_event_interaction["Interaction event"]
  node_event_message["Message event<br/>[messageCreate.ts]"]
  node_ready["Ready startup<br/>[ready.ts]"]
end

subgraph group_entrypoints["Commands and interactions"]
  node_dispatch["Interaction dispatch"]
  node_command_dispatch["Command dispatch<br/>[commandHandler.ts]"]
  node_admin_commands["Giveaway admin commands<br/>[gstart.ts]"]
  node_drop_command["Launch drop command<br/>[gdrop.ts]"]
  node_end_reroll_commands["End and reroll commands<br/>[gend.ts]"]
  node_list_command["Active list command<br/>[glist.ts]"]
  node_help_command["Help command<br/>[ghelp.ts]"]
  node_giveaway_modal["Giveaway creation modal<br/>[giveawayCreate.ts]"]
  node_drop_modal["Drop creation modal<br/>[dropCreate.ts]"]
  node_entry_button["Giveaway entry button<br/>[giveawayEnter.ts]"]
  node_claim_button["Drop claim button<br/>[dropClaim.ts]"]
  node_list_filter["List filter buttons<br/>[glistFilter.ts]"]
  node_end_menu["Giveaway end menu<br/>[giveawayEnd.ts]"]
  node_reroll_menu["Giveaway reroll menu<br/>[giveawayReroll.ts]"]
end

subgraph group_lifecycle["Giveaway and drop lifecycle"]
  node_giveaway_service["Giveaway lifecycle<br/>[giveawayService.ts]"]
  node_drop_service["Drop lifecycle<br/>[dropService.ts]"]
  node_scheduler["Deadline scheduler"]
end

subgraph group_state["State and eligibility"]
  node_anti_spam["Entry eligibility<br/>[antiSpamService.ts]"]
  node_database[("JSON persistence adapter<br/>[jsonAdapter.ts]")]
  node_config["Giveaway settings<br/>[giveawayConfig.ts]"]
end

subgraph group_presentation["Discord presentation"]
  node_giveaway_embed["Giveaway messages<br/>[giveawayEmbed.ts]"]
  node_drop_embed["Drop messages<br/>[dropEmbed.ts]"]
  node_list_embed["Giveaway and drop list<br/>[glistEmbed.ts]"]
  node_help_embed["Help message<br/>[helpEmbed.ts]"]
  node_error_embed["Error messages<br/>[errorEmbed.ts]"]
  node_success_embed["Success messages<br/>[successEmbed.ts]"]
end

node_discord_users(("Discord members"))
node_discord{{"Discord platform"}}

node_discord -->|"connects events"| node_app
node_app -->|"registers listener"| node_event_interaction
node_app -->|"registers listener"| node_event_message
node_app -->|"runs on ready"| node_ready
node_event_interaction -->|"forwards interaction"| node_dispatch
node_dispatch -->|"routes commands"| node_command_dispatch
node_command_dispatch -->|"dispatches commands"| node_admin_commands
node_command_dispatch -->|"dispatches commands"| node_drop_command
node_command_dispatch -->|"dispatches commands"| node_end_reroll_commands
node_command_dispatch -->|"dispatches commands"| node_list_command
node_command_dispatch -->|"dispatches commands"| node_help_command
node_discord_users -->|"sends interactions"| node_dispatch
node_dispatch -->|"routes modal"| node_giveaway_modal
node_dispatch -->|"routes modal"| node_drop_modal
node_dispatch -->|"routes button"| node_entry_button
node_dispatch -->|"routes button"| node_claim_button
node_dispatch -->|"routes button"| node_list_filter
node_dispatch -->|"routes menu"| node_end_menu
node_dispatch -->|"routes menu"| node_reroll_menu
node_admin_commands -->|"opens creation"| node_giveaway_modal
node_giveaway_modal -->|"creates giveaway"| node_giveaway_service
node_drop_command -->|"opens creation"| node_drop_modal
node_drop_modal -->|"creates drop"| node_drop_service
node_entry_button -->|"checks eligibility"| node_anti_spam
node_entry_button -->|"toggles entry"| node_giveaway_service
node_claim_button -->|"claims drop"| node_drop_service
node_end_reroll_commands -->|"ends or rerolls"| node_giveaway_service
node_end_menu -->|"ends giveaway"| node_giveaway_service
node_reroll_menu -->|"rerolls winner"| node_giveaway_service
node_list_command -->|"builds list"| node_list_embed
node_list_filter -->|"refreshes view"| node_list_embed
node_help_command -->|"shows help"| node_help_embed
node_giveaway_service -->|"reads and writes"| node_database
node_drop_service -->|"reads and writes"| node_database
node_anti_spam -->|"checks activity"| node_database
node_event_message -->|"tracks messages"| node_anti_spam
node_scheduler -->|"ends due draws"| node_giveaway_service
node_giveaway_service -->|"builds updates"| node_giveaway_embed
node_drop_service -->|"builds updates"| node_drop_embed
node_giveaway_service -->|"posts announcements"| node_discord
node_giveaway_service -->|"uses settings"| node_config
node_anti_spam -->|"uses thresholds"| node_config
node_giveaway_service -->|"updates messages"| node_discord
node_drop_service -.->|"posts drop"| node_discord
node_scheduler -->|"checks deadlines"| node_database

click node_app "https://github.com/jevenchy/giveaway/blob/main/src/core/app.ts"
click node_event_interaction "https://github.com/jevenchy/giveaway/blob/main/src/events/interactionCreate.ts"
click node_event_message "https://github.com/jevenchy/giveaway/blob/main/src/events/messageCreate.ts"
click node_ready "https://github.com/jevenchy/giveaway/blob/main/src/events/ready.ts"
click node_dispatch "https://github.com/jevenchy/giveaway/blob/main/src/handlers/interactionHandler.ts"
click node_command_dispatch "https://github.com/jevenchy/giveaway/blob/main/src/handlers/commandHandler.ts"
click node_admin_commands "https://github.com/jevenchy/giveaway/blob/main/src/commands/gstart.ts"
click node_drop_command "https://github.com/jevenchy/giveaway/blob/main/src/commands/gdrop.ts"
click node_end_reroll_commands "https://github.com/jevenchy/giveaway/blob/main/src/commands/gend.ts"
click node_list_command "https://github.com/jevenchy/giveaway/blob/main/src/commands/glist.ts"
click node_help_command "https://github.com/jevenchy/giveaway/blob/main/src/commands/ghelp.ts"
click node_giveaway_modal "https://github.com/jevenchy/giveaway/blob/main/src/interactions/modals/giveawayCreate.ts"
click node_drop_modal "https://github.com/jevenchy/giveaway/blob/main/src/interactions/modals/dropCreate.ts"
click node_entry_button "https://github.com/jevenchy/giveaway/blob/main/src/interactions/buttons/giveawayEnter.ts"
click node_claim_button "https://github.com/jevenchy/giveaway/blob/main/src/interactions/buttons/dropClaim.ts"
click node_list_filter "https://github.com/jevenchy/giveaway/blob/main/src/interactions/buttons/glistFilter.ts"
click node_end_menu "https://github.com/jevenchy/giveaway/blob/main/src/interactions/selectMenus/giveawayEnd.ts"
click node_reroll_menu "https://github.com/jevenchy/giveaway/blob/main/src/interactions/selectMenus/giveawayReroll.ts"
click node_giveaway_service "https://github.com/jevenchy/giveaway/blob/main/src/services/giveawayService.ts"
click node_drop_service "https://github.com/jevenchy/giveaway/blob/main/src/services/dropService.ts"
click node_scheduler "https://github.com/jevenchy/giveaway/blob/main/src/services/giveawaySchedulerService.ts"
click node_anti_spam "https://github.com/jevenchy/giveaway/blob/main/src/services/antiSpamService.ts"
click node_database "https://github.com/jevenchy/giveaway/blob/main/src/database/jsonAdapter.ts"
click node_giveaway_embed "https://github.com/jevenchy/giveaway/blob/main/src/embeds/giveawayEmbed.ts"
click node_drop_embed "https://github.com/jevenchy/giveaway/blob/main/src/embeds/dropEmbed.ts"
click node_list_embed "https://github.com/jevenchy/giveaway/blob/main/src/embeds/glistEmbed.ts"
click node_help_embed "https://github.com/jevenchy/giveaway/blob/main/src/embeds/helpEmbed.ts"
click node_error_embed "https://github.com/jevenchy/giveaway/blob/main/src/embeds/errorEmbed.ts"
click node_success_embed "https://github.com/jevenchy/giveaway/blob/main/src/embeds/successEmbed.ts"
click node_config "https://github.com/jevenchy/giveaway/blob/main/src/config/giveawayConfig.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_app,node_event_interaction,node_event_message,node_ready toneBlue
class node_dispatch,node_command_dispatch,node_admin_commands,node_drop_command,node_end_reroll_commands,node_list_command,node_help_command,node_giveaway_modal,node_drop_modal,node_entry_button,node_claim_button,node_list_filter,node_end_menu,node_reroll_menu toneAmber
class node_giveaway_service,node_drop_service,node_scheduler toneMint
class node_anti_spam,node_database,node_config toneRose
class node_giveaway_embed,node_drop_embed,node_list_embed,node_help_embed,node_error_embed,node_success_embed,node_discord_users,node_discord toneIndigo
```

## Components

### Bot runtime

- [Client and events](https://github.com/jevenchy/giveaway/blob/main/src/core/app.ts): `src/core/app.ts`
- [Interaction event](https://github.com/jevenchy/giveaway/blob/main/src/events/interactionCreate.ts): `src/events/interactionCreate.ts`
- [Message event](https://github.com/jevenchy/giveaway/blob/main/src/events/messageCreate.ts): `src/events/messageCreate.ts`
- [Ready startup](https://github.com/jevenchy/giveaway/blob/main/src/events/ready.ts): `src/events/ready.ts`

### Commands and interactions

- [Interaction dispatch](https://github.com/jevenchy/giveaway/blob/main/src/handlers/interactionHandler.ts): `src/handlers/interactionHandler.ts`
- [Command dispatch](https://github.com/jevenchy/giveaway/blob/main/src/handlers/commandHandler.ts): `src/handlers/commandHandler.ts`
- [Giveaway admin commands](https://github.com/jevenchy/giveaway/blob/main/src/commands/gstart.ts): `src/commands/gstart.ts`
- [Launch drop command](https://github.com/jevenchy/giveaway/blob/main/src/commands/gdrop.ts): `src/commands/gdrop.ts`
- [End and reroll commands](https://github.com/jevenchy/giveaway/blob/main/src/commands/gend.ts): `src/commands/gend.ts`
- [Active list command](https://github.com/jevenchy/giveaway/blob/main/src/commands/glist.ts): `src/commands/glist.ts`
- [Help command](https://github.com/jevenchy/giveaway/blob/main/src/commands/ghelp.ts): `src/commands/ghelp.ts`
- [Giveaway creation modal](https://github.com/jevenchy/giveaway/blob/main/src/interactions/modals/giveawayCreate.ts): `src/interactions/modals/giveawayCreate.ts`
- [Drop creation modal](https://github.com/jevenchy/giveaway/blob/main/src/interactions/modals/dropCreate.ts): `src/interactions/modals/dropCreate.ts`
- [Giveaway entry button](https://github.com/jevenchy/giveaway/blob/main/src/interactions/buttons/giveawayEnter.ts): `src/interactions/buttons/giveawayEnter.ts`
- [Drop claim button](https://github.com/jevenchy/giveaway/blob/main/src/interactions/buttons/dropClaim.ts): `src/interactions/buttons/dropClaim.ts`
- [List filter buttons](https://github.com/jevenchy/giveaway/blob/main/src/interactions/buttons/glistFilter.ts): `src/interactions/buttons/glistFilter.ts`
- [Giveaway end menu](https://github.com/jevenchy/giveaway/blob/main/src/interactions/selectMenus/giveawayEnd.ts): `src/interactions/selectMenus/giveawayEnd.ts`
- [Giveaway reroll menu](https://github.com/jevenchy/giveaway/blob/main/src/interactions/selectMenus/giveawayReroll.ts): `src/interactions/selectMenus/giveawayReroll.ts`

### Giveaway and drop lifecycle

- [Giveaway lifecycle](https://github.com/jevenchy/giveaway/blob/main/src/services/giveawayService.ts): `src/services/giveawayService.ts`
- [Drop lifecycle](https://github.com/jevenchy/giveaway/blob/main/src/services/dropService.ts): `src/services/dropService.ts`
- [Deadline scheduler](https://github.com/jevenchy/giveaway/blob/main/src/services/giveawaySchedulerService.ts): `src/services/giveawaySchedulerService.ts`

### State and eligibility

- [Entry eligibility](https://github.com/jevenchy/giveaway/blob/main/src/services/antiSpamService.ts): `src/services/antiSpamService.ts`
- [JSON persistence adapter](https://github.com/jevenchy/giveaway/blob/main/src/database/jsonAdapter.ts): `src/database/jsonAdapter.ts`
- [Giveaway settings](https://github.com/jevenchy/giveaway/blob/main/src/config/giveawayConfig.ts): `src/config/giveawayConfig.ts`

### Discord presentation

- [Giveaway messages](https://github.com/jevenchy/giveaway/blob/main/src/embeds/giveawayEmbed.ts): `src/embeds/giveawayEmbed.ts`
- [Drop messages](https://github.com/jevenchy/giveaway/blob/main/src/embeds/dropEmbed.ts): `src/embeds/dropEmbed.ts`
- [Giveaway and drop list](https://github.com/jevenchy/giveaway/blob/main/src/embeds/glistEmbed.ts): `src/embeds/glistEmbed.ts`
- [Help message](https://github.com/jevenchy/giveaway/blob/main/src/embeds/helpEmbed.ts): `src/embeds/helpEmbed.ts`
- [Error messages](https://github.com/jevenchy/giveaway/blob/main/src/embeds/errorEmbed.ts): `src/embeds/errorEmbed.ts`
- [Success messages](https://github.com/jevenchy/giveaway/blob/main/src/embeds/successEmbed.ts): `src/embeds/successEmbed.ts`

### Other components

- **Discord members**
- **Discord platform**

## Connections

- Discord platform → Client and events: connects events (evidence: `src/core/app.ts`)
- Client and events → Interaction event: registers listener (evidence: `src/core/app.ts`)
- Client and events → Message event: registers listener (evidence: `src/core/app.ts`)
- Client and events → Ready startup: runs on ready (evidence: `src/core/app.ts`)
- Interaction event → Interaction dispatch: forwards interaction (evidence: `src/events/interactionCreate.ts`)
- Interaction dispatch → Command dispatch: routes commands (evidence: `src/handlers/interactionHandler.ts`)
- Command dispatch → Giveaway admin commands: dispatches commands (evidence: `src/handlers/commandHandler.ts`)
- Command dispatch → Launch drop command: dispatches commands (evidence: `src/handlers/commandHandler.ts`)
- Command dispatch → End and reroll commands: dispatches commands (evidence: `src/handlers/commandHandler.ts`)
- Command dispatch → Active list command: dispatches commands (evidence: `src/handlers/commandHandler.ts`)
- Command dispatch → Help command: dispatches commands (evidence: `src/handlers/commandHandler.ts`)
- Discord members → Interaction dispatch: sends interactions (evidence: `README.md`)
- Interaction dispatch → Giveaway creation modal: routes modal (evidence: `src/handlers/interactionHandler.ts`)
- Interaction dispatch → Drop creation modal: routes modal (evidence: `src/handlers/interactionHandler.ts`)
- Interaction dispatch → Giveaway entry button: routes button (evidence: `src/handlers/interactionHandler.ts`)
- Interaction dispatch → Drop claim button: routes button (evidence: `src/handlers/interactionHandler.ts`)
- Interaction dispatch → List filter buttons: routes button (evidence: `src/handlers/interactionHandler.ts`)
- Interaction dispatch → Giveaway end menu: routes menu (evidence: `src/handlers/interactionHandler.ts`)
- Interaction dispatch → Giveaway reroll menu: routes menu (evidence: `src/handlers/interactionHandler.ts`)
- Giveaway admin commands → Giveaway creation modal: opens creation (evidence: `README.md`)
- Giveaway creation modal → Giveaway lifecycle: creates giveaway (evidence: `src/interactions/modals/giveawayCreate.ts`)
- Launch drop command → Drop creation modal: opens creation (evidence: `README.md`)
- Drop creation modal → Drop lifecycle: creates drop (evidence: `src/interactions/modals/dropCreate.ts`)
- Giveaway entry button → Entry eligibility: checks eligibility (evidence: `src/interactions/buttons/giveawayEnter.ts`)
- Giveaway entry button → Giveaway lifecycle: toggles entry (evidence: `src/interactions/buttons/giveawayEnter.ts`)
- Drop claim button → Drop lifecycle: claims drop (evidence: `src/interactions/buttons/dropClaim.ts`)
- End and reroll commands → Giveaway lifecycle: ends or rerolls (evidence: `README.md`)
- Giveaway end menu → Giveaway lifecycle: ends giveaway (evidence: `src/interactions/selectMenus/giveawayEnd.ts`)
- Giveaway reroll menu → Giveaway lifecycle: rerolls winner (evidence: `src/interactions/selectMenus/giveawayReroll.ts`)
- Active list command → Giveaway and drop list: builds list (evidence: `src/commands/glist.ts`)
- List filter buttons → Giveaway and drop list: refreshes view (evidence: `src/interactions/buttons/glistFilter.ts`)
- Help command → Help message: shows help (evidence: `src/commands/ghelp.ts`)
- Giveaway lifecycle → JSON persistence adapter: reads and writes (evidence: `src/services/giveawayService.ts`)
- Drop lifecycle → JSON persistence adapter: reads and writes (evidence: `src/services/dropService.ts`)
- Entry eligibility → JSON persistence adapter: checks activity (evidence: `src/services/antiSpamService.ts`)
- Message event → Entry eligibility: tracks messages (evidence: `src/events/messageCreate.ts`)
- Deadline scheduler → Giveaway lifecycle: ends due draws (evidence: `src/services/giveawaySchedulerService.ts`)
- Giveaway lifecycle → Giveaway messages: builds updates (evidence: `src/services/giveawayService.ts`)
- Drop lifecycle → Drop messages: builds updates (evidence: `src/services/dropService.ts`)
- Giveaway lifecycle → Discord platform: posts announcements (evidence: `src/services/giveawayService.ts`)
- Giveaway lifecycle → Giveaway settings: uses settings (evidence: `src/services/giveawayService.ts`)
- Entry eligibility → Giveaway settings: uses thresholds (evidence: `src/services/antiSpamService.ts`)
- Giveaway lifecycle → Discord platform: updates messages (evidence: `src/services/giveawayService.ts`)
- Drop lifecycle → Discord platform: posts drop
- Deadline scheduler → JSON persistence adapter: checks deadlines (evidence: `src/services/giveawaySchedulerService.ts`)
