gombit

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 0 Imported by: 0

README

Gombit

CI Release Go Reference

A Django-for-Go full-stack framework. One CLI scaffolds a typed Go API, its OpenAPI document, a matching TypeScript client, a React frontend, versioned SQL migrations, session auth, and a working admin — then builds the whole thing into a single binary.

go install github.com/gombit-dev/gombit/cmd/gombit@latest
gombit new tasks --database sqlite --auth cookie --ui mui
cd tasks && gombit dev

Status: pre-1.0. M0–M5 and ADMIN-1..3 are complete and CI-gated across SQLite, PostgreSQL, and MySQL. APIs may still change between minor versions.

Why Gombit

Go has excellent HTTP routers. What it doesn't have is the thing Django users miss on day one: the batteries, wired together and agreeing with each other.

Gombit's position is that the pieces you'd otherwise assemble by hand — schema, API contract, typed client, auth, admin — should be derived from one source of truth instead of hand-synchronized:

  • Your handler signature is the contract. OpenAPI 3.1 is emitted from Huma-typed handlers, never hand-written, and the TypeScript client is generated from that. A drift check fails CI when they disagree.
  • Your GORM model is the schema. Migrations are versioned SQL diffed by Atlas from your models — readable, reviewable, and reversible. No AutoMigrate in production, no hand-rolled migration DSL.
  • Your registry is the admin. A real Django-style admin at /admin/, served by the framework at runtime, not generated pages you inherit and maintain.

And the escape hatches are real: app.Router() hands you the raw *gin.Engine, tested and first-class.

What's in the box

Runtime Gin + Huma with typed handlers, framework.App lifecycle hooks, graceful shutdown, structured logging, typed env config with secret redaction
Data GORM over SQLite, PostgreSQL, and MySQL — all three CI-gated on every push, with a shared conformance suite
Migrations Atlas-backed gombit db makemigrations / migrate / rollback / status / seed / reset
Contract OpenAPI 3.1 emitted from code, interactive /docs, generated TypeScript client, contract drift check
Frontend Vite + React + TypeScript, React Hook Form, optional Material UI CRUD preset (--ui mui)
Auth Bearer JWT with refresh rotation (token in memory, never localStorage), or first-class cookie sessions with CSRF (--auth cookie)
Admin Runtime generic admin at /admin/ with introspection API, permissions, groups, and superuser bypass
CLI Cobra tree: new, dev, build --embed, make resource, make command, db, openapi, client, routes, doctor, config, createsuperuser, version
Deploy gombit build --embed — API, SPA, and admin in one binary

Quick start

Prerequisites: Go 1.25+, Node 22+, and a C toolchain (SQLite is cgo-only). Migrations also need Atlas: curl -sSf https://atlasgo.sh | sh -s -- --community. Full details in installation.md.

# 1. Install
go install github.com/gombit-dev/gombit/cmd/gombit@latest

# 2. Scaffold
gombit new tasks --database sqlite --auth cookie --ui mui
cd tasks

# 3. Run the API and frontend together
gombit dev

gombit dev serves the Go API and Vite together, proxies /api and /openapi.json, and regenerates the TypeScript client whenever the spec changes:

URL
http://127.0.0.1:5173 React app
http://127.0.0.1:8080/docs interactive API docs
http://127.0.0.1:8080/admin/ admin SPA
The CRUD loop
# Generate a feature package: model + Huma handler + routes + React pages.
gombit make resource Task title:string:required done:bool

# Diff your models into versioned SQL, then apply it.
gombit db makemigrations create_tasks --model github.com/example/tasks/internal/task.Task
gombit db migrate

# Regenerate the typed client from the live spec.
gombit client generate

# Create an admin account and open /admin/.
export GOMBIT_JWT_SECRET="$(openssl rand -hex 32)"
gombit createsuperuser --email admin@example.com

make resource edits cmd/server/main.go through go/ast — never regex — to register your routes and models. Generators are idempotent and additive, support --dry-run and --force, and never overwrite files you own.

Then ship it:

gombit build --embed   # one binary: API + SPA + admin

Next: the tutorial walks this whole loop with explanations, and examples/tutorial/ is the finished app.

Architecture

flowchart LR
  Model[GORM models] --> Atlas[Atlas diff]
  Atlas --> SQL[(versioned SQL)]
  Model --> Handler[Huma-typed handlers]
  Handler --> Gin[Gin router]
  Handler --> Spec[OpenAPI 3.1]
  Spec --> TS[TypeScript client]
  TS --> React[React + Vite]
  Model --> Registry[admin registry]
  Registry --> AdminUI["/admin/ SPA"]
  Gin --> Binary[single binary]
  React --> Binary
  AdminUI --> Binary

Both arrows out of your model are the point: one declaration drives the schema and the API, and one API drives the client.

The response envelope is fixed so clients can rely on it — success is {"data": ..., "meta"?: ...}, and errors carry a machine-readable code plus per-field detail:

{
  "error": {
    "code": "validation_error",
    "message": "The request contains invalid fields.",
    "fields": {"title": ["expected length >= 1"]},
    "request_id": "5db935cd-7c74-4ffe-a4de-0fa817451f54"
  }
}

The admin

No other Go web framework ships a real Django-style admin — not Gin, Echo, Fiber, or Encore. Gombit's is a runtime surface over an explicit registry:

admin.Register(app, Task{}, admin.Options{
	Slug:   "tasks",
	List:   []string{"title", "done"},
	Search: []string{"title"},
})

That gives you list, detail, create, update, and delete at /admin/, backed by GET /api/v1/admin/meta and a generic /api/v1/admin/resources/{slug} data plane. Permissions default to admin.{slug}.{action}, are granted directly or through groups, and superusers bypass them.

Registration is explicit and typed — resolved once at startup, with no request-time reflection over your models, and no generated admin pages for you to maintain. Requires cookie auth. See admin.md and ADR-013.

Compared with

Gombit Gin / Echo / Fiber Buffalo Encore
HTTP routing ✅ (Gin)
Typed OpenAPI from code ➖ add-on
Generated TS client + drift check
Versioned SQL migrations ✅ (Atlas) ✅ (fizz)
Scaffolding generators ✅ AST-safe
Session auth + CSRF
Django-style admin
Self-hosted, no vendor runtime

Gombit is younger than all of them. If you want a minimal router, use Gin directly — Gombit is Gin underneath, and hands it back to you on request.

Documentation

Start with installation and the tutorial. The full index — runtime, data, contract, frontend, auth, admin, and ADRs — is at docs/README.md.

Scope, locked architecture decisions, and the issue backlog live in docs/GOMBIT_BUILD_PLAN.md, which is authoritative.

Roadmap

Shipped: typed config and lifecycle (M1) · Atlas migrations (M2) · Huma contract, OpenAPI, and TS client (M3) · Cobra CLI and generators (M4) · React frontend, Bearer and cookie auth, MUI preset, embedded builds (M5) · the runtime admin with permissions (ADMIN-1..3).

Post-v0.1, deliberately not here yet: background jobs and queues, events, scheduler, mail, storage, gRPC, multi-tenancy, i18n.

Contributing

Issues and pull requests are welcome — start with CONTRIBUTING.md.

License

MIT © Gombit

Documentation

Overview

Package gombit is the root package for the Gombit framework.

Index

Constants

View Source
const ModulePath = "github.com/gombit-dev/gombit"

ModulePath is the canonical Go module path for Gombit.

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Package admin is Gombit's runtime generic admin (ADMIN-1 through ADMIN-3 / ADR-013).
Package admin is Gombit's runtime generic admin (ADMIN-1 through ADMIN-3 / ADR-013).
Package auth is Gombit's runtime Bearer JWT surface (C3 / M5-2).
Package auth is Gombit's runtime Bearer JWT surface (C3 / M5-2).
benchmarks
micro/gin
Package gin is the idiomatic plain-Gin row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): Gin routing and binding-tag validation, no Huma, no Gombit framework.
Package gin is the idiomatic plain-Gin row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): Gin routing and binding-tag validation, no Huma, no Gombit framework.
micro/gombit
Package gombit is the Gombit-runtime row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): the same four scenarios as benchmarks/micro/huma, but registered through a real framework.App instead of bare Huma+Gin (scenario.RegisterEnvelopedRoutes instead of scenario.RegisterRoutes — Gombit wraps responses in the D10 envelope, which bare Huma+Gin does not do by default), so the delta between the two rows isolates the cost of the Gombit runtime itself — request-id, security headers, XSS sanitization, D10 error mapping and envelope — on top of Huma.
Package gombit is the Gombit-runtime row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): the same four scenarios as benchmarks/micro/huma, but registered through a real framework.App instead of bare Huma+Gin (scenario.RegisterEnvelopedRoutes instead of scenario.RegisterRoutes — Gombit wraps responses in the D10 envelope, which bare Huma+Gin does not do by default), so the delta between the two rows isolates the cost of the Gombit runtime itself — request-id, security headers, XSS sanitization, D10 error mapping and envelope — on top of Huma.
micro/huma
Package huma is the bare Huma-over-Gin row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): Huma's typed handlers, validation, and OpenAPI emission on top of Gin, without the Gombit runtime around it and without the D10 response envelope (that's a Gombit convention, not a Huma default).
Package huma is the bare Huma-over-Gin row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): Huma's typed handlers, validation, and OpenAPI emission on top of Gin, without the Gombit runtime around it and without the D10 response envelope (that's a Gombit convention, not a Huma default).
micro/nethttp
Package nethttp is the plain net/http row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): no router, no framework, hand-written JSON encode/decode and manual validation.
Package nethttp is the plain net/http row of the BENCH-1 framework-tax microbenchmark matrix (issue #141): no router, no framework, hand-written JSON encode/decode and manual validation.
micro/scenario
Package scenario defines the five request/response scenarios shared by every row of the BENCH-1 framework-tax microbenchmark matrix (issue #141 "1.
Package scenario defines the five request/response scenarios shared by every row of the BENCH-1 framework-tax microbenchmark matrix (issue #141 "1.
Package build implements `gombit build --embed`: Vite production build, collectstatic into internal/web/static, and `go build` of a single binary that serves API + static + SPA fallback.
Package build implements `gombit build --embed`: Vite production build, collectstatic into internal/web/static, and `go build` of a single binary that serves API + static + SPA fallback.
Package cache provides Gombit's backend-neutral cache boundary.
Package cache provides Gombit's backend-neutral cache boundary.
Package cli is the Cobra command tree for `gombit` (D13 / ADR-014).
Package cli is the Cobra command tree for `gombit` (D13 / ADR-014).
Package client generates a TypeScript API client from an OpenAPI 3.1 document.
Package client generates a TypeScript API client from an OpenAPI 3.1 document.
cmd
gombit command
Package commandgen implements `gombit make command`.
Package commandgen implements `gombit make command`.
Package config provides Gombit's typed configuration boundary.
Package config provides Gombit's typed configuration boundary.
Package contract defines Gombit's Huma DTO conventions, the D10 success and error envelopes, and draft §41 application error category mapping.
Package contract defines Gombit's Huma DTO conventions, the D10 success and error envelopes, and draft §41 application error category mapping.
Package database opens supported GORM SQL drivers and exposes driver metadata.
Package database opens supported GORM SQL drivers and exposes driver metadata.
conformance
Package conformance hosts the multi-DB conformance suite.
Package conformance hosts the multi-DB conformance suite.
conformance/models
Package models holds GORM fixtures for the multi-DB conformance suite.
Package models holds GORM fixtures for the multi-DB conformance suite.
Package dev implements `gombit dev`: one command that runs the Go API (with reload when air or watchexec is available), the Vite frontend with HMR, and live OpenAPI → TypeScript client regeneration.
Package dev implements `gombit dev`: one command that runs the Go API (with reload when air or watchexec is available), the Vite frontend with HMR, and live OpenAPI → TypeScript client regeneration.
examples
admin command
auth command
auth-cookie command
cache command
config command
contract command
database command
embed command
lifecycle command
logging command
migrations command
router command
tutorial command
Command tutorial is the finished application from docs/tutorial.md: one Task resource served through Huma, with cookie auth and the runtime admin.
Command tutorial is the finished application from docs/tutorial.md: one Task resource served through Huma, with cookie auth and the runtime admin.
Package framework provides Gombit's runtime application lifecycle and HTTP surfaces (Gin router escape hatch and Huma contract API).
Package framework provides Gombit's runtime application lifecycle and HTTP surfaces (Gin router escape hatch and Huma contract API).
Package goldentest is the M4-5 generator golden suite.
Package goldentest is the M4-5 generator golden suite.
internal
Package logging builds Gombit's Zap logger and supports external sinks.
Package logging builds Gombit's Zap logger and supports external sinks.
Package migrations wraps Atlas versioned migrations for Gombit apps.
Package migrations wraps Atlas versioned migrations for Gombit apps.
Package resourcegen implements `gombit make resource`.
Package resourcegen implements `gombit make resource`.
Package scaffold generates a new Gombit application (gombit new).
Package scaffold generates a new Gombit application (gombit new).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL