@echo off
echo 🚀 Quick Start - AI Wireframe Generator
echo ======================================
echo.

echo 📋 Checking prerequisites...
echo.

REM Check if Python is installed
python --version >nul 2>&1
if errorlevel 1 (
    echo ❌ Python is not installed or not in PATH
    echo Please install Python 3.8+ and try again
    pause
    exit /b 1
)

REM Check if Node.js is installed
node --version >nul 2>&1
if errorlevel 1 (
    echo ❌ Node.js is not installed or not in PATH
    echo Please install Node.js 18+ and try again
    pause
    exit /b 1
)

echo ✅ Python and Node.js are installed
echo.

echo 🔧 Setting up backend...
cd backend

REM Check if .env exists
if not exist .env (
    echo 📝 Creating .env file...
    copy env.example .env
    echo ⚠️  Please edit .env and add your Claude API key
    echo    Then restart this script
    pause
    exit /b 1
)

REM Check if requirements are installed
pip show flask >nul 2>&1
if errorlevel 1 (
    echo 📦 Installing Python dependencies...
    pip install -r requirements.txt
    if errorlevel 1 (
        echo ❌ Failed to install dependencies
        pause
        exit /b 1
    )
)

echo ✅ Backend setup complete
echo.

echo 🚀 Starting backend in background...
start "Flask Backend" cmd /k "python run.py"

echo ⏳ Waiting for backend to start...
timeout /t 5 /nobreak >nul

echo 🌐 Backend should be running on http://localhost:5000
echo.

echo 🚀 Starting frontend...
cd ..
start "Next.js Frontend" cmd /k "npm run dev"

echo.
echo 🎉 Both services are starting!
echo.
echo 📱 Frontend: http://localhost:3000
echo 🔧 Backend: http://localhost:5000
echo.
echo 💡 Tips:
echo    - Wait for both services to fully start
echo    - Check the right sidebar for backend status
echo    - Try generating a wireframe with AI
echo.
echo Press any key to open the frontend in your browser...
pause >nul

start http://localhost:3000

echo.
echo 🎨 Happy wireframing! The AI will help you create professional layouts.
echo.
pause
