# yourpovv/mizu architecture

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

- Interactive diagram: https://gitdiagram.com/yourpovv/mizu
- Repository: https://github.com/yourpovv/mizu

## Overview

Mizu is a serverless Discord community bot. Discord sends slash-command, modal, and component interactions to one HTTP endpoint; the endpoint verifies and dispatches them, then returns responses or invokes Discord’s REST API. Its main workflows provide credits, color-role selection, game-ping management, and a custom embed preview with keep/delete confirmation. Role pickers read and update member roles; embed handling builds and posts previews. The graph follows the excerpts and README; connections for sampled modules are supported by the source index where noted, while unsampled command definitions are grouped without speculative runtime links.

Main entry points: [`api/interactions.ts`](https://github.com/yourpovv/mizu/blob/main/api/interactions.ts) (Interaction endpoint), [`src/lib/discord-rest.ts`](https://github.com/yourpovv/mizu/blob/main/src/lib/discord-rest.ts) (Discord REST client), [`src/lib/color-select.ts`](https://github.com/yourpovv/mizu/blob/main/src/lib/color-select.ts) (Color role handler), [`src/lib/game-select.ts`](https://github.com/yourpovv/mizu/blob/main/src/lib/game-select.ts) (Game role handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Interaction ingress"]
  node_api["Interaction endpoint<br/>[interactions.ts]"]
  node_commands["Slash command definitions"]
  node_credits["Credits response<br/>[credits.ts]"]
end

subgraph group_roles["Role pickers"]
  node_colors["Color picker data<br/>[colors.ts]"]
  node_colorselect["Color role handler<br/>[color-select.ts]"]
  node_games["Game picker data<br/>[games.ts]"]
  node_gameselect["Game role handler<br/>[game-select.ts]"]
end

subgraph group_embed["Embed builder"]
  node_embedflow["Embed workflow<br/>[embed-flow.ts]"]
  node_embeds["Embed construction<br/>[embeds.ts]"]
end

subgraph group_shared["Shared services"]
  node_config["Discord configuration<br/>[config.ts]"]
  node_env["Environment access<br/>[env.ts]"]
  node_rest["Discord REST client<br/>[discord-rest.ts]"]
end

node_discord(("Discord interactions"))
node_discordapi["Discord API"]

node_discord -->|"sends interactions"| node_api
node_api -->|"loads key"| node_config
node_config -->|"requires variable"| node_env
node_api -->|"builds response"| node_credits
node_api -->|"builds picker"| node_colors
node_api -->|"dispatches selection"| node_colorselect
node_colorselect -->|"uses role data"| node_colors
node_colorselect -->|"updates roles"| node_rest
node_api -->|"builds picker"| node_games
node_api -->|"dispatches selection"| node_gameselect
node_gameselect -->|"plans role sync"| node_games
node_gameselect -->|"reads and updates roles"| node_rest
node_api -->|"dispatches embed actions"| node_embedflow
node_embedflow -->|"builds modal and preview"| node_embeds
node_embedflow -->|"posts or deletes preview"| node_rest
node_rest -->|"makes REST requests"| node_discordapi

click node_api "https://github.com/yourpovv/mizu/blob/main/api/interactions.ts"
click node_commands "https://github.com/yourpovv/mizu/tree/main/src/commands"
click node_credits "https://github.com/yourpovv/mizu/blob/main/src/lib/credits.ts"
click node_config "https://github.com/yourpovv/mizu/blob/main/src/config.ts"
click node_env "https://github.com/yourpovv/mizu/blob/main/src/lib/env.ts"
click node_colors "https://github.com/yourpovv/mizu/blob/main/src/lib/colors.ts"
click node_colorselect "https://github.com/yourpovv/mizu/blob/main/src/lib/color-select.ts"
click node_games "https://github.com/yourpovv/mizu/blob/main/src/lib/games.ts"
click node_gameselect "https://github.com/yourpovv/mizu/blob/main/src/lib/game-select.ts"
click node_embedflow "https://github.com/yourpovv/mizu/blob/main/src/lib/embed-flow.ts"
click node_embeds "https://github.com/yourpovv/mizu/blob/main/src/lib/embeds.ts"
click node_rest "https://github.com/yourpovv/mizu/blob/main/src/lib/discord-rest.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_api,node_commands,node_credits toneBlue
class node_colors,node_colorselect,node_games,node_gameselect toneAmber
class node_embedflow,node_embeds,node_discordapi toneMint
class node_config,node_env,node_rest toneRose
class node_discord toneIndigo
```

## Components

### Interaction ingress

- [Interaction endpoint](https://github.com/yourpovv/mizu/blob/main/api/interactions.ts): `api/interactions.ts`
- [Slash command definitions](https://github.com/yourpovv/mizu/tree/main/src/commands): `src/commands`
- [Credits response](https://github.com/yourpovv/mizu/blob/main/src/lib/credits.ts): `src/lib/credits.ts`

### Role pickers

- [Color picker data](https://github.com/yourpovv/mizu/blob/main/src/lib/colors.ts): `src/lib/colors.ts`
- [Color role handler](https://github.com/yourpovv/mizu/blob/main/src/lib/color-select.ts): `src/lib/color-select.ts`
- [Game picker data](https://github.com/yourpovv/mizu/blob/main/src/lib/games.ts): `src/lib/games.ts`
- [Game role handler](https://github.com/yourpovv/mizu/blob/main/src/lib/game-select.ts): `src/lib/game-select.ts`

### Embed builder

- [Embed workflow](https://github.com/yourpovv/mizu/blob/main/src/lib/embed-flow.ts): `src/lib/embed-flow.ts`
- [Embed construction](https://github.com/yourpovv/mizu/blob/main/src/lib/embeds.ts): `src/lib/embeds.ts`

### Shared services

- [Discord configuration](https://github.com/yourpovv/mizu/blob/main/src/config.ts): `src/config.ts`
- [Environment access](https://github.com/yourpovv/mizu/blob/main/src/lib/env.ts): `src/lib/env.ts`
- [Discord REST client](https://github.com/yourpovv/mizu/blob/main/src/lib/discord-rest.ts): `src/lib/discord-rest.ts`

### Other components

- **Discord interactions**
- **Discord API**

## Connections

- Discord interactions → Interaction endpoint: sends interactions (evidence: `README.md`)
- Interaction endpoint → Discord configuration: loads key (evidence: `api/interactions.ts`)
- Discord configuration → Environment access: requires variable (evidence: `src/config.ts`)
- Interaction endpoint → Credits response: builds response (evidence: `api/interactions.ts`)
- Interaction endpoint → Color picker data: builds picker (evidence: `api/interactions.ts`)
- Interaction endpoint → Color role handler: dispatches selection (evidence: `api/interactions.ts`)
- Color role handler → Color picker data: uses role data (evidence: `src/lib/color-select.ts`)
- Color role handler → Discord REST client: updates roles (evidence: `src/lib/color-select.ts`)
- Interaction endpoint → Game picker data: builds picker (evidence: `api/interactions.ts`)
- Interaction endpoint → Game role handler: dispatches selection (evidence: `api/interactions.ts`)
- Game role handler → Game picker data: plans role sync (evidence: `src/lib/game-select.ts`)
- Game role handler → Discord REST client: reads and updates roles (evidence: `src/lib/game-select.ts`)
- Interaction endpoint → Embed workflow: dispatches embed actions (evidence: `api/interactions.ts`)
- Embed workflow → Embed construction: builds modal and preview (evidence: `src/lib/embed-flow.ts`)
- Embed workflow → Discord REST client: posts or deletes preview (evidence: `src/lib/embed-flow.ts`)
- Discord REST client → Discord API: makes REST requests (evidence: `src/lib/discord-rest.ts`)
