Skip to content

Features at a Glance ​

Everything included out of the box when you scaffold a project with GoForge (Go 1.25+), organized by subsystem with direct links to deep-dive documentation.


1. Core Architecture & Pure-Go DI (core/di, boot) ​

  • Pure-Go Reflection DI Container: Zero external DI runtime dependencies; topological dependency resolution with 3-color DFS cycle detection (A -> B -> A).
  • Modular Composition: di.Module (Providers, Invokes, Models, nested Modules), di.Bind[I], di.BindBoth[I], di.AutoCollect[I], and di.CollectModels.
  • Lifecycle Hooks: di.Lifecycle (OnStart with reverse rollback on failure; OnStop in LIFO order so EventBus.Shutdown drains before Database.Close).
  • Multi-Server Runner: boot.New / boot.NewWithConfig runs HTTP and gRPC concurrently under errgroup with SIGINT/SIGTERM graceful shutdown.

→ Architecture & Lifecycle · Dependency Injection


2. HTTP Server & Huma v2 OpenAPI (boot/server) ​

  • 6-Layer Hardened Middleware Pipeline: Recovery() → RequestID() → CustomLogger() → CORSWithConfig() → RateLimiterWithStore() → ErrorHandler(), followed by global AppKeyWithConfig().
  • Kubernetes-Ready Probes: Public GET /health (liveness) and GET /ready (2s-timeout db.Ping readiness check).
  • Hardened Defaults: SetTrustedProxies(nil) unless TRUSTED_PROXIES is set, configurable ReadHeaderTimeout (10s), ReadTimeout (30s), WriteTimeout (30s), IdleTimeout (120s), 1 MiB MaxHeaderBytes, and TLS 1.2+.
  • Huma v2 OpenAPI 3.1: Per-service interactive docs (/api/docs/<svc>), .json specs, and /schemas via server.NewHumaConfig.

→ HTTP Server & OpenAPI


3. Security & Limen Authentication ​

  • Constant-Time X-App-Key Auth: crypto/subtle.ConstantTimeCompare with fail-closed startup (ValidateForServe() rejects empty APP_KEY).
  • Debug-Gated Docs: /api/docs*, /openapi*, /docs* bypass X-App-Key only when APP_DEBUG=true.
  • Strict CORS: Wildcard * never sends Access-Control-Allow-Credentials; explicit CORS_ALLOWED_ORIGINS echo exact origins + Vary: Origin + credentials.
  • Bounded Rate Limiter: LimiterStore capped at 10,000 clients with 3m idle TTL eviction and clean Close() lifecycle.
  • Request Correlation & Masking: Validated/generated 128-bit X-Request-ID; sanitized 500 JSON responses without leaking internals.
  • Limen User Sessions: Built-in .agent/skills/limen-auth/ workflow (github.com/thecodearcher/limen, GORM adapter, bcrypt credential-password, /register, /login, /me, /logout, SessionFromRequest).

→ Security & Authentication · Tutorial Ch. 2: Limen Auth


4. gRPC Server & Interceptors (boot/server/grpc.go) ​

  • Auto-Collected Registries: Services implementing server.GRPCRegistry are collected via di.AutoCollect[server.GRPCRegistry]().
  • Full Unary & Stream Interceptors: Recovery → Logger → x-app-key metadata auth → per-IP port-stripped RateLimit (net.SplitHostPort).
  • TLS, Health & Reflection: GRPC_TLS_ENABLED cert/key support, standard grpc_health_v1 (SERVING/NOT_SERVING), and optional GRPC_REFLECTION.

→ gRPC Server & Interceptors


5. Multi-Driver Database, Migrations, SQLC & Seeders (core/database) ​

  • 4 Database Drivers: sqlite (CGO, WAL mode + _foreign_keys=on + _busy_timeout=5000), postgres (pgx/v5), mysql, and sqlserver — unused drivers are pruned by goforge new.
  • Injection-Safe DSNs & Pooling: mysqldriver.Config.FormatDSN() and url.URL / url.UserPassword escaping, DB_SSL_MODE, MaxOpenConns, MaxIdleConns, ConnMaxLifetime, and 5s startup ping.
  • Dual Migration Modes: Schema-driven Atlas SQL migrations (go run ./app/main.go loader) or GORM AutoMigrate (DB_MIGRATOR=gorm).
  • SQLC v2: Type-safe Go queries generated from internal/database/queries/*.sql.
  • Transactional Seeder Framework: database.Seeder registry (RegisterSeeder, ResolveSeeder, database.Call inside a single db.Transaction) + DatabaseSeeder & TodoSeeder.

→ Database, Migrations & Seeders


6. Generic Event Bus (core/events) ​

  • Type-Safe Pub/Sub: Generic Listener[T], On[T], Off[T], ListenerCount.
  • Async & Sync Dispatch: Non-blocking buffered Dispatch[T] (context.WithoutCancel(ctx) safe) and blocking DispatchSync[T] (errors.Join + ctx.Done()).
  • Resilience: invokeSafe panic recovery, pointer-identity deduplication, and Shutdown(ctx) draining on SIGTERM.

→ Event Bus


7. Errors, Validation & Configuration ​

  • Canonical AppError (core/errors): 10 named constructors (400–503), Wrap, WithDetails, Respond, ErrorHandler, and inspection helpers (IsNotFound, etc.).
  • Dedicated Validation (core/validator): Standalone validator/v10 (validate: tags, decoupled from Gin binding:), English translations, JSON field names (stripping ,omitempty), and RegisterRuleWithMessage.
  • Viper Configuration (core/config): 44+ typed env vars across App, HTTP, GRPC, DB, Encrypt, and Log with Validate() & ValidateForServe().

→ Error Handling · Validation · Configuration


8. Typed Clients (boot/client) ​

  • HTTP Client: NewHttpClient with WithTimeout, WithHttpAppKey, non-mutating Do() (clones requests), GetWithContext, PostWithContext.
  • gRPC Client: NewGrpcClient via grpc.NewClient with overridable TLS credentials, WithAppKey, and WithStreamAppKey.

→ HTTP & gRPC Clients


9. Observability, Pretty Logger & Interactive TUI (core/console) ​

  • Zerolog Pipeline: LOG_TYPE (terminal/file/both), LOG_FORMAT (log/json), LOG_COLOR (auto/always/never, NO_COLOR, FORCE_COLOR).
  • prettyWriter & Gin Redirect: Colorized HTTP/gRPC/Route logs with latency color thresholds (<100ms, <500ms, >=500ms).
  • Bubble Tea TUI Dashboard: Full-screen split-panel dashboard (All logs, HTTP, gRPC, System) with live server status, request/route/error counters, 5,000-line ring buffer, and --no-tui flag.

→ Logging & TUI Dashboard


10. 24-Command CLI & App Console (goforge-cli) ​

  • Interactive Command Center: Run goforge with no args to browse scaffolding commands in a Bubble Tea TUI.
  • Full Scaffolding Suite: new, app serve, gen:service/rem:service, gen:event, gen:command/rem:command, gen:config, gen:proto/rem:proto, rem:grpc, migrate, loader, gen:migration/rem:migration, db:seed/gen:seeder/rem:seeder, gen:sqlc/rem:sqlc, gen:key/rem:key, version, readme.

→ CLI & App Console Overview


11. AI-Agent Native Workspace (AGENT.md & .agent/) ​

  • Agent-Agnostic Guidance: AGENT.md + .agent/settings.json work out of the box with Antigravity, Claude Code, Cursor, Codex, and other AI assistants.
  • 4 Binding Rule Files: architecture.md, api-design.md, database.md, testing.md + 10 non-negotiable rules.
  • 6 Workflow Commands: context, next, review, ship-feature, state, session-end.
  • 10 Domain Skills & 12 Scripts: cli-commands, configuration, database-migrations, error-handling, goforge-core, http-grpc, limen-auth, testing, tls, validation.

→ AI Agent Workspace, Rules & Skills


12. Testing & Production Deployment ​

  • Test Patterns (internal/tests/): Isolated t.TempDir() SQLite unit, HTTP middleware, gRPC client, and boot.NewWithConfig integration tests.
  • Dev & Prod Tooling: air.toml live reload, -tags prod builds (excluding loader), and multi-stage golang:1.25-alpine → alpine:3.21 non-root Docker builds with HEALTHCHECK.

→ Testing · Building the Binary · Docker & Compose

Released under the Apache-2.0 License.