#!/bin/bash

# Setup script for warehouse management system
echo "Setting up warehouse management system..."

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

# Install Python dependencies
echo "Installing Python dependencies..."

# Try pip install first, then with --break-system-packages if needed
if ! pip install -r requirements.txt 2>/dev/null; then
    echo "Trying with --break-system-packages flag..."
    if ! pip install --break-system-packages -r requirements.txt; then
        echo "Error: Failed to install dependencies"
        echo "You may need to install dependencies manually or create a virtual environment"
        exit 1
    fi
fi

echo "Dependencies installed successfully."

# Run the database seeding script
echo "Seeding database..."
python3 script/seed

if [ $? -ne 0 ]; then
    echo "Error: Failed to seed database"
    exit 1
fi

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