# Design and Implementation of a Decentralized Music Streaming Platform Using ActivityPub and Peer-to-Peer Content Distribution ## Proposed Outline --- ## 1. Introduction - Motivation — limitations of centralized music platforms (Spotify, Apple Music): single points of failure, vendor lock-in, artist revenue issues - Problem statement — can a federated, decentralized platform provide acceptable availability without central storage? - Thesis goals and scope - Overview of contributions ## 2. Background and Related Work ### 2.1 The Fediverse and ActivityPub - History of federated social networks (GNU Social, Mastodon, Pleroma) - ActivityPub protocol overview (W3C recommendation) - ActivityStreams 2.0 vocabulary - Existing implementations (Mastodon, Pixelfed, Peertube, Funkwhale) ### 2.2 Peer-to-Peer Content Distribution - Overview of P2P network topologies - BitTorrent protocol - IPFS and content-addressed storage - iroh: QUIC-based content distribution with byte range requests - Comparison of approaches and rationale for choosing iroh ### 2.3 Decentralized Systems Architecture - Hexagonal architecture (Ports and Adapters) - Domain-Driven Design - Federation replication patterns ## 3. System Design ### 3.1 Requirements - Functional requirements - Non-functional requirements (availability, scalability, interoperability) ### 3.2 Representing Music in ActivityPub - Limitations of existing ActivityPub vocabulary for audio content - Extending ActivityStreams 2.0 with a custom JSON-LD namespace - Audio object design (metadata fields, duration, attribution) - Album as OrderedCollection - Embedding content addresses (BLAKE3 hash) in AP objects - Interoperability considerations with generic AP clients ### 3.3 Federation Model - Actor model — artists, listeners, instances - Content discovery via federation (Create, Announce activities) - Follow/unfollow across instances - WebFinger and NodeInfo ### 3.4 Content Distribution Model - Replication policies: eager vs on-demand - Instance as a stable seeding node - iroh-blobs for content-addressed audio transfer - Byte range requests for streaming and seeking - Native desktop clients as full P2P peers - NAT traversal via QUIC hole punching and relay fallback - Storage policy configuration ### 3.5 Architecture - Hexagonal architecture overview - Domain layer — pure types, port trait definitions - Application layer — use cases, event processing - Adapter layer — ActivityPub, P2P transport, PostgreSQL, NATS - Rationale for architectural decisions and tradeoffs ## 4. Implementation ### 4.1 Technology Stack - Rust backend (Axum, SQLx, k-ap federation crate) - PostgreSQL - NATS for async event fan-out - iroh and iroh-blobs for P2P content distribution - Native desktop client (Rust GUI framework + symphonia/rodio for audio) ### 4.2 Backend - k-ap crate (reusable federation layer) - Music-specific AP adapter - P2P transport adapter - Federation worker ### 4.3 Desktop Client - Rust GUI framework - Audio playback pipeline (symphonia/rodio) - Direct P2P participation via iroh - Byte range streaming and seeking ## 5. Evaluation ### 5.1 Correctness - Federation interoperability (does it federate with Mastodon, Funkwhale?) - ActivityPub conformance ### 5.2 Availability Analysis - Simulated network with varying node counts - Eager vs on-demand replication policy mix - Content popularity distribution (popular vs cold content) - Node churn (instances going offline) - Results and observations ### 5.3 Architectural Evaluation - Did hexagonal architecture deliver on its promises? - Concrete example: swapping P2P transport adapter - Test coverage enabled by the domain/adapter split ## 6. Known Problems and Limitations - Cold content availability — obscure tracks may disappear - Storage economics and lack of seeding incentives - Bootstrap problem for new instances - Content moderation and copyright in a decentralized network - No central takedown mechanism ## 7. Conclusions and Future Work - Summary of contributions - Lessons learned - Future directions: - Formal availability model - Incentive mechanisms for seeding - Integration with existing Fediverse platforms - PhD research direction: availability degradation in federated networks under heterogeneous replication policies ## References