How code100x/chess works
Main Components
a) Client Applications:
• Web Frontend (React + TypeScript)
• Native Mobile App (React Native)
• As separate client interfaces
b) Backend Services:
• Main Backend Server (Node.js)
• WebSocket Server (dedicated real-time game service)
• Authentication Service (with GitHub/Google OAuth)
c) Data Stores:
• PostgreSQL Database (for user data, game records)
• Redis (for real-time game moves queue)
[Client Layer]
• ↕️
[Service Layer]
• ↕️
[Data Layer]
Client Layer
• Both web and mobile clients
• Frontend components:
• Chess Board Component
• Game Management
• Authentication UI
• User Settings
Service Layer
• Main Backend API Service:
• Auth Router
• Game Management
• User Management
• WebSocket Server:
• Game Manager
• Socket Manager
• Real-time Communication
Data Layer
• PostgreSQL with tables for:
• Users
• Games
• Moves
• Ratings
• Redis for real-time game state
Communication Flows
• Blue: Client-side components
• Green: Backend services
• Yellow: Data stores
• Red: Authentication flows
• Purple: WebSocket connections
Important Architectural Patterns to Highlight:
Monorepo Structure
• Separation of apps/ and packages/
• Shared packages (ui, store, db)
Real-time Game Architecture
• WebSocket server communication flow
• Game state management
• Move validation and synchronization
Authentication Flow
• OAuth providers
• Session management
• User authentication states
Data Flow Patterns
• Game move propagation
• State updates
• Rating calculations
Special Considerations:
Real-time nature of the chess game
• How moves are synchronized between players
• Time control management
• Rating update mechanism
Shared package architecture
• How common UI components are shared
• Shared types and configurations
• Database access patterns