Songhive
- Overview
- Features
- Architecture
- Installation
- Configuration
- Running the service
- Testing the installation
- Development
- API
- License
A federated and self-hosted music sharing service, built with ActivityPub federation support.
Overview
Songhive is a music streaming platform similar to Funkwhale, with a focus on better federation. It allows users to upload, organize, and stream their music library while federating with other instances (including Mastodon) via ActivityPub.
Features
- Music Library: Upload and organize artists, albums, and tracks
- Streaming: Audio streaming with on-the-fly transcoding (MP3, OGG, FLAC, AAC, Opus)
- Metadata Enrichment: Fetch metadata from external services
- Federation: ActivityPub support via pubby — federate with Mastodon and other AP-compatible services
- Playlists & Radios: Create playlists and dynamic radio stations
- Multi-user: User registration, profiles, and admin management
- OAuth2 Provider: Third-party app authorization
- Subsonic API: Compatibility layer for Subsonic clients
- Flexible Storage: Local filesystem or S3-compatible object storage
Architecture
- Backend: FastAPI (REST API) + Tornado (WebSocket, streaming, process server)
- Models: Pydantic (validation) + SQLAlchemy (async ORM)
- Tasks: Celery + Redis (background import, transcoding, federation delivery)
- Frontend: Vue.js 3 + TypeScript + Pinia
See docs/ARCHITECTURE.md for detailed architecture documentation.
Installation
Songhive can be run either as a complete Docker stack or installed locally with
pip.
Docker
The Docker Compose setup builds the frontend and backend images, starts
PostgreSQL and Redis, and wires everything together behind an Nginx reverse
proxy. The songhive, worker, postgres and redis services all run as the
same non-root UID/GID as the host user, so the files in ./volumes are owned by
you and are easy to access from the host.
Latest image
# Run the docker-compose bootstrap script
curl -fsSL https://git.fabiomanganiello.com/songhive/raw/branch/main/docker/bootstrap.sh | sh
From a local checkout
# Clone the repository
git clone https://git.fabiomanganiello.com/songhive
# Or from GitHub: git clone https://github.com/blacklight/songhive
cd songhive
# Set the UID/GID to match the host user (the same value is used by all
# rootless services and by the setup step that fixes volume permissions).
export PUID=$(id -u)
export PGID=$(id -g)
# Build the images
docker compose build
pip
This path is useful for local development or running on an existing Python host. A published package is also available on PyPI and ships the built web UI, so the frontend does not need to be built manually when installing from PyPI.
Prerequisites:
- Python >= 3.10
- PostgreSQL (a SQLite database will also work, but it's not recommended for large installations)
- Redis/Valkey
- ffmpeg
- Node.js and npm (for the frontend)
Latest stable package
# Install from PyPI
pip install songhive
From a local checkout
Or, clone the repository and install in editable mode for development
git clone https://git.fabiomanganiello.com/songhive
# Or from GitHub: git clone https://github.com/blacklight/songhive
cd songhive
# Optional: create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e .
# Build the web UI (outputs to songhive/static/)
cd frontend
npm install
npm run build
cd ..
nginx setup
If you are planning to serve Songhive behind a reverse proxy, you can reuse the
nginx.conf used by the Docker setup.
Configuration
Getting the default configuration
-
If you installed Songhive through the docker-compose bootstrap script, then
config.tomlshould be already downloaded under the same folder asdocker-compose.yml. -
If you built Songhive from a local checkout, then copy the example configuration file:
cp config.toml.example config.toml
-
Otherwise, download the latest
config.toml:wget https://git.fabiomanganiello.com/songhive/raw/branch/main/config.toml.example
Base configuration
Set at least the following values in config.toml:
[auth]
secret_key = "..." # Generate with: python -c "import secrets; print(secrets.token_urlsafe(64))"
[storage]
local_path = "/path/to/writable/media" # e.g. ./data/media
[server]
cors_origins = ["*"] # Replace with your frontend origin(s) in production
[federation]
enabled = false # Set a real instance_domain to enable federation
# instance_domain = "music.example.com"
From environment variables
All the config.toml configuration entries can be overridden via environment
variables.
For example:
[database]
url = "postgresql+asyncpg://songhive:songhive@localhost:5432/songhive"
becomes:
SONGHIVE_DATABASE__URL="postgresql+asyncpg://songhive:songhive@localhost:5432/songhive"
Running the service
Docker installation
cd /path/to/your/songhive/installation
docker compose up -d
Then take down the stack with:
docker compose down
pip installation
SONGHIVE_CONFIG="/path/to/your/songhive/installation/config.toml"
songhive -c "$SONGHIVE_CONFIG"
Celery
This is only required in a non-Docker setup. The Docker stack already runs a separate container for the Celery workers.
Start the Celery worker in a second terminal:
celery -A songhive.tasks worker -B -l info
Creating the admin user
Docker installation
cd /path/to/your/songhive/installation
docker compose exec songhive songhive admin create-user \
--username admin \
--email admin@example.com \
--password secret \
--admin
pip installation
SONGHIVE_CONFIG="/path/to/your/songhive/installation/config.toml"
songhive -c "$SONGHIVE_CONFIG" admin create-user \
--username admin \
--email admin@example.com \
--password secret \
--admin
Testing the installation
Open:
- Web UI: http://localhost:8000/
- Swagger UI (only for the Docker setup): http://localhost:8000/swagger-ui/
- OpenAPI spec: http://localhost:8000/openapi.json
Development
# Run tests
python -m pytest
# Run linting
python -m flake8 songhive tests
# Format code
python -m black .
# Start Celery worker
celery -A songhive.tasks worker -l info
Frontend
cd frontend
npm install
npm run dev # Development server
npm run build # Production build (outputs to songhive/static/)
API
REST API available at /api/v1/:
| Endpoint | Description |
|---|---|
/api/v1/auth/ |
Authentication (login, register, refresh) |
/api/v1/auth/api-tokens/ |
API token management (create, list, revoke) |
/api/v1/users/ |
User profiles |
/api/v1/artists/ |
Artists |
/api/v1/albums/ |
Albums |
/api/v1/tracks/ |
Tracks |
/api/v1/playlists/ |
Playlists |
/api/v1/libraries/ |
User libraries |
/api/v1/favorites/ |
Favorites |
/api/v1/history/ |
Listening history |
/api/v1/radios/ |
Dynamic radios |
/api/v1/stream/{id} |
Audio streaming |
/api/v1/admin/ |
Admin endpoints |
WebSocket: /ws/events (real-time notifications)
Federation: /.well-known/webfinger, /ap/actor, /ap/inbox, /ap/outbox
License
AGPL-3.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file songhive-0.0.13.tar.gz.
File metadata
- Download URL: songhive-0.0.13.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f41096c0c3ed46cc87ea39c8fd4deeba63d315578d7cee21e50e4dae3fb171c
|
|
| MD5 |
bde25fee943ef8ee135d3ecfedd8bc20
|
|
| BLAKE2b-256 |
886c576e2e5df367c7c8151f8347d455ffb217e8980272587027478642e72840
|
File details
Details for the file songhive-0.0.13-py3-none-any.whl.
File metadata
- Download URL: songhive-0.0.13-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b9f8930623c45f18f4fd42c4866b9f41af86a81f8439b0f776797216568c69
|
|
| MD5 |
3e29f32ee3bb778e88f81d8319b3c3f3
|
|
| BLAKE2b-256 |
ccafd22f967e7a7b511fc92e4701341d5ea4ef64e1ddd66e0c2bd79a9ad544fc
|