1# plyr.fm - status 2 3## long-term vision 4 5### the problem 6 7today's music streaming is fundamentally broken: 8- spotify and apple music trap your data in proprietary silos 9- artists pay distribution fees and streaming cuts to multiple gatekeepers 10- listeners can't own their music collections - they rent them 11- switching platforms means losing everything: playlists, play history, social connections 12 13### the atproto solution 14 15plyr.fm is built on the AT Protocol (the protocol powering Bluesky) and enables: 16- **portable identity**: your music collection, playlists, and listening history belong to you, stored in your personal data server (PDS) 17- **decentralized distribution**: artists publish directly to the network without platform gatekeepers 18- **interoperable data**: any client can read your music records - you're not locked into plyr.fm 19- **authentic social**: artist profiles are real ATProto identities with verifiable handles (@artist.bsky.social) 20 21### the dream state 22 23plyr.fm should become: 24 251. **for artists**: the easiest way to publish music to the decentralized web 26 - upload once, available everywhere in the ATProto network 27 - direct connection to listeners without platform intermediaries 28 - real ownership of audience relationships 29 302. **for listeners**: a streaming platform where you actually own your data 31 - your collection lives in your PDS, playable by any ATProto music client 32 - switch between plyr.fm and other clients freely - your data travels with you 33 - share tracks as native ATProto posts to Bluesky 34 353. **for developers**: a reference implementation showing how to build on ATProto 36 - open source end-to-end example of ATProto integration 37 - demonstrates OAuth, record creation, federation patterns 38 - proves decentralized music streaming is viable 39 40--- 41 42**started**: October 28, 2025 (first commit: `454e9bc` - relay MVP with ATProto authentication) 43 44--- 45 46## recent work 47 48### December 2025 49 50#### avatar sync on login (PR #685, Dec 31) 51 52**avatars now stay fresh** - previously set once at artist creation, causing stale/broken avatars throughout the app: 53- on login, avatar is refreshed from Bluesky and synced to both postgres and ATProto profile record 54- added `avatar` field to `fm.plyr.actor.profile` lexicon (optional, URI format) 55- one-time backfill script (`scripts/backfill_avatars.py`) refreshed 28 stale avatars in production 56 57--- 58 59#### self-hosted redis (PR #674-675, Dec 30) 60 61**replaced Upstash with self-hosted Redis on Fly.io** - ~$75/month → ~$4/month: 62- Upstash pay-as-you-go was charging per command (37M commands = $75) 63- self-hosted Redis on 256MB Fly VMs costs fixed ~$2/month per environment 64- deployed `plyr-redis` (prod) and `plyr-redis-stg` (staging) 65- added CI workflow for redis deployments on merge 66 67**no state migration needed** - docket stores ephemeral task queue data, job progress lives in postgres. 68 69--- 70 71#### supporter-gated content (PR #637, Dec 22-23) 72 73**atprotofans paywall integration** - artists can now mark tracks as "supporters only": 74- tracks with `support_gate` require atprotofans validation before playback 75- non-supporters see lock icon and "become a supporter" CTA linking to atprotofans 76- artists can always play their own gated tracks 77 78**backend architecture**: 79- audio endpoint validates supporter status via atprotofans API before serving gated content 80- HEAD requests return 200/401/402 for pre-flight auth checks (avoids CORS issues) 81- `R2Storage.move_audio()` moves files between public/private buckets when toggling gate 82- background task handles bucket migration asynchronously 83- ATProto record syncs when toggling gate (updates `supportGate` field and `audioUrl`) 84 85**frontend**: 86- `playback.svelte.ts` guards queue operations with gated checks BEFORE modifying state 87- clicking locked track shows toast with CTA - does NOT interrupt current playback 88- portal shows support gate toggle in track edit UI 89 90--- 91 92#### supporter badges (PR #627, Dec 21-22) 93 94**phase 1 of atprotofans integration**: 95- supporter badge displays on artist pages when logged-in viewer supports the artist 96- calls atprotofans `validateSupporter` API directly from frontend (public endpoint) 97- badge only shows when viewer is authenticated and not viewing their own profile 98 99--- 100 101#### rate limit moderation endpoint (PR #629, Dec 21) 102 103**incident response**: detected suspicious activity - 72 requests in 17 seconds from a single IP targeting `/moderation/sensitive-images`. added `10/minute` rate limit using existing slowapi infrastructure. 104 105--- 106 107#### end-of-year sprint planning (PR #626, Dec 20) 108 109**focus**: two foundational systems need solid experimental implementations by 2026. 110 111| track | focus | status | 112|-------|-------|--------| 113| moderation | consolidate architecture, add rules engine | in progress | 114| atprotofans | supporter validation, content gating | shipped (phase 1-3) | 115 116**research docs**: 117- [moderation architecture overhaul](docs/research/2025-12-20-moderation-architecture-overhaul.md) 118- [atprotofans paywall integration](docs/research/2025-12-20-atprotofans-paywall-integration.md) 119 120--- 121 122#### beartype + moderation cleanup (PRs #617-619, Dec 19) 123 124**runtime type checking** (PR #619): 125- enabled beartype runtime type validation across the backend 126- catches type errors at runtime instead of silently passing bad data 127- test infrastructure improvements: session-scoped TestClient fixture (5x faster tests) 128 129**moderation cleanup** (PRs #617-618): 130- consolidated moderation code, addressing issues #541-543 131- `sync_copyright_resolutions` now runs automatically via docket Perpetual task 132- removed dead `init_db()` from lifespan (handled by alembic migrations) 133 134--- 135 136#### UX polish (PRs #604-607, #613, #615, Dec 16-18) 137 138**login improvements** (PRs #604, #613): 139- login page now uses "internet handle" terminology for clarity 140- input normalization: strips `@` and `at://` prefixes automatically 141 142**artist page fixes** (PR #615): 143- track pagination on artist pages now works correctly 144- fixed mobile album card overflow 145 146**mobile + metadata** (PRs #605-607): 147- Open Graph tags added to tag detail pages for link previews 148- mobile modals now use full screen positioning 149- fixed `/tag/` routes in hasPageMetadata check 150 151--- 152 153#### offline mode foundation (PRs #610-611, Dec 17) 154 155**experimental offline playback**: 156- storage layer using Cache API for audio bytes + IndexedDB for metadata 157- `GET /audio/{file_id}/url` backend endpoint returns direct R2 URLs for client-side caching 158- "auto-download liked" toggle in experimental settings section 159- Player checks for cached audio before streaming from R2 160 161--- 162 163### Earlier December 2025 164 165See `.status_history/2025-12.md` for detailed history including: 166- visual customization with custom backgrounds (PRs #595-596, Dec 16) 167- performance & moderation polish (PRs #586-593, Dec 14-15) 168- mobile UI polish & background task expansion (PRs #558-572, Dec 10-12) 169- confidential OAuth client for 180-day sessions (PRs #578-582, Dec 12-13) 170- pagination & album management (PRs #550-554, Dec 9-10) 171- public cost dashboard (PRs #548-549, Dec 9) 172- docket background tasks & concurrent exports (PRs #534-546, Dec 9) 173- artist support links & inline playlist editing (PRs #520-532, Dec 8) 174- playlist fast-follow fixes (PRs #507-519, Dec 7-8) 175- playlists, ATProto sync, and library hub (PR #499, Dec 6-7) 176- sensitive image moderation (PRs #471-488, Dec 5-6) 177- teal.fm scrobbling (PR #467, Dec 4) 178- unified search with Cmd+K (PR #447, Dec 3) 179- light/dark theme system (PR #441, Dec 2-3) 180- tag filtering and bufo easter egg (PRs #431-438, Dec 2) 181 182### November 2025 183 184See `.status_history/2025-11.md` for detailed history including: 185- developer tokens (PR #367) 186- copyright moderation system (PRs #382-395) 187- export & upload reliability (PRs #337-344) 188- transcoder API deployment (PR #156) 189 190## immediate priorities 191 192### quality of life mode (Dec 29-31) 193 194end-of-year sprint [#625](https://github.com/zzstoatzz/plyr.fm/issues/625) complete. remaining days before 2026 are for minor polish and bug fixes as they arise. 195 196**what shipped in the sprint:** 197- moderation consolidation: sensitive images moved to moderation service (#644) 198- atprotofans: supporter badges (#627) and content gating (#637) 199 200**aspirational (deferred until scale justifies):** 201- configurable rules engine for moderation 202- time-release gating (#642) 203 204### known issues 205- playback auto-start on refresh (#225) 206- iOS PWA audio may hang on first play after backgrounding 207 208### backlog 209- audio transcoding pipeline integration (#153) - transcoder service deployed, integration deferred 210- share to bluesky (#334) 211- lyrics and annotations (#373) 212 213## technical state 214 215### architecture 216 217**backend** 218- language: Python 3.11+ 219- framework: FastAPI with uvicorn 220- database: Neon PostgreSQL (serverless) 221- storage: Cloudflare R2 (S3-compatible) 222- background tasks: docket (Redis-backed) 223- hosting: Fly.io (2x shared-cpu VMs) 224- observability: Pydantic Logfire 225- auth: ATProto OAuth 2.1 226 227**frontend** 228- framework: SvelteKit (v2.43.2) 229- runtime: Bun 230- hosting: Cloudflare Pages 231- styling: vanilla CSS with lowercase aesthetic 232- state management: Svelte 5 runes 233 234**deployment** 235- ci/cd: GitHub Actions 236- backend: automatic on main branch merge (fly.io) 237- frontend: automatic on every push to main (cloudflare pages) 238- migrations: automated via fly.io release_command 239 240**what's working** 241 242**core functionality** 243- ✅ ATProto OAuth 2.1 authentication 244- ✅ secure session management via HttpOnly cookies 245- ✅ developer tokens with independent OAuth grants 246- ✅ platform stats and Media Session API 247- ✅ timed comments with clickable timestamps 248- ✅ artist profiles synced with Bluesky 249- ✅ track upload with streaming 250- ✅ audio streaming via 307 redirects to R2 CDN 251- ✅ play count tracking, likes, queue management 252- ✅ unified search with Cmd/Ctrl+K 253- ✅ teal.fm scrobbling 254- ✅ copyright moderation with ATProto labeler 255- ✅ docket background tasks (copyright scan, export, atproto sync, scrobble) 256- ✅ media export with concurrent downloads 257- ✅ supporter-gated content via atprotofans 258 259**albums** 260- ✅ album CRUD with cover art 261- ✅ ATProto list records (auto-synced on login) 262 263**playlists** 264- ✅ full CRUD with drag-and-drop reordering 265- ✅ ATProto list records (synced on create/modify) 266- ✅ "add to playlist" menu, global search results 267 268**deployment URLs** 269- production frontend: https://plyr.fm 270- production backend: https://api.plyr.fm 271- staging: https://stg.plyr.fm / https://api-stg.plyr.fm 272 273### technical decisions 274 275**why Python/FastAPI instead of Rust?** 276- rapid prototyping velocity during MVP phase 277- trade-off: accepting higher latency for faster development 278 279**why Cloudflare R2 instead of S3?** 280- zero egress fees (critical for audio streaming) 281- S3-compatible API, integrated CDN 282 283**why async everywhere?** 284- I/O-bound workload: most time spent waiting on network/disk 285- PRs #149-151 eliminated all blocking operations 286 287## cost structure 288 289current monthly costs: ~$20/month (plyr.fm specific) 290 291see live dashboard: [plyr.fm/costs](https://plyr.fm/costs) 292 293- fly.io (backend + redis + moderation): ~$14/month 294- neon postgres: $5/month 295- cloudflare (R2 + pages + domain): ~$1/month 296- audd audio fingerprinting: $5-10/month (usage-based) 297- logfire: $0 (free tier) 298 299## admin tooling 300 301### content moderation 302script: `scripts/delete_track.py` 303 304usage: 305```bash 306uv run scripts/delete_track.py <track_id> --dry-run 307uv run scripts/delete_track.py <track_id> 308uv run scripts/delete_track.py --url https://plyr.fm/track/34 309``` 310 311## for new contributors 312 313### getting started 3141. clone: `gh repo clone zzstoatzz/plyr.fm` 3152. install dependencies: `uv sync && cd frontend && bun install` 3163. run backend: `uv run uvicorn backend.main:app --reload` 3174. run frontend: `cd frontend && bun run dev` 3185. visit http://localhost:5173 319 320### development workflow 3211. create issue on github 3222. create PR from feature branch 3233. ensure pre-commit hooks pass 3244. merge to main → deploys to staging 3255. create github release → deploys to production 326 327### key principles 328- type hints everywhere 329- lowercase aesthetic 330- ATProto first 331- async everywhere (no blocking I/O) 332- mobile matters 333- cost conscious 334 335### project structure 336``` 337plyr.fm/ 338├── backend/ # FastAPI app & Python tooling 339│ ├── src/backend/ # application code 340│ ├── tests/ # pytest suite 341│ └── alembic/ # database migrations 342├── frontend/ # SvelteKit app 343│ ├── src/lib/ # components & state 344│ └── src/routes/ # pages 345├── moderation/ # Rust moderation service (ATProto labeler) 346├── transcoder/ # Rust audio transcoding service 347├── redis/ # self-hosted Redis config 348├── docs/ # documentation 349└── justfile # task runner 350``` 351 352## documentation 353 354- [docs/README.md](docs/README.md) - documentation index 355- [runbooks](docs/runbooks/) - production incident procedures 356- [background tasks](docs/backend/background-tasks.md) - docket task system 357- [logfire querying](docs/tools/logfire.md) - observability queries 358- [moderation & labeler](docs/moderation/atproto-labeler.md) - copyright, sensitive content 359- [lexicons overview](docs/lexicons/overview.md) - ATProto record schemas 360 361--- 362 363this is a living document. last updated 2025-12-31.