High-Performance, Real-Time Collaborative Code Editor
Built with CRDTs, WebSockets, and a modern authentication layer.
This editor is engineered with specific distributed systems and UI performance optimizations:
NexEditor uses Yjs CRDTs (Y.Text). Every character inserted is assigned a permanently unique identifier. This completely eliminates race conditions when multiple users type in the exact same location simultaneously.
Deleted nodes are marked internally as isDeleted: true to preserve the logical tree structure for network synchronization, while the editor binding ensures the deleted content is immediately removed from the view.
Mounted natively using CodeMirror 6 and @codemirror/theme-one-dark.
- No Virtual DOM overhead: Bypassing React/Vue to eliminate rendering bottlenecks.
- Direct transaction bridging: The
y-codemirror.nextbinding intercepts native CodeMirror transactions and converts them into CRDT updates with near-zero latency.
Built-in client-side batching and debouncing layer:
- Typing bursts are throttled (50ms debounce window).
- Multiple keystrokes are merged into a single binary CRDT payload.
If connectivity drops, local edits continue to register. Outgoing updates accumulate in a local buffer, which flushes gracefully upon reconnection to prevent update storms.
The backend acts purely as a high-speed stateless Pub/Sub message relay. It maintains room mappings and blindly broadcasts binary payloads between peers in the same room.
- Frontend: Vanilla JavaScript (ES6+), CodeMirror 6, Yjs,
y-codemirror.next,socket.io-client. - Backend: Node.js, Express,
socket.io. - Authentication: Passport.js (Google OAuth), JWT, bcrypt.
- Database & ORM: SQLite (
dev.db), Prisma,@prisma/adapter-better-sqlite3. - State Persistence: 100% Ephemeral for CRDT state (in-memory). Persistent SQLite storage for User Accounts.
NexEditor now features a robust, fully-integrated authentication system backed by SQLite and Prisma ORM, alongside a stunning new Particle Canvas UI.
- Google OAuth Integration: Seamless, one-click login using
passport-google-oauth20. - Email & Password: Secure local authentication utilizing
bcryptfor password hashing. - Anonymous Guest Mode: Instant access with auto-generated guest profiles.
- JWT Sessions: Stateless, secure session management using JSON Web Tokens stored in HTTP-only cookies.
- Beautiful UI: A brand new, interactive particle canvas landing page for authentication.
NexEditor/
├── prisma/
│ └── schema.prisma # Database schema for Users
├── server/
│ ├── auth.js # Passport, Google OAuth, and JWT routing
│ └── index.js # Stateless Express + Socket.io relay server
├── client/
│ ├── index.html # Landing page (Particle Canvas) & Editor UI
│ ├── style.css # Premium dark mode styles
│ ├── crdt.js # Shared Y.Doc, Y.Text type, and Yjs awareness
│ ├── network.js # WebSockets connection and reconnect buffer
│ ├── script.js # Auth UI logic & Particle animation engine
│ └── ui.js # CodeMirror initialization and routing
├── dev.db # SQLite Database
└── .env # Environment variables (Google Keys, JWT Secret)
- Node.js (v18+)
- npm
-
Clone the repository:
git clone https://github.com/xyron24/NexEditor.git cd NexEditor -
Install dependencies:
npm install
-
Environment Setup: Create a
.envfile in the root directory and add your Google OAuth credentials and JWT secret. -
Initialize Database (if not automatically done via postinstall):
npx prisma generate npx prisma db push
-
Start the development server:
npm run dev
-
Open your browser: Navigate to
http://localhost:3000.
- Local Network: Find your machine's IP (e.g.,
192.168.x.x). Peers can join viahttp://<your-local-ip>:3000/#<room-id>. - Remote Collaboration: Expose your local port using a tool like ngrok:
ngrok http 3000



