GitHub-Traffic-Dashboard

CLAUDE.md — GitHub Traffic Dashboard

Persistent instruction set for this repository. Read this before doing any work here.

What we are building

A self-hosted Grafana dashboard for GitHub repository Insights (Traffic: views, unique visitors, clones, unique cloners, referring sites, popular content; plus contributor/commit stats where useful).

Product intent — lead generation & analytics

This is not just a pretty traffic chart; it is a lead-generation / audience-insight tool. Design panels and the data model so the owner can answer:

Persist enough dimension detail (repo, day, metric, source/path, unique-vs-total, and repo attributes) that any of the above is a query, never a re-fetch. Never re-download traffic just to add a filter — repo attributes come from the cheap repo-list API.

Non-negotiable project rules (from the owner)

Data collection contract

Auth: CLI now, token later (keep provisions)

Relevant GitHub API endpoints (via gh api)

gh api repos/{owner}/{repo}/traffic/views              # total + unique views, 14d
gh api repos/{owner}/{repo}/traffic/clones             # total + unique clones, 14d
gh api repos/{owner}/{repo}/traffic/popular/referrers  # referring sites
gh api repos/{owner}/{repo}/traffic/popular/paths       # popular content
gh api repos/{owner}/{repo}/stats/contributors         # contributor stats

Traffic endpoints require push access to the repo (owner token satisfies this).

Target architecture

┌──────────────┐   daily    ┌──────────────┐   SQL upsert   ┌──────────────┐
│  collector   │──────────► │  GitHubClient │──────────────►│   SQLite      │
│ (scheduler)  │            │ + AuthProvider│               │ data/traffic.db│
└──────────────┘            └──────────────┘               └──────┬───────┘
                                                                   │ query (plugin)
                                                            ┌──────▼───────┐
                                                            │   Grafana     │
                                                            │  dashboards   │
                                                            └──────────────┘

Docker / local dev

Working style in this repo