hamr

module
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0

README

Disclaimer

This library and cli is still in development and can/will change. Meaning, if you use this now, features might be deprecated and you might need to pin version.

HAMR

HAMR Demo

HAMR Browser Overlay

HAMR

An opinionated Go full-stack framework and project scaffolding CLI. HAMR extracts proven patterns from production Go web applications into reusable packages and gives you a working project with one command.


hamr new

You get a production-ready Go + Templ + HTMX application (with optional Alpine.js) with sensible defaults, structured logging, database migrations, session auth, and AI-ready documentation baked in.

Documentation

What's in the box

HAMR is two things:

  1. Framework library (pkg/) -- reusable Go packages your project imports
  2. CLI tool (cmd/hamr/) -- scaffolds new projects that use the framework
Framework packages
Package What it does Guide
pkg/config Env-based configuration with typed accessors and .env file loading docs/guide/pkg/config.md
pkg/logging Context-aware structured logging via slog (JSON in prod, coloured in dev) docs/guide/pkg/logging.md
pkg/ptr Generic and concrete pointer helpers docs/guide/pkg/ptr.md
pkg/validate Pure-function validators with custom messages and a plugin registry docs/guide/pkg/validate.md
pkg/auth Argon2id password hashing, token generation, session management docs/guide/pkg/auth.md
pkg/db Database connection with retry, keep-alive, and migration runner docs/guide/pkg/db.md
pkg/htmx HTMX request detection and response header helpers docs/guide/pkg/htmx.md
pkg/respond HTTP response helpers (HTML via Templ, JSON, HTMX-aware redirects) docs/guide/pkg/respond.md
pkg/ctx Type-safe Echo context keys using generics docs/guide/pkg/ctx.md
pkg/middleware Auth, RBAC, error pages, flash, rate limiting, caching, audit, CSRF, CORS docs/guide/pkg/middleware.md
pkg/server Echo wrapper with functional options and lifecycle hooks docs/guide/pkg/server.md
pkg/janitor Background task scheduler docs/guide/pkg/janitor.md
pkg/storage File storage interface with local filesystem and S3/R2/RustFS backends docs/guide/pkg/storage.md
pkg/async Concurrent execution primitives with panic recovery docs/guide/pkg/async.md
pkg/websocket Session and room-based WebSocket hub with HTMX integration docs/guide/pkg/websocket.md
pkg/media Image and video upload, processing, and serving on top of storage docs/guide/pkg/media.md
pkg/sync S3 sync for static assets with file watching docs/guide/pkg/sync.md
pkg/e2e Reusable go-rod browser helpers for E2E testing docs/guide/pkg/e2e.md
pkg/templint Static linter for .templ files (control flow, a11y, style rules) docs/guide/pkg/templint.md
CLI commands
Command What it does
hamr new <name> Scaffold a new project with interactive options
hamr dev File watching, builds, process management, and live-reload proxy
hamr setup Interactive AI-agent setup: MCP bridge, tool permissions, skills
hamr compose [args] docker compose with hamr dev's port-walk override merged in
hamr ai capture <url> Capture a browser screenshot bundle, plus HTML/text/metadata
hamr ai upgrade Diff scaffold changes between project version and current HAMR
hamr gen static Fingerprint static assets into dist/ with compile-time manifest
hamr vendor Download and checksum frontend JS dependencies (htmx, alpine, etc)
hamr sync Sync a local directory to an S3-compatible bucket
hamr rename-module <path> Rename the Go module and update all import paths
hamr lint templ Lint .templ files for common issues
hamr version Print version and commit
hamr completion install Install shell completion scripts (bash, zsh, fish)

Install

CLI tool
go install github.com/FyrmForge/hamr/cmd/hamr@latest
Framework packages

Import the packages you need in your go.mod:

go get github.com/FyrmForge/hamr@latest

Then import individual packages:

import (
    "github.com/FyrmForge/hamr/pkg/config"
    "github.com/FyrmForge/hamr/pkg/logging"
    "github.com/FyrmForge/hamr/pkg/server"
)

Quick start

# Install the CLI
go install github.com/FyrmForge/hamr/cmd/hamr@latest

# Create a new project
hamr new myproject

# Follow the prompts to choose:
#   - GitHub username/org (auto-detected from gh CLI)
#   - CSS approach (plain CSS with design system or Tailwind)
#   - Database (PostgreSQL)
#   - File storage (none, local, or S3/RustFS)
#   - WebSocket support
#   - E2E testing scaffold

# Run it
cd myproject
hamr dev                    # starts Postgres, builds, watches, live-reloads

Generated project structure

myproject/
├── cmd/
│   ├── server/              # Application entry point + Dockerfile
│   └── migrate/             # Database migration runner
├── internal/
│   ├── db/migrations/       # SQL migrations (embed.FS)
│   ├── repo/                # Data access layer (postgres/)
│   ├── service/             # Business logic (auth service)
│   ├── api/                 # JSON API handlers
│   └── web/
│       ├── server.go        # Routes and middleware stack
│       ├── handler/         # One package per domain (home/, auth/, errors/)
│       └── components/      # Shared Templ components and layout
├── static/                  # CSS, JS (vendored HTMX + idiomorph; Alpine if opted in), images
├── docs/                    # ADRs, feature specs, AI guides
├── docker/                  # Docker Compose for PostgreSQL
├── .github/workflows/       # CI and deploy pipelines
├── hamr.toml                # Dev server configuration
├── Makefile
├── CLAUDE.md                # Claude Code instructions
├── AGENTS.md                # AI coding conventions
└── go.mod

Stack

Layer Technology
Language Go 1.25+
HTTP Echo v4
Templates Templ
Interactivity HTMX (+ optional Alpine.js)
Database PostgreSQL via pgx + sqlx
Migrations golang-migrate
Auth Argon2id + cookie sessions
CSS Plain CSS design system or Tailwind

Architecture highlights

Per-group error pages -- middleware catches errors and renders templ components, with per-status-code overrides.

Identity is a string -- all framework packages accept subject IDs as string. Projects using int64, uuid.UUID, or a field called account_id provide their own conversion at the boundary.

Callback-based extensibility -- auth middleware uses a SubjectLoader callback, RBAC uses a RoleChecker callback. The framework never knows your user struct.

Development

# Build the CLI
make build

# Run tests
make test

# Lint
make lint

# Vet
make vet

Requirements

  • Go 1.25 or later
  • PostgreSQL 15+ (for generated projects)
  • Docker (optional, for local Postgres via docker-compose)

License

Apache License 2.0. See LICENSE for details.

Directories

Path Synopsis
cmd
hamr command
internal
cli/generator
Package generator handles template execution and file writing for the HAMR CLI.
Package generator handles template execution and file writing for the HAMR CLI.
devserver
Package devserver — Stripe mock backend.
Package devserver — Stripe mock backend.
devserver/tui
Package tui implements the bubbletea-based dev runtime that backs `hamr dev`.
Package tui implements the bubbletea-based dev runtime that backs `hamr dev`.
Package llmsdocs embeds framework reference files for scaffolded projects.
Package llmsdocs embeds framework reference files for scaffolded projects.
pkg
auth
Package auth provides password hashing with Argon2id and cryptographically-secure token generation.
Package auth provides password hashing with Argon2id and cryptographically-secure token generation.
config
Package config provides typed accessors for environment variables with sensible defaults and panic-on-missing semantics.
Package config provides typed accessors for environment variables with sensible defaults and panic-on-missing semantics.
ctx
Package ctx provides type-safe context key helpers for Echo handlers.
Package ctx provides type-safe context key helpers for Echo handlers.
db
Package db provides PostgreSQL connection management with retry, keep-alive, and schema migration utilities.
Package db provides PostgreSQL connection management with retry, keep-alive, and schema migration utilities.
db/sqlite
Package sqlite provides SQLite connection management and schema migration utilities for hamr-scaffolded projects.
Package sqlite provides SQLite connection management and schema migration utilities for hamr-scaffolded projects.
e2e
Package e2e provides reusable go-rod browser helpers for E2E testing.
Package e2e provides reusable go-rod browser helpers for E2E testing.
email
Package email defines a provider-agnostic Sender interface for transactional email and the value types that flow through it.
Package email defines a provider-agnostic Sender interface for transactional email and the value types that flow through it.
emailmock
Package emailmock is a dev-only implementation of email.Sender that ships messages to the hamr dev server's mail inbox at /__hamr/mail.
Package emailmock is a dev-only implementation of email.Sender that ships messages to the hamr dev server's mail inbox at /__hamr/mail.
fingerprint
Package fingerprint provides content-based static asset fingerprinting.
Package fingerprint provides content-based static asset fingerprinting.
htmx
Package htmx provides request detection and response header helpers for htmx.
Package htmx provides request detection and response header helpers for htmx.
i18n
Package i18n provides internationalisation support: JSON translation files, CLDR plural rules, text/template interpolation, and a Bundle that holds per-locale Translators.
Package i18n provides internationalisation support: JSON translation files, CLDR plural rules, text/template interpolation, and a Bundle that holds per-locale Translators.
janitor
Package janitor provides a cron-based background task runner with per-task schedules, timeouts, and pre/post hooks.
Package janitor provides a cron-based background task runner with per-task schedules, timeouts, and pre/post hooks.
logging
Package logging provides context-aware structured logging wrapping log/slog.
Package logging provides context-aware structured logging wrapping log/slog.
media
Package media provides high-level image and video upload, processing, and serving on top of the storage package.
Package media provides high-level image and video upload, processing, and serving on top of the storage package.
middleware
Package middleware provides HTTP middleware for the HAMR framework.
Package middleware provides HTTP middleware for the HAMR framework.
ptr
Package ptr provides generic and concrete helpers for working with pointers.
Package ptr provides generic and concrete helpers for working with pointers.
respond
Package respond provides HTTP response helpers for HTMX-first applications.
Package respond provides HTTP response helpers for HTMX-first applications.
server
Package server wraps Echo v4 with functional options, production-safe defaults, and graceful shutdown.
Package server wraps Echo v4 with functional options, production-safe defaults, and graceful shutdown.
sms
Package sms defines a provider-agnostic Sender interface for transactional SMS and the value types that flow through it.
Package sms defines a provider-agnostic Sender interface for transactional SMS and the value types that flow through it.
smsmock
Package smsmock is a dev-only implementation of sms.Sender that ships messages to the hamr dev server's SMS inbox at /__hamr/sms.
Package smsmock is a dev-only implementation of sms.Sender that ships messages to the hamr dev server's SMS inbox at /__hamr/sms.
storage
Package storage provides a pluggable file storage abstraction with local filesystem and S3-compatible backends (AWS S3, RustFS, Cloudflare R2).
Package storage provides a pluggable file storage abstraction with local filesystem and S3-compatible backends (AWS S3, RustFS, Cloudflare R2).
sync
Package sync provides file-watching and S3-syncing for static assets.
Package sync provides file-watching and S3-syncing for static assets.
templint
Package templint provides a static linter for .templ files.
Package templint provides a static linter for .templ files.
validate
Package validate provides pure-function validators that return "" on success or a human-readable error message string on failure.
Package validate provides pure-function validators that return "" on success or a human-readable error message string on failure.

Jump to

Keyboard shortcuts

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