#!/usr/bin/env python3
"""
Code Assistant Bot - Application Runner
Author: RSK World (https://rskworld.in)
Founder: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in, +91 93305 39277
Year: 2026
"""

import os
import sys
from app import app

def main():
    """
    Main entry point for the Code Assistant Bot application
    """
    try:
        # Validate configuration
        from config import Config
        Config.validate_config()
        
        # Get configuration
        host = os.environ.get('HOST', '0.0.0.0')
        port = int(os.environ.get('PORT', 5000))
        debug = os.environ.get('FLASK_ENV', 'development') == 'development'
        
        print("=" * 60)
        print("🤖 Code Assistant Bot - AI-Powered Coding Assistant")
        print("=" * 60)
        print(f"📍 Server running on: http://{host}:{port}")
        print(f"🔧 Debug mode: {'ON' if debug else 'OFF'}")
        print(f"🌐 Environment: {os.environ.get('FLASK_ENV', 'development')}")
        print(f"👨‍💻 Author: RSK World (https://rskworld.in)")
        print(f"📞 Contact: help@rskworld.in | +91 93305 39277")
        print("=" * 60)
        print("🚀 Starting server...")
        print("📝 Press Ctrl+C to stop the server")
        print("=" * 60)
        
        # Run the application
        app.run(host=host, port=port, debug=debug)
        
    except KeyboardInterrupt:
        print("\n🛑 Server stopped by user")
        sys.exit(0)
    except Exception as e:
        print(f"❌ Error starting server: {str(e)}")
        sys.exit(1)

if __name__ == '__main__':
    main()
