KeySmasher is a modern, full-stack, multiplayer typing speed test and racing application. It allows users to practice typing, compete in real-time typing races, track their progress, and view leaderboards. Built with a React + Vite frontend and an Express + MongoDB backend, KeySmasher offers a sleek, responsive UI and robust real-time features powered by Socket.IO.
- Typing Practice: Solo typing tests with WPM, accuracy, and score calculation.
- Multiplayer Races: Join or create rooms to race against friends or random users in real-time.
- Leaderboard: Track top performers and your own stats.
- User Profiles: View and edit your profile, track your typing history and stats.
- Customizable Settings: Adjust test duration, dark mode, and more.
- Responsive UI: Works seamlessly on desktop and mobile devices.
- Real-time Updates: Powered by Socket.IO for instant race updates.
Frontend:
- React 19
- TailwindCSS for styling
- React Router for navigation
- React Icons for UI elements
Backend:
- Node.js + Express
- MongoDB (via Mongoose)
- Socket.IO for real-time communication
- JWT for authentication
- BcryptJS for password hashing
- Node.js (v18+ recommended)
- npm or yarn
- MongoDB (local or cloud instance)
-
Clone the repository:
git clone https://github.com/yourusername/KeySmasher.git cd KeySmasher -
Install dependencies for both frontend and backend:
cd frontend npm install cd ../backend npm install
-
Set up environment variables:
- Copy
.env.exampleto.envin thebackend/directory and fill in your MongoDB URI and JWT secret.
- Copy
Start the backend:
cd backend
npm startStart the frontend:
cd frontend
npm run dev- The frontend will typically run on http://localhost:5173
- The backend will run on http://localhost:3000 (or as configured)
KeySmasher/
β
βββ frontend/ # React + Vite frontend
β βββ src/
β β βββ components/ # UI components (TypingBox, TypingArea, LeaderBoard, etc.)
β β βββ pages/ # Main pages (Profile, Settings, RoomPage, etc.)
β β βββ context/ # React context for global state
β β βββ utils/ # Utility functions (text generation, result calculation)
β β βββ App.jsx # Main app entry
β βββ ... # Config files, public assets, etc.
β
βββ backend/ # Express + MongoDB backend
β βββ controllers/ # Route controllers (user, room, result)
β βββ models/ # Mongoose models (User, Room, Result)
β βββ routes/ # API route definitions
β βββ sockets/ # Socket.IO logic
β βββ middlewares/ # Express middlewares (auth, error handling)
β βββ config/ # DB and environment config
β βββ server.js # Main server entry point
β
βββ README.md # Project documentation
- Solo Typing Test: Visit the home page and start typing to test your speed and accuracy.
- Multiplayer Race: Create or join a room to compete with others in real-time. The race starts with a countdown and results are shown at the end.
- Profile & Stats: View your typing history, stats, and edit your profile.
- Leaderboard: See how you rank against other users.
The backend exposes RESTful endpoints under /api/:
POST /api/user/register- Register a new userPOST /api/user/login- Login and receive JWTGET /api/user/profile- Get user profile (auth required)POST /api/room/create- Create a new race roomPOST /api/room/join- Join an existing roomGET /api/room/:id- Get room detailsPOST /api/result- Submit typing resultGET /api/result/user/:id- Get user results
See the backend
routes/andcontrollers/for more details.
Contributions are welcome! To contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes
- Push to your fork and submit a pull request
Please open issues for suggestions or bug reports.
- Inspired by popular typing test platforms like Monkeytype and TypeRacer.