CollabWriter is a full-stack collaborative workspace that combines a rich-text document editor and a code playground in one application. Users get live cursors, in-editor chat, a simulated terminal, file-tree sync, and document persistence backed by MongoDB, with authentication handled by Clerk.
Live demo: https://collabwriter.serviceapp.live/
Presentation: https://tinyurl.com/collabwriter
Video Demo: https://youtu.be/5RbqNOZ_RKU
Most important thing the sharing option is named as manage access and it's in 3 dots right corner of document or code so don't consider it as non sharable document.
- Features
- Architecture overview
- Tech stack
- Repository structure
- Prerequisites
- Setup instructions
- Environment variables
- Running locally
- Production deployment (summary)
- AI tools used
- Known limitations
- Authentication: Sign-in and session management via Clerk.
- Rich-text documents: Quill-based editor with formatting toolbar and collaborative editing.
- Code editor: Ace editor with themes, multi-file tabs, and project file explorer.
- Real-time collaboration: Yjs-backed document sync, cursor presence, and change relay over WebSockets (
wson the collaboration server). - Side chat: Session-based chat rooms per project or context (messages are ephemeral when the room is cleared).
- Terminal: In-browser terminal UI with server-side command execution (sandboxed timeouts and project-scoped working directory).
- Persistence: MongoDB (Mongoose) for users, documents, and metadata; project files stored on disk under the collaboration server data directory.
- Optional media: AWS Cloud Storage integration for file uploads where configured.
The system is split into a Next.js client (React, App Router) and a Node.js collaboration server that exposes HTTP APIs for file content and a WebSocket endpoint for real-time events, Yjs updates, chat, and terminal I/O. The browser talks to the Next app over HTTPS and to the collaboration server over WebSocket (and HTTP for file tree and content endpoints).
High-level diagram (see repository asset):
Conceptual flow:
- Client (Next.js / React): Clerk handles auth. Editors connect to the collaboration WebSocket URL (
NEXT_PUBLIC_SOCKET_BACKEND_URL). The same base is converted to HTTP for/filesand/files/contentrequests. - Collaboration server (
backend/server.js): Useswson Nodehttpfor upgrades; manages per-document rooms, Yjs state vectors and updates, cursor relay, chat rooms, and project file operations on local disk (backend/data). - Data: MongoDB stores application entities (users, documents, permissions). Project files live on the server filesystem (suitable for EBS or equivalent on AWS).
- Production (typical): Traffic is often terminated at TLS (ALB, Nginx, or similar), then forwarded to the Next process and the collaboration server on private ports. WebSocket proxying must preserve
UpgradeandConnectionheaders.
| Layer | Technologies |
|---|---|
| Frontend | Next.js 14 (App Router), React 18, TypeScript, Tailwind CSS, Radix UI, shadcn-style patterns |
| Auth | Clerk (@clerk/nextjs, @clerk/themes) |
| Editors | Quill 2, React Ace (react-ace), Yjs (yjs) |
| Real-time | ws (WebSocket server), socket.io / socket.io-client (present in codebase for extended sync utilities) |
| Backend (collaboration) | Node.js, http, backend/server.js |
| Database | MongoDB via Mongoose |
| Optional | AWS Cloud Storage (S3, EBS) |
| Tooling | ESLint (eslint-config-next), PostCSS, Tailwind |
CollabWriter/
├── app/ # Next.js App Router pages, layouts, API routes
├── backend/
│ ├── server.js # Collaboration server (HTTP + WebSocket)
│ └── data/ # Project files (created at runtime; gitignored as appropriate)
├── components/ # React components (editors, terminal, chat, UI)
├── lib/ # Mongoose, server actions, models, realtime helpers
├── public/ # Static assets (including images/architecture.png)
└── package.json
- Node.js 18 or 20 (LTS recommended)
- npm (lockfile:
package-lock.json) - MongoDB (local or hosted; connection string required)
- Clerk account and application (publishable + secret keys)
-
Clone the repository
git clone https://github.com/sujay-deshpande/CollabWriter cd CollabWriter -
Install dependencies
npm install
-
Configure environment variables
Create a
.envfile in the project root (see Environment variables). Do not commit secrets. -
Start MongoDB
Ensure MongoDB is reachable at the URL you set in
MONGODB_URL. -
Run the application
You need two processes in development: the Next.js dev server and the collaboration server. See Running locally.
Create a .env file in the project root. Values below are illustrative; replace with your own.
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_APP_URL |
Yes | Public URL of the Next app (e.g. http://localhost:3000 in dev). |
MONGODB_URL |
Yes | MongoDB connection string (e.g. mongodb://localhost:27017/collabwriter). |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Yes | Clerk publishable key. |
CLERK_SECRET_KEY |
Yes | Clerk secret key. |
NEXT_PUBLIC_SOCKET_BACKEND_URL |
Yes | WebSocket URL for the collaboration server (e.g. ws://localhost:5001). The client derives HTTP base for /files by replacing ws with http. |
NODE_ENV |
Optional | development or production. |
BACKEND_PORT |
Optional | Collaboration server port (default 5001). |
BACKEND_HOST |
Optional | Bind address (default 0.0.0.0). |
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_S3_BUCKET |
Optional | Amazon S3 for uploads. |
Note: NEXT_PUBLIC_* variables are embedded at build time. Change them and rebuild before deploying.
Terminal 1 (Next.js):
npm run devTerminal 2 (collaboration server):
npm run backendDefault URLs:
- Next.js:
http://localhost:3000 - Collaboration server:
http://localhost:5001(WebSocket on the same port)
Production build:
npm run build
npm run startRun npm run backend (or your process manager) alongside next start with the same environment variables.
- Run Next.js (
next start) andnode backend/server.json the host or in containers. - Point
NEXT_PUBLIC_SOCKET_BACKEND_URLat your public WebSocket URL (usewss://behind HTTPS). - If you terminate TLS at a load balancer or Nginx, configure WebSocket proxying (
Upgrade,Connection, timeouts) and keep HTTP and WebSocket paths consistent with how the client buildsBACKEND_HTTP_URLfromNEXT_PUBLIC_SOCKET_BACKEND_URL. - Persist
backend/data(or equivalent volume) for project files. - Secure MongoDB and restrict network access; use strong credentials and TLS for remote clusters.
This project was developed with assistance from AI tools. In accordance with disclosure requirements, every tool used is listed below.
| Tool | How it was used |
|---|---|
| Anthropic Claude | Research, architecture discussion, and assistance with implementation details and additional features. |
| OpenAI ChatGPT | Research, brainstorming, and support for implementing and refining additional features. |
- Two-process architecture: The app expects both Next.js and
backend/server.js. Missing one process breaks live editing, file tree, terminal, or chat. - Build-time public env:
NEXT_PUBLIC_*values are fixed at build time; misconfigured production URLs require a rebuild. - Collaboration server state: In-memory rooms and Yjs documents on the Node process are not shared across multiple server instances without additional infrastructure (sticky sessions, shared pub/sub, or redesign).
- Chat ephemeral behavior: In-editor chat history is cleared when rooms empty in the current server logic (see
backend/server.jschat room handling). - Terminal and code execution: The server runs shell commands in a project-scoped directory with timeouts. Do not expose this to untrusted users without hardening (sandboxing, allowlists, resource limits).
- MongoDB required: Server actions that call
connectToDB()fail ifMONGODB_URLis missing or invalid. - TypeScript strictness:
next.config.mjsmay includetypescript.ignoreBuildErrors: true; some type errors may not block production builds. - Optional dependencies:
socket.ioserver modules exist underlib/realtime/; the default production path for the live editor is thewsserver inbackend/server.js. Verify which stack you deploy if you enable alternate sync servers.
This repository is marked private in package.json. Add a license file if you intend to distribute the project.
Developed by Sujay Deshpande. CollabWriter is a collaborative writing and coding workspace.
