$ show u8views/go-u8views
u8views is a production Go web application that tracks GitHub profile views and generates embeddable SVG badges showing view counts (day, week, month, total). Users authenticate via GitHub OAuth2, and the service counts views of their GitHub profile (likely via a tracking pixel or API). The monolithic backend uses Gin, PostgreSQL, sqlc for type-safe SQL, and quicktemplate for server-side HTML rendering. The frontend uses TypeScript with esbuild and ApexCharts for statistics dashboards. The codebase is well-structured with clean separation of concerns: controllers, services, repository pattern, and custom SVG badge generation with font measurement. It includes CI via GitHub Actions, Docker Compose for local development, and Ansible deployment scripts. Notable reusable components include the badge generation library and the OAuth2 flow implementation. Minor code smells include multiple legacy cmd versions (v1, v2, v3), fire-and-forget goroutines for view counting without error handling, and duplicated inline CSS across templates.
The LLM identified 3 files worth highlighting for reuse:
Custom SVG badge generation with font measurement and template caching. This module draws text on SVG badges using a precomputed font width table, allowing precise text positioning. It is self-contained (only imports standard library and go-badge) and could be extracted as a standalone library for generating SVG badges with custom text and colors. Demonstrates non-obvious skill in low-level SVG rendering and font metrics.
Clean implementation of the GitHub OAuth2 authorization code flow. Handles redirect URL generation, token exchange, and user profile fetching. It is self-contained (only imports standard library and internal models) and could be reused as a GitHub OAuth2 client in any Go project. Demonstrates proper error handling and separation of concerns.
Repository pattern implementation wrapping sqlc-generated queries with transaction support. Provides a clean interface for database operations, including a `WithTransaction` method that handles commit/rollback. While tied to the specific sqlc models, the pattern itself is reusable and demonstrates good database abstraction practices.