Demo: the real backend contract of MercyNight, a party-music app ← back to landing

Functions

Server-side surface of the contract: edge functions (runtime: deno) and Postgres RPC functions.

Edge functions 5

session-management POST

Session lifecycle (create/join/leave/end/state/play-song/advance-song/...). Action via URL path suffix.

game-logic POST

Voting with democratic skip, playback start, rotation calculation.

youtube-integration POST

YouTube search, video details, trending, availability checks.

quiz-generation POST

AI quiz challenge generation backed by challenge_pool.

realtime-coordination POST

Broadcast state, presence, heartbeat, event acknowledgement.

RPC functions 8

add_song_to_player_queue RPC

Adds a song to the calling player's personal queue; returns the queue item id.

  • req p_session_id uuid
  • req p_user_id uuid
  • req p_youtube_id text
  • req p_title text
  • req p_artist text
  • req p_thumbnail_url text
  • req p_duration integer
  • returns uuid

advance_to_next_player_song RPC

Advances rotation; returns rows (next_song_id, next_player_id, next_player_name).

  • req p_session_id uuid
  • returns json

get_current_player RPC

Current player in rotation; returns rows (user_id, user_name, avatar_url, queue_count).

  • req p_session_id uuid
  • returns json

initialize_player_rotation RPC

Seeds player_rotation_order on the session from active participants.

  • req p_session_id uuid
  • returns void

get_vote_tally RPC

Vote counts for a song (love_votes, meh_votes, skip_votes, total_participants, ...).

  • req session_uuid uuid
  • req song_uuid uuid
  • returns json

start_playing_song RPC

Marks a queue item as playing and finishes the previous one in the session.

  • req queue_item_id uuid
  • returns void

request_data_export RPC

Queues a GDPR data export; returns the (possibly reused pending) request id.

  • req user_id uuid
  • req email text
  • returns uuid

get_daily_challenges RPC

Stable per-day challenge set; returns SETOF challenge_pool (table not in client contract, hence json).

  • req p_date date
  • returns json