cat << 'EOF' > README.md
High-Performance Distributed Collaborative IDE with hierarchical directory locking capabilities
Building a collaborative code editor presents three massive engineering challenges:
- Edit Collisions: When multiple developers edit the same file simultaneously, race conditions occur. Traditional solutions like CRDTs (Conflict-free Replicated Data Types) or OT (Operational Transformation) introduce massive memory bloat and computational overhead.
- Network Bottlenecks: Sending entire file states over a WebSocket on every keystroke cripples bandwidth and causes synchronization latency.
- Malicious Code Execution: Allowing users to compile and run C++ code remotely exposes the host server to infinite loops, RAM exhaustion, and fork bombs.
- Pessimistic Locking: Instead of merging conflicting edits, we use a Trie-based Hierarchical Lock Manager to grant granular, atomic write-locks on files. Only the lock owner can edit, mathematically guaranteeing zero merge conflicts.
- O(1) Delta Engine: Text is synchronized using a vectorized line-buffer architecture, broadcasting only the exact line changes rather than full payloads.
- Hardened Sandbox: User code is injected into pre-warmed Docker containers with strict CPU, Memory, and PID limits, achieving sub-300ms "cold start" execution times while keeping the host server 100% secure.
DistW is a full-stack, distributed collaborative Integrated Development Environment (IDE) engineered for ultra-low-latency state synchronization and secure Remote Code Execution (RCE).
Designed for high-throughput concurrent developer sessions, DistW explicitly bypasses the memory bloat and computational overhead of traditional state-reconciliation algorithms like Operational Transformation (OT) or CRDTs. Instead, it enforces strict pessimistic concurrency via a custom Trie-based Hierarchical Distributed Lock Manager (HDLM), mathematically guaranteeing atomic data integrity and zero merge conflicts at the file and directory levels.
The architecture bridges a highly concurrent C++20 edge server (leveraging uWebSockets for event-driven, asynchronous I/O multiplexing) with a React/TypeScript frontend wrapping the Monaco Editor.
Under the hood, DistW solves two critical distributed systems challenges:
- Network-Efficient State Sync: A custom Delta Engine utilizing vectorized line buffers achieves amortized O(1) line-level insertions, broadcasting only differential keystroke payloads to remote clients rather than full file states.
- Hardened Remote Execution: A multi-threaded Admin Warm Pool daemon orchestrates a fleet of pre-booted Docker containers. This allows untrusted user code to be routed, compiled, and executed with sub-300ms latency, while strictly enforcing cgroup resource limits (CPU, RAM, PIDs) to protect the host machine from malicious exhaustion attacks.
- Systems Programming: C++20, Multi-threading (
std::jthread,std::mutex,std::atomic), POSIX Systems. - High-Performance Networking: Asynchronous I/O multiplexing, TCP/WebSockets via
uWebSockets. - Concurrency & Synchronization: Custom lock managers, thread-safe queues, race-condition mitigation.
- DevOps & Security: Docker container orchestration, process sandboxing, resource capping (cgroups).
- Frontend Engineering: React, TypeScript, Zustand (State Management), Monaco Editor integration, XTerm.js (Note: Frontend styling/scaffolding assisted via AI tooling).
graph TD
subgraph Client ["Client Layer (React / TS)"]
UI["EditorWorkspace (Monaco)"]
TERM["ExecutionPanel (xterm.js)"]
DASH["AdminDashboard (Telemetry)"]
end
subgraph Core ["C++20 Edge Server Core"]
WS["WebSocketRouter (uWebSockets)"]
HDLM["HierarchicalLockTree (HDLM Trie)"]
DELTA["DeltaEngine (Vectorized Line Buffer)"]
POOL["AdminWarmPool (Thread Pool)"]
REAPER["ReaperEngine & Shutdown Daemon"]
end
subgraph Sandbox ["Isolated Execution Environment"]
DOCKER["Pre-warmed Docker Fleet (gcc:latest)"]
end
UI <-->|Keystrokes / Lock Requests| WS
TERM <-->|Interactive Stdin / Stdout| WS
DASH -->|Metrics Polling| WS
WS -->|Validate File Locks| HDLM
WS -->|Apply Differential Edits| DELTA
WS -->|Dispatch RCE Jobs| POOL
WS -->|Session Cleanup| REAPER
POOL <-->|Container IO Pipes| DOCKER