How hxqlabs/helixque works
1. Overall shape
Helixque is a two-part application: a Next.js frontend for the user experience and a Node.js + TypeScript backend that acts as the real-time signaling and matchmaking service. The actual video/audio media is peer-to-peer via WebRTC; the backend does not carry media streams.
2. Frontend boundary
The frontend lives under frontend/ and uses the Next.js App Router. Its job is to manage pages, user interaction, device permissions, local UI state, and the browser-side RTCPeerConnection lifecycle. It is the only part that touches camera/microphone APIs directly.
3. Frontend page structure
The main routes are app/page.tsx (entry/landing), create-room, match, room/[roomId], and a test-toasts utility page. The room/[roomId] route is the core call experience, while match and create-room are entry points into the session flow.
4. Frontend RTC subsystem
Most call logic is concentrated in frontend/components/RTC/. Room.tsx appears to be the top-level coordinator for an active session, with supporting pieces for the video grid, control bar, device checks, timeout alerts, and chat UI. hooks.tsx and webrtc-utils.tsx likely encapsulate WebRTC state management and signaling helpers so the UI stays separate from connection mechanics.
5. Frontend UI composition
The frontend also includes a small reusable UI layer under components/ui/ for toasts, tooltips, shimmer buttons, cards, and similar presentation concerns. This is a supporting layer rather than a core architectural boundary, but it matters because the room experience is built from these reusable pieces.
6. Backend responsibility
The backend under backend/src/ is the real-time coordination service. It handles Socket.IO signaling, user presence, queueing/matching, room lifecycle, and likely chat/event relaying. This service is stateful enough to track who is waiting, who is matched, and which room a user belongs to.
7. Backend internal subsystems
The main backend modules are:
- managers/UserManger.ts for user/session state and queue behavior
- managers/RoomManager.ts for room creation, membership, and cleanup
- match/Matchmaker.ts for preference-based pairing logic
- chat/chat.ts for messaging
- cache/presence.ts and cache/redis.ts for shared presence/cache support
- index.ts as the server entry point wiring everything together
8. Matching and session flow
A typical flow is: a user opens the frontend, connects to the backend over Socket.IO, enters the matchmaking queue, and the backend pairs them using preference data. Once matched, the backend creates or assigns a room and instructs one side to initiate WebRTC offer/answer exchange. This is where the app transitions from “matching” to “active room.”
9. Signaling data path
After pairing, the frontend and backend exchange offers, answers, and ICE candidates through Socket.IO events. The backend relays these messages between peers and tracks room membership so each candidate or SDP message reaches the correct counterpart. This signaling layer is the critical bridge between the browser UI and the peer-to-peer media connection.
10. Presence, skips, and disconnect handling
The backend also manages user presence and room cleanup so the app can handle leaving, skipping, and partner disconnects cleanly. The README’s event list indicates the system supports queue:next, queue:leave, and partner:left, which suggests the backend is responsible for recovering the session state when one side exits.
11. Redis and scale-out boundary
cache/redis.ts and the README’s Redis notes indicate optional Redis-backed coordination for presence or multi-instance deployment. That means the architecture can run in a single-process mode for development, but can also be extended to multiple backend instances where shared state is needed.
12. External infrastructure
The app expects a NEXT_PUBLIC_BACKEND_URL in the frontend and PORT, CORS_ORIGINS, and optional REDIS_URL in the backend. The README also notes TURN servers for production WebRTC reliability, which is important because peer-to-peer media may fail without relay in restrictive networks.
13. Diagramming guidance
If you’re drawing the architecture, the main boxes are:
- Browser client / Next.js frontend
- Socket.IO signaling backend
- Optional Redis shared cache
- External TURN/STUN infrastructure
- Direct WebRTC peer-to-peer media path between two browsers
The key distinction is that signaling and matchmaking go through the backend, while audio/video flows directly between peers once the connection is established.
Main entry points: index.ts Server · Room.tsx RTC Room · app App Router · page.tsx Room Call
Components 24
Frontend
Next.js browser application and call UI
- App Router · Top-level routes and shell for the frontend
frontend/app - Landing · Entry page and general navigation
frontend/app/page.tsx - Match · Matchmaking entry point
frontend/app/match/page.tsx - Create Room · Room creation entry point
frontend/app/create-room/page.tsx - Room Call · Active call experience for a room
frontend/app/room/[roomId]/page.tsx - RTC Room · Coordinates session state, signaling, and room UI
frontend/components/RTC/Room.tsx - RTC Hooks · WebRTC and session state helpers
frontend/components/RTC/hooks.tsx - WebRTC Utils · Connection and signaling utility functions
frontend/components/RTC/webrtc-utils.tsx - Video Grid · Renders local and remote video tiles
frontend/components/RTC/VideoGrid.tsx - Control Bar · Call controls such as mute, skip, and leave
frontend/components/RTC/ControlBar.tsx - Device Check · Camera and microphone permission and device validation
frontend/components/RTC/DeviceCheck.tsx - Chat UI · In-room chat interface
frontend/components/RTC/Chat/chat.tsx - UI Kit · Reusable presentation components such as toasts, tooltips, and cards
frontend/components/ui
Backend
Socket.IO signaling and matchmaking service
- Server · Backend entry point wiring Socket.IO, managers, and caches
backend/src/index.ts - Matchmaker · Preference-based user pairing
backend/src/match/Matchmaker.ts - Users · User presence, queueing, and session state
backend/src/managers/UserManger.ts - Rooms · Room creation, membership, and cleanup
backend/src/managers/RoomManager.ts - Chat Relay · Backend chat and event relay
backend/src/chat/chat.ts - Presence Cache · Presence and optional shared coordination layer
backend/src/cache/presence.ts
External
Browser APIs and infrastructure outside the repo
- Browser · End-user browser running the app and local WebRTC stack
- Redis · Optional shared state backend for multi-instance deployment
- Socket.IO · Event transport between browser clients and backend
- P2P Media · Direct audio/video transport between browsers
- TURN/STUN · External relay and traversal infrastructure for WebRTC
Connections 30
- Browser → App Router: loads · Browser opens the Next.js application
- App Router → Landing: routes · App Router serves the landing page
- App Router → Match: routes · App Router serves matchmaking entry
- App Router → Create Room: routes · App Router serves room creation entry
- App Router → Room Call: routes · App Router serves the active room page
- Room Call → RTC Room: composes · Room route mounts the RTC session coordinator
- RTC Room → RTC Hooks: uses · Coordinator relies on WebRTC/session hooks
- RTC Room → WebRTC Utils: uses · Coordinator uses signaling and connection helpers
- RTC Room → Video Grid: renders · Coordinator renders the media grid
- RTC Room → Control Bar: renders · Coordinator renders the call controls
- RTC Room → Device Check: gates · Coordinator checks device permissions before call setup
- RTC Room → Chat UI: includes · Coordinator includes in-room chat
- RTC Room → UI Kit: uses · Coordinator relies on shared presentation components
- Browser → Socket.IO: signals · Browser exchanges match and WebRTC events with backend
- Socket.IO → Server: connects to · Socket transport terminates in the backend server
- Server → Matchmaker: delegates · Server delegates pairing decisions
- Server → Users: tracks · Server tracks users and queue state
- Server → Rooms: manages · Server manages room lifecycle
- Server → Chat Relay: relays · Server relays chat and session events
- Server → Presence Cache: shares state · Server uses shared presence/cache support
- Presence Cache → Redis: backed by · Optional Redis-backed coordination
- Matchmaker → Users: pairs from · Matchmaker consumes queue and preference state
- Rooms → Users: assigns · Room manager assigns matched users to rooms
- Server → Socket.IO: emits · Backend emits signaling events over Socket.IO
- Server → P2P Media: coordinates · Backend coordinates peer connection setup but not media
- Browser → P2P Media: streams · Browsers exchange audio/video directly
- P2P Media → TURN/STUN: falls back to · TURN/STUN assists traversal when direct path is blocked
- Match → Server: queues · Match route initiates matchmaking through the backend
- Create Room → Server: creates · Create-room flow registers a new session with the backend
- Room Call → Server: joins · Room route joins the signaling/session backend