#!/bin/bash # ChefSystem Setup Script # Creates virtual environment and installs dependencies set -e # Exit on error echo "================================" echo "ChefSystem Setup Script" echo "================================" echo "" # Check Python version echo "Checking Python version..." python3 --version if ! command -v python3 &> /dev/null; then echo "❌ Error: Python 3 is required but not found" exit 1 fi # Create virtual environment echo "" echo "Creating virtual environment..." if [ -d "venv" ]; then echo "⚠️ Virtual environment already exists" read -p "Remove and recreate? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then rm -rf venv python3 -m venv venv echo "✓ Virtual environment recreated" else echo "✓ Using existing virtual environment" fi else python3 -m venv venv echo "✓ Virtual environment created" fi # Activate virtual environment echo "" echo "Activating virtual environment..." source venv/bin/activate # Upgrade pip echo "" echo "Upgrading pip..." pip install --upgrade pip # Install dependencies echo "" echo "Installing dependencies from requirements.txt..." pip install -r requirements.txt # Create necessary directories echo "" echo "Creating necessary directories..." mkdir -p database outputs config # Initialize database echo "" echo "Initializing database..." PYTHONPATH=. python3 -c "from src.database.db_manager import DatabaseManager; db = DatabaseManager('database/chef.db'); db.init_database(); print('✓ Database initialized'); db.close()" # Create test recipes if database is empty echo "" echo "Checking for test recipes..." PYTHONPATH=. python3 -c " from src.database.db_manager import DatabaseManager from src.database.models import Recipe db = DatabaseManager('database/chef.db') recipes = Recipe.get_all(db) if len(recipes) == 0: print('No recipes found. Creating test recipes...') import subprocess subprocess.run(['python3', 'create_test_recipes.py']) else: print(f'✓ Found {len(recipes)} existing recipe(s)') db.close() " echo "" echo "================================" echo "✅ Setup Complete!" echo "================================" echo "" echo "To start using ChefSystem:" echo " 1. Activate the virtual environment:" echo " source venv/bin/activate" echo "" echo " 2. Run the application:" echo " python src/main.py" echo "" echo " 3. Run tests:" echo " pytest tests/ -v" echo "" echo "Happy cooking! 👨‍🍳"