feat: update project structure and docs

This commit is contained in:
2026-04-25 16:26:33 +03:00
parent 9c3b44b561
commit 9772c3c908
42 changed files with 1342 additions and 6 deletions

View File

@@ -1,21 +1,43 @@
"""FastAPI application factory and entry point."""
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI
from app.common.error_handler import register_exception_handlers
from app.core.config import settings
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan manager for startup/shutdown events."""
# Startup: initialize DB connections, cache, etc.
yield
# Shutdown: cleanup resources
def app_factory():
app = FastAPI(lifespan=lifespan)
def app_factory() -> FastAPI:
"""Create and configure FastAPI application instance.
Returns:
Configured FastAPI application.
"""
app = FastAPI(title=settings.app_name, debug=settings.debug, lifespan=lifespan)
# Register exception handlers
register_exception_handlers(app)
# Register routers (when added)
# from app.api.v1.router import api_router
# app.include_router(api_router, prefix="/api/v1")
return app
def main():
uvicorn.run(app_factory, factory=True, host="0.0.0.0", port=8000)
"""Run the application with uvicorn server."""
uvicorn.run(app_factory, factory=True, host=settings.host, port=settings.port)
if __name__ == "__main__":