feat(core): add core layer with config, clients, exceptions, models, and app factory

This commit is contained in:
2026-07-21 18:51:57 +03:30
parent c5bf8d5e1e
commit 4edc355ae5
6 changed files with 214 additions and 0 deletions

43
src/main.py Normal file
View File

@@ -0,0 +1,43 @@
"""FastAPI app factory. Composes all domain routers and middleware."""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.core.exceptions import (
ChunkingError,
BenchmarkError,
chunking_exception_handler,
benchmark_exception_handler,
)
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.
"""
app = FastAPI(
title="RAG Chunking Benchmarker",
description="Benchmark five chunking strategies on regulatory documents. "
"Compare retrieval quality, answer faithfulness, and cost.",
version="0.1.0",
)
# CORS — allow all origins for development
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Register exception handlers
app.add_exception_handler(ChunkingError, chunking_exception_handler)
app.add_exception_handler(BenchmarkError, benchmark_exception_handler)
return app
app = create_app()