Initial commit - SoundWave v1.0

- Full PWA support with offline capabilities
- Comprehensive search across songs, playlists, and channels
- Offline playlist manager with download tracking
- Pre-built frontend for zero-build deployment
- Docker-based deployment with docker compose
- Material-UI dark theme interface
- YouTube audio download and management
- Multi-user authentication support
This commit is contained in:
Iulian 2025-12-16 23:43:07 +00:00
commit 51679d1943
254 changed files with 37281 additions and 0 deletions

26
scripts/check_downloads.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/bash
echo "📊 SOUNDWAVE DOWNLOAD STATUS"
echo "=============================="
echo ""
# Playlists
echo "📝 PLAYLISTS:"
docker compose exec soundwave python manage.py shell -c "from playlist.models import Playlist; [print(f' {p.title}: {p.sync_status} - {p.downloaded_count}/{p.item_count} songs') for p in Playlist.objects.all()]" 2>/dev/null
echo ""
# Channels
echo "📺 CHANNELS:"
docker compose exec soundwave python manage.py shell -c "from channel.models import Channel; [print(f' {c.channel_name}: {c.sync_status} - {c.downloaded_count} songs') for c in Channel.objects.all()]" 2>/dev/null
echo ""
# Download Queue
echo "📥 DOWNLOAD QUEUE:"
docker compose exec soundwave python manage.py shell -c "from download.models import DownloadQueue; print(f' Pending: {DownloadQueue.objects.filter(status=\"pending\").count()}'); print(f' Downloading: {DownloadQueue.objects.filter(status=\"downloading\").count()}'); print(f' Completed: {DownloadQueue.objects.filter(status=\"completed\").count()}'); print(f' Failed: {DownloadQueue.objects.filter(status=\"failed\").count()}')" 2>/dev/null
echo ""
# Downloaded Audio
echo "🎵 DOWNLOADED AUDIO:"
docker compose exec soundwave python manage.py shell -c "from audio.models import Audio; print(f' Total songs: {Audio.objects.count()}')" 2>/dev/null

67
scripts/generate-pwa-icons.sh Executable file
View file

@ -0,0 +1,67 @@
#!/bin/bash
# Script to create placeholder PWA icons
# For production, use proper icon generator tools
ICON_DIR="frontend/public/img"
mkdir -p "$ICON_DIR"
echo "Creating placeholder PWA icons..."
echo "Note: For production, generate proper icons using:"
echo " - https://www.pwabuilder.com/imageGenerator"
echo " - https://realfavicongenerator.net/"
echo ""
# Function to create SVG placeholder icon
create_svg_icon() {
local size=$1
local file="$ICON_DIR/icon-${size}x${size}.png"
# Create SVG with ImageMagick if available
if command -v convert &> /dev/null; then
convert -size ${size}x${size} xc:"#1976d2" \
-fill white \
-font Arial-Bold \
-pointsize $((size/4)) \
-gravity center \
-annotate +0+0 "SW\n${size}" \
"$file"
echo "✓ Created $file"
else
echo "✗ ImageMagick not found. Skipping $file"
echo " Install: sudo apt-get install imagemagick (Linux)"
echo " brew install imagemagick (Mac)"
fi
}
# Check if ImageMagick is available
if ! command -v convert &> /dev/null; then
echo ""
echo "ImageMagick not found!"
echo "Please install ImageMagick to generate placeholder icons:"
echo ""
echo "Linux: sudo apt-get install imagemagick"
echo "Mac: brew install imagemagick"
echo "Windows: Download from https://imagemagick.org/script/download.php"
echo ""
echo "Or use online tools to generate icons:"
echo " - https://www.pwabuilder.com/imageGenerator"
echo " - https://realfavicongenerator.net/"
exit 1
fi
# Create all required icon sizes
create_svg_icon 72
create_svg_icon 96
create_svg_icon 128
create_svg_icon 144
create_svg_icon 152
create_svg_icon 192
create_svg_icon 384
create_svg_icon 512
echo ""
echo "✓ Placeholder icons created successfully!"
echo ""
echo "IMPORTANT: Replace these with proper app icons before deploying to production."
echo ""

195
scripts/migrate.sh Executable file
View file

@ -0,0 +1,195 @@
#!/bin/bash
# Migration script for existing Soundwave deployments
set -e
echo "🔄 Soundwave Data Persistence Migration"
echo "========================================"
echo ""
echo "This script will:"
echo "1. Stop existing containers"
echo "2. Backup current database (if exists)"
echo "3. Create persistent data directory"
echo "4. Migrate database to new location"
echo "5. Rebuild and restart containers"
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Confirm
read -p "Continue with migration? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Migration cancelled."
exit 0
fi
echo ""
echo "Step 1: Stopping containers..."
echo "-------------------------------"
docker-compose down
echo -e "${GREEN}✅ Containers stopped${NC}"
echo ""
echo "Step 2: Creating backup..."
echo "--------------------------"
BACKUP_DIR="backup_$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"
# Backup database if exists in backend/
if [ -f "backend/db.sqlite3" ]; then
echo "Found database in backend/"
cp backend/db.sqlite3 "$BACKUP_DIR/"
echo -e "${GREEN}✅ Database backed up to $BACKUP_DIR/${NC}"
else
echo -e "${YELLOW}⚠️ No database found in backend/ (might be first run)${NC}"
fi
# Backup audio if exists
if [ -d "audio" ] && [ "$(ls -A audio)" ]; then
echo "Backing up audio directory..."
du -sh audio
# Don't copy audio, just note it
echo "audio/ → Already in volume (no action needed)"
echo -e "${GREEN}✅ Audio files already in persistent volume${NC}"
fi
echo ""
echo "Step 3: Creating data directory..."
echo "-----------------------------------"
mkdir -p data
mkdir -p cache
mkdir -p audio
mkdir -p es
mkdir -p redis
echo -e "${GREEN}✅ Persistent directories created${NC}"
echo ""
echo "Step 4: Migrating database..."
echo "------------------------------"
if [ -f "backend/db.sqlite3" ]; then
echo "Moving database to data/"
mv backend/db.sqlite3 data/
echo -e "${GREEN}✅ Database migrated to data/db.sqlite3${NC}"
else
echo -e "${YELLOW}⚠️ No database to migrate (will be created fresh)${NC}"
fi
# Create .gitignore in data/
cat > data/.gitignore << 'EOF'
# Persistent database files
db.sqlite3
*.sqlite3-journal
*.sqlite3-shm
*.sqlite3-wal
EOF
echo -e "${GREEN}✅ Created data/.gitignore${NC}"
echo ""
echo "Step 5: Rebuilding containers..."
echo "---------------------------------"
echo "This may take a few minutes..."
docker-compose build --no-cache
echo -e "${GREEN}✅ Containers rebuilt${NC}"
echo ""
echo "Step 6: Starting services..."
echo "----------------------------"
docker-compose up -d
echo -e "${GREEN}✅ Services started${NC}"
echo ""
echo "Step 7: Waiting for services to initialize..."
echo "----------------------------------------------"
sleep 10
# Check if services are running
if docker ps | grep -q soundwave; then
echo -e "${GREEN}✅ Soundwave container is running${NC}"
else
echo -e "${RED}❌ Soundwave container failed to start${NC}"
echo "Check logs with: docker-compose logs soundwave"
exit 1
fi
echo ""
echo "Step 8: Verifying database location..."
echo "---------------------------------------"
DB_PATH=$(docker exec soundwave python -c "from django.conf import settings; print(settings.DATABASES['default']['NAME'])" 2>/dev/null || echo "ERROR")
if [[ $DB_PATH == *"/app/data/"* ]]; then
echo -e "${GREEN}✅ Database correctly configured at: $DB_PATH${NC}"
else
echo -e "${RED}❌ Database path incorrect: $DB_PATH${NC}"
echo "Expected: /app/data/db.sqlite3"
exit 1
fi
# Check if database file exists
if docker exec soundwave test -f /app/data/db.sqlite3 2>/dev/null; then
echo -e "${GREEN}✅ Database file exists in container${NC}"
# Get user count
USER_COUNT=$(docker exec soundwave python manage.py shell -c "from user.models import Account; print(Account.objects.count())" 2>/dev/null || echo "0")
echo " Users in database: $USER_COUNT"
else
echo -e "${YELLOW}⚠️ Database file not found - running migrations...${NC}"
docker exec soundwave python manage.py migrate
echo -e "${GREEN}✅ Migrations complete${NC}"
fi
echo ""
echo "Step 9: Testing persistence..."
echo "-------------------------------"
echo "Testing container restart..."
docker-compose restart soundwave
sleep 5
# Check database still exists
if docker exec soundwave test -f /app/data/db.sqlite3 2>/dev/null; then
echo -e "${GREEN}✅ Database persists after restart${NC}"
else
echo -e "${RED}❌ Database lost after restart!${NC}"
exit 1
fi
echo ""
echo "========================================"
echo "🎉 Migration Complete!"
echo "========================================"
echo ""
echo "Summary:"
echo "--------"
echo "✅ Containers rebuilt with new configuration"
echo "✅ Database moved to persistent volume"
echo "✅ Data will now survive container rebuilds"
echo "✅ Backup saved in: $BACKUP_DIR/"
echo ""
echo "Next steps:"
echo "-----------"
echo "1. Test the application: http://localhost:8889"
echo "2. Verify your data is intact"
echo "3. Test persistence:"
echo " docker-compose down"
echo " docker-compose up -d"
echo " # Data should still be there!"
echo ""
echo "Logs:"
echo "-----"
echo "docker-compose logs -f soundwave"
echo ""
echo "Documentation:"
echo "--------------"
echo "• docs/QUICK_REFERENCE.md - Quick guide"
echo "• docs/DATA_PERSISTENCE_FIX.md - Technical details"
echo "• docs/OFFLINE_PLAYLISTS_GUIDE.md - PWA features"
echo ""
# Show service status
echo "Current Status:"
echo "---------------"
docker-compose ps

83
scripts/update-logo.sh Executable file
View file

@ -0,0 +1,83 @@
#!/bin/bash
set -e
echo "🎨 SoundWave Logo Update Script"
echo "================================"
echo ""
# Paths
PROJECT_ROOT="/home/iulian/projects/zi-tube/soundwave"
SOURCE_LOGO="$PROJECT_ROOT/frontend/public/img/logo.png"
ICONS_DIR="$PROJECT_ROOT/frontend/public/img/icons"
FAVICON_PATH="$PROJECT_ROOT/frontend/public/favicon.ico"
# Check if source logo exists
if [ ! -f "$SOURCE_LOGO" ]; then
echo "❌ Error: Logo not found at $SOURCE_LOGO"
echo ""
echo "Please save your new logo image to:"
echo " $SOURCE_LOGO"
echo ""
echo "The logo should be the circular SoundWave logo with:"
echo " - Play button in center"
echo " - Concentric circles"
echo " - Sound wave indicators"
echo " - 'soundwave' text below"
echo " - Teal/turquoise and dark blue colors"
exit 1
fi
echo "✅ Source logo found"
echo ""
# Create icons directory if it doesn't exist
mkdir -p "$ICONS_DIR"
echo "📱 Generating PWA icons..."
# Generate various icon sizes
sizes=(72 96 128 144 152 192 384 512)
for size in "${sizes[@]}"; do
output="$ICONS_DIR/icon-${size}x${size}.png"
echo " → Generating ${size}x${size}..."
convert "$SOURCE_LOGO" -resize ${size}x${size} -background none -gravity center -extent ${size}x${size} "$output"
done
echo ""
echo "🎭 Generating maskable icons (with padding)..."
# Maskable icons need padding (safe zone)
convert "$SOURCE_LOGO" -resize 154x154 -background none -gravity center -extent 192x192 "$ICONS_DIR/icon-192x192-maskable.png"
convert "$SOURCE_LOGO" -resize 410x410 -background none -gravity center -extent 512x512 "$ICONS_DIR/icon-512x512-maskable.png"
echo ""
echo "🌐 Generating favicon..."
# Generate favicon.ico with multiple sizes
convert "$SOURCE_LOGO" \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
-delete 0 -alpha on -background none "$FAVICON_PATH"
echo ""
echo "✅ All icons generated successfully!"
echo ""
echo "📋 Generated files:"
echo " - PWA icons (72x72 to 512x512)"
echo " - Maskable icons (192x192, 512x512)"
echo " - Favicon (multi-size ICO)"
echo ""
echo "🔄 Next steps:"
echo " 1. Rebuild the frontend: cd frontend && npm run build"
echo " 2. Restart the app to see changes"
echo ""
echo "✨ Logo updated everywhere:"
echo " ✓ Login page"
echo " ✓ Sidebar"
echo " ✓ Splash screen"
echo " ✓ PWA home screen"
echo " ✓ Browser tab"
echo " ✓ Notifications"
echo ""

190
scripts/verify.sh Executable file
View file

@ -0,0 +1,190 @@
#!/bin/bash
# Verification script for Soundwave data persistence and PWA features
set -e
echo "🔍 Soundwave Verification Script"
echo "================================"
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to check status
check_status() {
if [ $? -eq 0 ]; then
echo -e "${GREEN}$1${NC}"
else
echo -e "${RED}$1${NC}"
exit 1
fi
}
echo "📁 Checking directory structure..."
echo "-----------------------------------"
# Check data directory
if [ -d "data" ]; then
echo -e "${GREEN}✅ data/ directory exists${NC}"
else
echo -e "${YELLOW}⚠️ data/ directory missing - will be created on first run${NC}"
fi
# Check volume directories
[ -d "audio" ] && echo -e "${GREEN}✅ audio/ directory exists${NC}" || echo -e "${YELLOW}⚠️ audio/ directory missing${NC}"
[ -d "cache" ] && echo -e "${GREEN}✅ cache/ directory exists${NC}" || echo -e "${YELLOW}⚠️ cache/ directory missing${NC}"
[ -d "es" ] && echo -e "${GREEN}✅ es/ directory exists${NC}" || echo -e "${YELLOW}⚠️ es/ directory missing${NC}"
[ -d "redis" ] && echo -e "${GREEN}✅ redis/ directory exists${NC}" || echo -e "${YELLOW}⚠️ redis/ directory missing${NC}"
echo ""
echo "🐍 Checking Python syntax..."
echo "----------------------------"
# Check Python files
python3 -m py_compile backend/config/settings.py 2>/dev/null
check_status "settings.py syntax valid"
python3 -m py_compile backend/playlist/urls.py 2>/dev/null
check_status "urls.py syntax valid"
echo ""
echo "🐳 Checking Docker configuration..."
echo "------------------------------------"
# Check docker-compose.yml
if command -v docker &> /dev/null; then
docker compose config --quiet 2>/dev/null
check_status "docker-compose.yml is valid"
else
echo -e "${YELLOW}⚠️ Docker not installed - skipping Docker checks${NC}"
fi
echo ""
echo "📦 Checking frontend build..."
echo "------------------------------"
if [ -d "frontend/dist" ]; then
echo -e "${GREEN}✅ Frontend build exists${NC}"
du -sh frontend/dist 2>/dev/null || echo "Size: Unknown"
else
echo -e "${YELLOW}⚠️ Frontend not built - run 'cd frontend && npm run build'${NC}"
fi
echo ""
echo "🔐 Checking security configuration..."
echo "--------------------------------------"
# Check if sensitive files are not committed
if [ -f ".gitignore" ]; then
if grep -q "db.sqlite3" .gitignore || grep -q "*.sqlite3" .gitignore; then
echo -e "${GREEN}✅ Database files in .gitignore${NC}"
else
echo -e "${YELLOW}⚠️ Database files should be in .gitignore${NC}"
fi
if grep -q ".env" .gitignore; then
echo -e "${GREEN}✅ .env in .gitignore${NC}"
else
echo -e "${YELLOW}⚠️ .env should be in .gitignore${NC}"
fi
fi
echo ""
echo "📱 Checking PWA files..."
echo "------------------------"
# Check PWA files
[ -f "frontend/public/manifest.json" ] && echo -e "${GREEN}✅ manifest.json exists${NC}" || echo -e "${RED}❌ manifest.json missing${NC}"
[ -f "frontend/public/service-worker.js" ] && echo -e "${GREEN}✅ service-worker.js exists${NC}" || echo -e "${RED}❌ service-worker.js missing${NC}"
# Check PWA implementation files
[ -f "frontend/src/utils/pwa.ts" ] && echo -e "${GREEN}✅ pwa.ts exists${NC}" || echo -e "${RED}❌ pwa.ts missing${NC}"
[ -f "frontend/src/utils/offlineStorage.ts" ] && echo -e "${GREEN}✅ offlineStorage.ts exists${NC}" || echo -e "${RED}❌ offlineStorage.ts missing${NC}"
[ -f "frontend/src/context/PWAContext.tsx" ] && echo -e "${GREEN}✅ PWAContext.tsx exists${NC}" || echo -e "${RED}❌ PWAContext.tsx missing${NC}"
echo ""
echo "📚 Checking documentation..."
echo "----------------------------"
docs=(
"docs/DATA_PERSISTENCE_FIX.md"
"docs/OFFLINE_PLAYLISTS_GUIDE.md"
"docs/AUDIT_SUMMARY_COMPLETE.md"
"docs/QUICK_REFERENCE.md"
)
for doc in "${docs[@]}"; do
if [ -f "$doc" ]; then
echo -e "${GREEN}$doc${NC}"
else
echo -e "${YELLOW}⚠️ $doc missing${NC}"
fi
done
echo ""
echo "🔄 Testing Docker persistence (if running)..."
echo "----------------------------------------------"
if command -v docker &> /dev/null && docker ps | grep -q soundwave; then
echo "Containers are running. Testing persistence..."
# Check database location in container
DB_PATH=$(docker exec soundwave python -c "from django.conf import settings; print(settings.DATABASES['default']['NAME'])" 2>/dev/null || echo "")
if [[ $DB_PATH == *"/app/data/"* ]]; then
echo -e "${GREEN}✅ Database in persistent volume (/app/data/)${NC}"
else
echo -e "${RED}❌ Database NOT in persistent volume!${NC}"
echo " Current path: $DB_PATH"
fi
# Check if db.sqlite3 exists in data directory
if docker exec soundwave test -f /app/data/db.sqlite3 2>/dev/null; then
echo -e "${GREEN}✅ Database file exists in container${NC}"
else
echo -e "${YELLOW}⚠️ Database file not yet created (run migrations)${NC}"
fi
else
echo -e "${YELLOW}⚠️ Containers not running - skipping runtime checks${NC}"
echo " Start with: docker-compose up -d"
fi
echo ""
echo "================================"
echo "🎉 Verification Complete!"
echo "================================"
echo ""
# Summary
echo "Summary:"
echo "--------"
echo "• All critical files present"
echo "• Python syntax valid"
echo "• Docker configuration valid"
echo "• PWA implementation complete"
echo "• Documentation available"
echo ""
if [ -d "data" ] && [ -f "docker-compose.yml" ]; then
echo -e "${GREEN}✅ Ready to deploy!${NC}"
echo ""
echo "Next steps:"
echo "1. docker-compose build"
echo "2. docker-compose up -d"
echo "3. Check logs: docker-compose logs -f soundwave"
else
echo -e "${YELLOW}⚠️ Some setup required${NC}"
echo ""
echo "Run these commands:"
echo "1. mkdir -p data audio cache es redis"
echo "2. docker-compose build"
echo "3. docker-compose up -d"
fi
echo ""
echo "📖 For more info, see:"
echo " • docs/QUICK_REFERENCE.md - Quick start"
echo " • docs/DATA_PERSISTENCE_FIX.md - Technical details"
echo " • docs/OFFLINE_PLAYLISTS_GUIDE.md - PWA features"