Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Ashokaas/BeeHex/llms.txt
Use this file to discover all available pages before exploring further.
Technology Stack
BeeHex is built as a modern Progressive Web App using the following core technologies:Frontend Framework
Next.js 14.2 with React 18 for server-side rendering and routing
Language
TypeScript 5 for type-safe development across the entire codebase
Styling
Styled Components 6.1 for component-scoped CSS-in-JS styling
Real-time Communication
Socket.io Client 4.7 for WebSocket-based multiplayer gameplay
System Architecture
BeeHex follows a client-heavy architecture where complex game logic and AI computations run directly in the browser.Core Components
- GameInstance
- WebSocket Handler
- AI Explorer
The central game state manager located in
src/app/hex/[gameId]/GameInstance.ts.Key Responsibilities:- Maintains the game grid as a 2D array:
Array<Array<number>> - Tracks player IDs (first_player_id, second_player_id)
- Manages turn state and validates moves
- Provides methods for state updates and player queries
Data Flow
Online Multiplayer Flow
Player initiates game search
Client sends
GAME_SEARCH packet with GameParameters (board size, ranked status)Offline Mode Flow
- Local Game Creation: Creates
GameInstancewithLocalGameParameters - AI Move Request:
Explorerspawns Web Workers to evaluate positions - Worker Exploration: Each worker explores 2 levels deep using
basicHeuristic - Move Recommendation: Best moves returned with optimal continuation paths
Performance Optimizations
BeeHex implements several performance optimizations to handle complex game tree search:
Array Caching
TheArrayCache class (src/app/hex/[gameId]/ArrayCache.ts:1) reduces memory allocation during game tree exploration:
Grid Hashing
Board positions are hashed to base-36 strings for efficient deduplication:Memory Management
Explored game states clear their grid arrays once children are created to conserve memory:Type System
BeeHex uses comprehensive TypeScript interfaces defined insrc/app/definitions.ts:
- Game Types:
Game,GameParameters,GameStatus - Network Packets:
ClientBoundPacket,ServerBoundPacketenums and interfaces - AI Types:
RawScoredGameInstance,ExploreResult,Coordinate - Identifiers:
UserId,GameId,RoomId,GridHash
All packet types use discriminated unions with
type field for type-safe message handling.Directory Structure
Next Steps
Game Engine
Deep dive into AI algorithms and game state management
WebSocket Protocol
Complete packet specification and communication flow