$ show looplj/axonhub
AxonHub is a production-grade, multi-provider LLM API gateway that routes, transforms, and manages requests to a wide range of AI providers (OpenAI, Anthropic, Gemini, DeepSeek, xAI, and 60+ others). It provides a unified API surface for chat completions, embeddings, moderations, audio, images, and video generation, with sophisticated features like load balancing (latency-aware, weighted round-robin, circuit breaker), per-channel rate limiting, provider quota enforcement, streaming, and reasoning token handling. The backend is written in Go using Gin, Ent ORM, gqlgen, and Uber Fx for dependency injection, supporting PostgreSQL, MySQL, and SQLite with automatic migration. The frontend is a comprehensive React/TypeScript SPA (Vite, TanStack Router/Query, Tailwind, shadcn/ui) that provides administration of channels, models, API keys, users, roles, projects, and system settings. It includes analytics dashboards, request tracing, usage logs, and OIDC SSO. The system is designed for multi-tenancy with fine-grained RBAC (scope-based permissions) and privacy policies enforced at the Ent ORM layer. Deployment is supported via Docker, Docker Compose, and Helm charts. The codebase exhibits strong engineering practices: extensive unit and integration tests (including race-condition tests and E2E Playwright tests), pipeline middleware for request transformation, generic caching abstractions, stream processing utilities, and a Zanzibar-inspired authorization framework. While there are minor issues (duplicate utility packages, a typo in a folder name, and some frontend boilerplate repetition), the overall architecture is clean, modular, and well-documented. The project is actively maintained with frequent commits, issue triage, and a clear release process.
The LLM identified 3 files worth highlighting for reuse:
A generic typed cache abstraction that supports multiple backends (memory, Redis, two-level chain) with a common interface. It provides negative caching, configurable TTL, and live invalidation events. This is a self-contained, reusable component that can be extracted into any Go project requiring a multi-tier caching layer with minimal code changes.
A set of generic stream utilities (Map, Filter, Append, Prepend, Slice) that operate on a `Stream[T]` interface. These utilities allow composable, functional-style transformations of streaming data without managing goroutines or channels directly. The implementation is clean, well-tested, and dependency-free, making it reusable across any Go project that needs stream processing (e.g., SSE, WebSocket messages, log lines).
A Zanzibar-inspired authorization framework implemented as Ent privacy rules. It defines reusable rule types (OwnerRule, UserReadScopeRule, UserPersonalAPIKeyReadRule, etc.) that compose into policies for secure multi-tenant data access. The rules are decoupled from business logic and can be applied to any Ent schema. This pattern demonstrates advanced access control design and is extractable as a standalone authorization library for Ent-based Go projects.