$ show zekroTJA/shinpuru
This repository contains shinpuru, a production-grade Discord bot written in Go with a React/TypeScript web dashboard. It serves as a comprehensive guild management and moderation platform, handling reports, kicks, bans, mutes, and community engagement features like karma, starboard, votes, and code execution. The backend is a monolith using the discordgo library for Discord interactions, Fiber for its REST API, and sarulabs/di for dependency injection, backed by MySQL, Redis, and MinIO. The architecture is well-structured with clear separation of concerns. The internal/ directory houses services (database, storage, permissions, karma, reports), event listeners, slash commands, and middleware. The pkg/ directory is a standout collection of over 30 reusable utility packages, covering areas like rate limiting (limiter), one-time authentication (onetimeauth), Discord embed building (embedbuilder), fuzzy object resolution (fetch), and permission management (permissions). These packages are largely self-contained and could be extracted for use in other Go projects. The frontend is a modern React SPA with i18n support (English and German), a typed API client (shinpuru-ts), and a comprehensive set of components for managing every aspect of the bot. The project demonstrates strong engineering practices with CI/CD pipelines, Docker support, and a clear contribution model. While the codebase is large and shows some signs of technical drift (legacy package versions, some raw SQL patterns, duplicated package versions), the core architecture and reusable packages make it a valuable reference for building complex Discord bots or Go web applications.
The LLM identified 7 files worth highlighting for reuse:
Implements a secure one-time authentication token system using JWT. This is a common requirement for web applications (e.g., passwordless login, sensitive action confirmation). The implementation is clean, well-abstracted, and includes its own options and error handling, making it highly reusable.
A generic rate-limiting middleware for the Fiber web framework. It supports multiple strategies (e.g., IP-based, route-based) and is configurable. The pattern is cleanly separated from the application logic, making it a drop-in component for any Fiber-based API.
A fluent builder for constructing Discord message embeds. It encapsulates the complex Discord embed structure into a clean, chainable API. This is a textbook example of the Builder pattern and is immediately reusable in any Discord bot project.
Provides a robust mechanism for resolving Discord objects (roles, members, channels) from user input (names, IDs, mentions). It handles ambiguity and caching, solving a very common and tricky problem in Discord bot development. The design is generic enough to be adapted for other platforms.
Manages a hierarchical permission system using bitmasks and arrays. It provides efficient Check, Update, and Merge operations. This is a domain-agnostic authorization component that could be extracted for any application requiring fine-grained, role-based permissions.
Implements the core token handling logic (access tokens, refresh tokens) for the web API. It demonstrates a clean separation between the token handler interface and its JWT-based implementation, making it a solid reference for implementing secure token-based auth in Go.
A custom React hook that provides a clean, typed interface for making API calls to the backend. It abstracts away the HTTP client logic, error handling, and authentication token management, providing a reusable pattern for frontend-backend communication in any React application.