Page - LLM Analytics

abstract

Deep analytics on AI trading performance — model win rates, symbol heatmap, cost vs. return scatter, pipeline combinations, and learning insights with 7/30/90 day period selector.

Route

PropertyValue
Path/llm-analytics
Filefrontend/src/app/llm-analytics/page.tsx
Auth RequiredNo
LayoutRoot layout with sidebar
Dynamic SegmentNone

Component Tree

LLMAnalyticsPage (page.tsx)
├── AppHeader (title="LLM Analytics", actions: period selector + refresh)
├── SummaryKpiCards (total calls, avg confidence, win rate, total cost)
├── Tabs: "Models" | "Pipelines" | "Learning"
│
├── Tab: Models
│   ├── ModelPerformanceTable (provider, model, calls, win rate, P&L, cost)
│   ├── ModelSymbolHeatmap (symbol × model win rate matrix)
│   ├── CostVsWinrateScatter (cost per call vs. win rate bubble chart)
│   ├── ActionDistributionChart (BUY/SELL/HOLD distribution)
│   └── PnlTimelineChart (P&L over time, colored by model)
│
├── Tab: Pipelines
│   └── PipelineCombinationsTable (agent combos: which combo wins most)
│
└── Tab: Learning
    └── LearningTab (confidence calibration + signal reliability + lessons)

Data Layer

Server State — Promise.all on mount

State VarAPI CallEndpoint
summaryllmAnalyticsApi.getSummary(days)GET /api/v1/llm-analytics/summary
performancellmAnalyticsApi.getModelPerformance(days)GET /api/v1/llm-analytics/model-performance
heatmapllmAnalyticsApi.getHeatmap(days)GET /api/v1/llm-analytics/heatmap
pnlTimelinellmAnalyticsApi.getPnlTimeline(days)GET /api/v1/llm-analytics/pnl-timeline
costTrendllmAnalyticsApi.getCostTrend(days)GET /api/v1/llm-analytics/cost-trend
pipelinesllmAnalyticsApi.getPipelineCombinations(days)GET /api/v1/llm-analytics/pipelines

All 6 calls fire in parallel via Promise.all. When days changes (period selector), fetchAll(days) reruns all 6.

Local State

VariableTypeInitialDescription
daysnumber30Lookback window: 7, 30, or 90
tab"Models" | "Pipelines" | "Learning""Models"Active tab
loadingbooleantrueAll-or-nothing loading state

Page Lifecycle

Validation & Conditions

Render Conditions

ConditionWhat Shows
loadingSkeleton cards
performance.length === 0"No LLM calls in this period" empty state
heatmap.data all zerosNeutral gray heatmap
LLM fetch errorconsole.error only — no toast
RoleLink
Backend APIAPI-LLM-Analytics
DB SchemaDB - llm_calls
DB SchemaDB - ai_journal