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