#!/bin/bash
# Start both VYNDR services
# Usage: ./scripts/start.sh

set -e

echo "[VYNDR] Starting services..."

# Start Python NBA stats service (port 8000)
echo "[VYNDR] Starting NBA stats service on port 8000..."
cd nba-service
source venv/bin/activate
uvicorn app.main:app --host 0.0.0.0 --port 8000 &
NBA_PID=$!
cd ..

# Start Node.js API server (port 3000)
echo "[VYNDR] Starting Node API server on port 3000..."
node src/server.js &
NODE_PID=$!

echo "[VYNDR] Services running:"
echo "  Node API:   http://localhost:3000  (PID: $NODE_PID)"
echo "  NBA Stats:  http://localhost:8000  (PID: $NBA_PID)"
echo ""
echo "Press Ctrl+C to stop all services."

trap "kill $NBA_PID $NODE_PID 2>/dev/null; echo '[VYNDR] Services stopped.'" EXIT

wait
