How techrill-academy/aic-usage-dashboard works
Purpose and Entry Points
A local Node.js dashboard that requests GitHub Enterprise AI Credit usage-report exports, waits for completion, downloads CSV results, and renders interactive usage analysis. Start with npm start; the HTTP server is server.js, serving index.html, app.js, and styles.css on localhost.
Browser Dashboard
index.html defines the credential/date input workflow and dashboard containers. app.js submits the enterprise slug, in-memory PAT, and reporting dates to the local server; displays report-generation progress; then transforms returned records into charts, summary views, a searchable/sortable table, and a combined CSV download. styles.css provides the presentation layer.
Paths: index.html, app.js, styles.css
Local API and Security Boundary
server.js is the trusted local boundary between the browser and GitHub. It receives the PAT only for the active request, forwards it to GitHub as a Bearer token, and does not persist it. The server must remain local/private because it exposes a pass-through capability using an enterprise billing credential.
Paths: server.js, README.md
GitHub Report Export Orchestration
The server calls GitHub Enterprise billing-report APIs: it creates an AI-credit usage export, receives a report ID, and polls the report-status endpoint until completion. Progress updates are returned while the potentially long-running export is pending. The API contract uses GitHub REST API version 2026-03-10.
Paths: server.js, README.md
CSV Retrieval and Normalization
After completion, the server downloads every URL in the report’s download_urls, parses the CSV exports, combines records, and returns JSON to the browser. This isolates remote download/parsing work from UI rendering and lets the client use one uniform record collection.
Paths: server.js, app.js
Visualization and Resilient Field Detection
Client-side aggregation detects common report columns such as date, quantity, monetary amounts, SKU/product/model, organization, and user identity. It drives timeline, SKU/product, organization, and user views; unavailable dimensions degrade to a “not detected” state rather than blocking the dashboard.
Paths: app.js, index.html
Runtime and External Dependencies
The app targets Node.js 18+ for native fetch and crypto.randomUUID. Its material external service is api.github.com, requiring a classic PAT with manage_billing:enterprise owned by an enterprise admin or billing manager. Browser-side charting and tabular interaction are part of the rendered dashboard dependency surface.
Paths: package.json, package-lock.json, server.js
Components 15
Browser Dashboard
- Dashboard page · Credential/date form, progress area, and analysis containers.
index.html - Dashboard client · Submits requests and renders analysis.
app.js - Presentation
styles.css - Interactive analysis · Timeline, SKU, organization, user, and searchable records views.
app.js - Field detection · Detects report dimensions and degrades unavailable views.
app.js - Combined CSV download
app.js
Local Node Runtime
Private boundary for enterprise billing credentials.
- Local HTTP server · Serves the dashboard and accepts active-request credentials.
server.js - Export orchestrator · Creates exports, polls status, and returns progress.
server.js - CSV normalizer · Downloads all report files, parses CSV, and combines records.
server.js - Node.js 18+ · Provides native fetch and crypto.randomUUID.
server.js - Package manifest · Defines runtime and browser dependency surface.
package.json - Operational guidance · Documents local/private deployment and required GitHub permissions.
README.md
GitHub Enterprise APIs
- Enterprise billing reports · AI-credit export and report-status endpoints, version 2026-03-10.
- Report CSV exports · One or more completed CSV files.
Other components
- Classic enterprise PAT · Requires manage_billing:enterprise; held only for the active request.
Connections 16
- Dashboard page → Dashboard client: loads
- Dashboard page → Presentation: uses
- Dashboard client → Local HTTP server: submits slug, PAT, dates
- Classic enterprise PAT → Local HTTP server: active request only
- Local HTTP server → Export orchestrator: starts report request
- Export orchestrator → Enterprise billing reports: create export and poll status
- Export orchestrator → Dashboard client: progress updates
- Export orchestrator → CSV normalizer: completed download URLs
- CSV normalizer → Report CSV exports: downloads CSV files
- CSV normalizer → Dashboard client: combined JSON records
- Dashboard client → Field detection: normalizes dimensions
- Field detection → Interactive analysis: drives available views
- Dashboard client → Combined CSV download: exports records
- Node.js 18+ → Local HTTP server: runs
- Package manifest → Node.js 18+: declares environment
- Operational guidance → Local HTTP server: documents security boundary