No description
  • Go 93.7%
  • templ 2.6%
  • JavaScript 1.7%
  • CSS 1.1%
  • KCL 0.9%
Find a file
2026-08-06 23:33:09 -04:00
app feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
authn feat(authn): add standard OIDC relying-party feature 2026-08-06 11:35:22 -04:00
config feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
coverage initial commit 2026-08-03 14:35:31 -04:00
cqrs initial commit 2026-08-03 14:35:31 -04:00
db feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
docs docs: record HATEOAS actions plan and Action glossary term (issue #11) 2026-08-06 23:33:09 -04:00
embeddedfga feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
embeddednats feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
embeddedoidc feat(embeddedoidc): add dev-login cookie jar helpers 2026-08-06 12:11:54 -04:00
events initial commit 2026-08-03 14:35:31 -04:00
example feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
kclmod feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
oapi feat(oapi): add OpenAPI spec loading + request-validation middleware and oapi-generate tool 2026-08-06 10:25:59 -04:00
projector initial commit 2026-08-03 14:35:31 -04:00
server initial commit 2026-08-03 14:35:31 -04:00
sessions/natskv initial commit 2026-08-03 14:35:31 -04:00
tools feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
AGENTS.md Update issue tracker skills 2026-08-06 21:39:43 -04:00
CONTEXT.md docs: record HATEOAS actions plan and Action glossary term (issue #11) 2026-08-06 23:33:09 -04:00
go.mod feat(authn): add standard OIDC relying-party feature 2026-08-06 11:35:22 -04:00
go.sum feat(authn): add standard OIDC relying-party feature 2026-08-06 11:35:22 -04:00
go.work feat(example): add canonical Kanban app exercising the toolbelt 2026-08-06 11:35:33 -04:00
go.work.sum docs: record HATEOAS actions plan and Action glossary term (issue #11) 2026-08-06 23:33:09 -04:00
kcl.mod feat(config): per-package KCL config fragments with service-owned defaults 2026-08-06 18:15:38 -04:00
README.md feat(authn): add standard OIDC relying-party feature 2026-08-06 11:35:22 -04:00

toolbelt

The shared platform for applications built at git.animeteamspeak.moe/ginjiruu. Consumed by ginjiruu/go-template and every project scaffolded from it. Extends delaneyj/toolbelt (kept as a dependency) with embedded OpenFGA, a durable-projector framework, the event envelope, an SCS NATS-KV session store, the field-driven config framework, and the composition root used to wire features.

Packages

Package Purpose
app Composition root. Owns the shared-infrastructure lifecycle and exposes it to features via Component + the Feature interface.
config Field-driven configuration framework (Viper-backed registry, Field structs, BuildLogger, validators).
oapi Runtime binding for spec-driven JSON APIs: OpenAPI spec loader + kin-openapi request-validation middleware for chi + structured error mapping.
db Embedded SQLite wrapper with fs.FS-backed migrations.
embeddednats Embedded NATS setup (free port, store dir, logging).
embeddedfga Embedded OpenFGA server, client, model bootstrapper, and tuple sources (YAML/file/mock).
embeddedoidc Embedded standards-compliant OIDC provider (zitadel-backed) plus Login, an automated auth-code login flow for dev servers and tests.
events Generic event envelope, DOMAIN stream config, publisher with optimistic concurrency.
projector Durable pull-consumer that applies DOMAIN-log events to one store (idempotent applies).
sessions/natskv SCS session store backed by a NATS JetStream KV bucket.
authn Standard OIDC relying-party authentication feature: installs Component.Authed, mounts /login /callback /logout, exposes RequireAuth, UserFromContext, and the UserProvision identity seam.
cqrs NATS KV projection writer used as the SSE read model.
server chi router scaffolding: standard middleware, SSE-aware timeout, access logger.
coverage FGA model test-coverage analysis (used by the fga-coverage tool).

Tools

Schema-codegen tools live in the nested tools/ module (own go.mod): fga-generate (emit Go type/relation constants from .fga models), fga-coverage, kcl-generate (emit the config Field registry and a typed Config struct from a KCL schema.k), and oapi-generate (emit types, a chi ServerInterface, and an embedded spec from an openapi.yaml via oapi-codegen). kcl-generate embeds the platform's universal schema (logging fields), so generated configs always include log.level / log.format.

The config/kcl package is the opt-in runtime binding: importing it registers a .k file loader and exposes kcl.ValidateConfig for enforcing schema check/rule blocks over the fully resolved config, plus kcl.SetField for config set on KCL files.

The oapi package is the runtime half of the spec-driven JSON API story: load an OpenAPI spec (oapi.Load from bytes, or oapi.LoadSpec from an oapi-codegen-generated GetSwagger() document), mount Validator.Middleware on the chi subrouter serving the API, and every request is validated against the spec. Rejected requests get a structured JSON error via oapi.WriteError (route/method/param/body failures mapped to 404/405/400/422/415). Pair it with the oapi-generate tool for the full OpenAPI → code + validation pipeline.

Using it

import "git.animeteamspeak.moe/ginjiruu/toolbelt/app"

a, err := app.New(ctx, logger, app.Config{...}, app.Options{
	ModelFS:      fgaModelFS,
	MigrationsFS: migrationsFS,
	Features:     []app.Feature{...},
})
defer a.Close()
return a.Run(ctx)

See ginjiruu/go-template for a full reference application.