$ show klsf/kldns
KLDNS is a production-grade, multi-tenant subdomain distribution and DNS management SaaS platform. Users register subdomains under administrator-managed parent domains, pay with an internal points economy, and create/manage DNS records that are synchronously written to external DNS providers. The backend is a layered Go application (Gin HTTP handlers → services → SQLite repositories via GORM plus raw SQL) with an embedded migration system, and the frontend is a Vue 3 + TypeScript + Element Plus SPA that gets compiled and embedded into the Go binary at release time. This is purely an application repo — no data research, pipelines, or analytics artifacts are present. The core workflows are: subdomain registration with points deduction and a pending-review approval workflow (with refunds on rejection), DNS record CRUD that writes remote provider APIs first and the local database second (with compensation deletes and a dns_write_jobs queue for failed remote operations), session/API-token authentication with hashed secrets, Cloudflare Turnstile captcha verification, and a full admin backend for users, groups, domains, provider credential configs, settings, and audit logs. DNS provider integrations use a factory-registered interface with adapters for Cloudflare, DNSPod, Aliyun, AWS Route53, Google Cloud DNS, Huawei, Baidu, and others — several implementing non-trivial signing schemes (AWS SigV4, Google JWT/OAuth2, Huawei SDK-HMAC-SHA256, Baidu BCE). Testing is a notable strength: services, repositories, utilities, and most provider adapters have unit tests using httptest servers, fake repositories, and fixed-time fixtures. The main weaknesses are internal consistency issues rather than broken functionality: duplicated domain/subdomain join SQL across repositories, a documented repository refactoring in progress, hardcoded magic values (admin group 99, default group 100), two different pagination strategies between admin (server-side) and user (client-side) frontend views, Chinese-language UI and error messages not abstracted behind localization, and a hardcoded default app secret that must be changed in production. The multi-provider DNS abstraction, crypto/validation utilities, and the embedded migration runner are genuinely reusable in other Go projects.
The LLM identified 8 files worth highlighting for reuse:
Defines the Provider interface (zone/record CRUD, configure, health check) and a package-level registry with Register() and New() lookup by provider type. Any Go project needing pluggable backend integrations (DNS, storage, auth) can extract this factory-registry pattern with minimal modification.
A configurable HTTP client wrapper supporting direct, HTTP proxy, and SOCKS5 proxy transports via a consistent request helper. Self-contained infrastructure that is directly reusable in any Go service that must call third-party APIs, especially through corporate proxies.
Complete AWS Route53 adapter implementing SigV4 request signing, XML change batching, and deterministic synthetic remote record IDs for providers without stable record IDs. An exemplar of non-obvious API integration craft; the SigV4 signing logic and pagination/marker handling are reusable in other AWS integrations.
Self-contained AES-256-GCM encrypt/decrypt helpers for storing sensitive credentials (e.g., DNS provider API keys) at rest. An isolated crypto utility that can be extracted into any Go project needing secure sealed storage of secrets.
Generates random API tokens, returns the plaintext to the caller exactly once, and stores only SHA-256 digests — the canonical 'show-once, store-hashed' API key pattern. Reusable authentication utility for any service issuing bearer tokens to users or integrations.
Defines AppError with a Code taxonomy (INVALID_ARGUMENT, UNAUTHORIZED, NOT_FOUND, CONFLICT, etc.) that HTTP handlers map to status codes. A clean, framework-agnostic error-model pattern suitable for any Go API service.
Validates DNS record values, subdomain labels, and record prefixes with provider-agnostic rules (label lengths, allowed characters, value formats). Reusable validation logic for any DNS-adjacent project, and useful as a reference model for input-validation utilities generally.
Migration runner that executes ordered .sql files from an embedded filesystem (with optional disk fallback) and tracks applied versions in a schema_migrations table. A portable pattern for shipping Go binaries with self-migrating database schemas.