You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lifecycle Policy: This master tracking issue details all architectural, infrastructural, and feature differences between upstream galnir/Master-Bot and the PhantomNimbi/Master-Bot modernization fork.
π Summary
This issue serves as the master architectural blueprint and tracking roadmap for modernizing Master-Bot. The project unifies the Discord bot gateway and the Next.js 15 web dashboard into a single, high-performance Node.js service, embeds the Lavalink v4 audio server via @helix-origin/lavalink-server, incorporates a universal testing suite via @helix-origin/vitest-suite, introduces dual external PostgreSQL/Redis support with zero-ops SQLite/ioredis-mock fallbacks, transitions hosting recommendations from unreliable PaaS cloud platforms to high-performance low-cost VPS providers (with Heroku as an optional cloud alternative), and deploys an extensive multi-agent ecosystem (.agents/).
Broken Audio Engine: Lavalink v3 experienced YouTube IP rate limits, broken scraping, and lacked plugin extensibility.
Operational Complexity: Required separate PostgreSQL and Redis server daemons to run even a single local development instance.
Multi-Process Friction: Separate Node.js processes for bot gateway (3000) and dashboard (3001) caused port collisions and deployment issues.
Cloud PaaS Limitations: Deploying to ephemeral PaaS containers (Render, Railway, Fly.io) resulted in lost SQLite data upon sleep/restart, high costs for 2GB+ RAM required by Java Lavalink, and blocked subdomains in OAuth flows.
Testing & Tooling Gaps: Incomplete test coverage and loose linting configurations led to hidden regressions.
This modernization fork resolves these challenges by making the stack zero-ops out of the box while establishing clear production paths on low-cost unmetered Linux VPS instances.
π Structural Guidance (Mermaid Diagrams)
1. Unified Service Architecture
flowchart TD
subgraph ClientLayer [Clients & Endpoints]
DiscordAPI[Discord Gateway API]
WebUsers[Browser Users / Dashboard]
VoiceGateway[Discord Voice WebSockets]
end
subgraph MasterBotService [Master-Bot Unified Service :3000]
Router[Internal HTTP / SSR Web Server]
BotClient[Sapphire Discord Client]
DashboardApp[Next.js 15 App Router & tRPC v11]
EmbeddedLavalink[Embedded Lavalink Server / Supervisor]
SessionMgr[In-Memory SessionManager]
end
subgraph StorageLayer [Dual Storage & Fallback Architecture]
subgraph DBEngine [Database Layer]
direction TB
PG[(External PostgreSQL)]
SQLite[(Local SQLite: db.sqlite)]
DBEngineSelect{DATABASE_URL starts with postgres?}
DBEngineSelect -->|Yes| PG
DBEngineSelect -->|No / Default| SQLite
end
subgraph CacheEngine [Cache Layer]
direction TB
ExtRedis[(External Redis Server)]
MockRedis[In-Memory ioredis-mock]
CacheSelect{REDIS_URL or REDIS_HOST set?}
CacheSelect -->|Yes| ExtRedis
CacheSelect -->|No / Fallback| MockRedis
end
end
DiscordAPI <--> BotClient
WebUsers <--> Router
Router <--> DashboardApp
DashboardApp <--> BotClient
BotClient <--> SessionMgr
SessionMgr <--> StorageLayer
BotClient <--> EmbeddedLavalink
VoiceGateway <--> EmbeddedLavalink
Loading
2. Embedded Lavalink Audio Pipeline
sequenceDiagram
autonumber
actor User as Discord User
participant Bot as Master-Bot (Sapphire Client)
participant Lava as Embedded Lavalink Server (@helix-origin/lavalink-server)
participant YT as YouTube API / Remote Cipher
participant DiscVoice as Discord Voice Channel
User->>Bot: /play query: "lo-fi beats"
Bot->>Lava: REST search / loadtracks
Lava->>YT: Resolve track metadata & stream signatures
YT-->>Lava: Audio track streams
Lava-->>Bot: Track load response
Bot->>DiscVoice: Join voice channel
Bot->>Lava: WebSocket voice update (session ID & token)
Lava->>DiscVoice: Stream real-time Opus audio packets
Bot-->>User: Now Playing rich embed with interactive buttons
Loading
3. Database & Cache Seamless Fallback State Machine
Unified Port & Process: Discord Bot Gateway (Sapphire framework) and Next.js 15 Web Dashboard (/dashboard) co-exist in a single Node.js process listening on PORT (default 3000).
Internal Web Server (apps/bot/src/lib/server/webServer.ts):
Serves landing root (/) and handles dashboard SSR routing.
Exposes /health endpoint for container health probes and uptime monitors.
Background keepAlive service auto-pings /health every 10 minutes to prevent ephemeral cloud spin-downs.
Unified Scripts: pnpm dev and pnpm start operate out of the box across all operating systems.
2. ποΈ Dual Database Architecture (PostgreSQL with SQLite Fallback)
Zero-Ops Default: Runs SQLite (packages/db/prisma/db.sqlite) automatically without database installation.
Dynamic Schema Preparation (packages/db/scripts/prepare-schema.mjs): Inspects DATABASE_URL at build/push time. When pointed at PostgreSQL, dynamically generates PostgreSQL schema with @db.Text annotations; otherwise configures SQLite.
Shared ORM Instance: Bot and Dashboard share @master-bot/db client for zero-latency cross-talk.
3. β‘ Dual Cache Architecture (External Redis with ioredis-mock Fallback)
Configurable External Redis: Reads REDIS_URL or REDIS_HOST & REDIS_PORT.
Automatic In-Memory Fallback: When Redis is omitted or unreachable, seamlessly activates in-memory ioredis-mock with graceful warning logs instead of crashing the process.
Why VPS is Preferred: Eliminates ephemeral filesystem resets that destroy SQLite databases, avoids high RAM pricing on PaaS for Lavalink audio, and prevents OAuth domain blocking.
Recommended Providers: Hetzner Cloud (CX22 β¬3.79/mo), OVHcloud Starter ($4.20/mo), DigitalOcean ($4-$6/mo), Linode ($5/mo), Vultr ($3.50-$5/mo), and Contabo (VPS S ~β¬5.50/mo for 8GB RAM).
Heroku Cloud Alternative: Documented as an optional choice for users requiring managed PaaS, configured with Heroku Postgres and external Lavalink.
Type Safety: pnpm type-check succeeds with 0 TypeScript compilation errors across all workspace packages.
Linting & Code Quality: pnpm lint passes with 0 errors via ESLint and manypkg.
Unit Testing: pnpm test executes with 100% pass rate using @helix-origin/vitest-suite.
Zero-Ops Default: Repository boots from scratch with pnpm install && pnpm start with zero external dependencies.
Production Scaling: Connecting PostgreSQL and Redis via environment variables works without code modifications.
VPS Ready: Clear guides provided for Docker Compose and Node.js + PM2 on low-cost VPS hosts (Hetzner, OVH, DigitalOcean, Linode, Vultr, Contabo), with Heroku as an optional cloud alternative.
π οΈ Verification Matrix
β pnpm lint β 0 errors across 6 workspaces (FULL TURBO)
β pnpm type-check β 0 errors across all packages (@master-bot/auth, @master-bot/bot, @master-bot/dashboard, @master-bot/db)
β pnpm test β 100% test pass rate using @helix-origin/vitest-suite presets
β Database Pre-check β Prepared Prisma schema for SQLite / PostgreSQL dynamically
β Deployment Docs β VPS guides (Docker/PM2) + low-cost host comparisons + optional Heroku guide
This master tracking issue remains OPEN until Pull Request #829 is accepted and merged into main.
πΊοΈ Roadmap(modernization): Master-Bot Unified Architecture, Lavalink v4 Audio Engine, Dual DB/Redis Fallbacks & Agent Ecosystem
Note
PhantomNimbi/Master-Bot.galnir/Master-Botand thePhantomNimbi/Master-Botmodernization fork.π Summary
This issue serves as the master architectural blueprint and tracking roadmap for modernizing Master-Bot. The project unifies the Discord bot gateway and the Next.js 15 web dashboard into a single, high-performance Node.js service, embeds the Lavalink v4 audio server via
@helix-origin/lavalink-server, incorporates a universal testing suite via@helix-origin/vitest-suite, introduces dual external PostgreSQL/Redis support with zero-ops SQLite/ioredis-mockfallbacks, transitions hosting recommendations from unreliable PaaS cloud platforms to high-performance low-cost VPS providers (with Heroku as an optional cloud alternative), and deploys an extensive multi-agent ecosystem (.agents/).π― Motivation & Context
Upstream
galnir/Master-Botfaced critical operational hurdles:3000) and dashboard (3001) caused port collisions and deployment issues.This modernization fork resolves these challenges by making the stack zero-ops out of the box while establishing clear production paths on low-cost unmetered Linux VPS instances.
π Structural Guidance (Mermaid Diagrams)
1. Unified Service Architecture
flowchart TD subgraph ClientLayer [Clients & Endpoints] DiscordAPI[Discord Gateway API] WebUsers[Browser Users / Dashboard] VoiceGateway[Discord Voice WebSockets] end subgraph MasterBotService [Master-Bot Unified Service :3000] Router[Internal HTTP / SSR Web Server] BotClient[Sapphire Discord Client] DashboardApp[Next.js 15 App Router & tRPC v11] EmbeddedLavalink[Embedded Lavalink Server / Supervisor] SessionMgr[In-Memory SessionManager] end subgraph StorageLayer [Dual Storage & Fallback Architecture] subgraph DBEngine [Database Layer] direction TB PG[(External PostgreSQL)] SQLite[(Local SQLite: db.sqlite)] DBEngineSelect{DATABASE_URL starts with postgres?} DBEngineSelect -->|Yes| PG DBEngineSelect -->|No / Default| SQLite end subgraph CacheEngine [Cache Layer] direction TB ExtRedis[(External Redis Server)] MockRedis[In-Memory ioredis-mock] CacheSelect{REDIS_URL or REDIS_HOST set?} CacheSelect -->|Yes| ExtRedis CacheSelect -->|No / Fallback| MockRedis end end DiscordAPI <--> BotClient WebUsers <--> Router Router <--> DashboardApp DashboardApp <--> BotClient BotClient <--> SessionMgr SessionMgr <--> StorageLayer BotClient <--> EmbeddedLavalink VoiceGateway <--> EmbeddedLavalink2. Embedded Lavalink Audio Pipeline
sequenceDiagram autonumber actor User as Discord User participant Bot as Master-Bot (Sapphire Client) participant Lava as Embedded Lavalink Server (@helix-origin/lavalink-server) participant YT as YouTube API / Remote Cipher participant DiscVoice as Discord Voice Channel User->>Bot: /play query: "lo-fi beats" Bot->>Lava: REST search / loadtracks Lava->>YT: Resolve track metadata & stream signatures YT-->>Lava: Audio track streams Lava-->>Bot: Track load response Bot->>DiscVoice: Join voice channel Bot->>Lava: WebSocket voice update (session ID & token) Lava->>DiscVoice: Stream real-time Opus audio packets Bot-->>User: Now Playing rich embed with interactive buttons3. Database & Cache Seamless Fallback State Machine
stateDiagram-v2 [*] --> InspectEnv: Service Startup InspectEnv --> PostgreSQL: DATABASE_URL = postgresql://... InspectEnv --> SQLiteFallback: Default / file:./db.sqlite PostgreSQL --> ConnectPostgres ConnectPostgres --> PostgresActive: Success ConnectPostgres --> SQLiteFallback: Connection Refused / Fallback InspectEnv --> ExternalRedis: REDIS_URL or REDIS_HOST configured InspectEnv --> MockRedisFallback: Default / In-Memory ExternalRedis --> ConnectRedis ConnectRedis --> RedisActive: Success ConnectRedis --> MockRedisFallback: Timeout / Errorπ High-Level Comparison Matrix
galnir/Master-Bot)PhantomNimbi/Master-Bot)3000) & Dashboard (3001) run separatelyPORT(3000)postgresql://...)packages/db/prisma/db.sqliteredis://...)ioredis-mock@helix-origin/lavalink-server@helix-origin/vitest-suitewith Discord & storage mocksβ¬3.79/mo), OVH ($4.20/mo), DigitalOcean, Linode, Vultr, Contabo (optional Heroku)/healthauto-pinged every 10 mins).agents/ecosystem: 8 agents, 8 skills (gh CLI, issue, wiki), 5 rules, 5 templatesπ Complete Modernization Breakdown
1. ποΈ Consolidated Single-Process Architecture
/dashboard) co-exist in a single Node.js process listening onPORT(default3000).apps/bot/src/lib/server/webServer.ts):/) and handles dashboard SSR routing./healthendpoint for container health probes and uptime monitors.keepAliveservice auto-pings/healthevery 10 minutes to prevent ephemeral cloud spin-downs.pnpm devandpnpm startoperate out of the box across all operating systems.2. ποΈ Dual Database Architecture (PostgreSQL with SQLite Fallback)
packages/db/prisma/db.sqlite) automatically without database installation.packages/db/scripts/prepare-schema.mjs): InspectsDATABASE_URLat build/push time. When pointed at PostgreSQL, dynamically generates PostgreSQL schema with@db.Textannotations; otherwise configures SQLite.@master-bot/dbclient for zero-latency cross-talk.3. β‘ Dual Cache Architecture (External Redis with
ioredis-mockFallback)REDIS_URLorREDIS_HOST&REDIS_PORT.ioredis-mockwith graceful warning logs instead of crashing the process.4. π΅ Embedded Lavalink v4 Audio Engine (
@helix-origin/lavalink-server)@helix-origin/lavalink-serverdirectly intoapps/bot.LAVA_EXTERNAL=truetoggle allows instant connection to external remote audio nodes when deploying on constrained container memory limits.5. π Low-Cost VPS Hosting Strategy (Replacing Ephemeral PaaS)
β¬3.79/mo), OVHcloud Starter ($4.20/mo), DigitalOcean ($4-$6/mo), Linode ($5/mo), Vultr ($3.50-$5/mo), and Contabo (VPS S ~β¬5.50/mo for 8GB RAM).6. π§ͺ Universal Modular Vitest Testing Suite (
@helix-origin/vitest-suite)defineMonorepoConfig.createMockClient,createMockInteraction,createMockGuild), HTTP server harnesses, and Redis test doubles.7. π€ Autonomous Agent Ecosystem (
.agents/&AGENTS.md)architect,database-engineer,audio-engineer,test-engineer,github-specialist,dashboard-specialist,bot-specialist,release-engineer.gh-cli-expert: Comprehensive GitHub CLI automation (issues, PRs, runs, releases, tarballs).issue-orchestrator: Human-readable issue creation with emojis, Mermaid diagrams, and sub-issues.wiki-management: Proper GitHub wiki links, sidebar, and footer pages.database-fallback: PostgreSQL/SQLite and Redis/ioredis-mock management.embedded-lavalink: Audio node supervision and proxy routing.vitest-suite-expert: Test authoring and quality gating.monorepo-orchestrator: Turbo and pnpm pipeline execution.release-orchestrator: Release tagging and packaging.π§© Sub-Issues & Tasks (Discrete Milestone Tracking)
INTERNAL_URL) and clean environment schemasapps/bot,@master-bot/db) and establish pre-compiled declarations@master-bot/dbioredis-mockfallback in@master-bot/db@helix-origin/lavalink-serverwith external node toggle@helix-origin/vitest-suitetesting toolkit and configure workspace test runners.agents/ecosystem (Agents, Skills, Rules, Templates) with GitHub CLI & Issue Standardspnpm lint,pnpm type-check, andpnpm test(0 errors)π Acceptance Criteria & Quality Gates
pnpm type-checksucceeds with 0 TypeScript compilation errors across all workspace packages.pnpm lintpasses with 0 errors via ESLint andmanypkg.pnpm testexecutes with 100% pass rate using@helix-origin/vitest-suite.pnpm install && pnpm startwith zero external dependencies.π οΈ Verification Matrix
This master tracking issue remains OPEN until Pull Request #829 is accepted and merged into
main.