Backend Architecture
System Overview
The backend of SPLFlip is built using Node.js and Express, with several key components handling game logic, transaction management, and WebSocket communications.
Core Components
Game Management System
In-memory game storage using Maps
Separate storage for open, active, and completed games
Automatic game expiration handling
Transaction verification and processing
Transaction Processing
Robust retry mechanism for failed transactions
Priority fee handling for faster confirmations
Balance verification before processing
Multi-token support with SPL token handling
WebSocket Implementation
Real-time game updates
Player notifications
Connection management per user
Event-based communication
Security Features
Transaction signature verification
Balance checks before game creation/joining
Duplicate transaction prevention
Error handling and recovery
Key Processes
Game Creation Process
Validation of user input
Transaction verification
Game state initialization
Expiration timer setup
WebSocket notification dispatch
Game Joining Process
Game availability verification
Transaction confirmation
State transition management
Result processing setup
Player notification
Result Processing
Cryptographic randomness generation
Winner determination
Payout transaction creation
State updates
Multi-channel notifications
Error Handling
Transaction retry mechanism
Automatic refund processing
Error reporting through WebSocket
State recovery procedures
Last updated