HexaGo¶
Generate production-ready Go applications with Hexagonal Architecture
HexaGo is an opinionated CLI tool to scaffold Go applications following the Hexagonal Architecture (Ports & Adapters) pattern. It helps developers maintain proper separation of concerns and build maintainable, testable applications from day one.
Features¶
-
Project Generation
One command creates a complete project with your chosen web framework, Docker support, graceful shutdown, configuration management, and observability built in.
-
Component Generation
Add services, domain entities, value objects, and adapters to existing projects. Auto-detects your project conventions and generates consistent, context-aware code.
-
High Value Features
Generate background workers (queue, periodic, event-driven), database migrations with sequential numbering, and validate your architecture compliance.
-
Template Customization
Modify generated code to match your team's style. Add company headers, enforce coding standards, and share templates across your organization via version control.
-
AI Assistant Integration
Built-in MCP server lets Claude Code, Claude Desktop, VS Code, Cursor, Windsurf, and Zed scaffold projects without leaving the conversation. The
--working-directoryflag means nocdis ever required.
Quick Install¶
Get Started in 60 Seconds¶
# Create a new project with Echo framework
hexago init my-api --module github.com/user/my-api --framework echo
cd my-api
# Add domain entities
hexago add domain entity User --fields "id:string,name:string,email:string"
# Add business logic
hexago add service CreateUser
# Add HTTP handler
hexago add adapter primary http UserHandler
# Validate architecture
hexago validate
# Build and run
make run
Visit http://localhost:8080/health to see it working!
Framework Support¶
HexaGo generates framework-specific code for:
| Framework | Handler Signature |
|---|---|
| stdlib | http.Handler |
| Echo | func(echo.Context) error |
| Gin | func(*gin.Context) |
| Chi | Standard library with chi router |
| Fiber | func(*fiber.Ctx) error |
Why Hexagonal Architecture?¶
Hexagonal Architecture separates your application into three distinct layers:
- Domain — Pure business entities, zero external dependencies
- Services — Application logic, orchestrates domain objects, defines port interfaces
- Adapters — Implementations of ports (HTTP handlers, repositories, external services)
This structure makes your application testable, maintainable, and framework-agnostic.