From 29edbf57c4892528ff5638ad391016fb7a3080a8 Mon Sep 17 00:00:00 2001 From: Mahdi Bazrafshan Date: Sun, 26 Jul 2026 09:38:02 +0330 Subject: [PATCH] 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 --- src/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index 59dc158..f319a73 100644 --- a/src/main.py +++ b/src/main.py @@ -9,14 +9,18 @@ from src.core.exceptions import ( chunking_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: """Create and configure the FastAPI application. 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( title="RAG Chunking Benchmarker", 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(BenchmarkError, benchmark_exception_handler) + # Mount domain routers + app.include_router(documents_router) + return app