A modern, production-ready touch typing practice website built with Next.js 15, TypeScript, and Tailwind CSS. Learn to type faster and more accurately through progressive lessons, speed tests, and real-time feedback.
- β 15 Progressive Lessons - From beginner (home row) to advanced (special characters)
- β Real-time WPM Calculation - Industry-standard Gross WPM and Net WPM metrics
- β Accuracy Tracking - Character-by-character accuracy with visual feedback
- β Speed Test Mode - Practice with randomized texts (500-1000 words)
- β Responsive Design - Works on desktop and mobile devices
- β Dark Mode Support - System-aware theme switching
- β Multiple Keyboard Layouts - QWERTY, Dvorak, Colemak, AZERTY, QWERTZ
- β
Multilingual Support (i18n) - 6 languages with database persistence for authenticated users
- English, Chinese, Japanese, Spanish, French, Thai
- Language preference synced across devices
- Full admin dashboard internationalization
- β SEO Optimized - Full metadata, sitemap, robots.txt, and social sharing
- β Docker Deployment - Complete Docker and Docker Compose setup
- β Testing & CI/CD - 98.64% test coverage with GitHub Actions automation
- β User Authentication - NextAuth.js 5.0 with email verification and OAuth (Google)
- β Admin Dashboard - Complete admin system with user/room management and analytics
- β Role-Based Access - First user becomes admin, automatic role assignment
- β Email Verification - SMTP-based email verification for new user registrations
- β Progress Tracking - MongoDB storage with sync API for authenticated users
- β Multiplayer Mode - Real-time typing games with Socket.IO
- β Leaderboards - Global and friend leaderboards with player statistics
- π§ Achievements & Gamification - Badges and rewards system (coming soon)
- Next.js 16.0.1 - React framework with App Router and Turbopack
- React 19.2.0 - Latest React features
- TypeScript 5 - Type-safe development
- Tailwind CSS 3.4 - Utility-first CSS framework
- Framer Motion 12.0 - Smooth animations
- Chart.js 4.4 - Data visualization
- React Chart.js 2 - React wrapper for Chart.js
- Clsx & Tailwind Merge - Dynamic className utilities
- Zustand 5.0 - State management
- NextAuth 5.0 (Beta 30) - Authentication solution with role-based access
- MongoDB 6.12 - NoSQL database
- Mongoose 8.9 - MongoDB ODM
- @auth/mongodb-adapter - NextAuth MongoDB integration
- Socket.IO 4.8 - Real-time bidirectional communication for multiplayer
- Nodemailer 6.9 - SMTP email sending for verification
- Redis 4.7 - Caching, session management, and real-time data
- bcryptjs 2.4 - Password hashing
- Zod 3.24 - Schema validation
- Custom i18n - React Context-based i18n system with NextAuth integration
- 6 Languages - English, Chinese, Japanese, Spanish, French, Thai (68+ keys per language)
- Database Persistence - Language preference saved to MongoDB for authenticated users
- Cross-Device Sync - Settings synchronized across devices and browsers
- ESLint 9 - Code linting
- Jest 29 - Testing framework with 98.64% code coverage
- @testing-library/react - React component testing
- @testing-library/jest-dom - DOM matchers for Jest
- PostCSS 8 - CSS processing
- Autoprefixer - CSS vendor prefixes
- Turbopack - Fast bundling (Next.js 16)
- Node.js 18+
- npm or pnpm
- MongoDB (optional, for user features)
- Redis (optional, for caching)
- Clone the repository:
git clone https://github.com/yourusername/typingtoy.git
cd typingtoy- Install dependencies:
npm install- Create environment file:
cp .env.local.example .env.local- Edit
.env.localwith your configuration:
# Database
MONGODB_URI=mongodb://localhost:27017/typingstudy
REDIS_URL=redis://localhost:6379
# Authentication
NEXTAUTH_SECRET=your-secret-key-here
NEXTAUTH_URL=http://localhost:3000
# Email (SMTP) - Required for email verification
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password
SMTP_FROM=typingtoy@444666.best
# Support Email (publicly visible for contact links)
NEXT_PUBLIC_SUPPORT_EMAIL=typingtoy@444666.best
# OAuth (Optional)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret- Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
The project includes a comprehensive unit test suite with 98.64% code coverage.
# Run all tests
npm test
# Run tests in watch mode (for development)
npm run test:watch
# Generate coverage report
npm run test:coverageTests cover:
- Typing Metrics - WPM and accuracy calculations
- Progress Storage - LocalStorage operations
- User Settings - Settings management
- Device ID - Device identification
- Skill Rating - Player rating calculations
- Sound Effects - Audio system
- Text Generator - Random text generation
- Name Generator - Display name generation
- Profanity Filter - Content filtering
- Lessons Data - Lesson structure validation
GitHub Actions workflow automatically runs tests on:
- Pull requests
- Pushes to main and dev branches
- Node.js 18 and 20 environments
typingtoy/
βββ app/ # Next.js App Router pages
β βββ api/ # API routes
β β βββ auth/ # NextAuth endpoints
β β β βββ register/ # User registration API
β β β βββ verify-email/ # Email verification API
β β βββ admin/ # Admin API routes
β β β βββ stats/ # Platform statistics
β β β βββ statistics/ # Detailed analytics
β β β βββ users/ # User management CRUD
β β β βββ rooms/ # Room management CRUD
β β βββ generate-text/ # Text generation API
β β βββ user/ # User data sync
β βββ admin/ # Admin dashboard (protected)
β β βββ layout.tsx # Admin layout with role check
β β βββ page.tsx # Admin dashboard
β β βββ users/ # User management page
β β βββ rooms/ # Room management page
β β βββ statistics/ # Analytics dashboard
β βββ auth/ # Authentication pages
β β βββ signin/ # Sign in page
β β βββ signup/ # Sign up page
β β βββ verify-email/ # Email verification page
β βββ lessons/ # Lesson pages
β β βββ page.tsx # Lessons list
β β βββ layout.tsx # Lessons metadata
β β βββ [id]/ # Individual lesson
β β βββ page.tsx # Lesson content
β β βββ layout.tsx # Dynamic metadata
β βββ test/ # Speed test page
β β βββ page.tsx # Test interface
β β βββ layout.tsx # Test metadata
β βββ practice/ # Custom practice
β β βββ page.tsx # Practice interface
β β βββ layout.tsx # Practice metadata
β βββ progress/ # Progress tracking
β β βββ page.tsx # Progress dashboard
β β βββ layout.tsx # Progress metadata
β βββ layout.tsx # Root layout with SEO
β βββ page.tsx # Home page
β βββ globals.css # Global styles
β βββ sitemap.ts # Dynamic sitemap
β βββ robots.ts # Dynamic robots.txt
βββ components/ # React components
β βββ TypingTest.tsx # Main typing test component
β βββ VirtualKeyboard.tsx # Keyboard visualization
β βββ HandDiagram.tsx # Hand position guide
β βββ LanguageSelector.tsx # Language switcher
β βββ UserMenu.tsx # User dropdown menu
β βββ TipsBanner.tsx # Tips for unregistered users
β βββ SessionProvider.tsx # NextAuth provider wrapper
βββ lib/ # Utilities and services
β βββ db/ # Database setup
β β βββ mongodb.ts # MongoDB connection
β β βββ models/ # Mongoose models
β β βββ User.ts # User model with role field
β β βββ VerificationToken.ts # Email verification tokens
β βββ admin.ts # Admin helper functions
β βββ i18n/ # Internationalization
β β βββ index.ts # i18n configuration
β β βββ LanguageContext.tsx # React context for i18n
β β βββ locales/ # Translation files
β β βββ en.ts # English
β β βββ zh.ts # Chinese
β β βββ ja.ts # Japanese
β β βββ es.ts # Spanish
β β βββ fr.ts # French
β β βββ th.ts # Thai
β βββ services/ # Business logic
β β βββ typingMetrics.ts # WPM/accuracy calculations
β β βββ progressStorage.ts # Progress tracking
β β βββ userSettings.ts # User settings management
β β βββ emailService.ts # SMTP email sending
β βββ utils/ # Helper functions
β β βββ textGenerator.ts # Random text generation
β βββ data/ # Static data
β βββ lessons.ts # Lesson content
β βββ keyboardLayout.ts # Keyboard layouts
βββ types/ # TypeScript type definitions
β βββ index.ts # Shared types
βββ public/ # Static assets
β βββ icon.svg # App icon (512x512)
β βββ favicon.svg # Favicon (32x32)
β βββ apple-touch-icon.svg # iOS icon (180x180)
β βββ manifest.json # PWA manifest
β βββ robots.txt # Static robots.txt
βββ docker-compose.yml # Docker Compose config
βββ Dockerfile # Docker build config
βββ Makefile # Docker commands
βββ package.json # Dependencies
The application uses industry-standard formulas:
Gross WPM (Raw Speed)
Gross WPM = (Total Characters Γ· 5) Γ· Time in Minutes
Net WPM (Adjusted for Errors)
Net WPM = Gross WPM - (Uncorrected Errors Γ· Time in Minutes)
Accuracy
Accuracy = (Correct Characters Γ· Total Characters) Γ 100
The TypingTest component (components/TypingTest.tsx) handles:
- Real-time keystroke tracking
- Visual feedback (green for correct, red for errors)
- Live WPM and accuracy updates every second
- Completion detection and final metrics
15 progressive lessons covering:
- Lessons 1-4: Home row keys (ASDF JKL;)
- Lessons 5-8: Top row keys (QWERTY UIOP)
- Lessons 9-12: Bottom row keys (ZXCV BNM,.)
- Lesson 13: Number keys (0-9)
- Lesson 14: Special characters (!@#$%^&*)
- Lesson 15: Master challenge (all keys)
Email Verification
- New user registrations require email verification via SMTP
- Verification tokens expire after 24 hours
- Automatic token cleanup using MongoDB TTL indexes
- First registered user automatically becomes admin (no verification required)
Role-Based Access Control
- Two roles:
user(default) andadmin - First user in database automatically assigned
adminrole - OAuth users (Google) follow same first-user-becomes-admin logic
- Admin role persisted in JWT token and session
Admin Dashboard (/admin)
- Protected route requiring
adminrole - User management: View, search, update roles, delete users
- Room management: Monitor and manage multiplayer rooms
- Statistics: Platform analytics with Chart.js visualizations
- Noindex meta tags prevent search engine indexing
The application uses Nodemailer for SMTP email sending. To enable email verification:
-
Gmail Setup (Recommended for development):
- Enable 2-factor authentication on your Google account
- Generate an App Password at https://myaccount.google.com/apppasswords
- Use these settings:
SMTP_HOST=smtp.gmail.com SMTP_PORT=587 SMTP_SECURE=false SMTP_USER=your-email@gmail.com SMTP_PASSWORD=your-app-password
-
Other SMTP Providers:
- Port 587: Use
SMTP_SECURE=false(STARTTLS) - Port 465: Use
SMTP_SECURE=true(SSL/TLS)
- Port 587: Use
-
Test Email Configuration:
npx tsx scripts/test-email.ts
For complete Docker deployment instructions, see docs/DOCKER.md.
Quick start:
# Copy environment file
cp .env.example .env
# Start with Docker Compose
docker compose up -d
# Or use the helper script
./docker-start.sh dev- Push your code to GitHub
- Import the project in Vercel
- Add environment variables in Vercel dashboard
- Deploy!
npm run build- Getting Started - Setup and installation guide
- Architecture - Technical architecture details
- Admin System - Admin dashboard and role management guide
- Docker Deployment - Complete Docker guide
- SEO Guide - SEO configuration and best practices
- Features - Detailed feature documentation
- Basic typing test interface
- Real-time WPM/accuracy calculation
- 15 progressive lessons
- Speed test mode with generated text (500-1000 words)
- Responsive design with dark mode
- Virtual keyboard visualization
- Hand position diagrams
- Multi-language support (6 languages)
- English, Chinese, Japanese, Spanish, French, Thai
- Custom i18n system with React Context
- Language selector component
- Multiple keyboard layouts (QWERTY, Dvorak, Colemak, etc.)
- NextAuth 5.0 authentication with JWT
- Email verification system (SMTP with Nodemailer)
- OAuth integration (Google Sign-In)
- Role-based access control (user/admin roles)
- First-user-becomes-admin logic
- Admin dashboard with user/room management
- Platform statistics and analytics with Chart.js
- MongoDB user data storage
- Progress tracking and history (MongoDB with sync API)
- User profiles and settings
- Cloud sync for authenticated users
- Leaderboards (global and friends)
- Achievement system (planned)
- Full SEO optimization (metadata, OG tags, Twitter cards)
- Dynamic sitemap.xml generation
- robots.txt configuration
- PWA manifest
- Docker & Docker Compose setup
- Production deployment ready
- Jest testing framework setup
- Unit tests for core functionality
- 98.64% code coverage achieved
- GitHub Actions CI/CD pipeline
- Automated testing on PRs
- Multi-version Node.js testing (18, 20)
- Real-time multiplayer typing games (Socket.IO)
- Room creation and management
- Online player list with presence tracking
- Global leaderboards
- Friend leaderboards
- Player statistics and rankings
- Quick match system
- Game lobby with chat
- Custom text practice presets
- Export typing data
- Additional typing games
- Daily challenges
- Streak tracking
- Achievement badges and rewards system
- Code snippet practice mode
- Advanced analytics dashboard
- Team competitions
- Live tournaments
- Season rankings
- Advanced matchmaking with ELO ratings
- Spectator mode for tournaments
- Replay system
- Lighthouse Score: 95+ (Performance)
- First Contentful Paint: < 1s
- Time to Interactive: < 2s
- Bundle Size: ~150KB (gzipped)
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+
- Mobile browsers (iOS Safari, Chrome Mobile)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
- Inspired by Monkeytype
- Built with Next.js
- Styled with Tailwind CSS
For questions or feedback, please open an issue on GitHub.
Happy Typing! π