How benikk/pair-program works
Project type and purpose
• This is a full-stack collaborative coding application ("pair-program") that lets multiple users join a room, discuss, write and review code together in real time, with audio/video support and AI-powered question generation.
• Key features (from README): real-time updates via WebSocket + CRDT (Y.js), audio/video via LiveKit, Express + TypeScript backend, Next.js + Tailwind frontend, AI question generation with Gemini.
File structure
• Top-level:
• frontend/ (Next.js app, UI components, Tailwind CSS, page routes including /room/[id])
• backend/ (Express + TypeScript server, HTTP routes, WS (ws library), CRDT utilities, LiveKit token routes)
• docker-compose.yml (compose both frontend & backend and any supporting services)
• backend/src/http/server.ts: sets up Express HTTP server and WS upgrade handlers.
• backend/src/ws/socket.ts + utils/broadCast.ts: core real-time and CRDT message distribution.
• backend/src/http/routes/livekit.ts: issues tokens/credentials for LiveKit.
• frontend/lib/api.ts & lib/utils.ts: wrapper for REST + WS client calls.
• frontend/app/room/[id]/page.tsx & components/Livekit.tsx: integrate audio/video UI and WebSocket/CRDT client.
README for additional insights
• Confirms CRDT conflict management via Y.js.
• AI question generation is an external API call (Gemini).
• Running instructions: docker-compose.
a. Main components
• Client (Next.js React SPA)
• Backend Service (Express + WS + CRDT logic)
• LiveKit Service (audio/video)
• External AI Service (Gemini for question generation)
• (Optional) Reverse proxy / load balancer if deployed in production
b. Relationships & interactions
• Client ↔ Backend HTTP: authentication, room metadata, AI question API calls
• Client ↔ Backend WebSocket: real-time CRDT document updates, chat/messages
• Client ↔ LiveKit: media negotiation & streaming (via tokens from backend)
• Backend → Gemini API: send code/context, receive generated questions
• docker-compose orchestrates frontend, backend, and can include a self-hosted LiveKit server
c. Architectural patterns & principles
• Two-tier full-stack: decoupled frontend & backend
• Real-time collaboration pattern using CRDT (Y.js) for conflict-free document merging
• Single WS endpoint handling CRDT synchronization
• Microservices-style external services (LiveKit, Gemini)
d. Key technologies/frameworks
• Next.js (frontend SSR/SSG & client-side routing)
• Tailwind CSS (styling)
• Express + ws (backend HTTP + WebSocket)
• TypeScript end-to-end
• Y.js (CRDT library)
• LiveKit (audio/video)
• Gemini API (AI question generation)
• Docker & docker-compose (container orchestration)