Architecture
Real-time token usage analytics. Every query through the edge router logs token counts, latency, and routing decisions to Firestore. The stats dashboard aggregates and visualizes this data live.
api.pazlabs.ioThe chat interface POSTs the user's query with a session ID. The edge-router processes it and returns a structured response.
Every API response includes a tokens object with input, output, and total counts — sourced from whichever provider handled the query (Ollama, Claude, Gemini, Grok, or OpenAI).
token_stats doc to FirestoreAfter each successful response, the chat UI logs a document to the token_stats Firestore collection with the session ID, query preview, provider, token counts, latency, and confidence score.
onSnapshotThe stats dashboard subscribes to the token_stats collection with a real-time listener. New documents appear instantly — no polling needed.
Client-side aggregation computes per-provider query counts, input/output tokens, and average latency. A line chart shows daily query volume by provider. Time filters: Session, Today, Week, Month, All Time.
Data Flow
Tech Stack