How akgondber/typing-game-cli works
Project Type & Purpose
• This is a Node.js command-line application: a typing-speed training game where a user competes against a “robot” typer or their personal best.
• Core use-cases: start a game round with varying robot speeds, select sentence topics (authors), display and persist results.
File Structure
• Top-level artifacts:
• loadr.mjs (executable loader)
• package.json / package-lock.json (dependencies)
• media/ (demo assets)
• readme.md (project overview)
• test.js + tests/ (unit tests)
• source/ directory (all runtime modules):
• cli.js – parses command-line options & launches the app
• app.js – orchestrates game flow
• Menu.js / Results.js – UI renderers for prompts & results display
• robotFrames.js – simulation frames for the typer-robot animation
• helpers.js, config.js, constants.js – shared utilities & settings
• sentences/ – JSON files organized by author (data source for typing text)
Review README Insights
• Node.js CLI installed globally
• Flags for game modes, speed levels, result display, filtering by author, etc.
• Demo screenshots show interactive terminal UI
Main Components & Their Interactions
a. CLI Parser Layer (cli.js)
• Reads user arguments
• Validates options (via a library or custom logic)
• Builds a GameConfig object
↳ passes config to
b. Application Core (app.js)
• Initializes game round based on GameConfig
• Loads sentence text from Sentence Store
• Instantiates Robot simulator & Game Timer
• Manages user input loop and compares to robot progress
• Computes metrics (CPM, WPM)
• Writes results to Results Store
↳ uses
c. Data Layer
1. Sentence Repository (source/sentences)
• Loads JSON by author/topic
2. Results Repository (e.g., JSON file in user’s home directory)
• Appends & reads past results
d. Presentation Layer
• Menu.js – displays initial prompts & loading screens
• robotFrames.js – emits CLI frames for robot typing animation
• Results.js – formats & prints results (compact or full)
e. Utility Layer
• config.js & constants.js – global settings (file paths, default speeds)
• helpers.js – shared functions (sorting, time formatting)
Architectural Patterns & Design Principles
• Modular separation: CLI parsing, core logic, data access, presentation, utilities
• Repository pattern for sentence & result stores
• Single-process, layered architecture; no external network calls
• Extensibility: add new sentence packs by dropping JSON in sentences/