Expand description
P2P social layer for Fugue.
This module provides an optional peer-to-peer social layer powered by Iroh. It enables direct connections between Fugue instances for sharing libraries, playlists, and listening activity.
§Architecture
The social layer uses Iroh’s QUIC transport with automatic NAT traversal, so it works behind firewalls without any port forwarding. Connections are established via ticket exchange: each node generates a ticket containing its public key and relay/address information. Friends exchange tickets out-of-band (e.g. messaging) and add them via the CLI.
§Identity
Each Fugue instance has a persistent ed25519 keypair stored in the SQLite database. This keypair is created on first run and reused across restarts, giving the node a stable identity. The public key serves as the node ID.
§Ticket Flow
- Alice runs
fugue ticketto get her ticket string - Alice sends the ticket to Bob (out-of-band)
- Bob runs
fugue friend add --name "Alice" <ticket> - Bob’s node connects to Alice directly via Iroh (QUIC + relay)
- Both nodes exchange library metadata and CRDT operations
§No Credentials Shared
Friends never see each other’s backend credentials. Fugue proxies streams on behalf of friends — the P2P layer transfers audio data directly, not Subsonic API credentials.
§Submodules
node— Iroh endpoint creation, keypair management, ticket generationfriends— friend list persistence (SQLite)service— background service that manages connections and gossipprotocol— wire protocol for P2P messageslibrary— shared library metadata exchangeactivity— listening activity (now playing) sharingbandwidth— adaptive bitrate measurement for P2P streamingcollab_playlist— collaborative playlist managementcrdt— OR-Set CRDT for collaborative playlist sync
Modules§
- activity
- Activity: now playing, chat messages between friends.
- bandwidth
- Bandwidth measurement and adaptive quality selection.
- collab_
playlist - Collaborative playlists: shared between Fugue nodes via gossip.
- crdt
- Lightweight OR-Set CRDT for collaborative playlists.
- friends
- Friend management: add, remove, list friends.
- library
- Library sharing: publish local library metadata for friends to discover.
- node
- Iroh node management: identity, endpoint lifecycle, tickets.
- protocol
- P2P protocol: message types exchanged between Fugue nodes.
- service
- Social service: manages gossip, incoming connections, and friend sync.