#!/bin/bash
# Run the API with a local venv (fixes: zsh: command not found: uvicorn).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT"
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"

if ! command -v python3 >/dev/null 2>&1; then
  echo "python3 not found. Install Python 3.11+ (e.g. brew install python@3.11)."
  exit 1
fi

if [ ! -d venv ]; then
  python3 -m venv venv
fi
# shellcheck disable=SC1091
source venv/bin/activate
pip install -q -r requirements.txt
exec python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
