
Token Monitor
I built a full-stack AI usage monitoring platform that tracks token consumption and costs across multiple devices and AI tools in real time. The system consists of three parts: a Next.
js dashboard with Recharts visualizations and Socket. io live updates, a NestJS backend with PostgreSQL for storage and a REST ingestion API, and a cross-platform Python agent that runs as a background daemon on each machine.
The agent auto-detects and collects usage data from Claude Code (via JSONL file watching with the watchdog library), Cursor (via SQLite DB), GitHub Copilot, Gemini CLI, Windsurf, and Continue — then ships records to the backend every 30 seconds. It installs itself as a systemd service on Linux, a launchd LaunchAgent on macOS, or a Task Scheduler job on Windows, and sends periodic heartbeats so the dashboard shows live device online/offline status.
Technologies
Project Features
- Cross-platform Python agent supporting Claude Code, Cursor, GitHub Copilot, Gemini CLI, Windsurf, and Continue
- Claude token collection via real-time JSONL file watching using the watchdog library
- Cursor usage collected from its SQLite tracking database with offset-based deduplication
- Agent auto-installs as systemd service (Linux), launchd agent (macOS), or Task Scheduler job (Windows)
- Real-time dashboard updates via Socket.io WebSockets with per-device online/offline heartbeats
- Interactive daily token chart and token distribution donut (Input, Output, Cache Read, Cache Write)
- JWT-secured authentication with admin role-based access and per-device cost attribution


