A beautiful, interactive CLI tool for Protoflow - built with Charm components for an exceptional developer experience.
Hatch scaffolds production-ready event-driven services with:
- ποΈ Complete project structure - App orchestration, use cases, events, database support
- π OpenTelemetry integration - Tracing, metrics, and structured logging out of the box
- π§ Viper configuration - Environment-driven config with sensible defaults
- π― Best practices - Pre-commit hooks, Taskfile automation, comprehensive documentation
- π Multiple transports - Kafka, RabbitMQ, NATS, AWS, HTTP, and more
- π¨ Beautiful UI: Built with Charm's Bubble Tea and Lip Gloss for a delightful terminal experience
- π Project Scaffolding:
hatch init- Generate new Protoflow projects instantly - π Handler Generation:
hatch handler add- Create type-safe handlers with boilerplate - β
Configuration Validation:
hatch validate- Validate configs before runtime - π― Interactive Prompts: Charm's survey components for guided workflows
git clone https://github.com/drblury/hatch.git
cd hatch
go install ./cmd/hatchgo install github.com/drblury/hatch/cmd/hatch@latestbrew install hatchhatch init my-serviceThis will create a production-ready project with:
- Application Structure:
main.gowith build metadata,internal/appfor lifecycle management - Business Logic:
internal/usecasepackage for clean architecture - Event Handling:
internal/eventswith middleware, validation, and retries - Database Support:
internal/databasewith MongoDB integration and health checks - Observability:
pkg/loggingwith OTEL tracing, metrics, and structured logging - Configuration: Viper-based config with
.env.exampletemplate - Development Tools: Pre-commit hooks, Taskfile, comprehensive documentation
hatch handler add OrderCreated --type proto --consume orders.createdhatch validate .envScaffold a new Protoflow service project.
Options:
--transport <name>- Select transport (kafka, rabbitmq, nats, aws, http, io, sqlite, postgres, channel)--with-examples- Include example handlers--with-simulator- Include event simulator--interactive- Use interactive mode (default when no args provided)
Example:
hatch init my-service --transport kafkaGenerate boilerplate for a new handler.
Releases are automatically created when a git tag is pushed. The CI pipeline uses GoReleaser to build binaries for multiple platforms and create GitHub releases.
- Update version numbers and changelog
- Commit your changes
- Create and push a git tag:
git tag -a v1.0.0 -m "Release v1.0.0" git push origin v1.0.0
The GitHub Actions workflow will automatically:
- Build binaries for Linux, macOS, and Windows (amd64 and arm64)
- Create a GitHub release with release notes
- Upload all binaries and checksums
- Generate Homebrew formula (if configured)
You can also trigger a release manually via GitHub Actions:
- Go to Actions β Release workflow
- Click "Run workflow"
- Enter the tag name (e.g.,
v1.0.0) - Click "Run workflow"
Options:
--type <proto|json|cloudevents>- Handler type (default: proto)--consume <queue>- Consume queue/topic (required)--publish <queue>- Publish queue/topic (optional)--interactive- Use interactive mode (default)
Example:
hatch handler add ProcessPayment \
--type json \
--consume payments.process \
--publish payments.completedValidate Protoflow configuration without running the service.
Options:
--config <file>- Configuration file path (default: .env)--transport <name>- Validate transport-specific config--verbose- Show detailed validation results
Example:
hatch validate .env
hatch validate --config .env --verboseBuilt with Charm libraries:
- Bubble Tea - TUI framework for interactive CLI
- Lip Gloss - Styling and layout
- Spinner - Loading indicators
- Table - Beautiful tables
- Progress - Progress bars
- Bubbles - Reusable Bubble Tea components
- Go 1.21+
- Protoflow library (for validation)
go build -o hatch ./cmd/hatch# Run all tests
go test ./...
# Run tests with coverage
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out
go tool cover -html=coverage.out -o coverage.html
# Run tests with verbose output
go test -v ./...When you run hatch init, you get a complete production-ready structure:
my-service/
βββ main.go # Entry point with build metadata
βββ go.mod # Dependencies
βββ .env.example # Environment configuration template
βββ .pre-commit-config.yaml # Pre-commit hooks
βββ taskfile.yml # Task automation
βββ handlers/
β βββ registry.go # Handler registration
β βββ *.go # Your event handlers
βββ internal/
β βββ app/ # Application orchestration
β β βββ app.go # Main app lifecycle
β β βββ bootstrap.go # Initialization
β β βββ config.go # Viper-based config
β β βββ http_server.go # HTTP server setup
β βββ usecase/ # Business logic layer
β β βββ usecase.go # Use case implementation
β βββ events/ # Event handling
β β βββ events_setup.go # Event service setup
β β βββ validator.go # Event validation
β β βββ config.go # Events config
β βββ database/ # Database support
β βββ db.go # MongoDB connection
β βββ config.go # Database config
βββ pkg/
βββ logging/ # Logging & observability
βββ logging.go # Structured logging
βββ tracing/ # OTEL tracing
βββ metrics/ # OTEL metrics
hatch/
βββ cmd/hatch/ # CLI entry point
βββ internal/
β βββ commands/ # Command implementations
β βββ ui/ # Charm UI components
β βββ scaffold/ # Code generation & templates
βββ docs/ # Documentation
βββ README.md
The project maintains high test coverage with comprehensive unit tests:
# Run all tests with coverage
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -func=coverage.out
go tool cover -html=coverage.out -o coverage.htmlContributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Clone the repository
- Install dependencies:
go mod download - Run tests:
go test ./... - Build:
go build ./cmd/hatch
MIT License - see LICENSE file.
The CLI generates a production-ready event-driven service with:
- App Orchestration (
internal/app) - Lifecycle management, graceful shutdown, initialization - Use Case Layer (
internal/usecase) - Business logic separation from handlers - Event Handling (
internal/events) - Event service setup with middleware, validation, retries - Database Support (
internal/database) - MongoDB integration with health checks - Observability (
pkg/logging) - Structured logging, OTEL tracing & metrics (stubs ready for implementation) - Configuration - Viper-based config with environment variable support
- Development Tools - Pre-commit hooks, Taskfile, comprehensive
.env.example
- Protoflow - The main library
- Charm - Beautiful CLI tools
- Event-Driven-Service-Example - Reference implementation