File size: 3,355 Bytes
491cd8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@echo off
title SaulGPT - Legal Intelligence Platform
color 0a
chcp 65001 >nul
set PYTHONIOENCODING=utf-8

:: Define directories
set "ROOT_DIR=%~dp0"
set "VENV_PYTHON=%ROOT_DIR%.venv\Scripts\python.exe"
set "BACKEND_DIR=%ROOT_DIR%backend"
set "FRONTEND_DIR=%ROOT_DIR%saulgpt-ui"

:: Add Node.js and local bins to PATH if installed via Winget
set "NODE_WINGET=%LOCALAPPDATA%\Microsoft\WinGet\Packages\OpenJS.NodeJS.LTS_Microsoft.Winget.Source_8wekyb3d8bbwe\node-v24.19.0-win-x64"
if exist "%NODE_WINGET%" (
    set "PATH=%NODE_WINGET%;%PATH%"
)
set "PATH=%USERPROFILE%\.local\bin;%PATH%"

cls
echo ===============================================
echo        SAULGPT - LEGAL INTELLIGENCE
echo ===============================================
echo.
echo  [1] Start SaulGPT (Backend + Frontend)
echo  [2] Setup (Install Python and Node Dependencies)
echo  [3] Exit
echo.
choice /c 123 /n /m "Select option (1-3): "

if errorlevel 3 goto :eof
if errorlevel 2 goto setup
if errorlevel 1 goto start

:start
cls
echo ===============================================
echo  Launching SaulGPT Services...
echo ===============================================
echo.

:: Verify virtual environment exists
if not exist "%VENV_PYTHON%" (
    echo [ERROR] Virtual environment not found at:
    echo         "%VENV_PYTHON%"
    echo.
    echo Please run Option [2] Setup first to configure the environment.
    echo.
    pause
    goto :eof
)

:: 1. Start Backend in its own window with correct working directory
echo [1/2] Starting FastAPI Backend on port 8000...
start "SaulGPT-Backend" cmd /k "cd /d "%BACKEND_DIR%" && title SaulGPT-Backend && "%VENV_PYTHON%" api_server.py"

:: Non-blocking wait for backend to bind port 8000
echo Waiting for Backend to initialize...
ping -n 5 127.0.0.1 >nul

:: 2. Start Frontend in its own window
echo [2/2] Starting Vite Frontend on port 5173...
start "SaulGPT-Frontend" cmd /k "cd /d "%FRONTEND_DIR%" && title SaulGPT-Frontend && npm.cmd run dev"

:: Non-blocking wait for Vite dev server
echo Waiting for Frontend to initialize...
ping -n 4 127.0.0.1 >nul

:: 3. Open the UI in default browser
echo.
echo Opening browser: http://localhost:5173
start http://localhost:5173

echo.
echo ===============================================
echo   SaulGPT is running!
echo   Frontend UI:  http://localhost:5173
echo   Backend API:  http://localhost:8000
echo   API Docs:     http://localhost:8000/docs
echo ===============================================
echo.
echo Leave the backend and frontend terminal windows open.
echo Close them whenever you want to stop SaulGPT.
echo.
pause
goto :eof

:setup
cls
echo ===============================================
echo  Setting up SaulGPT Environment
echo ===============================================
echo.

:: Check Python venv
if not exist "%VENV_PYTHON%" (
    echo Creating Python virtual environment...
    python -m venv "%ROOT_DIR%.venv"
)

echo Installing Backend requirements...
"%VENV_PYTHON%" -m pip install --upgrade pip
"%VENV_PYTHON%" -m pip install -r "%BACKEND_DIR%\requirements.txt"

echo.
echo Installing Frontend node_modules...
cd /d "%FRONTEND_DIR%"
call npm.cmd install
cd /d "%ROOT_DIR%"

echo.
echo ===============================================
echo  Setup complete! You can now start SaulGPT.
echo ===============================================
echo.
pause
goto :eof