#!/bin/bash
# Script de vérification autonomie

echo "=== Vérification Audio Classifier Autonome ==="
echo ""

# Check 1: Docker Compose
echo "✓ Checking docker-compose.yml..."
if [ ! -f "docker-compose.yml" ]; then
    echo "  ❌ docker-compose.yml missing"
    exit 1
fi
echo "  ✓ docker-compose.yml found"

# Check 2: Backend Dockerfile
echo "✓ Checking backend/Dockerfile..."
if ! grep -q "COPY models/" backend/Dockerfile; then
    echo "  ❌ Models not copied in Dockerfile"
    exit 1
fi
echo "  ✓ Models included in Dockerfile"

# Check 3: Models présents localement
echo "✓ Checking Essentia models..."
MODEL_COUNT=$(ls backend/models/*.pb 2>/dev/null | wc -l)
if [ "$MODEL_COUNT" -lt 4 ]; then
    echo "  ❌ Missing models in backend/models/ ($MODEL_COUNT found, need 4+)"
    exit 1
fi
echo "  ✓ $MODEL_COUNT model files found"

# Check 4: No volume mount for models
echo "✓ Checking no models volume mount..."
if grep -q "./backend/models:/app/models" docker-compose.yml; then
    echo "  ❌ Models volume mount still present in docker-compose.yml"
    exit 1
fi
echo "  ✓ No models volume mount (embedded in image)"

# Check 5: README updated
echo "✓ Checking README..."
if ! grep -q "100% Autonome" README.md; then
    echo "  ⚠️  README might need update"
else
    echo "  ✓ README mentions autonomous setup"
fi

echo ""
echo "=== ✓ All checks passed! ==="
echo ""
echo "Your Docker setup is fully autonomous:"
echo "  - Models included in image (28 MB)"
echo "  - No manual downloads required"
echo "  - Ready for deployment anywhere"
echo ""
echo "To deploy:"
echo "  docker-compose up -d"
echo ""
