Backend server for the SyncEditor collaborative code editor platform. Built for performance, security, and real-time synchronization.
SyncEditor Server is a high-performance Node.js service providing the backbone for real-time collaboration. It leverages Socket.IO for low-latency communication and integrated OpenTelemetry for production-grade observability.
Authentication model: the current implementation is intentionally simple β clients supply a plain username when emitting the join event; the server does not perform any credentials check. This keeps the focus on the collaboration features and makes the service easier to run locally.
- β‘ Real-Time Sync: Low-latency code and chat synchronization.
- π’ Room Management: Secure, isolated collaborative environments.
- π‘οΈ Production Security: Rate limiting, XSS protection, and CSP headers.
- π First-Class Observability: Distributed tracing with Jaeger v2 and log aggregation with Grafana/Loki.
- π§ͺ Simple auth: clients provide a username when joining; no backend login required.
Standardized observability using OpenTelemetry and Jaeger v2.
Visualize the entire lifecycle of collaborative events.
System interaction visualization and latency analysis.
Deep dive into span processing and event execution.
Real-time collaboration concurrency tracking.
Powered by winston, enriched with OpenTelemetry context, and aggregated via Loki.
- Enrichment: Logs are automatically injected with
trace_idandspan_id. - Scraping: Promtail tails the JSON log files.
- Aggregation: Logs are pushed to Loki for indexing.
- Visualization: View and query logs in Grafana, with direct links to distributed traces.
- Insights: Real-time log monitoring for rapid debugging.
- Runtime: Node.js (v18+)
- Framework: Express.js
- Real-time: Socket.IO
- Auth: none (naive username-based)
- Tracing: Jaeger
- Log Aggregation: Loki & Promtail
- Visualization: Grafana
- Observability: OpenTelemetry
- Logging: Winston
npm installCreate a .env file:
PORT=5555
FRONTEND_URL=http://localhost:5173
NODE_ENV=development
SOCKET_PING_TIMEOUT=120000
SOCKET_PING_INTERVAL=30000| Command | Description |
|---|---|
npm run dev |
Start development server with Nodemon |
npm start |
Run production-ready server |
join:{ roomId, username }leave:{ roomId, username }code-change:{ roomId, code, sender }send-message:{ roomId, message, sender, time }
user-joined:{ clients, username, socketId }user-left:{ socketId, username }code-change:{ code, sender }receive-message:{ message, sender, time }error:{ message }
Server/
βββ src/
β βββ index.js # Entry point: Starts server & initializes OTel
β βββ app.js # Application setup: Middleware, routes, & error handling
β βββ config/ # Configuration files
β β βββ otel.js # OpenTelemetry SDK configuration
β β βββ clerk.js # Authentication configuration (Clerk)
β βββ middleware/ # Express middleware
β β βββ auth.js # Authentication & user identification
β β βββ rateLimiter.js # Resource usage control
β β βββ validator.js # Input schema validation
β βββ sockets/ # Socket.IO implementation
β β βββ index.js # Socket server initialization
β β βββ handlers.js # Core logic for code sync, chat, & room management
β βββ utils/ # Helper functions
β βββ logger.js # Winston structured logging setup
βββ otel-config/ # Observability infrastructure config
β βββ logging/ # Loki, Promtail, & Grafana setup
β βββ otel/ # OTel Collector configurations
βββ k8s/ # Kubernetes manifests
β βββ deployment.yaml # App deployment & container spec
β βββ service.yaml # LoadBalancer & port config
β βββ hpa.yaml # Horizontal Pod Autoscaler
βββ assets/ # Documentation images & screenshots
βββ tests/ # Integration & Unit test suites
βββ Dockerfile # Production container definition
βββ package.json # Dependencies & scripts
- Socket Handlers: The brain of the real-time engine, handling complex concurrency for code edits and ensuring all room participants stay in sync.
- OTel Infrastructure: Provides the full observability pipeline, mapping application events to distributed traces for debugging production issues.
- K8s Manifests: Production-ready configurations for deploying the server in a scalable Kubernetes environment with automated scaling.
- Security Middleware: Multi-layered protection including rate limiting to prevent abuse and schema validation for all incoming socket/HTTP payloads.
- Rate Limiting: 100 req/15min per IP.
- Validation: Strict schema validation for all inputs.
- Headers: Helmet-secured headers (XSS, HSTS, CSP).
- Tracing (Jaeger)
- Centralized Log Aggregation (Loki/Grafana)
- Distributed Metrics (Prometheus)
- Health Dashboard UI
- Custom Performance Spans
Distributed under the MIT License. See LICENSE for more information.

