@echo off
chcp 65001 >nul
title HealthManager

set "PATH=D:\PostgreSQL\18\pgsql\bin;D:\Android\platform-tools;%PATH%"

echo ========================================
echo   HealthManager - Start Services
echo ========================================
echo.

echo [1/2] Starting PostgreSQL...
"D:\PostgreSQL\18\pgsql\bin\pg_ctl.exe" -D "D:\health_project\backend\pgdata" start 2>nul
if errorlevel 1 (echo   PG already running) else (echo   PG started)
echo.

echo [2/2] Starting .NET Backend...
start "Backend" cmd /k "cd /d D:\health_project\backend\src\Health.WebApi && dotnet run"
echo   Waiting for backend...
timeout /t 8 /nobreak >nul
echo.

echo All done. Phone connects via WiFi to this PC.
echo If your PC IP changed, rebuild app with:
echo   flutter run -d ^<device^> --dart-define=API_BASE_URL=http://^<pc-ip^>:5000
pause
