3 pages (market, PRINZIP drilldown, developers leaderboard) on top of existing v_developer_full_metrics + domrf_realization views. ECharts on the frontend, FastAPI router /api/v1/analytics on the backend.
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
from collections.abc import AsyncIterator
|
|
from contextlib import asynccontextmanager
|
|
|
|
import sentry_sdk
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.v1 import analytics, concepts, parcels
|
|
from app.core.config import settings
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
|
if settings.sentry_dsn:
|
|
sentry_sdk.init(
|
|
dsn=settings.sentry_dsn,
|
|
environment=settings.environment,
|
|
traces_sample_rate=0.1,
|
|
)
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="GenDesign API", version="0.1.0", lifespan=lifespan)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(concepts.router, prefix="/api/v1/concepts", tags=["concepts"])
|
|
app.include_router(parcels.router, prefix="/api/v1/parcels", tags=["parcels"])
|
|
app.include_router(analytics.router, prefix="/api/v1/analytics", tags=["analytics"])
|
|
|
|
|
|
@app.get("/health")
|
|
async def health() -> dict[str, str]:
|
|
return {"status": "ok", "environment": settings.environment}
|