How dendriel/princeps works
Project type and purpose
• This is a full-stack online multiplayer Memory Game.
• Client is a browser-based game built with Phaser and TypeScript.
• Server is an authoritative game server in TypeScript, using Socket.io (via Rozsa MOGS) for real-time communication.
• Shared package holds all message payload definitions and common types.
File structure
Top-level:
• assets, public: static assets (images, HTML, config).
• client.js, server-backend.js: entry points/scripts for deployment or local launch.
• packages/princeps-client: Phaser game client code.
• packages/server: Game server logic, command handlers, services.
• packages/shared: DTOs, command abstractions, shared types.
Patterns & configuration:
• Monorepo managed with package.json/workspaces.
• Each package has its own tsconfig.json.
• server/src/services implements game lifecycle (lobby, matchmaking, auto-shutdown).
• client/src/game-client handles incoming server commands and maps to game UI actions.
README for technical stack insights
• Frontend: Phaser (TypeScript), Rozsa MOGS over Socket.io.
• Backend: Node.js (TypeScript), Rozsa MOGS for websockets.
• Hosted on AWS (likely S3 + CloudFront for client, EC2/Lambda for server).
• No persistent database—state kept in memory, auto-shutdown service.
a. Main components to represent:
• Web Browser (Game UI)
‑ Phaser engine
‑ Chat Manager & UI components
‑ Command Dispatcher (turns server messages into UI updates)
• Shared Library (NPM workspace)
‑ Command and payload definitions (TypeScript interfaces)
• Game Server
‑ Rozsa MOGS / Socket.io layer
‑ Command Dispatcher → Handler modules (select-card, update-nickname, etc.)
‑ Services: lobby holder, matchmaking, match handler, auto-shutdown
• Static Hosting (AWS S3/CloudFront)
• AWS Compute (EC2 or Lambda hosting the server)
b. Relationships and data flow:
1. Browser requests index.html → static host → downloads client bundle & config.json.
2. Client initializes Phaser UI, connects to server via WebSocket.
3. Client-shared: client sends “client-command” (select-card, update-nickname) payload to server.
4. Server dispatches to appropriate handler, updates game state in memory, then emits “server-command” events.
5. Client receives server commands (e.g., show-card, update-score) → UI updates.
6. Optionally, chat messages flow through same WebSocket channel.
c. Architectural patterns and design principles:
• Command pattern: client and server both use command dispatchers and handlers.
• Monorepo modularity: shared code lives in a dedicated package to enforce strong typing across boundaries.
• In-memory stateful server with lifecycle services (lobby, matchmaking, auto-shutdown).
• Clear separation of concerns: game logic vs. networking vs. UI.
d. Relevant technologies:
• TypeScript throughout
• Phaser for game rendering/UI on client
• Rozsa MOGS (Socket.io wrapper) for communication
• Node.js runtime for server
• AWS hosting (S3, CloudFront, EC2/Lambda)
• JSON configuration (public/config.json, server services)
Elements
• Clear labels: e.g., “Game Client (Phaser)”, “WebSocket (Rozsa MOGS)”, “Game Server Command Dispatcher”.
– From Browser → Static Host (HTTP GET)
– From Browser ↔ Server (WebSocket full-duplex)
– Rectangles for components (Client, Server, Shared)