# Start FastAPI with hot reload (requires Python 3.11+). # Usage: .\scripts\start-local-backend.ps1 Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $env:ENV_FILE_PATH = 'C:\Users\dream\.secrets\shared.env' $root = Split-Path -Parent $PSScriptRoot $backend = Join-Path $root 'backend' Set-Location $backend $pythonExe = $null if (Get-Command py -ErrorAction SilentlyContinue) { try { $pythonExe = (& py -3 -c "import sys; print(sys.executable)").Trim() } catch { } } if (-not $pythonExe -and (Get-Command python -ErrorAction SilentlyContinue)) { $pythonExe = (Get-Command python).Source } if (-not $pythonExe) { Write-Error 'Python not found. Install from https://www.python.org/downloads/ or: winget install Python.Python.3.12' } Write-Host "Using Python: $pythonExe" $venvPy = Join-Path $backend '.venv\Scripts\python.exe' if (-not (Test-Path $venvPy)) { Write-Host 'Creating .venv ...' & $pythonExe -m venv .venv } & (Join-Path $backend '.venv\Scripts\pip.exe') install -q -r requirements.txt Write-Host 'Starting uvicorn on http://127.0.0.1:8000 (API docs: /docs) ...' & (Join-Path $backend '.venv\Scripts\uvicorn.exe') app.main:app --reload --host 0.0.0.0 --port 8000