A production-ready Go 1.25 fleet manager service for managing WebSocket connections and real-time communication with Nakama integration.
- 🚀 Go 1.25 with modern language features
- 📦 Idiomatic Project Layout following Go community standards
- 🔌 WebSocket Support using gorilla/websocket
- 🎮 Nakama Integration for real-time multiplayer communication
- ⚙️ Flexible Configuration via YAML files, environment variables, and command-line flags
- 🔐 Environment Variables support with dotenv
- 📝 Structured Logging using uber-go/zap
- 🐳 Docker Support with optimized Alpine-based multi-stage builds
- 🔄 Docker Compose for easy local development
- 🤖 GitHub Actions CI/CD pipeline with automatic container builds
- 📦 Container Registry automatic pushes to ghcr.io
- 🏷️ Semantic Versioning built into the release process
- 📋 Conventional Commits for consistent commit messages
- 🧪 Comprehensive Test Suite with 85%+ coverage target
- 👤 Non-root Container execution for security
- 🏥 Health Checks for container orchestration
- 📚 Comprehensive Documentation including agent guidelines
- Go 1.25 or later
- Docker and Docker Compose (optional, for containerization)
- Git
- Clone the repository:
git clone https://github.com/EchoTools/nevr-fleetmanager.git
cd nevr-fleetmanager- Copy the environment template:
cp .env.example .env- Install dependencies:
go mod download- Run the application:
go run cmd/app/main.goRun with default configuration:
go run cmd/app/main.goRun with custom configuration file:
go run cmd/app/main.go --config configs/config.yamlShow version information:
go run cmd/app/main.go --versionBuild the binary:
go build -o bin/app ./cmd/appBuild with version information:
VERSION=$(git describe --tags --always --dirty)
COMMIT=$(git rev-parse --short HEAD)
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
go build -ldflags="-X github.com/echotools/nevr-fleetmanager/pkg/version.Version=${VERSION} \
-X github.com/echotools/nevr-fleetmanager/pkg/version.Commit=${COMMIT} \
-X github.com/echotools/nevr-fleetmanager/pkg/version.BuildDate=${BUILD_DATE}" \
-o bin/app ./cmd/appBuild and run with Docker Compose:
docker-compose up --buildOr build and run manually:
docker build -t nevr-fleetmanager:latest .
docker run -p 8080:8080 nevr-fleetmanager:latestRun tests:
go test -v ./...Run tests with coverage:
go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.outRun tests with race detection:
go test -race ./server/The application supports multiple configuration sources with the following priority (highest to lowest):
- Command-line flags
- Environment variables
- Configuration file (YAML)
- Default values
Create a config.yaml file:
name: nevr-fleetmanager
port: 8080
logger:
level: info # debug, info, warn, error
format: json # json, console
output: stdout # stdout, stderr, or file path
stacktrace: falseSet environment variables directly or use a .env file:
APP_NAME=nevr-fleetmanager
APP_PORT=8080
LOG_LEVEL=debug
LOG_FORMAT=console
LOG_OUTPUT=stdout./app --config /path/to/config.yaml
./app --version.
├── cmd/ # Command-line applications
│ └── app/ # Main application
│ └── main.go # Application entry point
├── internal/ # Private application code
│ ├── config/ # Configuration management
│ │ └── config.go # Config loading and parsing
│ └── logger/ # Logging setup
│ └── logger.go # Zap logger initialization
├── pkg/ # Public packages (can be imported by other projects)
│ └── version/ # Version information
│ └── version.go # Version variables
├── server/ # Fleet manager server implementation
│ ├── fleetmanager.go # Main FleetManager logic
│ ├── handlers.go # WebSocket handlers
│ └── *_test.go # Test files
├── rtapi/ # Real-time API protocol buffers
├── configs/ # Configuration files
│ └── config.yaml # Default configuration
├── docs/ # Documentation
│ ├── CODING_AGENT_INSTRUCTIONS.md # Test implementation guidelines
│ ├── TASK_INDEX.md # Test suite task breakdown
│ └── tasks/ # Detailed task specifications
├── .github/ # GitHub-specific files
│ └── workflows/ # GitHub Actions workflows
│ └── build.yml # Container build and push workflow
├── .env.example # Example environment variables
├── .dockerignore # Docker build exclusions
├── .gitignore # Git exclusions
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Container image definition
├── go.mod # Go module definition
├── go.sum # Go module checksums
├── Makefile # Build automation
├── AGENTS.md # Guidelines for AI agents
├── README.md # This file
└── LICENSE # MIT License
This project follows Conventional Commits:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types:
feat: New feature (MINOR version bump)fix: Bug fix (PATCH version bump)docs: Documentation changesstyle: Code style changesrefactor: Code refactoringperf: Performance improvementstest: Test additions or updatesbuild: Build system changesci: CI/CD changeschore: Other changes
Breaking Changes:
Add ! after type or BREAKING CHANGE: in footer (MAJOR version bump):
feat!: remove deprecated API endpoints
BREAKING CHANGE: The v1 API has been removed. Use v2 endpoints.
This project follows Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward-compatible)
- PATCH: Bug fixes (backward-compatible)
- Update version if needed
- Commit changes with conventional commit message
- Create and push a tag:
git tag -a v1.0.0 -m "chore(release): version 1.0.0" git push origin v1.0.0 - GitHub Actions will automatically build and push the container image
The project includes a comprehensive CI/CD pipeline:
- On Push to Main: Builds and pushes container with
latesttag - On Tag Push (
v*): Builds and pushes with semantic version tags - On Pull Request: Builds container (doesn't push)
Images are automatically pushed to GitHub Container Registry:
ghcr.io/echotools/nevr-fleetmanager:latestghcr.io/echotools/nevr-fleetmanager:v1.0.0ghcr.io/echotools/nevr-fleetmanager:v1.0ghcr.io/echotools/nevr-fleetmanager:v1
docker pull ghcr.io/echotools/nevr-fleetmanager:latest
docker run -p 8080:8080 ghcr.io/echotools/nevr-fleetmanager:latestThe core fleet manager handles:
- WebSocket connection lifecycle management
- Real-time message routing
- Session state tracking
- Health monitoring and metrics
- Integration with Nakama real-time API
Inspired by Heroic Labs Nakama, the configuration system supports:
- YAML configuration files
- Environment variable overrides
- Command-line flag overrides
- Sensible defaults
- Hierarchical configuration structure
Uses uber-go/zap for high-performance structured logging:
- JSON or console output formats
- Multiple output destinations (stdout, stderr, file)
- Configurable log levels
- Caller information
- Optional stack traces
- Structured fields for better observability
- Multi-stage build: Separates build and runtime environments
- Alpine base: Minimal image size (~10MB)
- Non-root user: Enhanced security
- Health checks: Ready for orchestration
- CA certificates: HTTPS support
- Timezone data: Proper time handling
The project includes a comprehensive test suite implementation plan:
- Current Coverage: 45%
- Target Coverage: 85%+
- Test Files: Located in
server/*_test.go - Documentation: See
docs/CODING_AGENT_INSTRUCTIONS.mdanddocs/TASK_INDEX.md
# Run all tests
go test -v ./...
# Run with coverage
go test -v -coverprofile=coverage.out ./...
# Run with race detection
go test -race ./server/
# View coverage report
go tool cover -html=coverage.out- Non-root container execution
- No hardcoded secrets
- Environment variable support
- Minimal attack surface (Alpine)
- Regular dependency updates
- Security scanning in CI/CD
- Fork the repository
- Create a feature branch (
git checkout -b feat/amazing-feature) - Commit your changes using conventional commits
- Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
See AGENTS.md for detailed development guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- Heroic Labs Nakama for configuration system inspiration and real-time API
- uber-go/zap for excellent logging library
- gorilla/websocket for WebSocket implementation
- Conventional Commits for commit message standards
- Semantic Versioning for version management
- Go community for project layout standards
For issues, questions, or contributions, please open an issue on GitHub.