MusivaDocs
Internal Systems

Musiva Core Backend

The central orchestration server managing Discord bot interactions, API endpoints, and real-time state synchronization.

The Musiva Backend is the core operational hub of the ecosystem. Written in TypeScript and built on an asynchronous architecture, it coordinates Discord gateway events, player queues, database persistence, and external service communication.


Core Responsibilities

The backend server oversees the following major subsystems:

  1. Discord Gateway & Slash Commands:

    • Receives interaction events from Discord (/play, /skip, /filters, /queue).
    • Evaluates user voice channel states, permissions, and DJ role requirements.
  2. REST & WebSocket API Server:

    • Exposes authenticated endpoints consumed by the WebPlayer dashboard and mobile clients.
    • Dispatches bidirectional WebSocket events for real-time track progress, playback states (trackStart, playerResume, trackEnd), and queue mutations.
  3. Data Persistence & Cache (Drizzle ORM):

    • Persists user playlists, guild configurations, custom prefixes, volume defaults, and 24/7 channel settings into MySQL/MariaDB.
    • Utilizes in-memory caching mechanisms to minimize database query latency.
  4. Premium & Role Access Engine:

    • Validates server premium statuses, Patreon subscriber roles, and guild entitlements.
  5. Audio Source Orchestration:

    • Routes search queries through Musiva's prioritized engine order: Deezer -> Apple Music -> Tidal -> Spotify -> YouTube Music.