#!/bin/bash
echo "====================================="
echo "  Galaxy Catcher - Mini App Server  "
echo "====================================="
echo ""

if [ ! -f ".env" ]; then
  echo "[!] No .env file found. Starting with demo/test mode."
  echo "    Copy .env.example to .env and configure"
  echo "    your DB path and bot token for production."
  echo ""

  echo "[*] Installing dependencies..."
  python3 -m pip install -r requirements.txt --user --break-system-packages --quiet 2>/dev/null

  echo "[*] Starting server with test data..."
  echo ""
  DB_PATH=":memory:" BOT_TOKEN="" python3 server.py
  exit 0
fi

echo "[*] Installing dependencies..."
python3 -m pip install -r requirements.txt --user --break-system-packages --quiet 2>/dev/null

echo "[*] Starting server..."
echo ""
python3 server.py
