A modern, real-time typing application built with React, TypeScript, and PartyKit that enables users to practice typing while allowing others to spectate their sessions in real-time.
- Overview
- Features
- Technology Stack
- Project Structure
- Getting Started
- Usage
- Architecture
- API Reference
- Development
- Testing
- Deployment
- Contributing
- Future Improvements
- License
The Real-time Typing Trainer is a web application that combines traditional typing practice with modern real-time collaboration features. Users can create typing sessions where they practice typing while spectators watch their progress in real-time. The application provides comprehensive typing statistics, error tracking, and a clean, responsive user interface.
- Real-time Typing Sessions: Create sessions where others can watch your typing in real-time
- Spectator Mode: Join sessions to watch others type with live updates
- Solo Practice: Practice typing without real-time features
- Comprehensive Statistics: Track WPM, accuracy, and timing metrics
- Error Tracking: Visual feedback for typing errors with backspace correction
- Responsive Design: Works seamlessly across desktop and mobile devices
-
Session Management
- Create new typing sessions with custom names
- Join existing sessions as spectator or typist
- Generate shareable session links
- Solo practice mode for individual training
-
Real-time Collaboration
- Live typing updates for spectators
- Connection status monitoring
- Automatic reconnection on network issues
- Session state synchronization
-
Typing Analytics
- Words Per Minute (WPM) calculation
- Accuracy percentage tracking
- Error position highlighting
- Session timing and duration
-
User Experience
- Clean, modern interface with Tailwind CSS
- Responsive design for all screen sizes
- Real-time connection status indicators
- Intuitive session management
- Type Safety: Full TypeScript implementation with strict type checking
- State Management: React Context with useReducer for predictable state updates
- Real-time Communication: WebSocket-based communication via PartyKit
- Performance Optimization: Efficient re-rendering and state updates
- Error Handling: Comprehensive error handling and user feedback
- React 19: Modern React with latest features
- TypeScript: Type-safe development
- TanStack Router: File-based routing with type safety
- Tailwind CSS: Utility-first CSS framework
- Vite: Fast build tool and development server
- PartyKit: Real-time serverless platform for WebSocket connections
- PartySocket: WebSocket client for real-time communication
- ESLint: Code linting with Antfu's configuration
- Prettier: Code formatting
- Vitest: Unit testing framework
- Testing Library: React component testing utilities
- Vite: Build tooling and bundling
- TypeScript Compiler: Type checking and compilation
- PartyKit Deploy: Serverless deployment platform
- Node.js 18+ or Bun
- Package manager: pnpm (recommended), bun, or npm
-
Clone the repository
git clone <repository-url> cd typing
-
Install dependencies
# Using pnpm pnpm install # Using bun (recommended) bun install # Using npm npm install
-
Start the development servers
# Start both frontend and PartyKit server bun run dev:all # Or start them separately bun run dev # Frontend on port 3000 bun run dev:party # PartyKit server on port 1999
-
Open the application Navigate to
http://localhost:3000in your browser
The application automatically detects the environment:
- Development: Uses
localhost:1999for PartyKit server - Production: Uses
typing-trainer.oluwasetemi.partykit.dev
No additional environment variables are required for local development.
- Start the application and you'll see the session manager
- Enter a session name (optional) in the "Start a Typing Session" section
- Click "Create Session" to generate a new session
- Share the Session ID or spectator link with others
- Click "Start Typing" to begin your session
- Enter a Session ID in the "Watch a Session" section
- Click "Join as Spectator" to watch the typing session
- View real-time updates as the typist progresses
- Click "Start Solo Practice" in the session manager
- Practice typing without real-time features
- View your statistics after completing the text
- Type the displayed text character by character
- Use backspace to correct errors (removes error markers)
- View real-time statistics including WPM and accuracy
- See progress through the text with visual indicators
The application follows a component-based architecture with clear separation of concerns:
- Components: Reusable UI components with specific responsibilities
- Hooks: Custom hooks for business logic and state management
- Context: Global state management for typing sessions
- Routes: File-based routing with TanStack Router
The real-time functionality is built on PartyKit's WebSocket infrastructure:
Client (React) ←→ PartyKit Server ←→ Other Clients
↓ ↓ ↓
WebSocket Session State WebSocket
Connection Management Connection
The application uses a combination of React Context and local state:
- TypingContext: Manages typing state (text, errors, timing)
- RealtimeState: Handles WebSocket connections and spectator data
- Local State: Component-specific state (modals, forms)
- Session Creation: User creates session → PartyKit room created
- Connection: Clients connect via WebSocket with role (typist/spectator)
- Typing Updates: Typist actions → Server → Broadcast to spectators
- State Sync: All clients maintain synchronized session state
-
TYPING_UPDATE: Broadcast typing progress
{ "type": "TYPING_UPDATE", "data": { "sourceText": "string", "currentIndex": "number", "errors": "number[]", "typedText": "string", "startTime": "number | null", "finished": "boolean" }, "timestamp": "number" } -
SESSION_END: Signal session completion
{ "type": "SESSION_END", "data": {}, "timestamp": "number" }
- SESSION_INIT: Initialize typist session
- SPECTATOR_INIT: Initialize spectator session
- TYPING_UPDATE: Real-time typing progress
- SESSION_START: Session started notification
- SESSION_END: Session ended notification
- SPECTATOR_JOIN/LEAVE: Spectator count updates
- CONNECTION_REJECTED: Connection failure notification
Manages real-time typing functionality.
Parameters:
roomId: string- Session identifierrole: 'typist' | 'spectator'- User roleuserId?: string- Optional user identifierenabled?: boolean- Enable/disable connectionhost?: string- PartyKit server host
Returns:
realtimeState: RealtimeTypingState- Current stateisConnected: boolean- Connection statusconnectionError: string | null- Error informationconnect(): void- Manual connectiondisconnect(): void- Manual disconnectionbroadcastTypingUpdate(state): void- Send updatesbroadcastSessionEnd(): void- End session
Manages session creation and joining.
Returns:
createSession(name?): Session- Create new sessionjoinSession(id): void- Join existing sessiongetSessionUrl(id, role): string- Generate session URL
// Calculate Words Per Minute
calcWPM(charsTyped: number, elapsedMs: number): number;
// Calculate accuracy percentage
calcAccuracy(errors: number, total: number): number;
// Format time duration
formatTime(milliseconds: number): string;
# Development
bun run dev # Start frontend development server
bun run dev:party # Start PartyKit development server
bun run dev:all # Start both servers concurrently
# Building
bun run build # Build for production
bun run serve # Preview production build
# Code Quality
bun run lint # Run ESLint
bun run format # Run Prettier
bun run check # Format and lint
# Testing
bun run test # Run unit tests
# Deployment
bun run deploy:party # Deploy PartyKit serverThe project follows strict coding standards:
- TypeScript: Strict type checking enabled
- ESLint: Antfu's configuration with React rules
- Prettier: Consistent code formatting
- Naming Conventions:
- Files: kebab-case (
my-component.tsx) - Variables: camelCase (
myVariable) - Types: PascalCase (
MyInterface) - Constants: UPPER_CASE (
MAX_COUNT)
- Files: kebab-case (
- Create components in appropriate directories
- Add custom hooks for business logic
- Update types in relevant files
- Add tests for new functionality
- Update documentation as needed
# Run all tests
bun run test
# Run tests in watch mode
bun run test --watch
# Run tests with coverage
bun run test --coverageTests are located alongside the code they test:
src/utils/__tests__/- Utility function tests- Component tests can be added as
*.test.tsxfiles
The project uses:
- Vitest: Fast unit testing framework
- Testing Library: React component testing utilities
- jsdom: DOM simulation for browser APIs
# Deploy to PartyKit
bun run deploy:partyThe server will be available at: typing-trainer.oluwasetemi.partykit.dev
The frontend can be deployed to any static hosting service:
-
Build the application
bun run build
-
Deploy the
dist/directory to your hosting service -
Update the PartyKit host in the code if using a custom domain
- Development: Automatically uses localhost
- Production: Uses deployed PartyKit server
- Custom: Update host configuration in
useRealtimeTypinghook
- Fork the repository
- Create a feature branch
git checkout -b feature/your-feature-name
- Make your changes following the coding standards
- Add tests for new functionality
- Run the test suite
bun run check bun run test - Commit your changes
git commit -m "feat: add your feature description" - Push to your fork
git push origin feature/your-feature-name
- Create a Pull Request
- All changes require review
- Tests must pass
- Code must follow style guidelines
- Documentation should be updated
- User Authentication: Implement user accounts with persistent statistics
- Session History: Save and retrieve past typing sessions
- Custom Text Input: Allow users to upload or paste their own practice texts
- Keyboard Layout Support: Add support for different keyboard layouts (QWERTY, Dvorak, Colemak)
- Dark Mode: Implement theme switching with system preference detection
- Connection Resilience: Implement exponential backoff for reconnection attempts
- Offline Support: Add service worker for offline typing practice
- Performance Monitoring: Integrate Web Vitals tracking and performance metrics
- Error Boundaries: Add React error boundaries for better error handling
- Multi-language Support: Add support for different languages and character sets
- Typing Modes: Implement different practice modes (timed, word count, accuracy focus)
- Progress Tracking: Long-term progress tracking with charts and analytics
- Typing Tests: Standardized typing tests with difficulty levels
- Detailed Statistics: Character-level analysis, common error patterns
- Performance Insights: Identify weak areas and suggest improvements
- Comparative Analysis: Compare performance across different text types
- Export Functionality: Export statistics and progress data
- Multi-typist Sessions: Allow multiple people to type simultaneously
- Typing Competitions: Real-time typing competitions with leaderboards
- Team Sessions: Group typing sessions for teams or classrooms
- Session Recording: Record and replay typing sessions
- Mobile App: Native mobile application for iOS and Android
- Touch Typing Support: Optimize for mobile keyboard input
- Accessibility Improvements: Screen reader support, keyboard navigation
- Voice Commands: Voice-activated session management
- Adaptive Text Selection: AI-curated text based on user skill level
- Error Prediction: Machine learning to predict and prevent common errors
- Personalized Training: Custom training programs based on individual weaknesses
- Smart Suggestions: Real-time suggestions for improving typing technique
- Desktop Application: Native desktop app with system integration
- Browser Extension: Chrome/Firefox extension for typing practice
- API Platform: Public API for third-party integrations
- Educational Integration: LMS integration for educational institutions
- Video Integration: Optional video streaming during typing sessions
- Screen Sharing: Share screen content during typing sessions
- Collaborative Editing: Real-time collaborative text editing
- Voice Chat: Integrated voice communication for sessions
- Team Management: Admin dashboard for managing team typing sessions
- Compliance Tracking: Track typing proficiency for compliance requirements
- Custom Branding: White-label solution for organizations
- Advanced Analytics: Enterprise-level reporting and analytics
- Database Integration: Persistent storage for user data and statistics
- CDN Implementation: Global content delivery for better performance
- Microservices Architecture: Break down monolithic structure
- Container Orchestration: Kubernetes deployment for scalability
- Component Library: Extract reusable components into separate package
- Storybook Integration: Component documentation and testing
- E2E Testing: Comprehensive end-to-end testing with Playwright
- CI/CD Pipeline: Automated testing and deployment
- Data Encryption: End-to-end encryption for sensitive data
- Privacy Controls: Granular privacy settings for sessions
- GDPR Compliance: Full compliance with data protection regulations
- Security Auditing: Regular security audits and penetration testing
- Biomechanical Analysis: Study of typing patterns and ergonomics
- Cognitive Load Research: Understanding mental aspects of typing
- Accessibility Research: Improving typing for users with disabilities
- Performance Optimization: Research into optimal typing techniques
- WebAssembly Integration: High-performance typing algorithms
- WebRTC Implementation: Peer-to-peer real-time communication
- Blockchain Integration: Decentralized session management
- AR/VR Support: Virtual reality typing environments
This roadmap represents a comprehensive vision for evolving the Real-time Typing Trainer into a full-featured platform that serves individual learners, educational institutions, and enterprise customers while maintaining the core simplicity and effectiveness of the current implementation.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ using React, TypeScript, and PartyKit