Skip to content

Blog · 27 posts

Notes from the build.

What I learned building Melodius and Krypton: real decisions, real code, and the bugs that taught me something. No listicles.

  1. 1 Nov 2026PostgreSQL patterns for multi-process Discord botsFive PostgreSQL patterns from Krypton for bots that run as several processes: atomic claims, unique-row dedup, FOR UPDATE SKIP LOCKED queues, advisory locks, and LISTEN/NOTIFY cache invalidation.3 min
  2. 1 Nov 2026Keeping friends in sync: clock offsets and drift correction for group listeningHow Melodius Jams keep everyone on the same second of a song: server-anchored positions, NTP-style clock offsets, gentle playback-rate correction and reconnects with jitter.3 min
  3. 1 Nov 2026Building a 10-band equalizer with the Web Audio APIThe audio chain behind Melodius's equalizer: shelves, ten peaking filters, a stereo-width matrix, a leveler, loudness normalisation and a limiter, all changed with click-free parameter ramps.3 min
  4. 1 Nov 2026Designing a Discord AutoMod: rules, strikes and escalationHow Krypton's AutoMod handles a message: who is skipped, strongest rule wins, one case per member per rule, strikes counted in PostgreSQL, escalation that never lowers, and failing safe when the database is down.3 min
  5. 1 Nov 2026Lavalink audio filters explained: nightcore, 8D, bass boost and moreWhat Lavalink's timescale, rotation, equalizer, tremolo and vibrato filters actually do, with the exact values Melodius for Discord uses for nightcore, lofi, daycore, 8D and bass boost in lavalink.py.3 min
  6. 1 Nov 2026Now-playing panels with discord.py Components V2How Melodius for Discord builds its now-playing card with discord.py 2.6's LayoutView: four styles, premium-gated presets with a safe fallback, rebuilding on every change, and per-listener accent colours.3 min
  7. 1 Nov 2026Shipping a Tauri 2 app on Linux: blank windows, keyrings and deep linksWhat broke when the Melodius desktop app moved from Windows to Linux with Tauri 2, and the fixes: origins, custom schemes, the Secret Service keyring, WebKitGTK quirks, MPRIS and deep links in AppImage, .deb and .rpm.3 min
  8. 1 Nov 2026Fixing React Native Android crashes: FlatList recycling, memory and R8Production crash fixes from the Melodius Android app: removeClippedSubviews under the New Architecture, a list nested in a ScrollView, unhandled browser intents, and turning on R8 for release builds.3 min
  9. 1 Nov 2026Building Daily Mixes without audio featuresHow Melodius groups a listener's artists into Daily Mixes using only listening history: trusting listening time over skip flags, decaying old plays, session co-occurrence, catalog similarity and sticky groups.3 min
  10. 1 Nov 2026Discord bot reminders that fire exactly once, with natural time parsingKrypton's remind command: parsing 'tomorrow at 9am' and 'in 2h30m' in each user's time zone, limits under an advisory lock, and an atomic claim so no cluster or deploy ever sends a reminder twice.3 min
  11. 1 Nov 2026A persistent jail for Discord moderation, and the bugs an audit foundKrypton's jail: saved roles, restore on release, rejoin handling, one hierarchy check for every action. Plus the moderation bugs an audit found, from global concurrency to slowmode that added digits.3 min
  12. 1 Nov 2026Auto-pause and idle disconnect for a Discord music botHandling on_voice_state_update in discord.py so a music bot pauses when the channel empties, resumes when someone returns, never resumes a song the user paused, and leaves after idling unless in 24/7 mode.3 min
  13. 1 Nov 2026Signed, expiring stream URLs with HMAC in Node.jsA stateless capability token for streaming one track to one user: base64url payload, HMAC-SHA256 signature, constant-time verification, expiry, and optional binding to the browser session.3 min
  14. 1 Nov 2026Relaying an HLS audio stream as one seekable fileHow Melodius turns an HLS playlist into a single byte range every player can seek: parse the playlist, measure each segment, map range requests onto segments, and refuse what cannot be joined.3 min
  15. 1 Nov 2026An image proxy with edge caching and sized covers in Next.jsWhy Melodius serves every album cover from its own origin: a host allowlist, signed and unsigned tokens, five fixed widths, WebP, and separate browser and Cloudflare cache lifetimes.3 min
  16. 1 Nov 2026When playback fails: retry, skip or waitMelodius's recovery rules for a music player: separate a broken song from a broken connection, retry once with a fresh source, never skip while offline, and stop before a queue spins.3 min
  17. 1 Nov 2026Fixing a skip that played the previous song: a race in an audio playerA race condition in Melodius's web player: while the next track's source resolved, the old audio element's events still reached the store. How it showed up, why, and the fix.3 min
  18. 1 Nov 2026Recording each play exactly once with Redis SET NXAn idempotency key per play in Redis, claimed with SET NX EX alongside a rate-limit check, released when the request is refused, so retries and duplicate clients never double-count listening stats.3 min
  19. 1 Nov 2026Syncing settings across devices without leaking or losing changesTwo bugs in Melodius's cross-device settings sync, one privacy and one data loss, and the fixes: claim local data for the signed-in account before reading it, and refuse saves older than the server's copy.3 min
  20. 1 Nov 2026Case-insensitive usernames with live availability checks in PostgreSQLMelodius usernames: a citext column with a unique index, an availability check that distinguishes taken, yours, reserved and invalid, live feedback while typing, and the index as the final arbiter.3 min
  21. 1 Nov 2026Sharding a discord.py bot across processes and serversHow to run a large discord.py bot as several clustered processes on more than one server: shard ranges, a supervisor with health checks and backoff, and shared state in PostgreSQL.5 min
  22. 1 Nov 2026How a Discord anti-nuke bot should decide who to punishLessons from auditing Krypton's anti-nuke: matching audit-log entries to the right target, a single trust order, punishing once, and reverting every untrusted change.5 min
  23. 1 Nov 2026Matching the same song across Spotify, Apple Music, TIDAL and DeezerHow Melodius merges four music catalogues into one search without merging the wrong tracks: ISRC first, then strict title, version, artist, featuring and duration gates.3 min
  24. 1 Nov 2026Making a track start fast: mirrors, hedged requests and a stream relayHow Melodius turns a tap into audio quickly: cached playable copies, one copy per source first, hedged resolution after 2.5 seconds, a head start for the next tracks, and rate limits that ignore seeks.4 min
  25. 1 Nov 2026Shipping one music app to the web, Windows, Linux and AndroidHow Melodius ships to four platforms as a solo developer: Next.js on the web, the same UI in a Tauri 2 desktop window, Expo for Android, and a shared TypeScript core for schemas, playback and Jams.3 min
  26. 1 Nov 2026Recovering a Discord server when the owner account is lostDesigning Krypton's backup owner codes: a one-time recovery code that hands bot-level ownership to a trusted person, stored as a bound hash, with lockouts and automatic cleanup on transfer.4 min
  27. 1 Nov 2026Counting music plays from a Discord voice channelHow the Melodius Discord bot records what each listener actually heard: who counts as a listener, played time minus pauses, skips, and linking Discord to accounts without asking for a password.3 min