A Google Docs-style editor where multiple people write together and AI helps them write better
Role
Full-Stack Developer
Team
Solo, personal project
12+
AI Writing Capabilities
Full-Stack Developer
Role
Personal Project
Status
A cloud-based collaborative document platform, inspired by Google Docs, that combines real-time multi-user editing with an AI writing assistant. Anyone can be invited to a document by email — Gmail, Outlook, or any provider — and collaborators can draft, edit, and refine content together while AI handles generation, rewriting, summarization, and translation inline.
Teams writing documents together need more than a shared text box: they need to see who else is editing and where, resolve comments and suggestions without losing context, and get unstuck on the writing itself. Most collaborative editors handle the real-time part but leave the actual writing work — drafting, tightening, correcting tone — entirely to the user. This project set out to combine both: live multi-user collaboration and an AI assistant embedded directly in the editing flow, behind secure, role-based document access.
Multiple collaborators typing in the same document at the same time meant every keystroke had to be broadcast, ordered, and merged into a shared document state without clobbering another user's in-flight changes or desyncing the rich text editor's internal model.
AI operations like rewrite, tone adjustment, and translation needed to apply to a precise text selection inside a live, multi-user document — replacing just that range without disrupting other collaborators' cursors or triggering a conflicting edit.
Long-form AI generation (drafting, continuing, summarizing) arrives as a stream of tokens rather than a single response, and that stream had to be inserted into the document incrementally while still broadcasting a consistent state to every other connected collaborator.
Live cursors, presence indicators, threaded comments, and inline suggestions all overlay the same document content, so the editor needed a layering model where none of these features visually or functionally interfered with each other or with concurrent edits.
The editor treats every keystroke, cursor movement, comment, and AI edit as an event broadcast over a single Socket.IO connection per document room. The Next.js frontend holds the authoritative rendered state via the rich text editor's own document model, while the server relays and persists events so a user who reconnects — or joins mid-session — receives the current document state plus a replay of recent activity rather than a stale snapshot. AI requests are dispatched through the same backend as a distinct event type, so an AI-generated edit is synchronized to every collaborator exactly like a human one.
The editor is built around Lexical as the rich text core, wrapped in a collaboration layer that maps local edit operations to outgoing Socket.IO events and incoming events back into editor transactions. Presence, comments, and the AI assistant panel are built as separate feature modules that subscribe to the same document context rather than reaching into the editor internals directly, which kept each feature independently testable and let the AI panel operate on a selection without needing to understand the collaboration wiring underneath it.
src/
├─ app/
│ ├─ documents/[docId]/page.tsx
│ └─ documents/page.tsx
├─ features/
│ ├─ editor/
│ │ ├─ editorSlice.ts
│ │ ├─ use-socket-sync.ts
│ │ └─ components/
│ ├─ presence/
│ │ └─ use-live-cursors.ts
│ ├─ comments/
│ ├─ ai-assistant/
│ │ ├─ aiSlice.ts
│ │ ├─ use-ai-stream.ts
│ │ └─ components/
│ ├─ sharing/
│ └─ version-history/
├─ components/ui/
├─ lib/
│ ├─ socket-client.ts
│ └─ auth/
server/
├─ sockets/document-room.ts
├─ routes/
│ ├─ documents.ts
│ ├─ ai.ts
│ └─ sharing.ts
└─ models/Redux Toolkit holds document metadata, permissions, and comment/suggestion state, while the live text content itself is owned by the editor's own model and kept in sync via Socket.IO events rather than round-tripping through Redux on every keystroke. AI responses stream into a dedicated AI slice first — so the assistant panel can show progress and let the user accept or discard a suggestion — and are only merged into the shared document (and broadcast to collaborators) once accepted.
Document CRUD, sharing, and permission changes go through a REST API on Express, while all real-time editing, presence, and comment events flow over a persistent Socket.IO connection scoped to a per-document room. AI requests (generate, rewrite, summarize, translate, and the rest) are proxied through a dedicated Express route that calls the configured LLM provider, so the frontend never holds an API key or talks to the AI provider directly.
Authentication uses JWT issued at login, attached to both REST requests and the Socket.IO handshake so real-time events are scoped to an authenticated, authorized user. Document access is granted via email invitation — the invited email is checked against the account on sign-in, or a signup prompt is shown for new users — and every action is checked against the inviting document's role assignment (Owner, Editor, Viewer) before it's applied or broadcast.
Batched rapid local edit operations before broadcasting over Socket.IO instead of emitting one event per keystroke.
Reduced network chatter and kept the editor responsive with several concurrent collaborators
AI responses are streamed token-by-token into the assistant panel rather than waiting for the full completion.
Cut perceived latency on long generations like drafting and summarization
Auto-save persists document state on a debounced interval keyed to edit activity rather than saving on every change.
Kept writes to MongoDB proportional to actual editing activity instead of every keystroke
The editor and AI assistant panel are built with keyboard-first interaction in mind — accepting or discarding an AI suggestion, navigating comment threads, and switching tone/translation options are all reachable without a mouse, which matters for a text-heavy tool used for extended writing sessions.
Gallery coming soon.