A browser extension that lets you challenge friends to real-time LeetCode duels.
git clone https://github.com/etbala/LeetCodeDuels.git
cd LeetCodeDuelsInstall Node.js (v22+) and Angular CLI.
npm install -g @angular/clicd extension
npm install
ng buildNote: Build using -c local if you are running the server locally:
ng build -c localLoad Unpacked Extension from Directory: /extension/dist/browser
For Chrome, see https://support.google.com/chrome/a/answer/2714278
For Firefox, see https://extensionworkshop.com/documentation/develop/temporary-installation-in-firefox/
Install Go (v1.24+).
Create a .env file in the /server directory by copying the template file: /server/.env.template.
Ensure final file is located at
LeetCodeDuels/server/.env
cd server
go run ./cmd/serverInstall and run Docker.
cd server
go test ./... -vInstall Grafana k6 and Powershell.
cd server/tests/k6
./stress-test.ps1graph TD
Frontend[Frontend]
subgraph Cluster [Horizontally Scaled Cluster]
direction LR
B1[Backend Instance]
B2[Backend Instance]
end
Postgres[Postgres]
Redis[Redis]
Frontend -- "REST API" --> Cluster
Frontend -- "WebSocket" --> Cluster
Cluster -- "SQL Queries" --> Postgres
Cluster --> |"Session & State Storage"| Redis
Cluster <--> |"Horizontal Communication (Pub/Sub)"| Redis
-
Frontend: This is the client-side application that the user interacts with. It communicates with the backend via:
-
REST API: Used for standard actions like user login, registration, fetching user profiles, etc. Generally, REST endpoints are used by Angular when loading webpage information.
-
WebSockets: Used for real-time, two-way communication required for gameplay, invitations, and live online status updates.
-
-
Backend Cluster: The core application logic resides in a horizontally scalable cluster of backend instances. Designing the server to be stateless allows us to run multiple instances behind a load balancer so the backend can automatically scale to meet demand.
-
Postgres: Long-term storage. Handles account information, game history, and mirrors a simplified version of leetcode's problem database. Generally accessed via REST endpoints.
-
Redis:
-
Session & State Storage: Stores temporary data like active game sessions, pending user invites, and which users are currently online (and which server instance they are connected to).
-
Horizontal Communication (Pub/Sub): Redis acts as a message bus for backend instances to communicate with each other. For example, if a user connected to Instance A sends a game invite to a user connected to Instance B, the message is published to a Redis channel, which delivers it to the correct instance.
-