Problem Statement
Per-message token usage is persisted (packages/db/src/tables/chats.ts:82–86 — input_tokens, output_tokens, total_tokens, plus modelId in message metadata) but never aggregated or shown anywhere. System Admins have no view of consumption per user / per AI Model / over time.
Proposed Solution
- API: aggregation endpoint(s) summing tokens grouped by user, AI Model, and day (consider a cached/materialized table if message volume is high). Gate to System Admin.
- Frontend: a new "Usage & Analytics" Settings Section in the System Admin Category; charts via
recharts (already a dependency). Show totals, per-model split, and a time series.
Acceptance Criteria
Scope / Notes
Frontend + backend. Depends conceptually on nothing, but can additionally surface 👍/👎 feedback rates once the message-feedback issue lands.
Problem Statement
Per-message token usage is persisted (
packages/db/src/tables/chats.ts:82–86—input_tokens,output_tokens,total_tokens, plusmodelIdin message metadata) but never aggregated or shown anywhere. System Admins have no view of consumption per user / per AI Model / over time.Proposed Solution
recharts(already a dependency). Show totals, per-model split, and a time series.Acceptance Criteria
Scope / Notes
Frontend + backend. Depends conceptually on nothing, but can additionally surface 👍/👎 feedback rates once the message-feedback issue lands.