SwiftKeys is a real-time online multiplayer typing platform where users can compete in typing games, join multiplayer rooms, and track their performance through live game updates and leaderboards.
The application is built as a full-stack web application with a React frontend, Node.js/Express backend, Socket.io for real-time communication, and MongoDB for persistent data.
- 🔐 User authentication
- ⚡ Real-time multiplayer gameplay
- 🎮 Multiplayer game rooms
- ⌨️ Real-time typing interaction
- 🏁 Casual and Challenging game modes
- 👥 Room-based multiplayer sessions
- 📊 Live player progress
- 🏆 Leaderboards
- 💾 Persistent game/user data
- 🔄 Real-time synchronization using WebSockets
- 📱 Responsive web interface
- React
- Vite
- Zustand — client-side state management
- Socket.io Client — real-time communication
- Axios — HTTP API communication
- Tailwind CSS — styling
- JavaScript / JSX
- Node.js
- Express.js
- Socket.io
- MongoDB
- Mongoose
- JWT — authentication
- bcrypt / bcryptjs — password hashing
- Cookie Parser
- CORS
- Zod — validation
- Vercel — frontend
- Render — backend
- MongoDB — database
SwiftKeys follows a client-server architecture with REST APIs handling persistent operations and Socket.io handling real-time multiplayer communication.
┌─────────────────────────┐
│ User Browser │
│ │
│ React + Vite + │
│ Zustand │
└───────────┬─────────────┘
│
┌───────────┴─────────────┐
│ │
HTTP API WebSocket
│ │
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Express Backend │ │ Socket.io Server │
│ │ │ │
│ Authentication │ │ Rooms │
│ REST APIs │ │ Game State │
│ Business Logic │ │ Player Updates │
└────────┬─────────┘ └────────┬─────────┘
│ │
└───────────┬─────────────┘
▼
┌────────────────┐
│ MongoDB │
│ │
│ Users │
│ Games/Sessions │
│ Leaderboards │
└────────────────┘
Users can create an account and authenticate before accessing the multiplayer functionality.
The backend handles:
- User registration
- Password hashing
- Login
- JWT-based authentication
- Authentication cookies
- Protected API requests
The frontend communicates with the backend using Axios with credentials enabled where required.
Players can participate in multiplayer typing sessions through Socket.io-powered rooms.
A typical multiplayer flow is:
User
│
▼
Create / Join Room
│
▼
Socket.io Connection
│
▼
Join Multiplayer Room
│
▼
Players Synchronize
│
▼
Typing Game Starts
│
▼
Live Progress Updates
│
▼
Game Completion
│
▼
Results / Leaderboard
Socket.io is used because multiplayer game state needs to be communicated between connected clients with low latency rather than relying entirely on repeated HTTP requests.
A standard multiplayer typing experience focused on completing the typing challenge and competing with other players.
A more competitive game mode designed to provide a higher level of difficulty and challenge during multiplayer sessions.
SwiftKeys uses Socket.io to synchronize multiplayer game state.
Instead of repeatedly polling the backend, connected players maintain a WebSocket-based communication channel.
This allows the server to communicate events such as:
- Room creation
- Room joining
- Player connection
- Player disconnection
- Game state changes
- Typing/progress updates
- Game completion
- Multiplayer results
The exact event names are implemented in the Socket.io client/server layer.
The frontend uses Zustand for application state management.
State is separated according to application responsibilities, including areas such as:
- Authentication
- Current user
- Multiplayer/game state
- Room information
- Player information
- Game progress
This keeps transient UI/game state on the client while persistent information is handled through the backend and MongoDB.
MongoDB is used as the persistent database and Mongoose provides the data modeling layer for the Node.js backend.
The database is responsible for storing application data such as:
- User information
- Authentication-related user data
- Game/session information
- Multiplayer-related persistent data
- Leaderboard/performance information
SwiftKeys/
│
├── backend/
│ ├── src/
│ │ ├── controllers/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── middleware/
│ │ └── ...
│ │
│ ├── package.json
│ └── .env
│
├── frontend/
│ └── vite-project/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── stores/
│ │ └── ...
│ │
│ ├── package.json
│ └── vite.config.js
│
├── README.md
├── package.json
└── package-lock.json
The exact internal file organization may evolve as the project grows.
Make sure you have:
- Node.js
- npm
- MongoDB or a MongoDB Atlas database
- Git
git clone https://github.com/Ravi7035/SwiftKeys.git
cd SwiftKeysThe repository contains independent frontend and backend applications, so dependencies should be installed in their respective directories.
cd backend
npm installCreate a .env file inside the backend directory.
PORT=5003
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secretAdd any other environment variables required by the backend configuration.
Never commit real credentials or secrets to GitHub.
Start the backend in development mode:
npm run devOr start it normally:
npm startOpen another terminal:
cd frontend/vite-project
npm install
npm run devThe Vite development server will provide the local frontend URL.
The frontend communicates with the backend API and Socket.io server configured for the application environment.
SwiftKeys has separate frontend and backend configuration because the frontend and backend are deployed independently.
Frontend
http://localhost:5173
Backend
http://localhost:5003
Frontend
https://swift-keys-gray.vercel.app
Backend
https://swiftkeys.onrender.com
The production frontend should communicate with the deployed backend rather than localhost.
The frontend uses Axios to communicate with the Express backend.
The production API follows the structure:
https://swiftkeys.onrender.com/api
Authentication requests and other persistent operations are handled through the REST API.
For cross-origin authenticated requests, the frontend and backend are configured to support credentials where required.
REST APIs are used for request/response operations, while Socket.io is used for real-time multiplayer communication.
HTTP
────
Frontend ───────────────► Express API
Frontend ◄─────────────── Express API
WebSocket
─────────
Frontend ◄══════════════► Socket.io Server
│
└── Multiplayer Events
This separation allows the application to use the appropriate communication mechanism for each type of operation.
The current deployment architecture is:
Internet
│
▼
┌────────────────────────┐
│ Vercel │
│ React/Vite Frontend │
└────────────┬───────────┘
│
HTTPS / API
│
▼
┌────────────────────────┐
│ Render │
│ Node.js + Express │
│ Socket.io │
└────────────┬───────────┘
│
▼
┌────────────────────────┐
│ MongoDB │
└────────────────────────┘
The frontend is deployed using Vercel.
Production URL:
https://swift-keys-gray.vercel.app
The backend is deployed using Render.
Production backend:
https://swiftkeys.onrender.com
Because the frontend and backend are hosted on different domains in production, the backend must explicitly allow requests from the frontend origin.
Development:
http://localhost:5173
Production:
https://swift-keys-gray.vercel.app
Credentials must also be configured consistently between Axios, Express CORS, and authentication cookies.
SwiftKeys uses token-based authentication with cookie support.
The authentication system includes:
- User registration
- Password hashing
- Login
- JWT generation
- Authentication cookie
- Protected backend requests
- Logout
Authentication state is consumed by the React frontend to control access to authenticated features.
The application includes several basic security mechanisms:
- Password hashing
- JWT-based authentication
- HTTP-only authentication cookies where configured
- CORS restrictions
- Environment variables for sensitive configuration
- Backend-side validation
- Separation of frontend and backend responsibilities
Secrets such as database credentials and JWT secrets should never be committed to the repository.
A typical development workflow is:
1. Start MongoDB
↓
2. Start Express backend
↓
3. Start Vite frontend
↓
4. Open application
↓
5. Authenticate
↓
6. Create / join multiplayer room
↓
7. Play typing game
↓
8. Verify real-time communication
↓
9. Verify persistent results
Potential improvements for future versions include:
- Automated testing for multiplayer game flows
- Better matchmaking
- Room lifecycle management
- Improved reconnect handling
- Rate limiting
- More detailed player statistics
- Match history
- Tournament mode
- Improved game synchronization
- Performance monitoring
- Automated CI/CD
- Horizontal scaling for Socket.io servers
These are potential extensions and are not required for the current application.
Frontend: https://swift-keys-gray.vercel.app
Repository: https://github.com/Ravi7035/SwiftKeys
Ravi Teja