#!/bin/bash

# Setup script for gym membership portal
# Installs dependencies and seeds the database

set -e  # Exit on any error

echo "Setting up gym membership portal..."

# Check if we're in the right directory
if [ ! -f "requirements.txt" ]; then
    echo "Error: requirements.txt not found. Are you running this from the repository root?"
    exit 1
fi

# Install Python dependencies
echo "Installing Python dependencies..."
if command -v pip3 &> /dev/null; then
    pip3 install -r requirements.txt --break-system-packages 2>/dev/null || pip3 install -r requirements.txt --user
elif command -v pip &> /dev/null; then
    pip install -r requirements.txt --break-system-packages 2>/dev/null || pip install -r requirements.txt --user
else
    echo "Error: pip or pip3 not found. Please install Python and pip first."
    exit 1
fi

echo "Dependencies installed successfully."

# Seed the database
echo "Seeding database..."
./script/seed

echo "Setup complete!"
echo ""
echo "You can now run the application with:"
echo "  python3 main.py"