Skip to content

Configuration

All configuration is done via environment variables. Copy .env.example to .env and customize the values for your deployment.

Terminal window
cp .env.example .env

Required Variables

These must be set before starting EchoStats.

VariableDescriptionExample
SPOTIFY_CLIENT_IDOAuth client ID from your Spotify Developer Appa1b2c3d4e5f6...
SPOTIFY_CLIENT_SECRETOAuth client secret from your Spotify Developer Appf6e5d4c3b2a1...
JWT_SECRETSecret key for signing JWT session tokens. Must be at least 32 characters.(see below)
ENCRYPTION_KEYAES-256 key for encrypting Spotify OAuth tokens at rest. 64 hex characters.(see below)

Generating Secrets

Terminal window
# Generate JWT_SECRET (64-char hex string)
python -c "import secrets; print(secrets.token_hex(32))"
# Generate ENCRYPTION_KEY (64-char hex string)
python -c "import secrets; print(secrets.token_hex(32))"

Spotify API

VariableDescriptionDefault
SPOTIFY_CLIENT_IDOAuth client ID(required)
SPOTIFY_CLIENT_SECRETOAuth client secret(required)
SPOTIFY_REDIRECT_URIOAuth callback URL. Must match the redirect URI configured in your Spotify app.http://localhost:8000/api/v1/auth/callback

MongoDB

VariableDescriptionDefault
MONGO_URIFull MongoDB connection string including authenticationmongodb://echostats:changeme@mongodb:27017/echostats?authSource=admin
MONGO_DBDatabase nameechostats
MONGO_USERMongoDB root username (used by Docker Compose to initialize the database)echostats
MONGO_PASSWORDMongoDB root password (used by Docker Compose to initialize the database)changeme

Redis

VariableDescriptionDefault
REDIS_URLRedis connection URL. Used for caching and as the ARQ task queue broker.redis://redis:6379/0

API Server

VariableDescriptionDefault
API_HOSTHost address the API server binds to0.0.0.0
API_PORTPort the API server listens on8000
API_WORKERSNumber of Uvicorn worker processes2
LOG_LEVELLogging level (debug, info, warning, error)info
CORS_ORIGINSComma-separated list of allowed CORS originshttp://localhost:3000

Security

VariableDescriptionDefault
JWT_SECRETSecret key for JWT token signing. Generate with secrets.token_hex(32).(required)
ENCRYPTION_KEYAES-256 encryption key for Spotify token storage. 64 hex characters.(required)

Web Frontend

VariableDescriptionDefault
NEXT_PUBLIC_API_URLPublic API URL as seen by the browser. Used for client-side API calls.http://localhost:8000
INTERNAL_API_URLInternal API URL used for server-side rendering (SSR) requests within the Docker network.http://api:8000

Background Worker

VariableDescriptionDefault
SYNC_INTERVAL_MINUTESHow often the ARQ worker syncs Spotify data (in minutes)15
ANALYTICS_REFRESH_HOURSHow often computed analytics snapshots are refreshed (in hours)6

Telemetry (Optional)

VariableDescriptionDefault
UMAMI_URLURL of your self-hosted Umami analytics instance(empty — disabled)
UMAMI_WEBSITE_IDUmami website ID for tracking(empty — disabled)

Docker

VariableDescriptionDefault
COMPOSE_PROJECT_NAMEDocker Compose project name prefix for containers and volumesechostats
WEB_PORTHost port to expose the Next.js frontend on3000

Production Checklist

Before deploying to production, ensure you:

  1. ✅ Set strong, unique values for JWT_SECRET and ENCRYPTION_KEY
  2. ✅ Change MONGO_PASSWORD from the default and update MONGO_URI accordingly
  3. ✅ Set CORS_ORIGINS to your actual domain (e.g., https://echostats.example.com)
  4. ✅ Update SPOTIFY_REDIRECT_URI to your public URL
  5. ✅ Set NEXT_PUBLIC_API_URL to your public API URL
  6. ✅ Consider increasing API_WORKERS based on expected load
  7. ✅ Set LOG_LEVEL to warning or error to reduce log volume