Skip to content

cwklurks/codesprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeSprint

Next.js 15 React 19 Monaco Editor


CodeSprint demo

A code typing trainer that builds real syntax muscle memory.
Practice 1,800+ real LeetCode snippets across Python, JavaScript, Java, and C++
with syntax-aware scoring, spaced repetition, and adaptive difficulty.

Features  ·  How It Works  ·  Data Pipeline  ·  Running Locally

Why?

Most typing tests measure how fast you can type English. That doesn't translate when you're writing code full of brackets, operators, and indentation.

CodeSprint exists because syntax fluency matters — in interviews and in daily work. It lets you drill patterns like "Depth First Search in Python" or "Ring Buffer in C++" until your fingers know the shape of the code.

Note

CodeSprint runs entirely client-side. No account, no backend, no data leaves your browser.

Features

Syntax-Aware Scoring

CodeSprint tokenizes each snippet by language and weights different constructs differently:

  • Keywords and operators — weighted 1.5×
  • Delimiters (brackets, parens) — weighted 1.2×
  • Whitespace — weighted 0.5×

You get three metrics per session: raw WPM, adjusted WPM (only perfect words), and a pattern score that reflects how well you nailed the actual code constructs.

Spaced Repetition

Built on the SM-2 algorithm (the same one behind Anki). CodeSprint tracks per-snippet mastery and schedules reviews based on your performance. Snippets you struggle with come back sooner; ones you've nailed fade into longer intervals.

Adaptive Difficulty

Tracks your proficiency per language and recommends what to practice next. Adjusts difficulty based on your recent accuracy and speed so you're always working at the edge of your ability.

Achievements & Progression

30+ achievements across speed, accuracy, consistency, and exploration categories with rarity tiers from common to legendary. An XP system with leveling tracks overall progress, and streak tracking keeps you coming back daily.

Customizable Editor
  • 18+ color themes
  • Vim mode support
  • Configurable font size, caret width, and syntax highlighting level
  • Panel mode or immersive/terminal mode for distraction-free practice
  • Optional countdown timer before sessions
Multi-Language Support

1,800+ real snippets sourced from LeetCode problems across four languages (JavaScript, Python, Java, C++) and three difficulty tiers (easy, medium, hard), categorized by length.

How It Works

The Editor

CodeSprint runs a heavily customized Monaco Editor instance. It uses deltaDecorations to paint correct/incorrect keystrokes directly onto the editor model without breaking syntax highlighting, and overlays a custom caret that animates smoother than the native DOM cursor.

The Typing Engine

React's render cycle is too slow for a 100+ WPM feedback loop. The typing engine (hooks/useTypingEngine.ts) isolates keystroke logic from the React render tree, only triggering re-renders for specific UI updates like the WPM gauge. Metrics are recalculated on a throttled interval rather than every keystroke.

Storage

Everything runs client-side. Session history, achievements, mastery records, and XP live in IndexedDB with localStorage as a fallback for preferences. Data export is available in CSV and JSON formats.

Data Pipeline

Snippets are sourced from LeetCode via a custom GraphQL scraper that reverse-engineers their API. To sync fresh snippets:

# Requires Bun (https://bun.sh)
npm run sync:leetcode -- --limit 50 --difficulties medium,hard

This queries the LeetCode questionData endpoint, extracts code snippets for all four languages, strips docstrings and excessive comments, normalizes indentation, and outputs a categorized JSON catalog.

After syncing, build the processed snippet files with tokenization metadata:

npm run build:snippets

Running Locally

# Install dependencies
npm install

# Start the dev server (Next.js 15 + Turbopack)
npm run dev

Open http://localhost:3000.

Testing
npm run test         # Unit tests (Vitest)
npm run test:watch   # Watch mode
npm run test:e2e     # E2E tests (Playwright)
Production Build
npm run build
npm start

Roadmap

  • Custom Renderer — Migrating from Monaco to a WebGL/Canvas text renderer for zero DOM overhead (Gap Buffer implementation in progress).
  • Tree-sitter Integration — Semantic typing that lets you skip whitespace and formatting irrelevant to code logic.
  • Advanced Analytics — Pattern weakness identification across sessions.

License

MIT.

About

CodeSprint is a typing practice environment for software engineers that uses real LeetCode-style code snippets instead of lorem ipsum, tracking WPM, accuracy, and errors in real time inside a minimal, keyboard‑first Next.js/React UI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages