@echo off
REM Atomizer Dashboard - Development Restart Script
REM Kills existing processes and restarts both backend and frontend

echo ========================================
echo Atomizer Dashboard - Restart
echo ========================================

REM Kill existing processes on ports 8000 and 5173
echo Stopping existing processes...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :8000 ^| findstr LISTENING') do (
    taskkill /F /PID %%a 2>nul
)
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :5173 ^| findstr LISTENING') do (
    taskkill /F /PID %%a 2>nul
)

timeout /t 2 /nobreak >nul

REM Start backend in new window
echo Starting backend...
start "Atomizer Backend" cmd /k "cd /d %~dp0backend && conda activate atomizer && uvicorn api.main:app --reload --host 0.0.0.0 --port 8000"

timeout /t 3 /nobreak >nul

REM Start frontend in new window
echo Starting frontend...
start "Atomizer Frontend" cmd /k "cd /d %~dp0frontend && npm run dev"

echo ========================================
echo Dashboard restarted!
echo Backend:  http://localhost:8000
echo Frontend: http://localhost:5173
echo ========================================
pause
