"""Start the Chronara backend server."""

import os
import sys
import subprocess
from pathlib import Path

# Add src directory to Python path
src_path = Path(__file__).parent.parent / "src"
sys.path.insert(0, str(src_path))

# Set environment for bundled deployment
os.environ["CHRONARA_BUNDLED"] = "1"

# Start the FastAPI server
subprocess.run([
    sys.executable,
    "-m",
    "uvicorn",
    "backend.main:app",
    "--host", "127.0.0.1",
    "--port", "8000",
    "--reload" if os.environ.get("CHRONARA_DEV") else ""
])