How z9905080/slot-framework works
Main Components
• Game Logic Service – Found in the folder “internal/game_logic”. This service has its own domain, implementation, interfaces (including GRPC adapters), and use cases.
• Gateway Service – Located under “internal/gateway”. This acts as an intermediary that coordinates between external inputs and the back-end services. It too is organized with domain, repository, implementation, and use case layers.
• Player Service – Housed in “internal/player”. Similar architectural subdivision into domain, adapter (using GRPC), handler, and use case components.
• Common Packages – The “pkg” directory contains shared modules such as definitions, logging, encoding, microservice providers (with a Consul registry provider), and protobuf definitions which facilitate inter-service communication.
• Executable Commands – The “cmd” directory holds the entry point files for running each service (game_logic.go, gateway.go, and player.go) plus a root command.
• Configuration & Environment – “environment” contains configuration settings (e.g., config.go and JSON configuration files under “dev”) ensuring that environment-specific settings are clearly separated.
Relationships and Interactions
• Direct interactions exist between the Gateway and other services (Game Logic and Player), likely through defined GRPC or HTTP APIs provided in the adapter layers.
• Shared infrastructure such as logging and microservice registries (Consul) suggest that each microservice is discoverable and can report its status via the common “pkg/micro_service” packages.
• Communication is facilitated by protobuf interfaces defined in “pkg/protobuf”, indicating that the services interact using defined contracts.
• The flow might be: a client sends requests to the Gateway, which then coordinates with the Game Logic and Player services. Each service handles its business logic through well-separated, layered components (domain, use cases, and adapters).
Architectural Patterns and Design Principles
• Domain-Driven Design (DDD) evident from separate domains, entities, services, and interfaces in each service.
• Microservices architecture – each component (Game Logic, Gateway, Player) is clearly segregated with its own lifecycle and entry point.
• Clean separation of concerns – Each module (domain, adapter, implementation, usecase) has a clear responsibility.
• Use of external libraries and frameworks for logging, microservice registration, and message/contract handling (protobuf).