How insight-services-apac/tokenscope-public works
TokenScope is an AI-engineering usage attribution and budget-management product. Developers connect Claude Code or Copilot CLI, emit usage, and see it attributed to teammates, sessions, and projects; managers govern project budgets and top-ups, while finance and admins reconcile provider billing and manage organizational policy. The graph separates ingestion and attribution, reconciliation, project administration, and reporting/usage views. README statements support the major product flows; sampled source confirms selected UI calls, policy persistence, reconciliation, and worker behavior, but not every route-level connection.
Components 26
Usage capture
- Claude and Copilot
plugin/hooks/session-start.mjs - Connect guidance
app/components/connect/connect-guides.ts - Telemetry receiver
server - Provider APIs
Attribution and governance
- Usage attribution
drizzle/schema/attribution.ts - Identity and org
drizzle/schema/identity.ts - Governance rules
drizzle/schema/governance.ts - Billing reconciliation
server/reconciliation/engine.ts - Directory placement
server/reconciliation/placement-service.ts - Session tagging
app/components/home/TagSessionDialog.vue - Copilot overage allocation
server/governance/copilot-overage-allocation.ts - Telemetry gap detection
server/workers/mitigation-query.ts
Project operations
- Project budgets
app/pages/projects/[code].vue - Project requests
server/api/v1/admin/project-requests/index.get.ts - Budget allocations
server/allocations/append-topup.ts - Admin operations
app/pages/admin/org-setup.vue
Usage and reporting
- Developer dashboard
app/pages/index.vue - Personal usage
app/components/me/ActivityCard.vue - Finance and reports
app/pages/reporting/index.vue - Reporting engine
server/reporting/engine/usage-coverage.ts - Budget pace logic
app/composables/useRagState.ts
Identity and storage
- PostgreSQL
drizzle/schema/index.ts - Session and auth
app/composables/useSession.ts
Other components
- Developer
- Project manager
- Administrator
Connections 27
- Developer → Connect guidance: gets setup guidance
README.md - Connect guidance → Claude and Copilot: configures clients
README.md - Claude and Copilot → Telemetry receiver: emits usage
README.md - Provider APIs → Billing reconciliation: supplies billing truth
README.md - Telemetry receiver → Usage attribution: feeds usage attribution
README.md - Usage attribution → PostgreSQL: records usage
drizzle/schema/index.ts - Identity and org → PostgreSQL: stores identities
drizzle/schema/index.ts - Billing reconciliation → PostgreSQL: writes deltas
server/reconciliation/engine.ts - Billing reconciliation → Provider APIs: reads provider usage
README.md - Usage attribution → Project budgets: attributes project claims
README.md - Directory placement → Identity and org: resolves directory placement
- Project manager → Project budgets: manages budgets
README.md - Project manager → Project requests: reviews requests
README.md - Project requests → Budget allocations: may extend budget
- Administrator → Admin operations: configures organization
README.md - Admin operations → PostgreSQL: persists connection policy
- Developer → Developer dashboard: views spend and burn
README.md - Developer dashboard → Personal usage: renders activity
app/pages/index.vue - Developer dashboard → Session tagging: opens tagging dialog
app/pages/index.vue - Developer dashboard → Budget pace logic: computes budget pace
app/pages/index.vue - Finance and reports → Reporting engine: requests reporting data
- Reporting engine → PostgreSQL: queries usage coverage
- Finance and reports → Project manager: shows budget reporting
README.md - Finance and reports → Administrator: shows finance chargeback
README.md - Copilot overage allocation → PostgreSQL: persists allocations
- Telemetry gap detection → PostgreSQL: checks attribution gaps
server/workers/mitigation-query.ts - Session and auth → Developer dashboard: supports signed-in view