CleanPlays API
Go

CleanPlays API

Go/Fiber Backend Powering CleanPlays Streaming, Search & Billing

Overview

The CleanPlays API is the Go backend behind a royalty-free, AI-generated music streaming platform for businesses such as cafes, shops and salons. From a single Fiber service it powers streaming, catalog, search, recommendations and billing for both the web and iOS clients, backed by PostgreSQL, Redis and Elasticsearch. The codebase follows a clean handler/service/repository layering with substantial table-driven test coverage.

What It Does

It transcodes uploaded audio into adaptive HLS renditions, curates the catalog by business sector, and serves radios, daily/weekly mixes and autoplay recommendations. Full-text search runs on Elasticsearch with custom Turkish analyzers, in-venue announcements are synthesized with ElevenLabs TTS, and subscriptions are handled through PayTR recurring billing on web and RevenueCat on mobile. Background workers, schedulers and recovery loops keep transcoding, billing and search indexes healthy without manual intervention.

Tech Stack

GoFiberPostgreSQLGORMRedisElasticsearchAWS S3/CDNElevenLabsPayTR

Key Features

Adaptive HLS streaming: FFmpeg transcodes each track into 128 and 256 kbps AAC renditions with a generated master playlist

Elasticsearch search across songs, artists, albums, playlists, genres and sectors with custom Turkish analyzers and edge-ngram autocomplete

Sector-based curation, facet-driven radios, and deterministic per-user daily/weekly mixes

Weighted autoplay recommendations blending genre/BPM/mood/energy scoring with collaborative filtering and per-artist diversity caps

ElevenLabs TTS venue announcements (PRO-gated) with monthly quotas and scheduled day/time programs

PayTR recurring subscriptions with 3-D Secure, dunning and grace-period handling; RevenueCat webhooks for mobile

Server-side Meta Conversions API forwarding of purchase events

Google/Apple OAuth and JWT auth, admin bulk import from Excel, and idempotent CLI seeding tools

Technical Highlights

Go 1.25 with Fiber v2, GORM on PostgreSQL (JSONB facets, GIN full-text indexes), and Redis for caching, locks and quotas
Background HLS worker pool with distributed Redis locks, panic recovery, exponential-backoff retries and a stuck-job recovery loop
Elasticsearch v8 with alias-backed indices and zero-downtime reindexing; PostgreSQL stays authoritative and incremental sync runs on transcode completion
AI track-version model that keeps two takes of a composition at least eight positions apart across every queue, radio and mix
Subscription scheduler with Spotify-style dunning (retry days 1-4, five-day grace) and Redis-backed rate limiting shared across pods
AWS S3 storage with CDN-aware public URLs and streaming multipart uploads
Observability via structured slog logging, request IDs, health/readiness probes and admin-gated pprof

Key Achievements

01

Designed and shipped the entire backend solo as the engine for the CleanPlays web and iOS apps

02

Built a resilient media pipeline that survives corrupt files and pod restarts through locking, recovery loops and idempotent workers

03

Delivered Turkish-first search relevance with ICU folding, edge-ngram typeahead and popularity-weighted function scoring

04

Implemented end-to-end recurring billing with idempotent PayTR and RevenueCat webhooks plus server-side CAPI purchase attribution

05

Maintained a clean layered architecture with repository contracts and broad table-driven unit tests

Impact & Results

Serves as the single backend for the CleanPlays platform (web + iOS), built end to end at Group Taiga. Its HLS pipeline, sector curation and TTS announcements give businesses a compliant, on-brand alternative to collecting-society music licensing.