Project

gh-stats

A minimal, dependency-light serverless service that generates GitHub statistics visualizations as SVG images.

The problem

GitHub contribution graphs and repository statistics are useful for portfolios and dashboards, but embedding them requires either heavy JavaScript libraries or manual updates. Serverless functions are perfect for this — lightweight, scalable, and stateless — but most implementations over-engineer the solution with unnecessary dependencies.

Approach

Built a minimal serverless function that queries the GitHub API and generates clean SVG visualizations. The service is stateless, dependency-light, and optimized for fast response times. Each visualization is generated on-demand, eliminating cache invalidation headaches.

Key capabilities:

  • Contribution graph: Visual timeline of GitHub contributions
  • Repository stats: Stars, forks, language distribution
  • User stats: Public profile metrics and activity summaries
  • SVG generation: No external rendering services — pure SVG generation
  • Caching headers: Appropriate cache directives for dashboard embedding

Trade-offs

  • SVG over canvas/images: SVG is lightweight and infinitely scalable, but rendering is limited to basic shapes and text. No photorealistic charts.
  • On-demand over pre-computed: Function calls add latency, but eliminate stale data and infrastructure complexity.
  • Minimal dependencies: Reduces bundle size and attack surface, but requires more custom logic than using charting libraries.

Outcome

A lightweight tool for developers who want GitHub stats on their websites, portfolios, or dashboards without heavy client-side libraries. Particularly useful for status pages, portfolio sites, and internal dashboards where fresh data matters but heavy infrastructure doesn’t.