Case Study
Discord Gambling Hub
A multi-repo virtual economy and casino platform for Discord communities: configurable games, gated ATM deposits, predictions, raffles, VIP rooms, quests, and a Next.js admin panel.
Built as three applications: Discord bot, admin dashboard, and a shared NPM package. Schemas, math, and configuration never drift between Discord and the web.
Status
Shipped for the current scope: multi-repo economy and casino, European roulette, interactive sessions, engagement systems, admin ops, presentation demo, workers, CI/VPS deploy, and Vitest coverage. Core platform is complete.

How it grew
The project did not start as a three-repo platform. It grew in layers as the problem got harder:
- Phase 1 - Discord bot: slash commands, virtual currency, and early casino games living in one Node process.
- Phase 2 - Admin dashboard: guild managers needed tables, settings, and ATM approval without digging through Discord embeds.
- Phase 3 - Shared package: duplicated schemas and payout math were a drift risk, so models, Zod forms, and RTP helpers moved into gambling-bot-shared.
- Phase 4 - Ecosystem: interactive multi-bet games, quests, pay, workers for abandoned sessions, audits, and per-game ops controls.
Motivation & goals
The target was a persistent, auditable casino in Discord - deeper than one-off fun commands. Moderators tune the economy without redeploying; players get transparent rules, history, and fair odds.
- Per-guild virtual currency with immutable transaction logs and admin-approved deposits/withdrawals (suited to RP servers).
- Configurable casino games with computed RTP, not magic numbers - including multi-bet interactive sessions.
- Engagement systems: daily bonuses, VIP rooms, predictions, raffles, and quests.
- A web dashboard for managers to inspect users, cash flow, ATM queues, health, and settings.
- One shared TypeScript package so bot and dashboard never disagree on schemas or math.
System at a glance
Each app deploys independently and talks to the same MongoDB. The bot owns gameplay and Discord side effects; the dashboard owns OAuth, forms, and ops views; the shared package owns the rules both must agree on.
Discord Bot
- discord.js v14 + CommandKit
- Casino, ATM, VIP, predictions, raffles, quests, mod tools
- Background workers for sessions & economy hygiene
- Vitest + mongodb-memory-server
Shared Package
- Domain subpath exports (casino, vip, quests, …)
- Mongoose models + Zod form schemas
- RTP math, bet validators, defaults
- Versioned independently; bot & admin pin together
Admin Dashboard
- Next.js 16, React 19, Tailwind 4
- Discord OAuth + guild-scoped access
- Users, ATM queue, reports, health, audits
- Live RTP while editing casino settings
Deep dives
Chapter 1
Architecture & Shared Package
Three repos, one MongoDB, domain subpath exports that keep bot and dashboard aligned.
Chapter 2
Economy & Trust
Dual balances, immutable transactions, gated ATM, player pay, and lock reconciliation.
Chapter 3
Casino Engine & Fairness
Instant and interactive casino games, multi-bet sessions, per-game toggles, and computed RTP.
Chapter 4
Engagement Systems
Daily bonuses, VIP rooms, predictions, raffles, and quest progression.
Chapter 5
Admin Dashboard & Ops
Guild-scoped dashboard, ATM queue, audits, settings with live RTP, and /present demo mode.
Chapter 6
Testing & Reliability
CI, VPS/PM2 deploys, workers, Vitest coverage, and the hard problems the system had to solve.