How moke-game/game works
Main Components
• Game Server Core: Represented by the service code in the cmd/{game-name}/service directory and the internal services (e.g., internal/services/game0) that encapsulate game logic.
• Client Component: Shown in cmd/{game-name}/client, which implements an interactive shell client for testing and interaction.
• API Layer: The api directory holds the proto files along with the generated code (in api/gen) that provide communication interfaces using gRPC (and HTTP gateway as seen in the “.pb.gw.go” files).
• Data Persistence (Database Interaction): Highlight the components under internal/services/game0/db_nosql which seem responsible for database interactions.
• External and Infrastructure Services: Indicate the Deployment directories (docker-compose and k8s) that support infrastructure setup.
• Build & CI/CD: Note the build directory containing the Dockerfile, as well as the .github/workflows for automated testing, code analysis, and deployment.
• Additional Utilities/Shared Libraries: Components under pkg (e.g., pkg/dfx and pkg/modules) that provide reusable helper functions or client functionality.
• Testing: The tests directory contains integration and load testing files, which simulate real-world usage scenarios.
Relationships and Data Flow
• Interaction between the Client Component (both interactive client and automated load tests) and the Game Server via HTTP/gRPC.
• That the internal services rely on the NoSQL database layer – showing the DAO and factory patterns implemented.
• Build and deployment artifacts (docker-compose and Kubernetes manifests) which govern how the server is deployed in different environments.
Architectural Patterns and Design Principles
• Layered Architecture: Show separation between API, business logic, and data access layers.
• Microservices / Modular Components: Although it is a template for a single game server, indicate modularity through distinct modules (e.g., game0 versus gm in the API sub-folders and pkg/modules).
• Client-Server Communication: Illustrate the clear separation between clients (interactive client and load testing scripts) and the server endpoints.
Relevant Technologies and Frameworks
• Go as the primary programming language.
• Protocol Buffers (buf tool and generated Go code for gRPC and HTTP gateways).
• Docker and Docker Compose for containerized deployment.
• Kubernetes (as seen in the deployment/k8s folder) for orchestration.
• Load testing using k6.
• CI/CD via GitHub Actions (workflows in .github/workflows).
• Possibly NoSQL databases (implied by db_nosql components).