How phuhao00/nakama works
Main Components
• Client Interfaces: Outline various client types (mobile apps, web clients, game engines) that interact via different protocols such as REST (HTTP/JSON), gRPC, WebSockets, and rUDP.
• API Gateways & Protocol Layers: Represent protocol-specific endpoints. There are separate “apigrpc” and “console” directories that indicate gRPC interfaces and an embedded web console (with an Angular UI) respectively.
• Core Server Modules: The “server” directory contains many API endpoints (e.g., account, authentication, channels, matchmaking, notifications, social, tournaments, etc.). Group these together under a “Core Server / Business Logic” layer. This layer also encompasses specialized components for session management, matchmaking, leaderboards, runtime code execution (supporting Lua, JavaScript, and Go) and more.
• Runtime Extension/Subsystems: Highlight the runtime modules (evident in subdirectories like “internal/gopher-lua”, “internal/cronexpr”, and pluginbuilder components). These allow for extending server functionality via custom scripts.
• Build & Deployment Infrastructure: Optionally note the “build” directory with Dockerfiles and deployment scripts, and include CI/CD pipelines (e.g., GitHub workflows for tests and Docker builds) to show how the system is packaged and deployed.
Establish Relationships and Interactions
• From the API layer, connect to the Core Server modules where authentication, social, matchmaking, chat, and other game logic functions are executed.
• Link the Core Server to the Database, indicating bidirectional communication (queries/updates).
• For the Console UI, show it as an embedded component in the binary that communicates with the same backend APIs.
Important Architectural Patterns and Design Principles
• Modularity: Emphasize how the codebase is partitioned (e.g., separate packages for different functional areas like authentication, channels, matchmaking).
• Protocol Abstraction: Show that multiple protocols (gRPC, REST, WebSocket) funnel into unified core logic.
• Extensibility: Illustrate the plugin and runtime scripting capabilities, showing how the system can be extended without changing the core server.
• Single Binary with Multiple Roles: Note that the server binary includes both game server functions and the embedded admin console, yet they are logically separated.
Relevant Technologies and Frameworks
• Language/Runtime: Go (with built-in modules and vendor dependencies).
• Protocol Buffers and gRPC: For service definitions and efficient communication.
• Angular: UI framework for the admin console.
• Docker & CI/CD tools: Used for build automation and containerization (as evident in the “build” and “.github/workflows” directories).
• Database: CockroachDB/Postgres for persistence.