# fithia2 development commands
# Backend API: :18080  |  Frontend dev: :15173

# just run dev  → starts both servers in dev mode (colored logs)
# just run      → builds frontend, starts production server
run mode="prod":
    #!/usr/bin/env bash
    if [ "{{mode}}" = "dev" ]; then
        cd apps/web_frontend && npx concurrently \
            --names "api,web" \
            --prefix "[{name}]" \
            --prefix-colors "cyan.bold,green.bold" \
            --kill-others-on-fail \
            "cd ../.. && python -m uvicorn apps.web.main:app --reload --port 18080 --loop asyncio" \
            "npm run dev"
    else
        echo "→ Building frontend..."
        cd apps/web_frontend && npm run build
        echo "→ Starting server on :18080"
        python -m uvicorn apps.web.main:app --host 0.0.0.0 --port 18080
    fi

# Build frontend only
build:
    cd apps/web_frontend && npm run build

# Start API server only (dev, with reload)
api:
    python -m uvicorn apps.web.main:app --reload --port 18080 --loop asyncio

# Start frontend dev server only
frontend:
    cd apps/web_frontend && npm run dev

# Run tests
test:
    uv run pytest tests/unit -q

# Rebuild experiment index
reindex:
    fithia2 exp rebuild-index
