This repository hosts a typing simulator game built with vanilla JavaScript and the CodeSignal Design System.
Supported game modes are configured in client/config.json:
classic: standard line-by-line typing flowracing: player car vs opponents progressing across the typed textmeteoriteRain: type falling words before they hit the groundtowerDefense: type prompted words to defeat enemies before they reach the castle
client/index.html: single-page shell with containers and controls for classic, racing, meteorite rain, and tower defense modesclient/typing-simulator.js: entry point and initialization orchestrator; wires DOM, listeners, focus management, config/text loading, and mode bootstrappingclient/state.js: shared mutable state singleton used across all client modulesclient/config.js: loads and normalizes runtime configuration fromclient/config.jsonclient/text.js: loadsclient/text-to-input.txt, initializes character state, renders text, and triggers completion for text-based modesclient/input.js: central input and keydown handling with per-mode branchesclient/keyboard.js: visual keyboard rendering, key availability checks, and key highlightingclient/stats.js: real-time/final stats calculation, stats parsing, and/save-statspersistenceclient/completion.js: completion screen and stats dashboard flowclient/restart.js: reset and restart flow for all game modesclient/game-manager.js: game factory/lifecycle coordinator that instantiates the active mode and starts its loopsclient/games/classic-game.js: classic mode adapterclient/games/racing-game.js: racing mode behavior and animationclient/games/meteorite-rain-game.js: meteorite rain gameplay loopclient/games/tower-defense-game.js: tower defense gameplay loop and UI updatesclient/typing-simulator.css: simulator visuals for all game modesclient/help.js: help modal bootstrapclient/design-system/components/modal/modal.js: design-system modal component used by help modal flowclient/help-content.html: help guide loaded into the modal at runtimeclient/config.json: runtime feature toggles and mode parametersclient/text-to-input.txt: source text used for typing content/word poolserver.js: API server for/save-statsand production static hostingextract_solution.py: utility that parses and printsclient/stats.txt
# first-time setup
git submodule update --init --recursive
npm install
# local dev (Vite on :3000, API server on :3001)
npm run start:dev
# production build
npm run build
# serve dist/ in production mode on :3000
npm run start:prod- Text source: client fetches
./text-to-input.txt - Config source: client fetches
./config.json - Stats write path:
- client POSTs plain text to
/save-stats - server writes payload to
client/stats.txt
- client POSTs plain text to
- Keep the app framework-free unless a migration is explicitly requested.
- Keep cross-cutting logic in the shared modules above; do NOT dump new behavior into
client/typing-simulator.jsunless it is truly initialization/orchestration code. - Keep mode-specific gameplay inside
client/games/and shared behavior in the top-level client modules. - Preserve the
idand class hooks used acrossclient/index.html,client/typing-simulator.js,client/help.js, and the game modules. - If you change gameplay behavior, update both
README.mdandclient/help-content.html. - If you add, remove, or rename client modules, update the runtime architecture sections in both this file and
README.mdin the same change. - If you change config keys or API payloads, update this file and README in the same change.
client/app.csscontains shared shell styles; keepclient/index.htmland the design-system asset includes aligned to that file.
- Run
npm run buildafter JavaScript/CSS/HTML changes. - For UI/flow changes, manually verify:
- help modal opens from
#btn-help - active game mode from
client/config.jsoninitializes the correct container and input flow - completion and restart flows still work
- affected game loops still start/reset correctly (
racing,meteoriteRain,towerDefense) - stats persist to
client/stats.txtthrough/save-stats
- help modal opens from