feat(api): wire documents router and SQLite init in app factory
Why: - App factory needs to mount document routes and initialize SQLite at startup Changes: - Import and mount documents_router - Call init_db() on app creation
This commit is contained in:
@@ -9,14 +9,18 @@ from src.core.exceptions import (
|
|||||||
chunking_exception_handler,
|
chunking_exception_handler,
|
||||||
benchmark_exception_handler,
|
benchmark_exception_handler,
|
||||||
)
|
)
|
||||||
|
from src.documents.routes import router as documents_router
|
||||||
|
from src.storage.sqlite import init_db
|
||||||
|
|
||||||
|
|
||||||
def create_app() -> FastAPI:
|
def create_app() -> FastAPI:
|
||||||
"""Create and configure the FastAPI application.
|
"""Create and configure the FastAPI application.
|
||||||
|
|
||||||
Mounts domain routers and registers exception handlers.
|
Mounts domain routers and registers exception handlers.
|
||||||
Routers are imported lazily — domains are added in later phases.
|
|
||||||
"""
|
"""
|
||||||
|
# Ensure SQLite tables exist at startup
|
||||||
|
init_db()
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="RAG Chunking Benchmarker",
|
title="RAG Chunking Benchmarker",
|
||||||
description="Benchmark five chunking strategies on regulatory documents. "
|
description="Benchmark five chunking strategies on regulatory documents. "
|
||||||
@@ -37,6 +41,9 @@ def create_app() -> FastAPI:
|
|||||||
app.add_exception_handler(ChunkingError, chunking_exception_handler)
|
app.add_exception_handler(ChunkingError, chunking_exception_handler)
|
||||||
app.add_exception_handler(BenchmarkError, benchmark_exception_handler)
|
app.add_exception_handler(BenchmarkError, benchmark_exception_handler)
|
||||||
|
|
||||||
|
# Mount domain routers
|
||||||
|
app.include_router(documents_router)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user