fix: integrate AI cross-platform start scripts

Former-commit-id: 2054b6036d
This commit is contained in:
anoracleofra-code
2026-03-08 14:55:11 -06:00
parent c8f3812fbf
commit 9c85e08839
3 changed files with 44 additions and 18 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"scripts": {
"dev": "concurrently \"npm run dev:frontend\" \"npm run dev:backend\"",
"dev:frontend": "next dev",
"dev:backend": "cd ../backend && python -m uvicorn main:app --reload",
"dev:backend": "node ../start-backend.js",
"build": "next build",
"start": "next start",
"lint": "eslint"
+20
View File
@@ -0,0 +1,20 @@
const { execSync } = require("child_process");
const path = require("path");
const fs = require("fs");
const backendDir = path.resolve(__dirname, "backend");
const venvBin = process.platform === "win32"
? path.join(backendDir, "venv", "Scripts", "python.exe")
: path.join(backendDir, "venv", "bin", "python3");
if (!fs.existsSync(venvBin)) {
console.error(`[!] Python venv not found at: ${venvBin}`);
console.error("[!] Run start.sh (Mac/Linux) or start.bat (Windows) first to create the venv.");
process.exit(1);
}
console.log(`[*] Starting backend with: ${venvBin}`);
execSync(`"${venvBin}" -m uvicorn main:app --reload`, {
cwd: backendDir,
stdio: "inherit",
});
+23 -17
View File
@@ -10,31 +10,38 @@ if ! command -v npm &> /dev/null; then
exit 1
fi
# Check for Python
if ! command -v python3 &> /dev/null; then
# Check for Python 3
PYTHON_CMD=""
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
else
echo "[!] ERROR: python3 is not installed. Please install Python 3.10+ (https://python.org/)"
exit 1
fi
echo "[*] Using Python: $PYTHON_CMD ($($PYTHON_CMD --version 2>&1))"
# Get the directory where this script lives (handles running from any location)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "[*] Setting up Backend Environment..."
cd backend
cd "$SCRIPT_DIR/backend"
if [ ! -d "venv" ]; then
echo "[*] Creating Python Virtual Environment..."
python3 -m venv venv
$PYTHON_CMD -m venv venv
fi
echo "[*] Installing Backend dependencies..."
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# In case someone runs this in Git Bash on Windows
source venv/Scripts/activate
else
source venv/bin/activate
fi
pip install -r requirements.txt
cd ..
source venv/bin/activate
pip install -q -r requirements.txt
deactivate
cd "$SCRIPT_DIR"
echo "[*] Setting up Frontend Environment..."
cd frontend
cd "$SCRIPT_DIR/frontend"
if [ ! -d "node_modules" ]; then
echo "[*] Installing Frontend dependencies..."
npm install
@@ -42,11 +49,10 @@ fi
echo ""
echo "======================================================="
echo " 🚀 Starting Services... "
echo " Dashboard will be available at: http://localhost:3000"
echo " Keep this window open! Note: Initial load takes ~10s "
echo " Starting Services... "
echo " Dashboard will be available at: http://localhost:3000 "
echo " Keep this window open! Initial load takes ~10s "
echo "======================================================="
echo ""
# Start both services (npm run dev automatically calls the python backend on Mac/Linux if scripts are configured cross-platform)
npm run dev