#!/bin/bash

# Synthetic Data Generator - Start Script

echo "=================================="
echo "Synthetic Data Generator"
echo "=================================="
echo ""

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

# Check if dependencies are installed
echo "Checking dependencies..."
python3 -c "import flask, pandas, ydata_synthetic" 2>/dev/null

if [ $? -ne 0 ]; then
    echo ""
    echo "Dependencies not found. Installing..."
    pip3 install -r requirements.txt

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

echo "✓ Dependencies OK"
echo ""

# Start Flask app
echo "Starting Flask application..."
echo "Access the app at: http://localhost:5000"
echo ""
echo "Press Ctrl+C to stop the server"
echo ""

cd src
python3 app.py
