Spaces:
Sleeping
Sleeping
File size: 7,518 Bytes
7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 539a868 7a30d73 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | @echo off
title BankBot AI β Launcher
echo.
echo ============================================================
echo BankBot AI ^| One-Click Launcher
echo Frontend : http://localhost:3000
echo Backend : http://localhost:8000
echo API Docs : http://localhost:8000/docs
echo ============================================================
echo.
REM ββ Step 1: Check Python ββββββββββββββββββββββββββββββββββββββββββββββββββββ
python --version >nul 2>&1
if errorlevel 1 (
echo [ERROR] Python not found.
echo Install Python 3.11+ from https://python.org
echo During install, tick "Add Python to PATH"
pause
exit /b 1
)
echo [OK] Python found
REM ββ Step 2: Check Node.js βββββββββββββββββββββββββββββββββββββββββββββββββββ
node --version >nul 2>&1
if errorlevel 1 (
echo [ERROR] Node.js not found.
echo Install Node.js 18+ from https://nodejs.org
pause
exit /b 1
)
echo [OK] Node.js found
REM ββ Step 3: Create backend venv if missing ββββββββββββββββββββββββββββββββββ
if not exist "backend\venv\Scripts\python.exe" (
echo.
echo [SETUP] Creating Python virtual environment...
python -m venv backend\venv
if errorlevel 1 (
echo [ERROR] Failed to create virtual environment.
pause
exit /b 1
)
echo [OK] Virtual environment created
) else (
echo [OK] Virtual environment exists
)
REM ββ Step 4: Install backend dependencies if not yet installed βββββββββββββββ
backend\venv\Scripts\python.exe -c "import uvicorn" >nul 2>&1
if errorlevel 1 (
echo.
echo [SETUP] Installing backend dependencies ^(first run, ~2 min^)...
backend\venv\Scripts\pip.exe install -r backend\requirements.txt --quiet
if errorlevel 1 (
echo [ERROR] Failed to install backend dependencies.
pause
exit /b 1
)
echo [OK] Backend dependencies installed
) else (
echo [OK] Backend dependencies already installed
)
REM ββ Step 5: Install frontend dependencies if missing ββββββββββββββββββββββββ
if not exist "frontend\node_modules\next\package.json" (
echo.
echo [SETUP] Installing frontend dependencies ^(first run, ~1 min^)...
cd frontend
npm install --legacy-peer-deps --silent
if errorlevel 1 (
echo [ERROR] Failed to install frontend dependencies.
cd ..
pause
exit /b 1
)
cd ..
echo [OK] Frontend dependencies installed
) else (
echo [OK] Frontend dependencies already installed
)
REM ββ Step 6: Create backend .env if missing ββββββββββββββββββββββββββββββββββ
if not exist "backend\.env" (
echo.
echo [SETUP] Creating backend\.env ...
(
echo USE_SQLITE=true
echo JWT_SECRET_KEY=bankbot-local-dev-secret-change-in-prod
echo ACCESS_TOKEN_EXPIRE_MINUTES=60
echo BACKEND_CORS_ORIGINS=["http://localhost:3000"]
) > backend\.env
echo [OK] backend\.env created
echo [TIP] Open backend\.env and add your GROQ_API_KEY for live AI chat
echo Get a free key at: https://console.groq.com/keys
) else (
echo [OK] backend\.env exists
)
REM ββ Step 7: Seed demo data only if database is empty ββββββββββββββββββββββββ
echo.
echo [1/2] Checking demo data...
backend\venv\Scripts\python.exe -c "import sys,os; sys.path.insert(0,'backend'); os.chdir('backend'); os.environ.setdefault('USE_SQLITE','true'); from app.database.database import SessionLocal; from app.database.models import User; db=SessionLocal(); c=db.query(User).count(); db.close(); sys.exit(0 if c>0 else 1)" >nul 2>&1
if errorlevel 1 (
echo [SEED] Seeding demo account ^(alex@bankbot.dev^)...
cd backend
call venv\Scripts\activate.bat
python app\scripts\seed_demo.py
if errorlevel 1 (
echo [WARN] Seed had warnings β continuing anyway
) else (
echo [OK] Demo account seeded
)
cd ..
) else (
echo [OK] Demo data already present β skipping seed
)
REM ββ Step 8: Free ports 3000 and 8000 if already occupied ββββββββββββββββββββ
echo.
echo [CLEAN] Freeing ports 3000 and 8000...
for /f "tokens=5" %%a in ('netstat -ano 2^>nul ^| findstr ":3000 " ^| findstr "LISTENING"') do (
taskkill /PID %%a /F >nul 2>&1
)
for /f "tokens=5" %%a in ('netstat -ano 2^>nul ^| findstr ":8000 " ^| findstr "LISTENING"') do (
taskkill /PID %%a /F >nul 2>&1
)
echo [OK] Ports are free
REM ββ Step 9: Start backend in its own window ββββββββββββββββββββββββββββββββββ
echo.
echo [2/2] Launching services...
start "BankBot Backend" cmd /k "title BankBot Backend (port 8000) & cd /d "%~dp0backend" & call venv\Scripts\activate.bat & echo. & echo Backend: http://localhost:8000 & echo Docs: http://localhost:8000/docs & echo Press Ctrl+C to stop. & echo. & uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"
REM ββ Step 10: Wait for backend to be ready (max 30 seconds) ββββββββββββββββββ
echo [WAIT] Waiting for backend to start...
set TRIES=0
:WAIT_BACKEND
set /a TRIES=%TRIES%+1
if %TRIES% GTR 30 goto BACKEND_TIMEOUT
timeout /t 1 /nobreak >nul
curl -s -o nul http://localhost:8000/health
if errorlevel 1 goto WAIT_BACKEND
echo [OK] Backend is ready ^(took %TRIES% seconds^)
goto BACKEND_READY
:BACKEND_TIMEOUT
echo [WARN] Backend taking longer than usual β continuing anyway
:BACKEND_READY
REM ββ Step 11: Start frontend in its own window ββββββββββββββββββββββββββββββββ
start "BankBot Frontend" cmd /k "title BankBot Frontend (port 3000) & cd /d "%~dp0frontend" & echo. & echo Frontend: http://localhost:3000 & echo Press Ctrl+C to stop. & echo. & npm run dev"
REM ββ Step 12: Wait for frontend to compile, then open browser βββββββββββββββββ
echo [WAIT] Waiting for frontend to compile ^(~8 seconds^)...
timeout /t 8 /nobreak >nul
start "" http://localhost:3000
REM ββ All done ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
echo.
echo ============================================================
echo BankBot AI is running!
echo.
echo Frontend : http://localhost:3000
echo Backend : http://localhost:8000
echo API Docs : http://localhost:8000/docs
echo Metrics : http://localhost:8000/api/metrics
echo Health : http://localhost:8000/health
echo.
echo Demo Login :
echo Email : alex@bankbot.dev
echo Password : BankBot2026!
echo.
echo Two terminal windows are now open:
echo "BankBot Backend" β close to stop the API
echo "BankBot Frontend" β close to stop the UI
echo.
echo Run this file again any time to restart.
echo ============================================================
echo.
pause
|