Backend Architecture

Purr Poker's backend architecture is designed to handle real-time game processing while maintaining tight integration with blockchain systems for security and fund management.

System Overview

Game Server Cluster

Game Logic
State Mgmt
WebSockets

Blockchain Service

  • • Contract Interactions
  • • Transaction Signing
  • • Balance Monitoring

Redis Database

  • • Game State Cache
  • • Pub/Sub System
  • • Session Management

API Gateway

Authentication & Rate Limiting

Analytics Service

Event Processing & Statistics

Hand History Service

Storage & Replay

Core Components

Game Server

The heart of Purr Poker's backend, responsible for managing game logic, player actions, and state.

  • Built with Node.js for high concurrency and low latency
  • Implements Texas Hold'em rules and hand evaluation
  • Manages betting rounds, turn timers, and showdowns
  • Handles player connectivity and reconnection
  • Signs settlement transactions for blockchain processing

WebSocket Service

Maintains real-time communication between clients and the game server.

  • Socket.IO implementation with fallback options
  • Automatic reconnection with session persistence
  • Message queueing for disconnected clients
  • Secure protocol with JWT authentication
  • Optimized binary transmission for game state updates

Blockchain Service

Bridges the game server with the Hyperliquid blockchain.

  • Monitors contract events for deposits and withdrawals
  • Prepares and signs settlement transactions
  • Implements retry logic for transaction failures
  • Maintains player balance synchronization
  • Manages secure key storage for transaction signing

Redis Database

In-memory data store for fast access to critical game data.

  • Stores active game states for quick recovery
  • Powers Pub/Sub for inter-service communication
  • Manages player sessions and tables
  • Implements distributed locking for concurrent operations
  • Persists critical data with AOF and RDB backup

Data Flow

1

Player Action

A player makes a move (bet, fold, check, etc.) through the client interface. This action is sent to the server via WebSocket.

2

Game Processing

The game server validates the action, updates the game state, and determines next steps. The updated game state is stored in Redis and broadcast to all players at the table.

3

Hand Completion

When a hand completes, the server calculates the pot distribution, determines rake, and prepares a settlement transaction. The complete hand history is stored in the database.

4

Blockchain Settlement

The Blockchain Service signs and submits the settlement transaction to the Table Contract. It monitors the transaction until it is confirmed and updates player balances accordingly.

High Availability & Scalability

Load Balancing

Multiple game server instances are deployed behind a load balancer to distribute traffic and ensure high availability. WebSocket connections use sticky sessions to maintain consistency.

Redis Clustering

Redis is deployed in a clustered configuration with replica nodes for fault tolerance. Sentinel monitors the nodes and performs automatic failover if the master node becomes unavailable.

Microservices

The backend is designed as a collection of microservices that can be scaled independently based on demand. This allows for efficient resource allocation and easier updates.

Security Measures

Authentication & Authorization

  • JWT-based authentication with short expiration
  • Role-based access control for admin functions
  • Rate limiting to prevent abuse
  • IP-based restrictions for sensitive operations

Data Protection

  • All traffic encrypted with TLS 1.3
  • Sensitive data stored with AES-256 encryption
  • Private keys managed in HSM
  • Regular security audits and penetration testing

Anti-Cheating Measures

  • Server-side card validation
  • Collusion detection algorithms
  • Behavior analysis for bot detection
  • Real-time game monitoring

Fault Tolerance

  • Automated backup and recovery procedures
  • Graceful degradation under high load
  • Circuit breakers for failing services
  • Comprehensive monitoring and alerting

Ready to Explore More?