A CLI tool to spawn Go microservices with different configurations.
Gonstrukt generates Go microservices with configurable options for databases, caching, observability, and rate limiting. It supports creating gateway and authentication services with predefined architectural patterns.
go build -o gonstruktgonstrukt create <github.com/username/project> [flags]- Service Name: Must follow format
github.com/<username/org>/<project_name> - Service Type (
-s,--service-type):gatewayorauth - Database (
-d,--database):psql - Config (
--config):yamlorvault
Gateway Services require:
- Cache (
--cache):memory,redis, orvalkey - Rate Limiter (
-r,--rate-limiter):token-bucketorapproximated-sliding-window
Auth Services have optional:
- Cache and rate limiter (not required)
- Observability (
-o,--observability):otlpornone(defaults tootlp)
gonstrukt create github.com/myorg/api-gateway \
--service-type gateway \
--database psql \
--config yaml \
--cache redis \
--rate-limiter token-bucket \
--observability otlpgonstrukt create github.com/myorg/auth-service \
-s auth \
-d psql \
--config vault \
-o noneGenerate shell completion scripts:
# Bash
gonstrukt completion bash > /etc/bash_completion.d/gonstrukt
# Zsh
gonstrukt completion zsh > "${fpath[1]}/_gonstrukt"
# Fish
gonstrukt completion fish > ~/.config/fish/completions/gonstrukt.fish- Purpose: API gateway for routing and traffic management
- Required: Cache (for performance), Rate limiter (for traffic control)
- Features: Request routing, load balancing, rate limiting
- Purpose: Authentication and authorization service
- Optional: Cache and rate limiter
- Features: User authentication, token management, authorization
- psql: PostgreSQL database
- memory: In-memory caching
- redis: Redis cache
- valkey: Valkey cache
- yaml: Local YAML configuration files
- vault: HashiCorp Vault configuration
- token-bucket: Token bucket algorithm
- approximated-sliding-window: Approximated sliding window algorithm
- otlp: OpenTelemetry Protocol for traces and spans
- none: No observability (logs still generated)
The CLI provides comprehensive error messages with suggestions for valid options:
error: cache is required for gateway services: caching is mandatory for performance
error: rate-limiter is required for gateway services: rate limiting is essential for gateway traffic control
Usage:
gonstrukt create <git_repo_url> [flags]
...
go build -o gonstruktgo test ./...