from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse from app.api.routes import api_router from app.core.config import settings from app.db.session import engine from app.db.base import Base # Create database tables Base.metadata.create_all(bind=engine) app = FastAPI( title=settings.PROJECT_NAME, version=settings.VERSION, description=settings.DESCRIPTION, openapi_url="/openapi.json", docs_url="/docs", redoc_url="/redoc" ) # CORS configuration app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Include API routes app.include_router(api_router, prefix="/api/v1") @app.get("/") async def root(): return JSONResponse(content={ "title": settings.PROJECT_NAME, "version": settings.VERSION, "description": settings.DESCRIPTION, "documentation": "/docs", "health_check": "/health" }) @app.get("/health") async def health_check(): return JSONResponse(content={ "status": "healthy", "service": settings.PROJECT_NAME, "version": settings.VERSION }) if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=8000)