root 6f61d0660c feat: implement 5 high-value Phase 2 features
Phase 2 features:
1. Contract Risk Analysis - AI-powered risk detection with suggestions
2. Case Prediction Engine - Win probability and outcome prediction
3. Legal Knowledge Graph - Entity and relation management
4. Multi-language Translation - Legal document translation
5. Lawyer Matching - Intelligent lawyer recommendation

All 63 unit tests passing.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 03:42:37 +08:00

63 lines
1.5 KiB
Python

"""Main FastAPI application."""
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.core.config import settings
from app.core.database import init_db
from app.core.exceptions import AppException
from app.core.exception_handlers import app_exception_handler
from app.api.v1 import laws, analyses, contracts, signatures, phase2
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan handler."""
# Startup
await init_db()
yield
# Shutdown
pass
app = FastAPI(
title=settings.APP_NAME,
version=settings.APP_VERSION,
lifespan=lifespan,
)
# Register exception handlers
app.add_exception_handler(AppException, app_exception_handler)
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Configure in production
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers
app.include_router(laws.router, prefix="/api/v1")
app.include_router(analyses.router, prefix="/api/v1")
app.include_router(contracts.router, prefix="/api/v1")
app.include_router(signatures.router, prefix="/api/v1")
app.include_router(phase2.router, prefix="/api/v1")
@app.get("/")
async def root():
"""Root endpoint."""
return {
"name": settings.APP_NAME,
"version": settings.APP_VERSION,
"status": "running"
}
@app.get("/health")
async def health_check():
"""Health check endpoint."""
return {"status": "healthy"}