🚀 Master-Bot Unified Architecture, Lavalink v4 Audio Engine, Dual DB/Redis Fallbacks & Agent Ecosystem - #829
Closed
PhantomNimbi wants to merge 101 commits into
Closed
PhantomNimbi wants to merge 101 commits into
PhantomNimbi wants to merge 101 commits into
Conversation
…nd update now playing embed
…YouTube device flow auth to console
…s for interactive terminal view
… auth output and file log exclusion
… audit, and API key gating
…thout disk mutation
…d strip trailing JSON delimiters
…Redis keys in Queue.leave() unconditionally
…nce bot & dashboard - Upgrade Next.js to 15.2.0 and migrate App Router to async request APIs (await params, useParams) - Upgrade Auth.js/NextAuth to v5 beta with server action handlers and safe Discord avatar URL resolution - Upgrade @next/eslint-plugin-next to 15.2.0 and align environment parsers to @t3-oss/env-* 0.13.11 - Replace pure-ESM env wrapper in @master-bot/bot with native Zod schema parsing for 100% CJS compatibility - Wire dynamic feature flags (LAVA_ENABLED, GIFS_ENABLED, TWITCH_ENABLED, NEWS_ENABLED, IGDB_ENABLED) across bot preconditions - Connect automated cross-platform PostgreSQL and Redis service checks (connect-or-auto-launch) - Implement dynamic command help registry and standardized help tables across all 60 slash commands - Enhance web dashboard with active-tab sidebar navigation, server overview statistics, and Redis log streaming - Resolve next-themes hydration mismatch by adding suppressHydrationWarning to root layout
…sabled commands - Group slash commands into structured categories (GIFs & Anime, Twitch, News, Games & Entertainment, General & Utilities) - Filter out categories and individual commands disabled globally via environment feature flags (LAVA_ENABLED, GIFS_ENABLED, TWITCH_ENABLED, NEWS_ENABLED, IGDB_ENABLED) - Display server-specific enable/disable toggles and active status badges for all active commands
…ys monorepo-wide - Configure remoteCipher in application.yml with default endpoint (https://cipher.kikkia.dev/) and support custom YOUTUBE_CIPHER_URL / YOUTUBE_CIPHER_PASSWORD - Pass deterministic Java system properties (-D) for YouTube OAuth, skipInitialization, cipher, and Spotify credentials in launcher scripts - Wire YOUTUBE_CIPHER_URL and YOUTUBE_CIPHER_PASSWORD into @master-bot/bot, @master-bot/api, @master-bot/dashboard env schemas and .env.example - Display active cipher endpoint in dev and production console status banners
…ash command, and fix dual-domain auth
… remote cipher, and active music engine
16 tasks
…nds with fuzzy matching and scoring
…t, and add granular audit log dashboard
…on and ticket features
…, and README button
…eholders in app.json
application.yml.example is a customized config, not Lavalink stock: it fixes broken YouTube playback (youtube-plugin multi-client rotation + remoteCipher + optional OAuth) and Spotify resolution (lavasrc ISRC providers), with tuned streaming buffers. - Add missing wiki/Lavalink.md (fixes dangling reference in application.yml.example header): what the config changes vs stock, plugin pins, env vars, PORT/LAVA_PORT interplay, plugin upgrades - Prepare application.yml from our template in heroku-setup-lavalink.sh and warn against Lavalink default config in Deployment/Music/ Getting-Started docs
pnpm --filter runs the bot with cwd=apps/bot, so the Next.js dashboard was never found (/.next missing) and the internal web service failed to start on Heroku. Add candidates relative to the package dir and the compiled dist path so /app/apps/dashboard resolves correctly.
…; recommend custom domain
…self-hosted VPS & Docker - 🗑️ Removed Procfile cloud deployment file - 🌐 Added curated list of recommended low-cost compatible VPS services (Hetzner, OVH, DigitalOcean, Linode, Vultr) with hardware sizing tips - 🔗 Removed retired onrender.com public Lavalink endpoints across documentation and wiki guides - 📚 Updated README, Getting-Started, Music, Configuration, Deployment, and FAQ guides to standardize on self-hosted Docker and VPS infrastructure - ⚡ Preserved internal keep-alive service for custom environments
… & legal policies - Import @helix-origin/vitest-suite (v0.2.3) as universal monorepo testing suite - Import @helix-origin/lavalink-server (v1.1.0) and embed Lavalink v4 engine in apps/bot - Implement dynamic PostgreSQL and SQLite schema switching via packages/db/scripts/prepare-schema.mjs - Implement dual external Redis and in-memory ioredis-mock fallback in packages/db/index.ts - Construct comprehensive .agents ecosystem with 8 agents, 8 skills, 6 rules, 6 templates, and root AGENTS.md - Replace cloud hosting documentation with low-cost VPS providers (Hetzner, OVH, DigitalOcean, Linode, Vultr, Contabo) and optional Heroku guide - Author complete PRIVACY.md, TOS.md, and SECURITY.md policies with corresponding /privacy and /terms dashboard routes - Configure .github/SECURITY.md and issue template security advisory contact links - Fix linting, TypeScript types, and dependency sorting issues across all workspaces - Ref galnir#828, galnir#829
- Rename .github/workflows/main.yml to .github/workflows/ci.yml and configure concurrency grouping - Inject environment variables and auto-generate .env from template prior to pnpm install to resolve Prisma SQLite generation in CI - Remove unconfigured legacy Prettier step in favor of pnpm lint, pnpm test, pnpm type-check, and pnpm build quality gates - Create .github/workflows/wiki.yml to synchronize wiki/ documentation directory with GitHub Wiki repository - Document PAT_TOKEN requirement in wiki-management skill for automated wiki deployment - Ref galnir#828, galnir#829
… docs - Remove /youtube-auth slash command and legacy youtubeOAuth module in favor of embedded Lavalink startup authorization - Move getApplicationOwnerUser helper to apps/bot/src/lib/structures/owner.ts for dashboard command access control - Update command counts from 74 to 73 across README and documentation - Update README.md, apps/bot/README.md, and wiki guides (Commands, Configuration, FAQ, Getting-Started, Music) to detail automatic embedded server startup token handling - Ref galnir#828, galnir#829
… alerts - Consolidate gif commands into a single /gif command with modular tag options in apps/bot/src/lib/gifs/options/ under category fun - Consolidate /set subcommands into a single /set command with modular options in apps/bot/src/lib/set/options/ - Migrate database connection strictly to DB_URI (file:/data/database.db) and eliminate redundant DATABASE_URL and DB_URL variables - Remove unused YOUTUBE_API_KEY and configure YOUTUBE_CLIENT_ID and YOUTUBE_CLIENT_SECRET for YouTube Stream & Upload Alerts - Support forum and text channels for YouTube alerts - Set INTERNAL_URL format to 0.0.0.0:3000 for dual public (PUBLIC_URL) and internal connectivity - Add unit tests for gif, set, youtube alerts, database fallback, and embedHandler (all 44 tests passing)
- Streamline README.md to follow upstream general format, delegating in-depth deployment and config details to the wiki - Update SECURITY.md to clarify fork purpose is fixing issues and contributing improvements upstream via PR
- Remove all mentions of this repository being a fork from README.md, SECURITY.md, and wiki/_Sidebar.md - Ensure all documentation reads canonically for direct upstream integration - Update CONTRIBUTING.md SQLite db path to /data/database.db
…stream alert guides
…e to db.sqlite - Introduce 7 visual themes: Dark, Light, Glassmorphism, Cyberpunk, Dracula, Nord, and Emerald - Add 10 accent color schemes with live CSS variable overrides and swatches in theme dropdown - Implement ColorSchemeContext in ThemeProvider with localStorage persistence and dynamic scheme-* class application - Update dashboard layout and home page to utilize semantic Tailwind tokens (bg-background, text-foreground) - Standardize SQLite persistence file to db.sqlite with automatic migration fallback from legacy database.db - Expose DASHBOARD_THEME and DASHBOARD_COLOR_SCHEME in env validation and turbo.json - Update all documentation and wiki references to db.sqlite and theme customization
- Set maintainer attribution to galnir and the Master-Bot community
- Update package.json license fields across all packages and workspaces to MIT - Update wiki badges, _Footer.md, and TOS.md to reference MIT license
- Add scripts/common.mjs with shared utilities: loadEnv(), loadYouTubeToken(), extractPort(), freePort(), killProcessTree(), isPortInUse(), waitForPort(), checkJavaVersion(), createLogWriter(), and YouTube OAuth token capture/persist helpers - Add scripts/dev.mjs as the development launcher: spawns bot (which auto-embeds the dashboard), supports --parallel flag to split bot and dashboard into separate processes with DISABLE_INTERNAL_DASHBOARD=true, wires dedicated log streams (bot.log, dashboard.log, combined.log) with prefixed, color-coded output - Add scripts/start.mjs as the production launcher: spawns the unified bot+dashboard process, wires bot.log and combined.log, prints a branded production banner, handles graceful SIGINT/SIGTERM/SIGHUP shutdown via killProcessTree() - Neither script attempts to spawn Redis (handled in-process via ioredis-mock) or Lavalink.jar (handled by embedded @helix-origin/lavalink-server package) - Update root package.json dev/start scripts to point to node scripts/dev.mjs and node scripts/start.mjs instead of calling pnpm --filter directly
Author
|
Ok. after going through all this work and having it working almost perfectly on my machine I decided to test it on my VPS only to discover I had wasted my time and money on AI credits attempting to fix the problems in this repo. At this point I think I'm going to give up. The turbo rebuild is causing too many problems that need to be patched around instead of properly fixed and that just doesn't sit right with me. So I'm closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Master-Bot Unified Architecture, Lavalink v4 Audio Engine, Dual DB/Redis Fallbacks & Agent Ecosystem
Note
📖 Summary
This pull request consolidates and delivers a complete architectural modernization of Master-Bot. It unifies the Discord bot gateway (Sapphire Framework) and the Next.js 15 App Router web dashboard into a single, high-performance Node.js service on port
3000, 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, establishes an extensive multi-agent ecosystem (.agents/), authors full Discord verification legal and security policies (PRIVACY.md,TOS.md,SECURITY.md), and updates deployment guides prioritizing high-performance low-cost VPS providers (with optional Heroku support).📐 Structural Overview (GitHub-Formatted Mermaid Diagrams)
1. Unified Single-Process Architecture
flowchart TD subgraph Clients [Clients & Web Endpoints] DiscordGateway[Discord API Gateway] BrowserUsers[Web Dashboard Users] VoiceGateway[Discord Voice WebSockets] end subgraph MasterBotUnifiedService [Master-Bot Single Service :3000] WebServer[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] KeepAlive[Keep-Alive Service: Auto-Ping /health] end subgraph DualStorageLayer [Dual Storage & Fallback Architecture] subgraph DBEngine [Database Layer] direction TB PG[(External PostgreSQL)] SQLite[(Local SQLite: db.sqlite)] DBSelect{DATABASE_URL starts with postgres?} DBSelect -->|Yes| PG DBSelect -->|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 DiscordGateway <--> BotClient BrowserUsers <--> WebServer WebServer <--> DashboardApp DashboardApp <--> BotClient BotClient <--> SessionMgr SessionMgr <--> DualStorageLayer BotClient <--> EmbeddedLavalink VoiceGateway <--> EmbeddedLavalink KeepAlive -->|"GET /health"| WebServer2. 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 chillhop" Bot->>Lava: REST search / loadtracks Lava->>YT: Resolve track metadata & stream signatures YT-->>Lava: Stream Opus audio Lava-->>Bot: Track loaded response Bot->>DiscVoice: Join voice channel Bot->>Lava: WebSocket voice state update Lava->>DiscVoice: Stream real-time audio packets Bot-->>User: Interactive player embed with live progress bar3. 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-serverwith external node toggle@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)PRIVACY.md,TOS.md,SECURITY.md, and dashboard/privacy&/terms.agents/ecosystem: 8 agents, 8 skills, 6 rules, 6 templates, and rootAGENTS.md🚀 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):/), health checks (/health), and proxies dashboard SSR routing.keepAliveservice auto-pings/healthevery 10 minutes to prevent ephemeral dyno spin-downs.pnpm devandpnpm startoperate out of the box across all platforms without child-process window popups.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 (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_PORTif provided.ioredis-mockwith graceful warning logs instead of crashing the process.4. 🎵 Embedded Lavalink v4 Audio Engine (
@helix-origin/lavalink-server)@helix-origin/lavalink-serverv1.1.0 directly intoapps/bot.LAVA_EXTERNAL=truetoggle allows instant connection to external remote audio nodes when deploying on constrained container memory limits./bassboost,/nightcore,/vaporwave, and/karaoke.5. 🧪 Universal Modular Vitest Testing Suite (
@helix-origin/vitest-suite)defineMonorepoConfig.createMockClient,createMockInteraction,createMockGuild), HTTP server harnesses, and Redis test doubles.6. 🌐 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).7. ⚖️ Legal, Privacy & Security Policies (Discord Verification Ready)
PRIVACY.mdandTOS.mdcomplying with Discord Developer verification standards./privacyand/termslinked in the dashboard landing page footer.SECURITY.mdand.github/SECURITY.mdenabling GitHub's native Security Policy tab and private vulnerability reporting..github/ISSUE_TEMPLATE/config.ymlwith security advisory contact links.8. 🤖 Autonomous Agent Ecosystem (
.agents/&AGENTS.md)architect,database-engineer,audio-engineer,test-engineer,github-specialist,dashboard-specialist,bot-specialist,release-engineer.gh-cli-expert,issue-orchestrator,wiki-management,database-fallback,embedded-lavalink,vitest-suite-expert,monorepo-orchestrator,release-orchestrator.AGENTS.md.9. 📚 Comprehensive 16-Page Documentation Wiki
🧩 Sub-Issues & Completed Milestones
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 StandardsPRIVACY.md,TOS.md, andSECURITY.mdwith dashboard/privacyand/termsroutespnpm lint,pnpm type-check,pnpm test, andpnpm build(0 errors)🔍 Acceptance Criteria & Quality Gates
pnpm type-checksucceeds with 0 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 pull request is completely prepared, tested, and submitted for review and merging into
main.