How poooel/knucklebones works
Component Details
a. Client Layer (Top):
• Sub-components:
• Game UI Components (GameContext, PlayerBoard, Dice)
• State Management (GameContext)
• I18n System (translations)
• API Interface (utils/api.ts)
b. Edge Computing Layer (Middle):
• Endpoints:
• WebSocket Handler
• Game Management Endpoints
• Player Management Endpoints
c. State Management Layer (Bottom):
• GameStateDurableObject
• WebSocketDurableObject
Connection Flows
• Frontend → Cloudflare Workers (HTTP/WebSocket connections)
• Workers → Durable Objects (State persistence)
• WebSocket connections between clients (through Workers)
[Frontend (React Application)]
• Components Layer
• Game UI
• Player Boards
• Game Settings
• State Management
• GameContext
• API Interface
[Cloudflare Workers]
• Endpoint Handlers
• Game Management
• Player Management
• WebSocket Handler
• AI Implementation
[Durable Objects]
• GameStateDurableObject
• WebSocketDurableObject
[Shared Package]
• Common Code
• Game Logic
• Types
• Utilities
Real-time Communication
• WebSocket connections between clients
• State synchronization paths
State Management
• How game state is maintained in Durable Objects
• State propagation to connected clients
Shared Code
• How the common package is used by both frontend and backend
Deployment Flow
• Cloudflare Pages deployment for frontend
• Worker deployment path
This architecture is particularly interesting because it leverages Cloudflare's edge computing capabilities, so make sure to emphasize how the system takes advantage of this distributed nature for better performance and reliability.