light-tokenmeter Architecture

light-tokenmeter Architecture An architecture diagram generated by Archify. llm-proxy & Apps · Event producers · Architecture component llm-proxy & Apps Event producers llm-proxy-admin · Dashboards & curl · Architecture component llm-proxy-admin Dashboards & curl gRPC Server · UsageService :9090 · light-tokenmeter Service gRPC Server UsageService :9090 HTTP Server · REST & Probes :8080 · light-tokenmeter Service HTTP Server REST & Probes :8080 UsageService · Domain validation · light-tokenmeter Service UsageService Domain validation Repository · COPY & SQL builder · light-tokenmeter Service Repository COPY & SQL builder ClickHouse · usage_events MergeTree · Architecture component · TTL 90 days ClickHouse usage_events MergeTree TTL 90 days PostgreSQL · usage_events table · Architecture component · append-only PostgreSQL usage_events table append-only RecordUsageEvent(s) GetUsageByMeta POST /v1/usage/events GET /v1/usage/summary GET /readyz Record / Query Record / Summary Domain calls Batch & Analytics COPY & GROUP BY light-tokenmeter Service Legend Frontend Backend Database External

Idempotent Ingestion

  • • Every event carries a UUID; ON CONFLICT (event_id) DO NOTHING prevents double counting
  • • Batches up to 500 events stream into a temp table via pgx COPY before atomic insert

Usage Analytics & Meta Queries

  • • Daily summaries bucketed by event time with 10k safety cap and partial index on meta.job_id
  • • Optional ClickHouse backend provides async batching with in-memory deduplication and 90-day TTL