Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 

Repository files navigation

TypeBrawl

A real-time multiplayer typing battle game inspired by MonkeyType, featuring low-latency WebSocket synchronization, a live leaderboard, and anti-cheat mechanisms. The system uses Redis for caching & pub/sub events, PostgreSQL for persistent data, and React + WebSockets for a smooth frontend experience.


πŸš€ Features

βœ… Real-Time Multiplayer Battles – Instant input tracking using WebSockets
βœ… Live Leaderboard – Updates every second via Redis
βœ… Dynamic Prompt Generation – AI-generated or pre-stored texts
βœ… Fair Gameplay & Anti-Cheat – Detects unnatural typing speeds
βœ… Reconnect Support – Players can resume mid-game
βœ… Global Deployment – Low-latency performance using Redis & WebSockets


πŸ›  Tech Stack

Frontend:

  • React (Vite) + Tailwind CSS – Responsive UI
  • Native WebSockets (WebSocket API) – Real-time updates
  • Web Workers – Offload intensive WPM calculations
  • Service Workers – Background sync & offline support

Backend:

  • Node.js (Express + ws) – WebSocket & API server
  • Redis (Pub/Sub & Leaderboards) – Ultra-fast real-time updates
  • PostgreSQL (pg module) – Persistent storage for game history
  • Kafka – Event-driven architecture for analytics

Infrastructure & Scaling:

  • Docker + Kubernetes – Containerized deployment
  • Cloudflare (WebSocket Proxying) – Reduce latency globally
  • AWS (EC2) – Scalable backend hosting
  • Redis Cluster + Sentinel – High-availability caching

πŸ“‚ Folder Structure

/TypeBrawl
│── backend/                # Node.js WebSocket & API Server  
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/    # Game logic & matchmaking  
β”‚   β”‚   β”œβ”€β”€ services/       # Prompt generation, leaderboard handling  
β”‚   β”‚   β”œβ”€β”€ utils/          # Rate limiting, anti-cheat checks  
β”‚   β”‚   β”œβ”€β”€ database.js     # Raw PostgreSQL (pg module) connection  
β”‚   β”‚   β”œβ”€β”€ redis.js        # Redis connection  
β”‚   β”‚   β”œβ”€β”€ index.js        # WebSocket server  
β”‚   β”‚   β”œβ”€β”€ api.js          # Express API routes  
β”‚   β”œβ”€β”€ Dockerfile          
│── frontend/               # React Client  
β”‚   β”œβ”€β”€ src/  
β”‚   β”‚   β”œβ”€β”€ components/     # UI components  
β”‚   β”‚   β”œβ”€β”€ hooks/          # WebSocket & state management  
β”‚   β”‚   β”œβ”€β”€ pages/          # Game UI, leaderboard  
β”‚   β”œβ”€β”€ package.json  
β”‚   β”œβ”€β”€ Dockerfile  
│── docker-compose.yml      # Redis + PostgreSQL setup  
│── README.md  

πŸ”§ Setup Instructions

1️⃣ Clone the Repository

git clone https://github.com/yourusername/TypeBrawl.git
cd TypeBrawl

2️⃣ Start Backend

cd backend
npm install
npm start

3️⃣ Start Frontend

cd frontend
npm install
npm run dev

4️⃣ Run Redis & PostgreSQL (Docker)

docker-compose up -d

πŸ“ Roadmap

  • Implement WebRTC for lower-latency communication
  • Add AI-generated typing prompts
  • Introduce ranking & competitive matchmaking

πŸ“œ License

MIT


About

A real-time multiplayer typing battle game inspired by MonkeyType, featuring low-latency WebSocket synchronization, a live leaderboard, and anti-cheat mechanisms. The system uses Redis for caching & pub/sub events, PostgreSQL for persistent data, and React + WebSockets for a smooth frontend experience.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors