Help us shape the future of Go! Take the 2026 Go Developer Survey

labena

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT

README

Labena

A batteries-included Go framework for modular applications.

Build HTTP APIs, background workers and business workflows with authentication, persistence, queues, mail, notifications, storage and observability already connected. Labena combines established Go libraries with explicit constructors, module-owned registration and a shared application lifecycle.

Documentation · Create an application · First module · Deployment · Contributing

Labena is delivered as an application template. Create a project, choose its Go module and application name, and own the resulting source. You can change its modules, dependencies and deployment model as your application grows. Upstream updates are reviewed and applied to your copy; the support policy defines compatibility and maintenance for the current 0.x release series.

What's included

Capability Included behavior
HTTP APIs Typed Huma operations on Go's HTTP mux, request validation, consistent responses, middleware and live OpenAPI documentation
Authentication Email OTP, Google sign-in, access and refresh tokens, persisted sessions, revocation and rate limits
Persistence PostgreSQL with Bun, explicit transaction boundaries, Goose migrations and seeders
Background work Redis-backed Asynq jobs, retries, queue administration and a dedicated scheduler
Events Watermill subscriptions for process-local, best-effort reactions
Mail SMTP delivery, shared HTML/plain-text views, application branding and optional queued sending
Notifications Database, email and Expo push channels, with durable notification intent and delivery tracking
Storage and media Named storage disks, local and cloud adapters, public/private assets, signed access and deletion recovery
Cache Memory, Redis and database stores with explicit configuration
Logging Structured standard-output and file logs, plus an optional Basic Auth log viewer independent of OpenTelemetry
Observability Request correlation, OpenTelemetry traces/log export, metrics and local Grafana tooling
Operations CLI commands, health/readiness endpoints, graceful shutdown, Docker, Compose and Tilt development workflows

Application modules require PostgreSQL; background jobs use Redis. Optional capabilities are enabled through configuration. See the verified support matrix for backend and provider coverage. Phone/SMS authentication is reserved for future work and is not part of the current sign-in flow.

Create an application

You need the Go version declared in go.mod and access to the template repository. Git is required for local-checkout generation; Docker is used by the local development walkthrough.

Install from a release

Install the released CLI:

go install github.com/wisalgroup/labena/cmd/labena@latest

Use @v0.3.0 instead of @latest for reproducible team setup. Add Go's binary directory to your current shell if labena is not found:

go_bin="$(go env GOBIN)"
export PATH="${go_bin:-$(go env GOPATH)/bin}:$PATH"
labena --version

Add the resolved directory to your shell configuration to keep it on PATH in future terminals. The public Labena repository needs no GitHub authentication. See the installation details.

From the directory that should contain your new application:

labena new myapp \
  --module github.com/your-org/myapp \
  --name MyApp

Replace github.com/your-org/myapp with your application's Go module path.

The installer rewrites the Go module and imports, sets application branding, creates a local quickstart .env, records template provenance in .labena.json, regenerates documentation and verifies the build. It refuses to overwrite an existing directory. It does not create a GitHub repository or copy the template's Git history.

Use the current checkout

To try local changes, run this from the Labena checkout:

go install ./cmd/labena

Then create the app from your preferred parent directory, replacing the source path below with the absolute path of that checkout:

labena new myapp \
  --module github.com/your-org/myapp \
  --name MyApp \
  --source /absolute/path/to/labena

--source identifies the Labena template, while myapp is the new destination. --source . only works when your current directory is the Labena checkout. See creating applications for version selection, private repository access and skipping verification with --skip-checks.

Run locally

Open the generated application:

cd myapp

You can also run the following steps from the Labena checkout to evaluate it.

Start the disposable PostgreSQL and Redis services described in installation. The tutorial uses host ports 55432 and 56379. Then select the matching profile, apply migrations and start the app:

export APP_ENV_FILE=.env.quickstart.example
go run ./cmd/cli migrate up
go run ./cmd/app

In another terminal:

curl -i http://127.0.0.1:8080/healthz
curl -i http://127.0.0.1:8080/readyz

Open the running API documentation or its OpenAPI schema. Both are generated from the registered HTTP operations.

The quickstart disables authentication and optional integrations so you can run without provider credentials. Protected endpoints become available after configuring Identity. Mail connects only when sending; application startup never runs migrations. The full .env.example enables more capabilities and requires their credentials.

To explore a module without starting PostgreSQL or Redis:

go test ./tests/modules -run TestFirstModule -count=1

Make it yours

Set APP_NAME to control the API title, mail defaults, log viewer and telemetry service identity. Mail sender and brand names can be overridden independently. The installer sets these defaults when creating your application.

Database names, token issuers/audiences, Redis namespaces, queues and deployment resources remain explicit operational settings. A display-name change does not rename persisted identifiers. Use the configuration guide and complete reference when enabling capabilities.

Application design

cmd/
  app/                 HTTP, workers and local event consumers
  worker/              Dedicated background execution
  scheduler/           Recurring enqueue operations
  cli/                 Application commands
  labena/              Project installer; omitted from generated applications
internal/
  app/                 Composition, process selection and resource lifecycle
    config/            Environment settings and owner configuration
  modules/
    identity/          Account and authentication operations
    shared/            Shared business entities, enums and event contracts
  platform/            Shared application capabilities and transport integration
pkg/                   Reusable technical packages
examples/              Compiled usage examples and starter modules
tests/                 Application, business and integration suites
docs/                  Guides and the static documentation site
deployments/           Container and development environment configuration

Modules construct their local collaborators and expose a package-level Register function. App owns connections, creates authentication before protected targets, registers modules and manages shutdown. Services receive their actual collaborators; module registration borrows dependencies.Resources and dependencies.Targets. Recurring schedules live in one application schedule definition.

Business modules own their writes and published event meanings. Platform packages remain independent of business modules, and pkg stays independent of internal. Read your first module, module registration and the project conventions before extending the framework.

Choose how processes run

Command Responsibility
go run ./cmd/app HTTP, queue workers, notification dispatch and local event consumers
go run ./cmd/worker Queue workers, notification dispatch and local event consumers
go run ./cmd/scheduler Recurring enqueue operations; run one instance per schedule set
go run ./cmd/cli <command> Migration, inspection or maintenance, then cleanup

Entrypoints select processes explicitly in Go. Local events stay inside their publishing process; Redis jobs can be processed by another worker process. Notification intent can commit with a business SQL transaction. Redis enqueue and external delivery have separate failure boundaries. The events, queues and transactional notifications guides explain these guarantees.

For deployment, follow deployment and recovery, application lifecycle and release readiness. Supplied development manifests and sample credentials are for local use; configure ingress, secrets, dependency readiness, backups and retention for your environment.

Documentation

Start with the introduction, then follow a complete workflow:

Build and browse the searchable documentation locally:

go run docs/build.go
go run docs/serve.go

Open the local documentation. The site includes keyboard search, topic navigation, light/dark themes, diagrams and Markdown downloads. It can be hosted as static files; see publishing with GitHub Pages. The live application API at /docs is served by the Go application separately.

Testing and maintenance

go test -race ./...
go vet ./...
go build ./cmd/... ./examples/...

CI also verifies documentation, generated applications, the container image and vulnerabilities. Its integration job runs against disposable PostgreSQL and Redis. Use the testing guide and integration script for backend setup; tests that skip an unavailable backend have not verified it.

Keep .labena.json, the original license and a record of the upstream changes you incorporate. Follow adoption and updates for porting fixes into your customized application. Updating Go dependencies alone does not update copied framework source.

Contributing and security

Contributions should follow CONTRIBUTING.md and the architecture contract. Report reproducible, non-sensitive bugs through GitHub issues. Use the private reporting route in SECURITY.md for vulnerabilities. Maintenance scope and compatibility commitments are documented in SUPPORT.md. See release notes for the current release and adoption changes.

License

Labena is available under the MIT license.

Directories

Path Synopsis
cmd
app command
cli command
The console command runs application and module commands through Cobra.
The console command runs application and module commands through Cobra.
labena command
Labena creates independent applications from a versioned template.
Labena creates independent applications from a versioned template.
labena/internal/scaffold
Package scaffold creates application source without starting application services.
Package scaffold creates application source without starting application services.
scheduler command
worker command
examples
cache command
Run with CACHE_DRIVER=memory go run ./examples/cache.
Run with CACHE_DRIVER=memory go run ./examples/cache.
cli command
A complete console application and module command in one file.
A complete console application and module command in one file.
httpclient command
Run with go run ./examples/httpclient.
Run with go run ./examples/httpclient.
httpclient/catalog
Package catalog demonstrates a small REST integration built on httpclient.
Package catalog demonstrates a small REST integration built on httpclient.
mail command
Render Identity OTP and welcome mail views locally.
Render Identity OTP and welcome mail views locally.
mail/delivery
Package delivery demonstrates queued mail using borrowed application clients.
Package delivery demonstrates queued mail using borrowed application clients.
module/profile
Package profile demonstrates a business change with transactional notification intent.
Package profile demonstrates a business change with transactional notification intent.
push command
Run with PUSH_EXPO_ACCESS_TOKEN (if enabled in Expo) and PUSH_REGISTRATION.
Run with PUSH_EXPO_ACCESS_TOKEN (if enabled in Expo) and PUSH_REGISTRATION.
social-login command
This local-only example tests an installed-app Google OAuth client with the API.
This local-only example tests an installed-app Google OAuth client with the API.
storage command
Run from the repository root: APP_ENV_FILE= go run ./examples/storage
Run from the repository root: APP_ENV_FILE= go run ./examples/storage
internal
app
Package app assembles business modules and platform capabilities and owns their execution lifetime.
Package app assembles business modules and platform capabilities and owns their execution lifetime.
app/config
Package config loads and validates this application's typed settings.
Package config loads and validates this application's typed settings.
modules/identity
Package identity constructs account operations and registers their transports.
Package identity constructs account operations and registers their transports.
modules/identity/delivery/events
Package events reacts to Identity events using borrowed delivery clients.
Package events reacts to Identity events using borrowed delivery clients.
modules/identity/delivery/http
Package http exposes authentication and self-service account, media and notification endpoints.
Package http exposes authentication and self-service account, media and notification endpoints.
modules/identity/delivery/jobs
Package jobs handles Identity's native Asynq tasks.
Package jobs handles Identity's native Asynq tasks.
modules/identity/domain
Package domain defines Identity policies and business failures without transport dependencies.
Package domain defines Identity policies and business failures without transport dependencies.
modules/identity/integrations
Package integrations verifies external identity credentials without owning accounts.
Package integrations verifies external identity credentials without owning accounts.
modules/identity/jobs
Package jobs defines Identity's native Asynq tasks and their serializable inputs.
Package jobs defines Identity's native Asynq tasks and their serializable inputs.
modules/identity/mailviews
Package mailviews defines Identity email content for the default branded layout.
Package mailviews defines Identity email content for the default branded layout.
modules/identity/migrations
Package migrations embeds the SQL owned by identity.
Package migrations embeds the SQL owned by identity.
modules/identity/notifications
Package notifications defines Identity's named notifications and channel content.
Package notifications defines Identity's named notifications and channel content.
modules/identity/repository
Package repository owns Identity persistence using PostgreSQL and the application pool.
Package repository owns Identity persistence using PostgreSQL and the application pool.
modules/identity/service
Package service owns Identity account and authentication operations.
Package service owns Identity account and authentication operations.
modules/shared/enums
Package enums defines shared application enum types, grouped by business concept.
Package enums defines shared application enum types, grouped by business concept.
modules/shared/events
Package events defines published business events and their occurrence metadata.
Package events defines published business events and their occurrence metadata.
modules/shared/migrations
Package migrations embeds application-wide SQL migrations.
Package migrations embeds application-wide SQL migrations.
platform/adminhttp
Package adminhttp protects browser-based operational endpoints independently of business authentication and CORS settings.
Package adminhttp protects browser-based operational endpoints independently of business authentication and CORS settings.
platform/api
Package api assembles Huma on Go's HTTP server with shared request policies.
Package api assembles Huma on Go's HTTP server with shared request policies.
platform/api/response
Package response constructs typed Huma outputs and safe HTTP problem details.
Package response constructs typed Huma outputs and safe HTTP problem details.
platform/auth
Package auth defines authenticated identity without tokens or transport dependencies.
Package auth defines authenticated identity without tokens or transport dependencies.
platform/cli
Package cli assembles module commands into a Cobra command tree.
Package cli assembles module commands into a Cobra command tree.
platform/dependencies
Package dependencies defines the resources and registration targets shared by application assembly and business modules.
Package dependencies defines the resources and registration targets shared by application assembly and business modules.
platform/internal/reference
Package reference defines the shared syntax of platform model references.
Package reference defines the shared syntax of platform model references.
platform/lifecycle
Package lifecycle supervises process readiness, ordered drain and resource ownership.
Package lifecycle supervises process readiness, ordered drain and resource ownership.
platform/logviewer
Package logviewer serves a protected, bounded local view of application logs.
Package logviewer serves a protected, bounded local view of application logs.
platform/mail
Package mail sends email immediately or through an optional Asynq queue.
Package mail sends email immediately or through an optional Asynq queue.
platform/mail/integration
Package integration registers the mail capability with application transports.
Package integration registers the mail capability with application transports.
platform/media
Package media manages public and private polymorphic assets using database metadata and borrowed blob disks.
Package media manages public and private polymorphic assets using database metadata and borrowed blob disks.
platform/media/integration
Package integration connects media to the application's transports and migrations.
Package integration connects media to the application's transports and migrations.
platform/media/migrations
Package migrations embeds the SQL owned by media.
Package migrations embeds the SQL owned by media.
platform/notification
Package notification sends channel-specific messages and stores polymorphic database notifications.
Package notification sends channel-specific messages and stores polymorphic database notifications.
platform/notification/integration
Package integration connects notifications to the application's transports and migrations.
Package integration connects notifications to the application's transports and migrations.
platform/notification/migrations
Package migrations embeds the SQL owned by the notification package.
Package migrations embeds the SQL owned by the notification package.
platform/seeders
Package seeders registers named seed operations for explicit console execution.
Package seeders registers named seed operations for explicit console execution.
platform/testdb
Package testdb creates isolated databases for integration tests.
Package testdb creates isolated databases for integration tests.
pkg
apperror
Package apperror describes safe application failures without transport dependencies.
Package apperror describes safe application failures without transport dependencies.
asynqx
Package asynqx defines application integration contracts for Asynq.
Package asynqx defines application integration contracts for Asynq.
asynqx/middleware
Package middleware composes application policies around native Asynq enqueue calls.
Package middleware composes application policies around native Asynq enqueue calls.
cache
Package cache defines an optional cache with raw bytes and JSON convenience operations.
Package cache defines an optional cache with raw bytes and JSON convenience operations.
cache/database
Package database caches bytes in PostgreSQL or MySQL through a caller-owned Bun DB.
Package database caches bytes in PostgreSQL or MySQL through a caller-owned Bun DB.
cache/memory
Package memory provides a process-local byte cache with synchronous writes.
Package memory provides a process-local byte cache with synchronous writes.
cache/migrations
Package migrations provides SQL templates for opt-in application migrations.
Package migrations provides SQL templates for opt-in application migrations.
cache/redis
Package redis caches bytes using native Redis expiration.
Package redis caches bytes using native Redis expiration.
database
Package database configures SQL pools, Bun dialects, and transaction scopes.
Package database configures SQL pools, Bun dialects, and transaction scopes.
database/migrate
Package migrate combines registered SQL sources and runs Goose explicitly.
Package migrate combines registered SQL sources and runs Goose explicitly.
hasher
Package hasher provides bounded bcrypt hashing, independent of account policy.
Package hasher provides bounded bcrypt hashing, independent of account policy.
httpclient
Package httpclient sends declarative, tagged requests through net/http.
Package httpclient sends declarative, tagged requests through net/http.
httpserver
Package httpserver runs a standard HTTP handler with explicit startup and graceful shutdown.
Package httpserver runs a standard HTTP handler with explicit startup and graceful shutdown.
logging
Package logging provides execution-scoped structured logging.
Package logging provides execution-scoped structured logging.
mailview
Package mailview renders branded transactional emails independently of delivery.
Package mailview renders branded transactional emails independently of delivery.
mapper
Package mapper transforms values and collections with explicit mapping functions.
Package mapper transforms values and collections with explicit mapping functions.
metrics
Package metrics owns an isolated OpenTelemetry meter provider and Prometheus scrape handler.
Package metrics owns an isolated OpenTelemetry meter provider and Prometheus scrape handler.
otp
Package otp generates decimal codes and keyed proof digests.
Package otp generates decimal codes and keyed proof digests.
push
Package push sends provider messages without a database, queue or application bootstrap.
Package push sends provider messages without a database, queue or application bootstrap.
ratelimit
Package ratelimit provides transport-independent admission limits.
Package ratelimit provides transport-independent admission limits.
redis
Package redis constructs Redis clients.
Package redis constructs Redis clients.
storage
Package storage constructs Go CDK blob buckets.
Package storage constructs Go CDK blob buckets.
token
Package token issues and validates UUID-based session access tokens using golang-jwt.
Package token issues and validates UUID-based session access tokens using golang-jwt.
tracing
Package tracing constructs an explicitly owned OpenTelemetry provider.
Package tracing constructs an explicitly owned OpenTelemetry provider.

Jump to

Keyboard shortcuts

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