How jarryuser/github-visualizer works
1. System shape
- This is a client-side TypeScript dashboard hosted on GitHub Pages, with a small Cloudflare Worker acting as the only server-side component.
- The browser app renders GitHub profile analytics; the Worker protects the GitHub token and caches API responses.
2. Front-end shell
- index.html is the only HTML entry point; there is no UI framework.
- src/main.ts is the orchestrator: it reads URL state, switches between tabs/views, triggers profile loading, and coordinates rendering.
3. UI state and routing
- The app is URL-driven via query parameters such as ?user=..., ?tab=compare&a=...&b=..., and ?embed=1.
- This makes profile views shareable and allows the same codebase to serve the main dashboard, comparison mode, and the compact embed card.
4. Data access boundary
- src/api.ts is the browser’s single gateway for GitHub data.
- It sends requests to the Worker proxy instead of calling api.github.com directly, so the browser bundle never contains secrets.
5. Cloudflare Worker proxy
- worker/index.ts is the server-side boundary.
- It enforces a small allowlist of GitHub routes, attaches the GITHUB_TOKEN secret, and returns only the proxied responses needed by the app.
6. Caching and freshness
- The Worker uses Workers KV as an edge cache.
- Different endpoints have different TTLs: profile and repo metadata are cached for minutes, language stats longer, and /rate_limit very briefly so the header badge stays current.
- ?fresh=1 bypasses cache for a one-off refresh.
7. Profile data flow
- On profile load, the app fetches core profile data and repositories in parallel, then fans out to repo-language endpoints, contribution data, and recent events.
- The README describes this as a Promise.all-heavy pipeline to keep load times low and to render most widgets once the main profile payload arrives.
8. Visualization subsystem
- The main charts are split into focused modules:
- streak.ts for contribution heatmap and streak counters
- commitHeatmap.ts for the 7×24 coding-hours grid
- languages.ts for the animated language breakdown
- activityChart.ts for weekly activity trend
- These modules use D3.js for SVG rendering and theme-aware colors.
9. Profile content modules
- repos.ts renders top repositories and their metadata.
- healthScore.ts computes and displays repository health indicators such as description, license, activity, and topics.
- profileReadme.ts fetches and renders {username}/{username}/README.md when present.
- embed.ts builds the compact iframe-friendly profile card.
10. Comparison mode
- compare.ts handles the side-by-side profile view.
- It compares stats, language overlap, and heatmaps, using the same underlying API layer but a different presentation boundary.
11. Cross-cutting presentation
- styles/main.css defines the visual system, including GitHub-dark/light styling and layout for all tabs and cards.
- Theme selection is persistent in browser storage and influences chart rendering as well as page styling.
12. External services
- Primary data source: GitHub REST API v3.
- Contribution history comes from github-contributions-api because GitHub’s native heatmap data is GraphQL-based.
- Deployment is split: front-end to GitHub Pages, Worker to Cloudflare Workers with KV.
13. Build and runtime boundaries
- The front-end is built with Vite and TypeScript; tsconfig.json covers src/.
- The Worker has its own TypeScript config and runtime config (tsconfig.worker.json, wrangler.toml), which cleanly separates browser code from edge code.
14. Important architectural constraint
- The browser never receives the GitHub token.
- All sensitive API access, quota handling, and caching are centralized in the Worker, which is the key security and performance boundary of the system.
Main entry points: main.ts Main app · index.ts Worker proxy · api.ts API gateway · index.html index.html
Components 17
Browser app
Client-side TypeScript dashboard rendered from a single HTML entry point.
- index.html · Single HTML entry point for the browser app.
index.html - Main app · Reads URL state, switches tabs and views, and coordinates profile loading and rendering.
src/main.ts - API gateway · Browser-side gateway for GitHub data; sends requests through the Worker proxy.
src/api.ts - Compare view · Side-by-side profile comparison mode and shared stats.
src/compare.ts - Embed card · Compact iframe-friendly profile card.
src/embed.ts - Profile README · Fetches and renders a user's repository README when present.
src/profileReadme.ts - Main styles · Global visual system, layout, and GitHub-dark/light styling.
styles/main.css
Presentation modules
Focused view and chart modules used by the dashboard.
- Repos panel · Renders top repositories and their metadata.
src/repos.ts - Health score · Computes repository health indicators such as description, license, activity, and topics.
src/healthScore.ts - Streaks · Contribution heatmap and streak counters.
src/streak.ts - Commit grid · 7×24 coding-hours heatmap.
src/commitHeatmap.ts - Languages · Animated language breakdown visualization.
src/languages.ts - Activity trend · Weekly activity trend chart.
src/activityChart.ts
Cloudflare edge
Worker boundary that proxies GitHub data and caches responses.
- Worker proxy · Cloudflare Worker that allowlists GitHub routes, attaches the token, and returns proxied responses.
worker/index.ts
Build and deploy
Tooling and deployment configuration for browser and worker runtimes.
- Vite config · Browser build configuration for the TypeScript front end.
vite.config.ts - Worker config · TypeScript configuration for the edge runtime.
tsconfig.worker.json - Wrangler config · Cloudflare Worker deployment and runtime configuration.
wrangler.toml
Connections 17
- index.html → Main app: boots app · The HTML entry point loads the orchestrator script.
- Main app → API gateway: loads data · Main app delegates all GitHub fetching to the API gateway.
- Main app → Compare view: compare mode · URL state can switch the app into side-by-side comparison.
- Main app → Embed card: embed mode · URL state can switch the app into compact embed rendering.
- Main app → Repos panel: renders repos · The orchestrator feeds profile repository data into the repos panel.
- Main app → Health score: renders health · Repository metadata is summarized in the health score view.
- Main app → Streaks: renders streaks · Contribution history is visualized in the streak module.
- Main app → Commit grid: renders grid · The coding-hours grid is drawn as part of profile analytics.
- Main app → Languages: renders langs · Language data is passed to the animated breakdown chart.
- Main app → Activity trend: renders trend · Weekly activity data drives the trend chart.
- Main app → Profile README: loads README · The app fetches a profile README when available.
- Main app → Main styles: applies theme · Theme state influences page styling and chart presentation.
- API gateway → Worker proxy: proxy calls · Browser requests go through the Cloudflare Worker instead of GitHub directly.
- Worker proxy → API gateway: returns data · The Worker returns proxied GitHub responses to the browser.
- Worker proxy → Wrangler config: deploys with · Wrangler config defines how the Worker is deployed and run.
- Vite config → Main app: builds · Vite bundles the browser TypeScript application.
- Worker config → Worker proxy: types · Worker-specific TypeScript config covers the edge runtime.