Files
auto-virtual-tryon/app/main.py
2026-03-27 00:10:28 +08:00

40 lines
1.2 KiB
Python

"""FastAPI application entrypoint."""
from contextlib import asynccontextmanager
from fastapi import FastAPI
from app.api.routers.assets import router as assets_router
from app.api.routers.health import router as health_router
from app.api.routers.orders import router as orders_router
from app.api.routers.reviews import router as reviews_router
from app.api.routers.workflows import router as workflows_router
from app.config.settings import get_settings
from app.infra.db.session import init_database
@asynccontextmanager
async def lifespan(_: FastAPI):
"""Initialize local resources for the MVP runtime."""
settings = get_settings()
if settings.auto_create_tables:
await init_database()
yield
def create_app() -> FastAPI:
"""Create and configure the FastAPI application."""
settings = get_settings()
app = FastAPI(title=settings.app_name, debug=settings.debug, lifespan=lifespan)
app.include_router(health_router)
app.include_router(orders_router, prefix=settings.api_prefix)
app.include_router(assets_router, prefix=settings.api_prefix)
app.include_router(reviews_router, prefix=settings.api_prefix)
app.include_router(workflows_router, prefix=settings.api_prefix)
return app
app = create_app()