Deploying uWave
Introduction
uWave (pronounced you-wave) is a collaborative listening platform that brings people together through shared music experiences. Users take turns playing songs from YouTube and SoundCloud in a virtual room where everyone listens together in real-time. Think of it as a modern take on playlist.com or turntable.fm with a focus on community and simplicity.
Built with Node.js and React, uWave provides a polished web interface where users can build playlists, join the DJ queue, vote on tracks, and chat with other listeners. The platform supports multiple media sources and features a robust plugin system for customization.
Key highlights of uWave:
- Collaborative Listening: Everyone hears the same song at the same time
- DJ Queue: Take turns playing music for the room
- Multi-Source: Play music from YouTube and SoundCloud
- Voting System: Upvote or downvote the current track
- Chat Integration: Real-time chat alongside the music
- User Playlists: Build and manage personal playlists
- Customizable Rooms: Configure room settings and appearance
- User Roles: Managers, moderators, and regular users
- History Tracking: See what songs have been played
- Plugin System: Extend functionality with plugins
- Open Source: Licensed under MIT
This guide walks through deploying uWave on Klutch.sh using Docker, configuring your community room, and managing the listening experience.
Why Deploy uWave on Klutch.sh
Deploying uWave on Klutch.sh provides several advantages for running your collaborative listening room:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds uWave without complex configuration. Push to GitHub, and your music room deploys automatically.
Persistent Storage: Attach persistent volumes for user data, playlists, and history. Your community’s data survives container restarts.
HTTPS by Default: Klutch.sh provides automatic SSL certificates, essential for secure authentication and real-time WebSocket connections.
GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.
Scalable Resources: Allocate CPU and memory based on expected concurrent listeners.
Environment Variable Management: Securely store API keys and secrets through Klutch.sh’s environment variable system.
Custom Domains: Assign a custom domain for your music community.
Always-On Availability: Your listening room remains accessible 24/7 for members around the world.
Prerequisites
Before deploying uWave on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- A Google Cloud account for YouTube Data API access
- A MongoDB instance (can be deployed on Klutch.sh or use a managed service)
- A Redis instance for real-time features
- Basic familiarity with Docker and Node.js
Understanding uWave Architecture
uWave consists of several interconnected components:
u-wave-core: The Node.js backend server handling authentication, user management, playlist storage, and the DJ booth logic.
u-wave-web: The React frontend providing the user interface for interacting with the room.
MongoDB: Stores user accounts, playlists, media metadata, and room history.
Redis: Handles real-time features including the DJ waitlist, voting, and live updates.
WebSocket Server: Enables real-time communication between the server and connected clients.
Media Sources
uWave supports multiple media sources through plugins:
| Source | Description |
|---|---|
| YouTube | Videos and music from YouTube |
| SoundCloud | Tracks from SoundCloud |
Preparing Your Repository
To deploy uWave on Klutch.sh, create a GitHub repository containing your configuration.
Repository Structure
uwave-deploy/├── Dockerfile├── server.js├── config.json├── README.md└── .dockerignoreCreating the Dockerfile
Create a Dockerfile for uWave:
FROM node:20-alpine
# Install build dependenciesRUN apk add --no-cache python3 make g++ git
# Create app directoryWORKDIR /app
# Initialize package.jsonRUN npm init -y
# Install uWave packagesRUN npm install u-wave-core u-wave-http-api u-wave-web \ u-wave-source-youtube u-wave-source-soundcloud
# Copy server configurationCOPY server.js /app/server.jsCOPY config.json /app/config.json
# Create non-root userRUN adduser -D -u 1000 uwaveRUN chown -R uwave:uwave /appUSER uwave
# Environment variablesENV NODE_ENV=productionENV PORT=6042
# Expose web portEXPOSE 6042
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:6042/health || exit 1
# Start uWaveCMD ["node", "server.js"]Server Configuration
Create a server.js file:
const uwave = require('u-wave-core');const createWebApi = require('u-wave-http-api');const createWebClient = require('u-wave-web/middleware').default;const youTubeSource = require('u-wave-source-youtube');const soundCloudSource = require('u-wave-source-soundcloud');
const port = process.env.PORT || 6042;
async function start() { const uw = uwave({ mongo: process.env.MONGODB_URI, redis: process.env.REDIS_URL, secret: process.env.SECRET_KEY, });
// Configure YouTube source if (process.env.YOUTUBE_API_KEY) { uw.source(youTubeSource, { key: process.env.YOUTUBE_API_KEY, }); }
// Configure SoundCloud source if (process.env.SOUNDCLOUD_API_KEY) { uw.source(soundCloudSource, { key: process.env.SOUNDCLOUD_API_KEY, }); }
// Create HTTP API const httpApi = createWebApi(uw, { secret: process.env.SECRET_KEY, });
// Create web client const webClient = createWebClient(uw, { title: process.env.ROOM_NAME || 'uWave Room', });
// Start the server const server = httpApi.listen(port, '0.0.0.0');
// Mount web client httpApi.use(webClient);
console.log(`uWave server running on port ${port}`);
// Graceful shutdown process.on('SIGTERM', async () => { console.log('Shutting down...'); await uw.close(); server.close(); process.exit(0); });}
start().catch(err => { console.error(err); process.exit(1);});Configuration File
Create a config.json file for additional settings:
{ "room": { "name": "My uWave Room", "description": "A collaborative listening experience", "welcomeMessage": "Welcome to the room! Add songs to your playlist and join the DJ queue." }, "booth": { "maxPlayDuration": 480000, "skipVoteThreshold": 0.5 }, "users": { "allowGuests": false, "requireEmail": true }}Creating the .dockerignore File
Create a .dockerignore file:
.git.github*.mdLICENSE.gitignore*.log.DS_Store.envnode_modulesEnvironment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
MONGODB_URI | Yes | - | MongoDB connection string |
REDIS_URL | Yes | - | Redis connection URL |
SECRET_KEY | Yes | - | Secret key for sessions and tokens |
YOUTUBE_API_KEY | Recommended | - | Google/YouTube Data API key |
SOUNDCLOUD_API_KEY | No | - | SoundCloud API key |
ROOM_NAME | No | uWave Room | Display name for your room |
PORT | No | 6042 | HTTP server port |
Deploying uWave on Klutch.sh
Once your repository is prepared, follow these steps to deploy:
- Deploy them on Klutch.sh
- Use managed services like MongoDB Atlas and Redis Cloud
- YouTube Data API: Create a project in Google Cloud Console, enable the YouTube Data API v3, and create an API key
- SoundCloud API: Apply for API access through SoundCloud’s developer portal (optional)
- Select HTTP as the traffic type
- Set the internal port to 6042
- Build the container image
- Install uWave and dependencies
- Start the server
- Provision an HTTPS certificate
Set Up Required Services
uWave requires MongoDB and Redis. You can:
Note your connection strings for environment variables.
Get API Keys
Obtain necessary API keys:
Generate Secret Key
Create a secure random string for session management. Use at least 32 characters.
Push Your Repository to GitHub
Initialize your repository and push to GitHub:
git initgit add .git commit -m "Initial uWave deployment configuration"git remote add origin https://github.com/yourusername/uwave-deploy.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Name it something descriptive like “uwave” or “music-room”.
Create a New App
Within your project, create a new app. Connect your GitHub account and select your uWave repository.
Configure HTTP Traffic
uWave serves its interface over HTTP:
Set Environment Variables
Configure the following environment variables:
| Variable | Value |
|---|---|
MONGODB_URI | Your MongoDB connection string |
REDIS_URL | Your Redis connection URL |
SECRET_KEY | Your generated secret key |
YOUTUBE_API_KEY | Your YouTube Data API key |
ROOM_NAME | Your room’s display name |
Attach Persistent Volumes
Add persistent storage:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/app/data | 5 GB | Application data and cache |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Access Your Room
Once deployed, access your uWave room at your deployment URL. Register the first account to become the room admin.
Initial Setup and Configuration
Creating the Admin Account
The first user to register becomes the administrator:
- Navigate to your uWave room
- Click “Register” or “Sign Up”
- Create your account with email and password
- You automatically receive admin privileges
Room Configuration
Configure your room through the admin panel:
| Setting | Description |
|---|---|
| Room Name | Display name shown to users |
| Description | Room description on the landing page |
| Welcome Message | Message shown when users join |
| Max Song Duration | Maximum length for played tracks |
| Skip Threshold | Percentage of votes needed to skip |
User Roles
uWave supports multiple user roles:
| Role | Capabilities |
|---|---|
| Admin | Full control over room settings and users |
| Manager | Can promote/demote moderators, manage history |
| Moderator | Can skip songs, remove users from queue |
| DJ | Can add songs to playlists and join queue |
| User | Can listen, chat, and vote |
Using uWave
Building Playlists
- Search for songs using the search bar
- Click the add button to add to your playlist
- Organize songs within your playlist
- Create multiple playlists for different moods
Joining the DJ Queue
- Select a playlist to play from
- Click “Join Queue” to enter the waitlist
- When your turn comes, your selected song plays
- After your song finishes, you move to the back of the queue
Voting and Interaction
- Upvote: Show appreciation for the current song
- Downvote: Indicate you don’t like the current song
- Grab: Add the current song to your playlist
- Chat: Discuss music and interact with others
Production Best Practices
Security Recommendations
- Strong Secret Key: Use a long, random secret key
- HTTPS Only: Always use HTTPS for production
- API Key Protection: Never expose API keys in client code
- User Moderation: Appoint trusted moderators
- Registration Control: Consider invite-only registration
Performance Optimization
- MongoDB Indexes: Ensure proper indexes for queries
- Redis Persistence: Configure Redis persistence appropriately
- Connection Pooling: Use connection pooling for databases
- Resource Allocation: Scale based on concurrent users
Community Management
- Clear Rules: Establish and communicate room rules
- Active Moderation: Maintain an active moderation team
- Regular Cleanup: Clean up inactive users and old data
- Backup History: Regularly back up play history
Troubleshooting Common Issues
Connection Issues
Symptoms: Users cannot connect or experience disconnections.
Solutions:
- Verify WebSocket connectivity through HTTPS
- Check Redis connection for pub/sub
- Review server logs for errors
- Ensure adequate resources for concurrent connections
Media Playback Issues
Symptoms: Songs don’t play or show errors.
Solutions:
- Verify YouTube API key is valid and has quota
- Check if specific videos are restricted
- Ensure proper permissions for API access
- Review source plugin configuration
Authentication Problems
Symptoms: Users cannot log in or sessions expire.
Solutions:
- Verify secret key is consistent across restarts
- Check Redis connection for session storage
- Clear browser cookies and try again
- Review MongoDB connection for user data
Additional Resources
- uWave Official Website
- uWave GitHub Organization
- u-wave-core Repository
- u-wave-web Repository
- YouTube Data API
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
Conclusion
Deploying uWave on Klutch.sh gives you a collaborative listening platform where your community can share and discover music together. The combination of uWave’s engaging social features and Klutch.sh’s deployment simplicity means you can create a vibrant music community without managing complex infrastructure.
Whether you’re building a public listening room or a private space for friends, uWave on Klutch.sh provides the foundation for shared musical experiences that bring people together.