How iamkr07/codesync works
Purpose and entry points
CodeSync is a room-based collaborative IDE for pair programming, interviews, and shared live coding. The React client starts at frontend/src/main.jsx, routes through frontend/src/App.jsx, and presents landing and room experiences in frontend/src/pages/LandingPage.jsx and frontend/src/pages/RoomPage.jsx. The backend entry point is server/server.js.
Client application shell
frontend/src/layouts/MainLayout.jsx composes the workspace UI: navigation, editor, collaboration panels, output, AI tools, and replay/snapshot views. frontend/src/pages/LandingPage.jsx is the session-entry surface; frontend/src/pages/RoomPage.jsx is the isolated live-room surface. The browser is responsible for interactive editing, room participation, and rendering remote session state.
Shared room state and synchronization boundary
Room-scoped state is centralized in frontend/src/state/RoomContext.jsx and frontend/src/state/roomState.js. Socket lifecycle and event subscription are encapsulated by frontend/src/hooks/useSocket.js, forming the client boundary to the real-time backend. The intended flow is local editor/user/chat actions → Socket.io events → server room broadcast → peer clients update shared room state.
Collaborative IDE workspace
frontend/src/components/Editor.jsx is the Monaco-based code editing surface and primary source of code-change events. frontend/src/components/UsersPanel.jsx exposes room presence, while frontend/src/components/ChatPanel.jsx handles participant communication. frontend/src/components/OutputConsole.jsx presents program execution results, separating code authoring from backend execution/output delivery.
Server orchestration and room runtime
server/server.js hosts the Express and Socket.io runtime. It is the authoritative coordination point for connections, room membership, real-time broadcasts, and requests that cross from the browser into privileged backend capabilities. Rooms isolate collaboration sessions, so participants should receive only events and state associated with their active room.
AI and execution services
frontend/src/components/AIPanel.jsx initiates AI-assisted code analysis and interview-oriented assistance. server/services/aiService.js encapsulates the backend integration with Google Gemini, keeping API credentials and model invocation outside the browser. The server also provides the execution boundary for JavaScript and Python: client code and language selection are submitted for execution, then output is returned to OutputConsole.
Persistence, snapshots, and replay
Firebase is initialized at frontend/src/firebase.js and serves as the client persistence integration point for Firestore-backed events and snapshots. frontend/src/components/SnapshotModal.jsx captures or restores session checkpoints; frontend/src/components/ReplayPanel.jsx reconstructs session activity from persisted event history. This creates a hybrid model: Socket.io carries low-latency live updates, while Firestore retains durable replay/snapshot data.
Material infrastructure
The system runs a Vite/React frontend (frontend/package.json) and a Node/Express server (server/package.json). Core external services are Socket.io for bidirectional transport, Firebase Firestore for event/snapshot persistence, Google Gemini for AI intelligence, and backend language runtimes for code execution. The frontend is deployed separately from the server-facing real-time and service boundaries.
Main entry points: MainLayout.jsx Workspace shell · server.js Room coordinator · App.jsx App routing · Editor.jsx Code editor
Components 19
React client
- Client entry
frontend/src/main.jsx - App routing
frontend/src/App.jsx - Landing page
frontend/src/pages/LandingPage.jsx - Room page
frontend/src/pages/RoomPage.jsx - Workspace shell
frontend/src/layouts/MainLayout.jsx - Room state · Centralizes room-scoped collaboration state.
frontend/src/state/RoomContext.jsx - Socket boundary · Owns socket lifecycle and event subscriptions.
frontend/src/hooks/useSocket.js - Code editor · Primary source of code-change events.
frontend/src/components/Editor.jsx - Presence and chat
frontend/src/components/ChatPanel.jsx - Output console
frontend/src/components/OutputConsole.jsx - AI panel
frontend/src/components/AIPanel.jsx - Snapshots and replay
frontend/src/components/ReplayPanel.jsx - Firebase integration
frontend/src/firebase.js
Backend runtime
- Room coordinator · Authoritatively manages connections, room membership, and broadcasts.
server/server.js - Execution boundary · Runs submitted JavaScript or Python outside the browser.
server/server.js - Gemini service · Keeps credentials and model invocation on the server.
server/services/aiService.js
External services
- Firebase Firestore · Stores durable events and session snapshots.
- Google Gemini
- Language runtimes
Connections 23
- Client entry → App routing: starts
- App routing → Landing page: routes to
- App routing → Room page: routes to
- Room page → Workspace shell: renders
- Workspace shell → Room state: reads shared state
- Workspace shell → Code editor: hosts
- Workspace shell → Presence and chat: hosts
- Workspace shell → Output console: hosts
- Workspace shell → AI panel: hosts
- Workspace shell → Snapshots and replay: hosts
- Code editor → Socket boundary: code changes
- Presence and chat → Socket boundary: presence and chat
- Socket boundary → Room coordinator: room events · Bidirectional Socket.io transport.
- Room coordinator → Room state: room broadcasts · Peer events update active-room state.
- AI panel → Room coordinator: AI request
- Room coordinator → Gemini service: delegates AI
- Gemini service → Google Gemini: model invocation
- Code editor → Room coordinator: run request
- Room coordinator → Execution boundary: dispatches code
- Execution boundary → Language runtimes: executes
- Execution boundary → Output console: returns output
- Snapshots and replay → Firebase integration: save and load history
- Firebase integration → Firebase Firestore: persist events and snapshots