#!/usr/bin/env python3
"""
BookBeach Application Startup Script
Run this to start the refactored Flask application
"""

import sys
import os

# Add current directory to Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

try:
    # Import the refactored application
    from main import app
    
    print("🎉 BookBeach Application Starting...")
    print("📁 Using refactored modular architecture")
    print(f"📊 {len(app.blueprints)} blueprints registered:")
    for name in app.blueprints.keys():
        print(f"   ✓ {name}")
    
    print("\n🌐 Application will be available at:")
    print("   📱 Local: http://localhost:8080")
    print("   🌍 Network: http://0.0.0.0:8080")
    print("\n📋 Available endpoints:")
    print("   🏠 Homepage: http://localhost:8080/")
    print("   🏖️ Beaches: http://localhost:8080/beaches-grid")
    print("   🏔️ Adventures: http://localhost:8080/adventures-grid") 
    print("   🏪 Markets: http://localhost:8080/markets-grid")
    print("   🍽️ Restaurants: http://localhost:8080/restaurants")
    print("   ⚙️ Admin Panel: http://localhost:8080/admin")
    print("   📡 API: http://localhost:8080/api/beaches-grid")
    
    print("\n" + "="*50)
    print("🚀 Starting Flask development server...")
    print("💡 Press Ctrl+C to stop the server")
    print("="*50 + "\n")
    
    # Start the application
    app.run(
        debug=True,
        host='0.0.0.0', 
        port=8080,
        use_reloader=True
    )
    
except ImportError as e:
    print(f"❌ Import Error: {e}")
    print("💡 Make sure you're in the backend directory and all dependencies are installed")
    sys.exit(1)
    
except Exception as e:
    print(f"❌ Startup Error: {e}")
    import traceback
    traceback.print_exc()
    sys.exit(1)