Game Night is envisioned as a local, serverless, and free real-time quiz game, inspired by platforms like Kahoot. The primary goal is to enable users to create, host, and play interactive quizzes in a group setting (e.g., a "game night" in the same room) using a shared local Wi-Fi network. Unlike many commercial platforms, Game Night will require no payments for creating or playing games, offering full flexibility to its users.
The core concept involves one user acting as the Host on their device (mobile or desktop), managing the quiz and game flow. Other participants join as Clients using their own devices. Questions are displayed, and participants answer in real-time, with scores and statistics presented dynamically.
The system is designed to be serverless and database-less in the traditional sense, relying on peer-to-peer communication over the local network.
- Host Device:
- Stores all quiz data (questions, answers, images) in its local storage.
- Manages game state and progression.
- Serves questions and receives answers from clients.
- Performs encryption of quiz content.
- Calculates and broadcasts scores/statistics.
- Client Devices:
- Connect to the Host device over the local Wi-Fi.
- Store their own profile information (name, image, description) locally.
- Receive question data (or decryption keys for it) from the host.
- Send selected answers and their timestamps to the host.
- Display questions, answer options, and game statistics.
- Communication Protocol:
- WebRTC (Web Real-Time Communication) will be the primary technology for establishing peer-to-peer connections between the host and client devices. This allows for direct, low-latency communication suitable for real-time interactions.
- An initial handshake might require a STUN/TURN server to facilitate NAT traversal if devices are on complex local networks, but the core data exchange (questions, answers, stats) will be P2P.
- Time Synchronization:
- Network Time Protocol (NTP) or a similar mechanism should be employed to ensure sub-millisecond time synchronization across all connected devices. This is crucial for fair scoring based on answer submission times.
- Quiz Creation & Local Storage: The host can create quizzes consisting of questions and answers. This data is stored locally on the host's device.
- Question Types: Questions can be text-based or include images.
- Answer Types: Answers are multiple-choice, with a flexible number of options (e.g., 2 to 6).
- Import/Export Quizzes: Users should be able to import and export quizzes (e.g., using JSON files) to easily share game nights.
- Game Initiation: The host initiates a "game night," making their device discoverable on the local network.
- Client Joining: Clients discover and connect to the host's game session. (Developer note: Specify discovery mechanism, e.g., mDNS, host IP entry).
- Client Profiles:
- Each client creates a profile including a name, a descriptive text, and an image.
- This profile is stored locally on the client's device.
- Profile information (name, image, description) is transmitted to the host upon joining.
- Host Control: Only the host can navigate between questions (start question, end question, show results, move to next question). The host will have a simple UI for this (e.g., "Next Question," "Show Results" buttons).
- Question Display: Questions are presented to all participants. (Developer note: Clarify if questions are broadcast to client screens directly or if clients primarily view a central host screen).
- Answering: Clients select their answers on their own devices.
- Timestamped Answers: Each client device records the precise local timestamp when an answer is selected. This timestamp is transmitted to the host along with the answer. The host uses this, adjusted for synchronized time, to determine scoring, ensuring fairness regardless of minor network latency differences.
- Question Encryption: Each question (or the set of questions and answers for a quiz) is encrypted by the host. Encryption keys are generated and managed by the host.
- Minimal Payload Encryption Key Transfer: Upon the host moving to the next question, only two digits of the encryption code for that specific upcoming question are transmitted to all client devices.
- Local Decryption: Client devices use these two digits to decrypt the incoming question content locally. This minimizes network payload and adds a layer of security to the question content during transit. (Developer note: The exact nature of this "two-digit code" and its role in the decryption algorithm needs to be clearly defined and securely implemented).
- Latency Tracking: The system will implement real-time latency tracking between the host and each connected client device using WebRTC's capabilities. This helps monitor connection quality.
- Per-Question Statistics: After each question, statistics are displayed to all participants. This includes:
- The correct answer.
- Distribution of answers.
- Current scores and leaderboard.
- End-of-Round/Game Statistics: Comprehensive statistics are presented at the end of defined game rounds or the entire game.
- Modularity: The codebase must be modular. Features should be developed in a way that they are loosely coupled and can be worked on, updated, or modified independently.
- Class-Based Structure: Employ an object-oriented approach using classes to structure the code logically, promoting reusability and maintainability.
- Feature Separation via Functions/Modules: Each distinct feature or piece of functionality should be encapsulated within its own function(s), methods (within classes), or modules. This makes it easier to add new features, update existing ones, or debug issues.
- Local Storage: Utilize browser local storage (or equivalent for mobile/desktop platforms) for storing quiz data on the host and profile data on clients.
- Cross-Platform Compatibility (Consideration): While initial development might target a specific platform (e.g., web browsers), the architecture should ideally allow for future porting to other platforms (e.g., mobile apps via web views or native implementations).
Developers should seek or define clarity on the following aspects during the design and implementation phases:
- Device Discovery Mechanism: How will client devices discover the host on the local network (e.g., mDNS/Bonjour, manual IP entry, QR code scan displayed by host)?
- WebRTC Signaling: Detail the signaling process for establishing WebRTC connections (e.g., using a temporary local HTTP server on the host, or a minimal external signaling server for NAT traversal handshake only).
- "Two-Digit Encryption Code" Implementation:
- Specify the cryptographic algorithm used for question encryption.
- Clearly define how the "two digits" are generated by the host and used by the client for decryption. What is the full key derivation process?
- Analyze the security implications of this approach.
- Quiz File Format: Define a clear and versioned schema for the import/export of quiz files (recommend JSON). Include fields for question text, image paths/data, answer options, correct answer index, etc.
- Error Handling & Resilience:
- How will the system handle network interruptions (e.g., temporary Wi-Fi drops)?
- What happens if the host device disconnects or crashes?
- How are client disconnections handled by the host and other clients?
- User Interface (UI) / User Experience (UX):
- Wireframes or mockups for host and client interfaces.
- How are questions, especially those with images, displayed optimally on various device screen sizes?
- Is there a main shared screen (like Kahoot) driven by the host, with client devices acting primarily as controllers? Or do clients get all visual information on their own screens?
- Definition of "Round": Clarify if a "round" is simply the interval after each question, or if it comprises a set of questions.
- Scalability: Define any expected limits on the number of concurrent players the system should comfortably support on a typical local network.
- Profile Image Handling: How are profile images transmitted and stored? Consider size limits and formats.
This document provides the foundational requirements for Game Night. Successful implementation will depend on careful consideration of these details and robust technical design.