Phase 2 of the full modernization: - App factory pattern with create_app() - Settings via dataclass with env vars - Dependency injection container - Router stubs for auth, storage, api, recipes, cache, runs - Service layer stubs for run, recipe, cache - Repository layer placeholder Routes are stubs that import from legacy server.py during migration. Next: Migrate each router fully with templates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
"""
|
|
Art-DAG L1 Server Application Factory.
|
|
|
|
Creates and configures the FastAPI application with all routers and middleware.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
|
|
from artdag_common import create_jinja_env
|
|
|
|
from .config import settings
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
"""
|
|
Create and configure the L1 FastAPI application.
|
|
|
|
Returns:
|
|
Configured FastAPI instance
|
|
"""
|
|
app = FastAPI(
|
|
title="Art-DAG L1 Server",
|
|
description="Content-addressed media processing with distributed execution",
|
|
version="1.0.0",
|
|
)
|
|
|
|
# Initialize Jinja2 templates
|
|
template_dir = Path(__file__).parent / "templates"
|
|
app.state.templates = create_jinja_env(template_dir)
|
|
|
|
# Include routers
|
|
from .routers import auth, storage, api, recipes, cache, runs, home
|
|
|
|
# API routers
|
|
app.include_router(auth.router, prefix="/auth", tags=["auth"])
|
|
app.include_router(storage.router, prefix="/storage", tags=["storage"])
|
|
app.include_router(api.router, prefix="/api", tags=["api"])
|
|
app.include_router(recipes.router, tags=["recipes"])
|
|
app.include_router(cache.router, tags=["cache"])
|
|
app.include_router(runs.router, tags=["runs"])
|
|
app.include_router(home.router, tags=["home"])
|
|
|
|
return app
|
|
|
|
|
|
# Create the default app instance
|
|
app = create_app()
|