Skip to content

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:

  1. 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.
  2. 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 ​

SubsystemWhat GoForge ProvidesReference
Dependency InjectionPure-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 hooksDependency Injection
HTTP Server & OpenAPIGin engine, 6-layer middleware pipeline, /health & /ready probes, TrustedProxies, server timeouts, TLS 1.2+, and Huma v2 OpenAPI 3.1 docsHTTP Server & OpenAPI
Security & AuthConstant-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 sessionsSecurity & Authentication
gRPC ServerGRPCRegistry 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 & Seederssqlite (WAL + FKs), postgres, mysql, sqlserver drivers, connection pooling, Atlas & GORM migrations, SQLC v2 queries, transactional Seeder registryDatabase, Migrations & Seeders
Event BusGeneric EventBus (On[T], Off[T], async Dispatch[T], blocking DispatchSync[T]), panic recovery, instance-identity dedup, graceful Shutdown drainingEvent Bus
Errors & ValidationCanonical AppError JSON responses (400–503) with ErrorHandler correlation; dedicated validator/v10 (validate: tags) with JSON field names and custom rulesError Handling, Validation
Typed ClientsNon-mutating HttpClient (X-App-Key header cloning) and GrpcClient (grpc.NewClient + TLS override + WithAppKey / WithStreamAppKey)HTTP & gRPC Clients
Logging & TUIZerolog (terminal/file/both, log/json, LOG_COLOR), colorized prettyWriter, Gin route redirect, and a live Bubble Tea split-panel TUI dashboardLogging & TUI Dashboard
Testing & DevOpsIsolated t.TempDir() SQLite unit/HTTP/gRPC/integration test patterns, Air live reload, two-stage golang:1.25-alpine -tags prod Dockerfile, and .agent/ AI workspaceTesting, 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/
DirectoryOwnershipRule of Thumb
app/EntrypointMinimal — delegates directly to console.Execute().
boot/Framework-ownedDo not edit unless customizing server/middleware behavior globally.
core/Framework-ownedImport freely (core/di, core/errors, core/events, core/validator, core/database); extend via core/config/ or core/console/.
internal/Your codeBuild your services, models, migrations, queries, seeders, protos, and tests here.

Next Steps ​

Released under the Apache-2.0 License.