How roshan-anand/code-join works
Project Type and Purpose
• This is a full-stack, collaborative, real-time code-editing web application (“CODE JOIN”).
• The front end is a React + TypeScript single-page application served via Vite (and Nginx in Docker).
• The back end is a Node.js + TypeScript service using WebSockets for live collaboration, Passport for authentication, and Docker to spin up isolated containers for code execution and terminals.
File Structure Analysis
• Top-level:
• frontend/ – React SPA, Vite build, UI components, hooks, Redux slices, environment, Dockerfile.
• backend/ – Express (or similar) server, Socket configurations, route definitions, listeners for Chat, Editor, Room, Container, Terminal, Docker configs, Passport setup.
• compose.dev.yaml & compose.prod.yaml – multi-container orchestration definitions.
• traefik.yaml – edge router configuration (Traefik) for SSL, domain routing.
• Makefile – convenience tasks.
• Patterns:
• Separation of concerns: UI vs business logic vs real-time event handlers.
• Publish/subscribe via Socket listeners.
• Micro-service style container spawning for code sandboxing.
README Insights
• Title: “CODE JOIN an interactive code editor.”
• Confirms focus on interactive, collaborative editing.
a. Main Components
1. Ingress Layer: Traefik proxy (handles HTTPS, routing to front or back).
2. Frontend Service: React SPA running in a container with Nginx.
3. Backend API Service: Node.js/TypeScript app exposing REST endpoints (auth, file operations) and WebSocket endpoints (chat, editor, terminal, room lifecycle).
4. Docker Daemon (host or sidecar): Backend invokes Docker SDK to create per-room sandboxes.
5. Authentication Store: e.g., MongoDB/Redis or JWT (implied by Passport).
6. (Optional) Persistent Storage: for user session data, logs.
7. Client Browsers: connect over HTTPS/WebSocket.
b. Relationships & Data Flows
• Clients → Traefik → Frontend (HTTP 200 + static assets).
• Frontend → Traefik → Backend (REST calls for login, file listing, room management).
• Frontend ↔ Backend via WebSocket (event streams for code changes, chat messages, terminal I/O).
• Backend → Docker Daemon (gRPC or local socket) to spin up / tear down sandbox containers.
• Backend → Auth Store / DB (validate tokens, session info).
c. Architectural Patterns & Principles
• Single Page Application (SPA) with clear separation from the API.
• Event-driven architecture: each listener handles its domain (Chat, Editor, Terminal, Container, Room).
• Containerized sandbox per user or room for security and isolation.
• API gateway / ingress controller (Traefik) for unified SSL termination and routing.
d. Technologies & Frameworks
• Frontend: React, TypeScript, Vite, Redux, WebSocket client.
• Backend: Node.js, TypeScript, Express (or similar), Passport (auth), Socket.io or ws, Docker SDK.
• Orchestration: Docker Compose (dev and prod), Traefik.