Introduction
GoForge is a production-ready Go application framework and scaffolding CLI designed to take you from goforge new to a hardened, modular backend in minutes — without hiding standard Go behind magic code generation.
GoForge consists of two main parts:
goforge-cli— A 24-command interactive Bubble Tea CLI for project scaffolding, vertical-slice service generation, event wiring, protocol buffers, Atlas migrations, SQLC codegen, and database seeders.goforge-template— A batteries-included Go 1.25+ application skeleton with a pure-Go reflection DI container, hardened HTTP & gRPC servers, Huma v2 OpenAPI 3.1 docs, multi-driver GORM database support, generic event bus, and an interactive terminal dashboard.
Complete Feature Matrix
| Subsystem | What GoForge Provides | Reference |
|---|---|---|
| Dependency Injection | Pure-Go reflection container (core/di), Module composition, Bind[I] / BindBoth[I] interface bindings, AutoCollect[I], CollectModels, 3-color DFS cycle detection, OnStart/OnStop LIFO lifecycle hooks | Dependency Injection |
| HTTP Server & OpenAPI | Gin engine, 6-layer middleware pipeline, /health & /ready probes, TrustedProxies, server timeouts, TLS 1.2+, and Huma v2 OpenAPI 3.1 docs | HTTP Server & OpenAPI |
| Security & Auth | Constant-time X-App-Key auth, APP_DEBUG docs gating, strict CORS_ALLOWED_ORIGINS, bounded LimiterStore (10k cap / 3m TTL), RequestID propagation, safe DSNs, -tags prod non-root Docker, plus Limen user sessions | Security & Authentication |
| gRPC Server | GRPCRegistry auto-collection, gRPC TLS, grpc_health_v1, server reflection, full Unary & Stream interceptor chain (Recovery, Logger, AppKey, per-IP port-stripped RateLimit) | gRPC Server |
| Database & Seeders | sqlite (WAL + FKs), postgres, mysql, sqlserver drivers, connection pooling, Atlas & GORM migrations, SQLC v2 queries, transactional Seeder registry | Database, Migrations & Seeders |
| Event Bus | Generic EventBus (On[T], Off[T], async Dispatch[T], blocking DispatchSync[T]), panic recovery, instance-identity dedup, graceful Shutdown draining | Event Bus |
| Errors & Validation | Canonical AppError JSON responses (400–503) with ErrorHandler correlation; dedicated validator/v10 (validate: tags) with JSON field names and custom rules | Error Handling, Validation |
| Typed Clients | Non-mutating HttpClient (X-App-Key header cloning) and GrpcClient (grpc.NewClient + TLS override + WithAppKey / WithStreamAppKey) | HTTP & gRPC Clients |
| Logging & TUI | Zerolog (terminal/file/both, log/json, LOG_COLOR), colorized prettyWriter, Gin route redirect, and a live Bubble Tea split-panel TUI dashboard | Logging & TUI Dashboard |
| Testing & DevOps | Isolated t.TempDir() SQLite unit/HTTP/gRPC/integration test patterns, Air live reload, two-stage golang:1.25-alpine -tags prod Dockerfile, and .agent/ AI workspace | Testing, AI Agent & Skills, Plugins |
Directory Ownership Model
GoForge separates framework runtime packages from your application code so upgrades and CLI scaffolding stay predictable:
text
my-app/
├── app/
│ └── main.go # Entry point — calls console.Execute()
├── boot/ # Framework-owned: kernel, servers, middleware, clients
│ ├── kernel.go # boot.New / boot.NewWithConfig & errgroup lifecycle
│ ├── client/ # HttpClient & GrpcClient
│ └── server/ # HTTPServer, GRPCServer, Huma docs, middleware/*
├── core/ # Framework-owned: config, console, database, di, errors, events, validator
│ ├── config/ # Viper env loader & Validate / ValidateForServe
│ ├── console/ # Cobra commands, pretty logger, Bubble Tea TUI dashboard
│ ├── database/ # GORM connect, safe DSNs, drivers, seeder registry, atlas.hcl, sqlc.yaml
│ ├── di/ # Reflection DI container & Lifecycle
│ ├── errors/ # AppError & HTTP Respond helpers
│ ├── events/ # Generic EventBus
│ └── validator/ # Dedicated validator/v10 setup & custom rules
└── internal/ # User-owned application code
├── database/
│ ├── migrations/ # Atlas SQL migrations + atlas.sum
│ ├── queries/ # SQLC .sql query files
│ ├── gen/ # SQLC generated Go code (gitignored)
│ └── seeders/ # DatabaseSeeder & custom seeders
├── proto/ # .proto definitions & generated pb.go
├── services/
│ ├── kernel.go # Composition root: Modules() & Model()
│ └── <service>/ # 9-file vertical slice (module, model, service, handler, routes, ...)
└── tests/ # unit/, http/, grpc/, integration/| Directory | Ownership | Rule of Thumb |
|---|---|---|
app/ | Entrypoint | Minimal — delegates directly to console.Execute(). |
boot/ | Framework-owned | Do not edit unless customizing server/middleware behavior globally. |
core/ | Framework-owned | Import freely (core/di, core/errors, core/events, core/validator, core/database); extend via core/config/ or core/console/. |
internal/ | Your code | Build your services, models, migrations, queries, seeders, protos, and tests here. |
