A clone-ready Go 1.23 module starter that imports github.com/plinth-dev/sdk-go/* packages. Authentication enforcement, fail-closed authorization, audit emission, OTel tracing, structured logging, healthcheck, and a strict three-layer architecture — all pre-wired.
Status: v0.1.0 — Phase C in progress. Cloneable, but the SDK packages it depends on are still in design.
git clone https://github.com/plinth-dev/starter-api my-module-api
cd my-module-api
go mod download
go run ./cmd/serverFor everything-running-locally:
docker compose up --build # Postgres, Cerbos, NATS, SigNoz, the module- Go 1.23 with
chirouter andlog/slogstructured logging. - Three-layer architecture:
internal/handlers/→internal/service/→internal/repository/. Boundaries enforced via Go'sinternal/visibility rules and a CI lint. - Database:
pgx(v5) +sqlcfor type-safe queries;golang-migratefor reversible migrations. - Authorization:
authz.NewClient(...).CheckAction(...)— fail-closed by default, dev-bypass requires explicit env + non-prod environment. - Audit:
audit.Publish(...)to NATS JetStream; never blocks the request path. - OTel: traces and metrics via OTLP/HTTP to the cluster collector.
- Validation:
go-playground/validatoron request bodies. - Config:
koanf(env, file, defaults — composable, no scope creep). - Tests:
testcontainers-goagainst real Postgres / NATS / Redis. No mocks of the database. - OpenAPI: generated from struct tags via
swaggo.
.
├── cmd/
│ └── server/ # main.go — wire dependencies, start chi
├── internal/
│ ├── handlers/ # HTTP handlers; thin
│ ├── service/ # Business logic; testable
│ ├── repository/ # sqlc-generated queries + custom pgx
│ ├── apperrors/ # Sentinel errors used across layers
│ └── ...
├── api/ # OpenAPI spec output
├── db/
│ ├── migrations/ # golang-migrate SQL files
│ └── queries/ # sqlc input
├── cerbos/ # Resource policies (one kind per module by default)
└── docker-compose.yml # Local dev stack
After cloning, search the repo for // TODO: Customize for your module and walk each one. Then update:
go.mod— module path:github.com/<org>/<module>-api.internal/config/config.go— env var prefix.cerbos/*.yaml— replaceItemwith your resource kind.
starter-web— the matching Next.js frontend.sdk-go— the SDK packages this starter imports.cli—plinth newautomates the rename + register flow.
MIT — see LICENSE.