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