A modern, scalable music streaming application built with microservices architecture, featuring adaptive streaming, AI-powered recommendations, and real-time audio visualization.
MusicStream is a full-stack cloud-native music streaming platform that combines a React-based frontend with a microservices backend architecture. The platform offers personalized recommendations, adaptive audio quality, and immersive visualizations.
- Authentication with Clerk (Sign In/Sign Up)
- Browse and stream public songs and albums
- AI-powered personalized recommendations via Recombee
- Trending songs feed
- Similar songs discovery
- Real-time audio visualization (Bars, Wave, Circular)
- Create and manage private playlists
- Add/remove songs to/from playlists
- Search songs and albums
- Queue management + Shuffle + Repeat
- Fullscreen visualizer mode with dynamic colors
- View and edit user profile
- Upload songs (image + audio via Cloudinary)
- Create public/private albums
- Edit/remove songs and albums
- Toggle visibility (public/private)
- Artist dashboard with statistics
- Track performance metrics
- User management (list, block/unblock, delete, change roles)
- Song management (toggle visible/hidden)
- Album management (toggle visible/hidden)
- Admin dashboard with tabs
- Content moderation tools
- System analytics
- Play/Pause + Next/Previous
- Seek bar with time display
- Volume control
- Queue management UI
- Now Playing metadata
- Audio Visualization (3 modes)
- Adaptive streaming quality (network-aware)
- Manual quality control (64/128/320 kbps)
- Smart AI recommendations while listening
- Playback analytics (play, complete, skip)
- Dynamic color extraction from album art
- Gradient backgrounds and immersive animations
- Real-time frequency bars and waveforms
- Auto-hide player controls
- Keyboard shortcuts:
- Space β Play/Pause
- Esc β Exit fullscreen
- Spinning vinyl animation
- 3 Visualization Types:
- Bars
- Wave
- Circular
- Smart Caching with Redis (5β10 min TTL)
- RBAC Roles: User / Artist / Admin
- AI personalized recommendations
- Adaptive streaming (Cloudinary + Web APIs)
- Microservices communication via API Gateway
- CI/CD Pipeline with GitHub Actions
- Auto-deployment to DigitalOcean Kubernetes
- Zero-downtime deployments with auto-rollback
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React + Vite) β
β β’ Adaptive Streaming β’ Audio Visualization β
β β’ Smart Recommendations β’ Dynamic Theming β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β API Gateway (Port 3000) β
β β’ Request Routing β’ Health Checks β
ββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β User Service β β Song Service β βAlbum Service β
β Port 3001 β β Port 3002 β β Port 3003 β
ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β β
βββββββββββββββββββΌββββββββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
βΌ βΌ
ββββββββββββββββ ββββββββββββββββ
β MongoDB Atlasβ β Redis Cloud β
β β’ users_db β β β’ Caching β
β β’ songs_db β β β’ TTL 5-10m β
β β’ albums_db β β β
ββββββββββββββββ ββββββββββββββββ
External Services:
- Clerk (Authentication)
- Cloudinary (Media Storage & Adaptive Streaming)
- Recombee (AI Recommendations)
CI/CD Pipeline:
GitHub Actions β Build & Test β Docker Build β DigitalOcean Registry β K8s Deploy
- React 18.2 with Vite 5
- React Router v6.20
- Zustand 4.4 (State Management)
- TailwindCSS 3.3
- Clerk 4.30 (Authentication)
- Axios 1.6
- Web Audio API
- Lucide React 0.294
- Node.js with Express
- MongoDB with Mongoose
- Redis for caching
- Clerk SDK for authentication
- Cloudinary for media storage
- Recombee for recommendations
- Multer for file uploads
- Deployment: DigitalOcean Kubernetes (DOKS)
- Container Registry: DigitalOcean Container Registry
- Orchestration: Kubernetes with HPA (Horizontal Pod Autoscaling)
- CI/CD: GitHub Actions
- Monitoring: Prometheus + Grafana
- SSL/TLS: cert-manager with Let's Encrypt
- Ingress: NGINX Ingress Controller
music-stream/
βββ .github/
β βββ workflows/
β βββ backend-cicd.yml # CI/CD Pipeline
β
βββ frontend-ui/ # React frontend application
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ services/ # API services
β β βββ store/ # Zustand stores
β β βββ hooks/ # Custom hooks
β β βββ contexts/ # React contexts
β βββ Dockerfile
β βββ package.json
β
βββ backend-microservices/ # Microservices backend
β βββ user-service/ # User management
β βββ song-service/ # Song management & recommendations
β βββ album-service/ # Album/playlist management
β βββ api-gateway/ # API gateway & routing
β βββ k8s/ # Kubernetes manifests
β β βββ namespace.yaml
β β βββ secrets.yaml
β β βββ *-deployment.yaml
β β βββ prometheus.yaml
β β βββ grafana.yaml
β β βββ ingress.yaml
β β βββ letsencrypt-issuer.yaml
β βββ scripts/
β β βββ quick-setup.sh # Quick setup script
β βββ docker-compose.yml
β
βββ docs/
β βββ CICD-SETUP-GUIDE.md # Complete CI/CD setup guide
β
βββ .gitignore
βββ README.md # This file
- Node.js 18+
- Docker & Docker Compose
- kubectl (for Kubernetes deployment)
- doctl (DigitalOcean CLI)
- MongoDB Atlas account
- Redis Cloud account
- Clerk account
- Cloudinary account
- Recombee account (optional)
- DigitalOcean account (for production deployment)
- Clone the repository:
git clone <repository-url>
cd music-stream- Setup Frontend:
cd frontend-ui
cp .env.example .env
# Edit .env with your credentials
npm install- Setup Backend:
cd backend-microservices
cp .env.example .env
# Edit .env with your credentialscd backend-microservices
docker-compose up -dServices will be available at:
- Frontend: http://localhost:5173
- API Gateway: http://localhost:3000
- User Service: http://localhost:3001
- Song Service: http://localhost:3002
- Album Service: http://localhost:3003
Terminal 1 - Frontend:
cd frontend-ui
npm run devTerminal 2 - User Service:
cd backend-microservices/user-service
npm run devTerminal 3 - Song Service:
cd backend-microservices/song-service
npm run devTerminal 4 - Album Service:
cd backend-microservices/album-service
npm run devTerminal 5 - API Gateway:
cd backend-microservices/api-gateway
npm run devcd backend-microservices
# Make script executable
chmod +x scripts/quick-setup.sh
# Run automated setup
./scripts/quick-setup.shThe script will:
- β Check prerequisites (kubectl, doctl)
- β Authenticate with DigitalOcean
- β Connect to your Kubernetes cluster
- β Create namespace and secrets
- β Install Ingress Controller
- β Install cert-manager
- β Get LoadBalancer IP
See detailed instructions in CI/CD Setup Guide
The project includes automated CI/CD pipeline that:
- Build & Test - Tests all microservices
- Docker Build - Builds and tags images
- Push to Registry - Pushes to DigitalOcean Registry
- Deploy to K8s - Deploys to Kubernetes cluster
- Auto Rollback - Rolls back on failure
Trigger Deployment:
git add .
git commit -m "feat: your changes"
git push origin mainMonitor Deployment:
- Go to GitHub β Actions tab
- Watch the pipeline execution
- Check deployment logs
VITE_API_URL=http://localhost:3000
VITE_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key# MongoDB
MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net
# Redis
REDIS_URL=redis://user:pass@redis-cloud.com:port
# Clerk
CLERK_SECRET_KEY=your_clerk_secret_key
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Recombee (Optional)
RECOMBEE_DATABASE_ID=your_database_id
RECOMBEE_PRIVATE_TOKEN=your_private_token
RECOMBEE_REGION=us-westAdd these secrets in GitHub Repository Settings:
DIGITALOCEAN_ACCESS_TOKEN
MONGODB_USERS_URI
MONGODB_SONGS_URI
MONGODB_ALBUMS_URI
REDIS_URL
CLERK_SECRET_KEY
CLERK_PUBLISHABLE_KEY
CLOUDINARY_CLOUD_NAME
CLOUDINARY_API_KEY
CLOUDINARY_API_SECRET
RECOMBEE_DATABASE_ID (optional)
RECOMBEE_PRIVATE_TOKEN (optional)
RECOMBEE_REGION (optional)
All authenticated requests require Clerk JWT token in headers:
Authorization: Bearer <token>
Songs:
GET /api/songs- List all public songsGET /api/songs/trending- Get trending songsGET /api/songs/:id/similar- Get similar songsGET /api/songs/recommendations/for-you- Personalized recommendationsPOST /api/songs- Upload song (Artist)POST /api/songs/:id/track/play- Track play interaction
Albums:
GET /api/albums- List all public albumsGET /api/albums/:id- Get album with songsPOST /api/albums- Create album/playlistPOST /api/albums/:id/songs- Add song to album
Admin:
GET /api/admin/users- List all usersPATCH /api/admin/users/:id/block- Block/unblock userGET /api/admin/songs- List all songsPATCH /api/admin/songs/:id/visible- Toggle visibility
For complete API documentation, see Backend README.
Each service exposes a /health endpoint:
curl http://localhost:3001/health # User Service
curl http://localhost:3002/health # Song Service
curl http://localhost:3003/health # Album ServiceAPI Gateway provides consolidated health status:
curl http://localhost:3000/health/servicesAccess Grafana dashboard:
URL: https://grafana.YOUR_IP.nip.io
Username: admin
Password: admin123
View metrics:
- Request rates
- Response times
- Error rates
- Resource usage (CPU, Memory)
- Pod status
- JWT-based authentication via Clerk
- Role-based access control (RBAC)
- CORS configured for trusted origins
- Secrets managed via Kubernetes Secrets
- HTTPS enforced in production
- Input validation and sanitization
- Non-root containers
- Security contexts in Kubernetes
- Auto-scales based on CPU/Memory usage
- Min replicas: 1
- Max replicas: 8-15 (depends on service)
- Target CPU: 70%
- Target Memory: 75-80%
- Zero-downtime deployments
- maxSurge: 1-2 pods
- maxUnavailable: 0
- Gradual rollout
- Liveness: Restart unhealthy pods
- Readiness: Remove pod from service if not ready
- Startup: Give pod time to start
- Prometheus: Metrics collection
- Grafana: Visualization dashboards
- Real-time metrics and alerts
- Backend README - Microservices documentation
- CI/CD Setup Guide - Complete deployment guide
- Frontend README - React app documentation
# 1. Make changes to code
# 2. Test locally with docker-compose
docker-compose up -d
# 3. Verify changes
curl http://localhost:3000/health/services# 1. Commit changes
git add .
git commit -m "feat: your feature"
# 2. Push to trigger CI/CD
git push origin main
# 3. Monitor deployment
# - Check GitHub Actions
# - Watch kubectl get pods -n music-stream -w# Manual rollback
kubectl rollout undo deployment/song-service -n music-stream
# Or CI/CD auto-rollback on failurekubectl get pods -n music-stream
kubectl describe pod <pod-name> -n music-stream
kubectl logs <pod-name> -n music-streamkubectl get svc -n music-stream
kubectl get ingress -n music-streamkubectl get events -n music-stream --sort-by='.lastTimestamp'ImagePullBackOff: Check registry credentials
kubectl delete secret regcred -n music-stream
# Recreate secret with correct credentialsCrashLoopBackOff: Check pod logs
kubectl logs <pod-name> -n music-stream --previousService Unavailable: Check ingress and service
kubectl describe ingress music-stream-ingress -n music-stream- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat: add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License