File size: 2,398 Bytes
c2cb41b
 
e4c3be8
c2cb41b
 
6f69304
c2cb41b
 
 
 
 
 
 
 
 
 
 
f397f69
 
 
 
 
 
c2cb41b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4c3be8
c2cb41b
 
6f69304
c2cb41b
 
 
 
 
 
 
 
 
e4c3be8
 
 
 
 
c2cb41b
e4c3be8
c2cb41b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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)


@app.get("/")
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"
        }
    }


@app.get("/health")
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
    )