Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from api.auth_routes import router as auth_router | |
| from api.jira_routes import router as jira_router | |
| from api.intelligence_routes import router as intelligence_router | |
| from api.webhook_routes import router as webhook_router | |
| from config.settings import settings | |
| import logging | |
| # Configure logging | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| ) | |
| logger = logging.getLogger(__name__) | |
| # Startup Checks | |
| if settings.supabase_url and settings.supabase_key: | |
| logger.info("Supabase Integration: ENABLED") | |
| else: | |
| logger.warning("Supabase Integration: DISABLED (Missing SUPABASE_URL or SUPABASE_KEY)") | |
| # Create FastAPI app | |
| app = FastAPI( | |
| title="Enterprise Delivery & Workforce Intelligence API", | |
| description="AI-powered enterprise intelligence system for engineering operations", | |
| version="1.0.0", | |
| debug=settings.debug | |
| ) | |
| # Configure CORS | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # In production, specify actual origins | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Include routers | |
| app.include_router(auth_router) | |
| app.include_router(jira_router) | |
| app.include_router(intelligence_router) | |
| app.include_router(webhook_router) | |
| async def root(): | |
| """Root endpoint""" | |
| return { | |
| "message": "Enterprise Delivery & Workforce Intelligence API", | |
| "version": "1.0.0", | |
| "status": "operational", | |
| "authentication": { | |
| "required": True, | |
| "login_endpoint": "/auth/login", | |
| "instructions": "POST your Jira credentials to /auth/login to receive an access token" | |
| }, | |
| "endpoints": { | |
| "auth": "/auth", | |
| "jira": "/jira", | |
| "intelligence": "/intelligence", | |
| "docs": "/docs", | |
| "redoc": "/redoc" | |
| } | |
| } | |
| async def health_check(): | |
| """Health check endpoint""" | |
| return { | |
| "status": "healthy", | |
| "timestamp": "2026-02-07T00:00:00Z" | |
| } | |
| if __name__ == "__main__": | |
| import uvicorn | |
| logger.info(f"Starting server on {settings.api_host}:{settings.api_port}") | |
| uvicorn.run( | |
| "main:app", | |
| host=settings.api_host, | |
| port=settings.api_port, | |
| reload=settings.debug | |
| ) | |