"""Verify that the project setup is complete and correct.""" import os import sys from pathlib import Path def check_file(filepath, required=True): """Check if a file exists.""" if os.path.exists(filepath): print(f"✅ {filepath}") return True else: status = "❌" if required else "⚠️" print(f"{status} {filepath} {'(REQUIRED)' if required else '(optional)'}") return not required def check_env_vars(): """Check if .env file has required variables.""" if not os.path.exists('.env'): print("❌ .env file not found!") return False required_vars = ['GEMINI_API_KEY', 'SERPAPI_API_KEY'] optional_vars = ['TELEGRAM_BOT_TOKEN', 'WHATSAPP_ACCESS_TOKEN'] with open('.env', 'r') as f: content = f.read() print("\n📝 Environment Variables:") all_good = True for var in required_vars: if var in content and 'your_' not in content.split(var)[1].split('\n')[0]: print(f"✅ {var} is set") else: print(f"❌ {var} is NOT set (REQUIRED)") all_good = False for var in optional_vars: if var in content and 'your_' not in content.split(var)[1].split('\n')[0]: print(f"✅ {var} is set") else: print(f"⚠️ {var} is not set (optional)") return all_good def check_dependencies(): """Check if key dependencies are installed.""" print("\n📦 Dependencies:") deps = { 'fastapi': True, 'uvicorn': True, 'gradio': True, 'langchain': True, 'google.generativeai': True, 'telegram': False, 'serpapi': True, } all_good = True for dep, required in deps.items(): try: __import__(dep) print(f"✅ {dep}") except ImportError: status = "❌" if required else "⚠️" print(f"{status} {dep} {'(REQUIRED)' if required else '(optional)'}") if required: all_good = False return all_good def main(): """Run all verification checks.""" print("="*60) print("🔍 Rural E-commerce Bot - Setup Verification") print("="*60 + "\n") print("📂 Core Files:") files_ok = all([ check_file('api.py'), check_file('agent.py'), check_file('database.py'), check_file('tools.py'), check_file('config.py'), check_file('main.py'), check_file('gradio_ui.py'), check_file('requirements.txt'), check_file('.env'), ]) print("\n📂 Channel Handlers:") handlers_ok = all([ check_file('channels/whatsapp_handler.py'), check_file('channels/telegram_handler.py'), ]) print("\n📂 Utilities:") utils_ok = all([ check_file('utils/error_handler.py'), check_file('scripts/setup.py'), ]) print("\n📂 Documentation:") docs_ok = all([ check_file('README.md'), check_file('QUICKSTART.md'), check_file('DEPLOYMENT.md'), check_file('PROJECT_SUMMARY.md'), ]) print("\n📂 Tests:") tests_ok = check_file('tests/test_agent.py') env_ok = check_env_vars() deps_ok = check_dependencies() print("\n" + "="*60) print("📊 Verification Summary") print("="*60) results = { "Core Files": files_ok, "Channel Handlers": handlers_ok, "Utilities": utils_ok, "Documentation": docs_ok, "Tests": tests_ok, "Environment Variables": env_ok, "Dependencies": deps_ok, } for category, status in results.items(): icon = "✅" if status else "❌" print(f"{icon} {category}") all_ok = all(results.values()) print("\n" + "="*60) if all_ok: print("🎉 All checks passed! Your setup is complete.") print("="*60) print("\n🚀 Next steps:") print("1. Run: python main.py --mode all") print("2. Open: http://localhost:7860") print("3. Test with: 'I need a mobile under ₹5000'") print("\n✨ Happy coding!\n") return 0 else: print("⚠️ Some checks failed. Please fix the issues above.") print("="*60) print("\n💡 Quick fixes:") print("- Missing files: Check if you're in the right directory") print("- .env not set: Run 'python scripts/setup.py'") print("- Dependencies: Run 'pip install -r requirements.txt'") print() return 1 if __name__ == "__main__": sys.exit(main())