Go Microservice Architecture Generator
Generates complete Go microservice projects following hexagonal/clean architecture principles, optimized for AWS Lambda with SQS event processing.
Overview
This skill creates production-ready Go microservice projects with:
- •Hexagonal/clean architecture separation (core, driving, libraries, shared)
- •AWS Lambda handler with SQS event processing
- •MySQL database client with connection pooling
- •Docker multi-stage builds
- •AWS SAM templates for deployment
- •Local development setup with Makefile
When to Use
Use this skill when the user:
- •Requests to create a new Go microservice
- •Wants to scaffold a Lambda function in Go
- •Needs an AWS Lambda + SQS event processor
- •Asks for a hexagonal/clean architecture template
- •Wants a production-ready Go service structure
Quick Start
Ask questions like:
- •"Create a new microservice called ms-orders for processing orders"
- •"Generate a Go Lambda function to handle user events"
- •"Set up a new Go service with hexagonal architecture"
The skill will ask for:
- •Service name (e.g., "ms-everflow", "user-service")
- •Domain entity (e.g., "event", "user", "order")
- •Go module path (e.g., "github.com/company/project")
Generated Structure
code
project-name/
├── buildspec-ecs.yaml # AWS CodeBuild/ECS deployment
├── Dockerfile # Production multi-stage build
├── Dockerfile.local # Local development
├── Makefile # Development commands
├── template.yaml # AWS SAM template
├── sqs_event.json # Sample SQS event for testing
└── src/
├── go.mod # Go module definition
├── cmd/
│ └── lambda-{service}/
│ └── main.go # Lambda entrypoint
└── internal/
├── core/ # Business logic (domain entities)
│ └── {domain}/
│ └── domain/
├── driving/ # Inbound adapters (handlers)
│ └── lambda_handler/
│ ├── lambda.go
│ ├── database.go
│ ├── timeout.go
│ └── types.go
├── libraries/ # Infrastructure clients
│ └── mysql/
│ └── mysql_client.go
└── shared/ # Shared domain utilities
└── domain/
├── error.go
└── log.go
Implementation Process
- •Gather Requirements: Confirm service name, domain, and module path with user
- •Copy Templates: Use files from
assets/skeleton/directory - •Replace Placeholders: Substitute all template variables:
- •
{MODULE_PATH}: Go module path - •
{SERVICE_NAME}: Service name - •
{DOMAIN}: Domain name (lowercase) - •
{ENTITY}: Entity name (PascalCase) - •
{LAMBDA_FUNCTION_NAME}: CloudFormation resource name
- •
- •Create Structure: Build complete directory tree
- •Verify: Ensure all imports and references are correct
Key Components
Lambda Handler
- •SQS batch event processing
- •Structured logging with slog
- •Database connection lifecycle
- •Timeout handling with graceful shutdown
- •Batch failure reporting
Database Layer
- •MySQL client with configurable pools
- •Environment-based configuration
- •Connection verification
- •Graceful closure
Domain Layer
- •Clean business entities
- •No infrastructure dependencies
- •Custom error types
Infrastructure
- •Dockerfile: Multi-stage with Lambda runtime and Lambda Insights
- •Makefile: Local SAM invocation
- •SAM Template: Lambda configuration with SQS trigger
- •Buildspec: ECS deployment automation
Template Placeholders
All templates in assets/skeleton/ use these placeholders:
| Placeholder | Example | Description |
|---|---|---|
{MODULE_PATH} | github.com/company/project | Go module import path |
{SERVICE_NAME} | ms-everflow | Kebab-case service name |
{DOMAIN} | event | Lowercase domain name |
{ENTITY} | Event | PascalCase entity name |
{LAMBDA_FUNCTION_NAME} | EventProcessorFunction | CloudFormation resource name |
Post-Generation Commands
After creating the project, guide the user:
bash
# Install dependencies
cd src && go mod tidy
# Run locally with SAM
make run-dev
# Build Docker image
docker build -t {service-name} .
# Deploy with SAM
sam build && sam deploy
Resources
assets/skeleton/
Template files that get copied and customized when generating a new project:
- •
go.mod.template- Go module definition - •
main.go.template- Lambda entrypoint - •
lambda.go.template- SQS event handler - •
database.go.template- MySQL initialization - •
timeout.go.template- Graceful shutdown - •
types.go.template- Custom types placeholder - •
event.go.template- Domain entity - •
mysql_client.go.template- Database client - •
error.go.template- Custom errors - •
log.go.template- Logging utilities - •
Dockerfile.template- Production build - •
Makefile.template- Development commands - •
template.yaml.template- SAM configuration - •
sqs_event.json.template- Test event - •
buildspec-ecs.yaml.template- CI/CD pipeline
See assets/skeleton/README.md for detailed file mapping.