A modern microservices architecture built with Go, featuring dependency injection with Uber FX, gRPC communication, and comprehensive observability.
This monorepo contains a microservices ecosystem with the following components:
- Product Service: gRPC-based service for product management
- Gateway Service: HTTP REST API gateway that communicates with backend services
- Shared Libraries: Common utilities, database connections, and telemetry
- Port: gRPC server (configurable)
- Purpose: Manages product CRUD operations
- Technology: Go + gRPC + PostgreSQL
- Features: Product creation, retrieval, listing, and deletion
- Port: HTTP server (configurable)
- Purpose: REST API gateway for client applications
- Technology: Go + HTTP + gRPC client
- Features: HTTP-to-gRPC translation, request routing
- Language: Go 1.25+
- Framework: Uber FX (Dependency Injection)
- Communication: gRPC, HTTP REST
- Database: PostgreSQL
- Code Generation: Protocol Buffers, SQLC
- Observability: OpenTelemetry, Zap logging
- Build Tools: Docker, Make
- CI/CD: GitHub Actions
├── packages/
│ ├── gateway-service/ # HTTP REST API gateway
│ ├── product-service/ # gRPC product service
│ └── shared/ # Shared libraries and utilities
├── proto/ # Protocol Buffer definitions
├── gen/ # Generated code from protobuf
├── scripts/ # Build and utility scripts
├── .github/workflows/ # CI/CD pipelines
├── go.work # Go workspace configuration
├── Makefile # Build automation
└── README.md # This file
- Go 1.25 or later
- Docker and Docker Compose
- PostgreSQL (for local development)
- Protocol Buffers compiler (
protoc) - Make
-
Clone the repository
git clone <repository-url> cd go-fx-v1
-
Setup development environment
make setup
-
Build all services
make build
-
Run tests
make test
# Build Docker images
make docker-build
# Run with docker-compose (if available)
docker-compose up# Terminal 1: Start Product Service
cd packages/product-service
go run main.go
# Terminal 2: Start Gateway Service
cd packages/gateway-service
go run main.goServices use YAML configuration files:
packages/product-service/config.yamlpackages/gateway-service/config.yaml
Environment variables can override configuration values. See .env.example files for reference.
The Product Service exposes the following gRPC methods:
GetProduct(id)- Retrieve a single productListProducts(page_size, page_token)- List products with paginationCreateProduct(name, description, price, currency, stock_quantity)- Create a new productDeleteProduct(id)- Delete a product
The Gateway Service provides REST endpoints that proxy to backend services:
GET /api/products/{id}- Get product by IDGET /api/products- List products with paginationPOST /api/products- Create a new productDELETE /api/products/{id}- Delete a product
make help # Show all available commands
make build # Build all services
make test # Run tests for all modules
make test-coverage # Run tests with coverage
make test-integration # Run integration tests
make lint # Run golangci-lint
make clean # Clean build artifacts
make docker-build # Build Docker images
make docker-push # Build and push Docker images
make setup # Setup development environmentThis project uses code generation for:
- Protocol Buffers: Generate Go code from
.protofiles - SQLC: Generate type-safe Go code from SQL queries
Regenerate code after making changes:
# Generate protobuf code
buf generate
# Generate SQLC code (if applicable)
sqlc generateThe project includes multiple test types:
- Unit Tests:
make test - Integration Tests:
make test-integration - Coverage Reports:
make test-coverage
Code quality is enforced with golangci-lint:
make lintEach service has its own Dockerfile optimized for production:
# Build images
make docker-build
# Push to registry (set DOCKER_USERNAME env var)
DOCKER_USERNAME=your-username make docker-pushGitHub Actions workflows handle:
- Unit Tests: Run on every PR and push
- Linting: Code quality checks
- Docker Build: Multi-service container builds
- Integration Tests: End-to-end testing
- Structured logging with Zap
- Configurable log levels
- Request correlation IDs
- OpenTelemetry integration
- Distributed tracing across services
- Custom metrics collection
- Service health endpoints
- Database connectivity checks
- Dependency health monitoring
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
make test) - Run linting (
make lint) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Go conventions and best practices
- Use
gofmtfor code formatting - Write meaningful commit messages
- Add tests for new functionality
- Update documentation as needed
Build Failures
# Clean and rebuild
make clean
make setup
make buildTest Failures
# Run tests with verbose output
go test -v ./...Docker Issues
# Clean Docker cache
docker system prune -a
make docker-buildThis project is licensed under the MIT License - see the LICENSE file for details.
For questions and support:
- Create an issue in the GitHub repository
- Check existing documentation
- Review the troubleshooting section
Built with ❤️ using Go and modern microservices patterns