How dieg0r01/explo-kittens-distributed-sys works
Project type and purpose
• This is a Java-based, turn-based multiplayer card game (“Exploding Kittens”) implemented as a client–server application.
• Clients provide a GUI for players; the server manages rooms, game sessions and enforces game rules concurrently using thread pools.
File structure
• Top-level src/ contains three logical modules:
• DomainModel: all card definitions, deck and player data structures.
• BusinessLogic: game rules, turn/order management, hand and priority managers.
• Client: split into GUI (presentation) and ClientNetwork (socket I/O).
• Server: split into ServerNetwork (connection handling) and GameLogic (room and session management).
Key insights from the README
• Uses ExecutorService (newCachedThreadPool for client connections; newSingleThreadExecutor per game/session) for concurrency.
• RoomManager centralizes thread-safe room creation/joining.
• GameSession runs in its own thread, invoking BusinessLogic and DomainModel classes.
• Simple text-based protocol (“CREATE”, “JOIN”, “START”, “EXIT”) over TCP sockets with ObjectInputStream/PrintStream.
Main components
a. Client Side
• GUI Layer: Swing/Java GUI + CardImages (view)
• ClientNetwork: ClientNet (socket connector)
b. Network Layer
• TCP Socket connection
c. Server Side
• ServerNetwork
– ServerNet (listener + global ExecutorService)
– ClientHandler (per‐client SingleThreadExecutor + I/O streams)
• GameLogic
– RoomManager (create/join rooms)
– Room (holds players, game settings)
– GameSession (per-room SingleThreadExecutor)
• BusinessLogic (Game, TurnManager, HandManager, etc.)
• DomainModel (Card, Deck, Player, CardFactory, etc.)
Relationships & interactions
• GUI → ClientNet sends user commands over TCP
• ServerNet accepts incoming sockets → spawns ClientHandler
• ClientHandler registers with RoomManager (CREATE/JOIN)
• RoomManager assigns players to a Room
• On “START”, RoomManager triggers a GameSession
• GameSession invokes BusinessLogic classes, manipulating DomainModel objects
• GameSession sends state updates back to clients via their ClientHandler streams
Architectural patterns & design principles
• Layered architecture: Presentation (GUI), Network, Server Logic, Business Logic, Domain Model
• Concurrency via ExecutorService pools (cached vs. single-threaded)
• Command/message protocol for client–server communication
• Separation of concerns: DomainModel is pure data, BusinessLogic is rule engine, ServerNetwork handles I/O
Relevant technologies & frameworks
• Java SE sockets (java.net.ServerSocket, Socket)
• java.util.concurrent.ExecutorService
• ObjectInputStream / PrintStream for message marshalling
• Swing or JavaFX for GUI (inferred by CardImages folder)