# michadasis/uowm-auth-discord-bot architecture

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

- Interactive diagram: https://gitdiagram.com/michadasis/uowm-auth-discord-bot
- Repository: https://github.com/michadasis/uowm-auth-discord-bot

## Overview

This is a Discord verification bot for UoWM Informatics members. The main workflow starts with `/auth`, validates an institutional address, sends a one-time code, accepts it through a button or `/code`, then links the account and grants the appropriate role. The graph also shows documented administration, guest access, semester-role enforcement, statistics, and cleanup. Some of these modules were not sampled; their paths and capabilities come from the tree and README, so uncertain internal wiring is omitted.

Main entry points: [`bot/src/lib/emailVerification.js`](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/emailVerification.js) (Code verification), [`bot/src/lib/repository.js`](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/repository.js) (Data repository), [`bot/src/events/clientReady/maintenance.js`](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/clientReady/maintenance.js) (Startup maintenance), [`bot/src/lib/linker.js`](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/linker.js) (Account linker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_verification["Email verification"]
  node_auth_command["Auth command<br/>[auth.js]"]
  node_verification_services["Verification wiring<br/>[services.js]"]
  node_email_verification["Code verification"]
  node_email_policy["Address policy<br/>[emailPolicy.js]"]
  node_mailer["Mailer<br/>[mailer.js]"]
  node_code_entry["Code entry<br/>[codeEntry.js]"]
  node_code_interaction["Code interaction<br/>[codeEntry.js]"]
  node_linker["Account linker<br/>[linker.js]"]
  node_discord_adapter["Discord adapter<br/>[discordAdapter.js]"]
end

subgraph group_discord["Discord workflows"]
  node_admin_commands["Admin commands"]
  node_guest_management["Guest roles"]
  node_privacy_notice["Privacy instructions<br/>[privacyNotice.js]"]
  node_bot_entry["Bot runtime<br/>[bot.js]"]
end

subgraph group_operations["Member operations"]
  node_semester_guard["Semester role guard<br/>[semesterRoles.js]"]
  node_maintenance["Startup maintenance<br/>[maintenance.js]"]
  node_member_departure["Departure cleanup"]
  node_stats["Verification stats<br/>[stats.js]"]
end

subgraph group_state["Persistence and policy"]
  node_repository["Data repository<br/>[repository.js]"]
  node_database_pool["Database pool<br/>[database.js]"]
  node_schema["Database schema<br/>[setup.sql]"]
end

node_member(("Server member"))
node_discord_api(("Discord API"))
node_smtp(("Email transport"))
node_mariadb[("MariaDB")]

node_member -->|"requests code"| node_auth_command
node_auth_command -->|"gets verifier"| node_verification_services
node_verification_services -->|"constructs"| node_email_verification
node_email_verification -->|"checks address"| node_email_policy
node_email_verification -->|"sends code"| node_mailer
node_mailer -->|"delivers email"| node_smtp
node_email_verification -->|"stores challenge"| node_repository
node_member -->|"submits code"| node_code_interaction
node_code_interaction -->|"handles entry"| node_code_entry
node_code_entry -->|"verifies code"| node_email_verification
node_email_verification -->|"links account"| node_linker
node_linker -->|"checks and saves"| node_repository
node_linker -->|"assigns role"| node_discord_adapter
node_discord_adapter -->|"updates member"| node_discord_api
node_repository -->|"queries"| node_database_pool
node_database_pool -->|"reads and writes"| node_mariadb
node_schema -->|"defines tables"| node_mariadb
node_admin_commands -->|"manages verification"| node_verification_services
node_guest_management -->|"manages guest role"| node_discord_api
node_guest_management -->|"records guest"| node_mariadb
node_maintenance -->|"purges challenges"| node_repository
node_maintenance -->|"checks role policy"| node_semester_guard
node_maintenance -->|"sweeps members"| node_discord_api
node_member_departure -->|"deletes member data"| node_mariadb
node_member_departure -->|"logs departure"| node_discord_api
node_stats -->|"counts verified users"| node_mariadb
node_bot_entry -->|"connects bot"| node_discord_api
node_member -->|"runs admin command"| node_admin_commands
node_member -->|"moderates guest access"| node_guest_management
node_privacy_notice -.->|"posts notice"| node_discord_api

click node_auth_command "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/commands/utility/auth.js"
click node_verification_services "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/services.js"
click node_email_verification "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/emailVerification.js"
click node_email_policy "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/emailPolicy.js"
click node_mailer "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/mailer.js"
click node_code_entry "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/codeEntry.js"
click node_code_interaction "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/interactionCreate/codeEntry.js"
click node_linker "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/linker.js"
click node_discord_adapter "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/discordAdapter.js"
click node_repository "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/repository.js"
click node_database_pool "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/database.js"
click node_schema "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/db/setup.sql"
click node_admin_commands "https://github.com/michadasis/uowm-auth-discord-bot/tree/main/bot/src/commands/admin"
click node_guest_management "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/interactionCreate/guestRoleManagement.js"
click node_semester_guard "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/semesterRoles.js"
click node_maintenance "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/clientReady/maintenance.js"
click node_member_departure "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/guildMemberRemove/delete-user-data.js"
click node_stats "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/commands/public/stats.js"
click node_privacy_notice "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/privacyNotice.js"
click node_bot_entry "https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/bot.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_auth_command,node_verification_services,node_email_verification,node_email_policy,node_mailer,node_code_entry,node_code_interaction,node_linker,node_discord_adapter toneBlue
class node_admin_commands,node_guest_management,node_privacy_notice,node_bot_entry,node_mariadb toneAmber
class node_semester_guard,node_maintenance,node_member_departure,node_stats,node_member,node_discord_api toneMint
class node_repository,node_database_pool,node_schema toneRose
class node_smtp toneIndigo
```

## Components

### Email verification

- [Auth command](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/commands/utility/auth.js): `bot/src/commands/utility/auth.js`
- [Verification wiring](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/services.js): `bot/src/lib/services.js`
- [Code verification](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/emailVerification.js): `bot/src/lib/emailVerification.js`
- [Address policy](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/emailPolicy.js): `bot/src/lib/emailPolicy.js`
- [Mailer](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/mailer.js): `bot/src/lib/mailer.js`
- [Code entry](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/codeEntry.js): `bot/src/lib/codeEntry.js`
- [Code interaction](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/interactionCreate/codeEntry.js): `bot/src/events/interactionCreate/codeEntry.js`
- [Account linker](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/linker.js): `bot/src/lib/linker.js`
- [Discord adapter](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/discordAdapter.js): `bot/src/lib/discordAdapter.js`

### Discord workflows

- [Admin commands](https://github.com/michadasis/uowm-auth-discord-bot/tree/main/bot/src/commands/admin): `bot/src/commands/admin`
- [Guest roles](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/interactionCreate/guestRoleManagement.js): `bot/src/events/interactionCreate/guestRoleManagement.js`
- [Privacy instructions](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/privacyNotice.js): `bot/src/lib/privacyNotice.js`
- [Bot runtime](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/bot.js): `bot/src/bot.js`

### Member operations

- [Semester role guard](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/semesterRoles.js): `bot/src/lib/semesterRoles.js`
- [Startup maintenance](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/clientReady/maintenance.js): `bot/src/events/clientReady/maintenance.js`
- [Departure cleanup](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/events/guildMemberRemove/delete-user-data.js): `bot/src/events/guildMemberRemove/delete-user-data.js`
- [Verification stats](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/commands/public/stats.js): `bot/src/commands/public/stats.js`

### Persistence and policy

- [Data repository](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/repository.js): `bot/src/lib/repository.js`
- [Database pool](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/bot/src/lib/database.js): `bot/src/lib/database.js`
- [Database schema](https://github.com/michadasis/uowm-auth-discord-bot/blob/main/db/setup.sql): `db/setup.sql`

### Other components

- **Server member**
- **Discord API**
- **Email transport**
- **MariaDB**

## Connections

- Server member → Auth command: requests code
- Auth command → Verification wiring: gets verifier
- Verification wiring → Code verification: constructs
- Code verification → Address policy: checks address
- Code verification → Mailer: sends code
- Mailer → Email transport: delivers email
- Code verification → Data repository: stores challenge
- Server member → Code interaction: submits code
- Code interaction → Code entry: handles entry
- Code entry → Code verification: verifies code
- Code verification → Account linker: links account
- Account linker → Data repository: checks and saves
- Account linker → Discord adapter: assigns role
- Discord adapter → Discord API: updates member
- Data repository → Database pool: queries
- Database pool → MariaDB: reads and writes
- Database schema → MariaDB: defines tables
- Admin commands → Verification wiring: manages verification
- Guest roles → Discord API: manages guest role
- Guest roles → MariaDB: records guest
- Startup maintenance → Data repository: purges challenges
- Startup maintenance → Semester role guard: checks role policy
- Startup maintenance → Discord API: sweeps members
- Departure cleanup → MariaDB: deletes member data
- Departure cleanup → Discord API: logs departure
- Verification stats → MariaDB: counts verified users
- Bot runtime → Discord API: connects bot
- Server member → Admin commands: runs admin command
- Server member → Guest roles: moderates guest access
- Privacy instructions → Discord API: posts notice
