Skip to content

Repository files navigation

GitHub Banners

Go VersionPostgreSQLApache KafkaDockerLicense: MIT


A high-performance backend service that generates dynamic banners displaying GitHub user statistics. Perfect for enhancing your GitHub profile README with real-time stats.

github-banners-preview.1.mp4

Overview

GitHub Banners fetches user data from the GitHub API, calculates aggregated statistics (repositories, stars, forks, languages), and renders beautiful SVG banners that automatically update.

Key Features

FeatureDescription
Statistics AggregationFetches and calculates total repositories, stars, forks, and language breakdowns
Dynamic SVG BannersRenders customizable banners with real-time user statistics
Multi-Token SupportSupports multiple GitHub tokens for higher rate limits with automatic rotation
Smart CachingMulti-layer caching (in-memory + PostgreSQL) with soft/hard TTL strategy
Background RefreshAutomatically refreshes statistics for tracked users
Event-DrivenKafka-based communication between microservices
Secure CommunicationHMAC-based request signing for inter-service authentication

Tech Stack

Tech Stack

ComponentTechnology
LanguageGo 1.25.5
HTTP Routerchi/v5
DatabasePostgreSQL 15
Message QueueApache Kafka ( Kraft manager )
GitHub APIgo-github/v81
Migrationsgoose/v3
Cachinggo-cache
ContainerizationDocker / Docker Compose

Architecture

Github Stats Caching Strategy

LayerTTLBehavior
Soft TTL10 minutesServes cached data
Hard TTL24 hoursMaximum cache lifetime , triggers background refresh
In-MemoryConfigurableFast access via go-cache
PostgreSQLPersistentDurable storage for cached data

Database Schema

TableDescription
bannersBanner configurations and storage paths
github_data.usersGitHub user profile data
github_data.repositoriesRepository data linked to users

Quick Start

Requirements

  • Go 1.25+
  • Docker & Docker Compose
  • GitHub Personal Access Token(s)

Installation

1. Clone the repository

git clone https://github.com/hurtki/github-banners.git
cd github-banners

2. Configure environment variables

Use .env.example that lay in every folder

Oneliner ( some changes, like api tokens may be required )

cp .env.example .env ; cp ./api/.env.example ./api/.env ; cp ./renderer/.env.example ./renderer/.env ; cp ./storage/.env.example ./storage/.env
  • Root .env
  • api/.env
  • renderer/.env
  • storage/.env

3. Start services

Dev mode, 80 port without https

docker compose up --build
# OR Detached mode ( only build logs )
docker compose up --build -d

Production mode, 443 port ( for cloudflare only )

Cloudflare configuration:

telegram-cloud-photo-size-4-5915536458141862905-y

Where to get cert and key:

telegram-cloud-photo-size-4-5915536458141862904-m

Put certificate cert.pem and private key key.pem to /etc/nginx/ssl/

Docker compose

# production docker compose uses already built images from dockerhub# VER should be in "x.x.x" format# check images: https://hub.docker.com/repository/docker/hurtki/github-banners-api/tagsexport VER=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//')
docker compose -f docker-compose.prod.yaml up -d

Development

For testing consider using "dev" version of docker compose

# Run tests
./run_tests.sh
# CI static check:# fix formatting
gofmt -s -w .# tests check
./run_tests.sh
# spelling ( go install github.com/client9/misspell/cmd/misspell@latest )# it will automatically fix all issues
misspell -source=auto -w .# global api bundle ( only if you touched api.yaml files )# It will combine description of global api in `/docs/api.yaml`# into `bundled.yaml`# for install https://redocly.com/docs/cli/installation
redocly bundle docs/api.yaml -o docs/bundled.yaml

Services

ServicePortDescription
nginx80/443 ( public )API gateway + static banners
api80Main API service
api-psgr5432PostgreSQL database
renderer80Banner rendering service
storage80Banner storage service
kafka9092Apache Kafka broker

API Endpoints

MethodEndpointDescription
GET/banners/previewGet banner preview for a GitHub user
POST/bannersCreate a new lont-term banner
GET/{banner-url-path}Get long term banner ( constantly updating since you created it)

License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with Go

About

Backend for github banners with statistics

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages