A real-time checkbox grid app built with Express, Socket.IO, Redis/Valkey, and OIDC authentication.
- Large checkbox grid rendered in the browser
- Real-time checkbox updates through Socket.IO
- Shared checkbox state stored in Redis/Valkey
- Manual socket rate limiting
- OIDC-based authentication and session handling
Create a .env file with these values:
PORT- server port for the Express appCLIENT_SERVER_PORT- client/server port used in auth redirectsAUTH_SERVER_PORT- OIDC auth server portOIDC_CLIENT_ID- OIDC client identifierOIDC_CLIENT_SECRET- OIDC client secretSESSION_SECRET- Express session secretNODE_ENV- optional, set toproductionwhen deploying
If PORT is not set, the app falls back to CLIENT_SERVER_PORT, then 7777.
Redis/Valkey is required for:
- storing the shared checkbox state
- publishing checkbox changes to all connected clients
- storing the interaction count
- keeping per-socket rate limit metadata
- Start the Redis container:
npm run db:up-
Confirm Redis is running on
localhost:6379. -
Start the app:
npm run devThe app uses the Redis connection defined in redis-connection.js.
The app uses OIDC for login.
- A user visits
/. - If the session is missing, the app redirects to
/auth/login. - The
/auth/loginroute redirects the user to the OIDC provider. - After successful authentication, the provider redirects back to
/auth/callback. - The callback exchanges the auth code for tokens and stores them in the session.
- The user is redirected back to
/and can access the protected app. - Logout destroys the session and clears the cookie.
Auth logic is split across:
- src/modules/auth/auth.route.js
- src/modules/auth/auth.controller.js
- src/modules/auth/auth.service.js
- src/modules/auth/auth.middleware.js
- The browser connects to Socket.IO after the page loads.
- When a user toggles a checkbox, the client emits
client:checkbox:change. - The server rate-limits the event per socket.
- If allowed, the server updates the checkbox array in Redis.
- The server increments the interactions counter in Redis.
- The server publishes the update to Redis Pub/Sub.
- The subscriber receives the event and broadcasts
server:checkbox:changeto all connected clients. - Every connected client updates the matching checkbox in real time.
The main flow lives in index.js.
The app implements manual socket rate limiting without an external package.
- Each socket gets a Redis key like
rate-limit:<socket.id> - The server stores the timestamp of the last accepted checkbox action
- If a new event arrives too quickly, the server emits
server:errorand ignores the change - This prevents event spam from a single socket connection
This is intentionally simple and easy to explain during evaluation.
- index.js - app bootstrap, Socket.IO, Redis coordination, and main HTTP routes
- redis-connection.js - Redis client setup
- src/modules/auth - authentication logic
- public - frontend pages
- The checkbox grid is fetched from
/checkboxon page load. - The app expects Redis/Valkey to be available before interacting with the grid.
- For production deployment, set
NODE_ENV=productionand use secure session settings appropriately.



