↖▢✒TPen tool · drawing
T Piyush Yadav · vector
Piyush0 × 180 · 0%
  • ↳ Importing Cover
0%

▢ Case study · 2026

Draftly

A real-time collaborative document editor with live co-authoring, presence cursors, inline comments, nested docs and auto-saved version history. Teams can organize documents into shared workspaces.

Landing Page
Role
Full-stack developer
Year
2026
Timeline
Jul 2026
Built with
TypeScriptNext.js 15ReactConvexLiveblocksYjsTiptapClerkTailwind CSSshadcn/uiVitestVercel

01

The problem

Teams writing together often end up emailing documents back and forth, or overwriting each other’s changes. Tools like Google Docs solve this, but I wanted to understand how real-time co-editing actually works and to build my own version of that experience.

The goal was a clean, distraction-free editor where several people can write at once, discuss changes inline, and safely undo mistakes with version history.

02

What he built

Draftly is a collaborative document workspace.

Writing together

  • Live co-authoring with no conflicts, using Yjs through Liveblocks

  • Presence cursors, text selections and name labels for everyone in the document

  • A rich-text editor built on Tiptap, with resizable tables, images and adjustable page margins

Version history

  • Snapshots saved automatically in the background, at most once a minute after 10 seconds of inactivity

  • A read-only preview of any past version, and one-click restore for everyone in the document

Organization

  • Nested folders, plus sub-documents shown as tabs inside a document

  • Starred documents and title search

  • Personal and team workspaces through Clerk Organizations

Collaboration tools

  • Inline comment threads on any text selection, with resolve and reopen

  • Email-based sharing with in-app notifications

  • Templates for resumes, proposals and cover letters

  • Export to PDF, HTML, JSON or plain text

Architecture. The Next.js 15 frontend is on Vercel. Convex provides a reactive database that pushes updates to clients in real time. Liveblocks handles text syncing, presence and comments, and Clerk handles sign-in and organizations.

03

The hard parts

Securing real-time rooms. Each document’s live editing session is a Liveblocks room. A naive setup would let anyone who guessed a room ID join it. Draftly’s auth endpoint first checks with Convex that the user can actually access the document, and only then grants access to that one room.

One set of permission rules everywhere. Access checks live in shared helper functions on the backend:

  • View and edit: document owners, members of the document’s organization, and people it’s been shared with

  • Delete and manage sharing: the owner only

Every query and mutation goes through these helpers, so the rules can’t drift between features.

Sub-documents as separate rooms. Each tab inside a document gets its own collaboration room. Tab rooms are named after their parent document, so the auth check can trace any tab back to the parent’s permissions.

Version history without flooding the database. Saving on every keystroke would create thousands of snapshots. Snapshots are instead debounced and rate-limited, so each one captures a meaningful pause in editing.

Migrating sharing data. Sharing started as a list of emails stored on each document, which is slow to query from the recipient’s side (“what’s been shared with me?”). I moved it to a dedicated indexed shares table and wrote a migration to backfill existing shares.

04

How it turned out

Draftly is live at draftly.piyushydv.com (opens in a new tab) and deploys automatically on Vercel.

  • About 10K lines of TypeScript

  • Feature-complete: co-authoring, comments, version history, nested documents, workspaces and export

  • A modular codebase split into document, home and room modules, with backend logic split by domain

This was my first real-time project. It taught me how collaborative editing works under the hood, and that access control matters as much in real-time systems as in regular APIs.

Gallery · 2

  • Dashboard
  • Docs