@echo off
setlocal

set "ROOT_DIR=%~dp0"
set "MODE=%~1"
if "%MODE%"=="" set "MODE=dev"

if /I "%MODE%"=="dev" goto DEV
if /I "%MODE%"=="build" goto BUILD

echo Usage: sproutgate.bat [dev^|build]
exit /b 1

:DEV
echo ==^> Starting backend (Gin)...
start "SproutGate Backend" cmd /k "cd /d %ROOT_DIR%sproutgate-backend && go run ."

echo ==^> Starting frontend (React)...
cd /d %ROOT_DIR%sproutgate-frontend

npm run dev
exit /b 0

:BUILD
echo ==^> Building frontend...
cd /d %ROOT_DIR%sproutgate-frontend
if not exist node_modules (
  npm install
)
npm run build
exit /b 0
