
System Architecture
Discord Bot Ecosystem
- Listens to guild membership, messages, edits, deletes, bans, kicks, and audit events.
- Reports join/leave state through
/api/internal/bot-membership.
GET /health,GET /channels,GET /guildPOST /snowflake-dispatchfor embeds, showcases, rules, products, and changelogs.- Moderation routes for timeout, kick, ban, nickname, roles, reactions, and deletion.
Indexes Discord messages into MySQL for dashboard search, context panels, deleted-state tracking, embeds, attachments, and moderation history.
Dashboard calls include x-tenant-id, x-guild-id, and the shared bot API secret so tenants cannot cross-act.
Control Plane and Data Ownership
Discord OAuth signs users in, installs the bot when requested, seeds webhooks, creates tenant rows, and assigns owner access.
- Helmet CSP, strict origin handling, image proxy checks, and body-size caps.
- HttpOnly JWT session plus role checks for owner, admin, moderator, and viewer.
- Redis-backed rate limits with memory fallback when Redis is offline.
/__bot-proxyand WS tickets keep bot secrets server-side.
Bot Owns Live Discord State
- Channels, roles, members, presence, permissions
- Messages, reactions, moderation actions
- Bot install status and gateway telemetry
Website Owns Product State
- Tenants, plans, users, branding, settings
- Products, showcases, changelogs, schedules
- Landing pages, webhooks, billing, telemetry
The browser never receives bot secrets. /__bot-proxy validates the session, injects the bot secret, and forwards scoped calls.
/api/bot/ws-ticket mints short-lived tickets for the bot /ws stream, with REST polling fallback.
Website and Dashboard
Staff activity, system logs, webhook delivery health, moderation history, daily telemetry snapshots, and CSV exports.
Studio+ tenants expose community landing pages at panel.snowflake-studios.xyz/c/{slug} while staff work stays authenticated.
External Services
- OAuth2 login and guild discovery
- Bot install and permissions consent
- Gateway events plus REST moderation actions
- Seeded during OAuth setup
- Managed per tenant and channel
- Used for publish and alert workflows
- Checkout sessions and customer portal
/api/billing/webhookplan updates- Sentry captures server and client errors
Domains and Hosting
Persistence, Guards, and Deployment
MySQL Persistence
- Tenant isolation through
tenant_idforeign keys and scoped helpers. - Core tables: tenants, users, branding, bot settings, products, showcases, changelogs.
- Operational tables: messages, moderation history, activity logs, telemetry, webhooks.
Redis and Runtime Guards
- Distributed API and login rate limiting with memory fallback.
- Bot health cache prevents noisy status pings.
- Proxy caps and private-host checks reduce SSRF and abuse risk.
Build and Release Path
npm run buildcreates the Vite SPA indist.npm run startrunsserver.cjs.npm run db:migrateapplies production schema upgrades.