How willxup/cpa-usage-keeper works
CPA Usage Keeper is a standalone persistence and analytics dashboard for CLIProxyAPI. Its main workflow collects CPA usage and configuration data, stores usage in SQLite, and presents usage, cost, request-event, and health analytics in a web dashboard. The README also describes credential/provider monitoring and quota refresh, pricing synchronization, optional backups, community rankings, and read-only CPA API-key views. Connections for backend subsystems are based on documented capabilities and project structure; unsampled implementation details are not asserted.
Main entry points: usage_service.go Usage Services · router.go HTTP API · App.tsx Web Application · poller Usage Collection
Components 22
Collection and Storage
- Keeper Server
cmd/server/main.go - Usage Collection
internal/poller - CPA Client
internal/cpa/client.go - SQLite Persistence
internal/repository - Scheduled Backups
internal/backup/backup.go - HTTP API
internal/api/router.go
Usage Analytics
- Usage Services
internal/service/usage_service.go - Activity Aggregation
internal/activity/aggregate.go - Overview Analytics
internal/overview/aggregate.go - Latency Analytics
internal/latency/aggregate.go - Model Pricing
internal/pricing
Operations and Management
- Quota Inspection
internal/quota/service.go - Metadata Sync
internal/service/metadata_sync.go - Community Ranking
internal/ranking/service.go - Authentication
internal/auth/session.go
Web Experience
- Web Application
web/src/App.tsx - Usage Dashboard
web/src/pages/UsagePage.tsx - API Key Views
web/src/pages/KeyOverviewPage.tsx - API Client
web/src/lib/api.ts - CPAMC Embed
web/src/embed/cpamcEmbed.ts
Other components
- CLIProxyAPI
- Dashboard User
Connections 23
- CLIProxyAPI → Usage Collection: provides usage
README.md - Usage Collection → CPA Client: collects data
- Usage Collection → SQLite Persistence: persists usage
README.md - Keeper Server → HTTP API: serves routes
- HTTP API → Usage Services: serves usage
- Usage Services → SQLite Persistence: reads usage
- Scheduled Backups → SQLite Persistence: backs up
README.md - Usage Services → Activity Aggregation: aggregates activity
- Usage Services → Overview Analytics: builds overview
- Usage Services → Latency Analytics: analyzes latency
- Usage Services → Model Pricing: estimates cost
README.md - HTTP API → Quota Inspection: exposes refresh
README.md - Metadata Sync → CLIProxyAPI: syncs configuration
README.md - HTTP API → Community Ranking: exposes rankings
README.md - HTTP API → Authentication: protects access
README.md - Dashboard User → Web Application: uses dashboard
README.md - Web Application → Authentication: authenticates
- Web Application → Usage Dashboard: routes to
web/src/App.tsx - Web Application → API Key Views: routes to
web/src/App.tsx - Usage Dashboard → API Client: requests analytics
web/src/pages/UsagePage.tsx - API Key Views → API Client: requests key views
- API Client → HTTP API: calls endpoints
README.md - Web Application → CPAMC Embed: supports embedding
web/src/App.tsx