<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vivek</title>
    <description>The latest articles on DEV Community by Vivek (@vivek_z9).</description>
    <link>https://dev.to/vivek_z9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3948703%2Fd0fa8de2-9ff1-4dd2-830d-4acb3029532b.jpg</url>
      <title>DEV Community: Vivek</title>
      <link>https://dev.to/vivek_z9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vivek_z9"/>
    <language>en</language>
    <item>
      <title>Building Pixel Room — a Real-Time Collaborative Whiteboard (Excalidraw Clone)</title>
      <dc:creator>Vivek</dc:creator>
      <pubDate>Thu, 09 Jul 2026 15:25:54 +0000</pubDate>
      <link>https://dev.to/vivek_z9/building-pixel-room-a-real-time-collaborative-whiteboard-excalidraw-clone-11gk</link>
      <guid>https://dev.to/vivek_z9/building-pixel-room-a-real-time-collaborative-whiteboard-excalidraw-clone-11gk</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqztotgzy3ycdfomyr4zz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqztotgzy3ycdfomyr4zz.jpeg" alt=" " width="799" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built this
&lt;/h2&gt;

&lt;p&gt;I wanted to actually understand how tools like Excalidraw and Figma pull off real-time multiplayer canvas sync — so instead of reading about it, I built my own version. Meet &lt;strong&gt;Pixel Room&lt;/strong&gt;: a collaborative whiteboard where you create a room, draw shapes with your crew, and chat live while you sketch.&lt;/p&gt;

&lt;p&gt;It's still a work in progress, but the core sync engine works, and I learned a &lt;em&gt;lot&lt;/em&gt; building it. Here's the breakdown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj8dqp1xjw3xgz6koyi6j.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj8dqp1xjw3xgz6koyi6j.jpeg" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Turborepo&lt;/strong&gt; monorepo — shared packages across frontend, backend, and the WebSocket server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React + TypeScript&lt;/strong&gt; frontend, rendering on HTML5 Canvas&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node.js + Express&lt;/strong&gt; for the main backend/API&lt;/li&gt;
&lt;li&gt;A dedicated &lt;strong&gt;ws-server&lt;/strong&gt; purely for real-time WebSocket traffic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL + Prisma&lt;/strong&gt; for persistence&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BullMQ + Redis&lt;/strong&gt; for async job processing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Monorepo structure
&lt;/h2&gt;

&lt;p&gt;One decision I'm glad I made early: keeping shared DB logic in &lt;code&gt;packages/db&lt;/code&gt; instead of duplicating Prisma client setup inside each app. Both the Express backend and the ws-server import from the same package, so schema changes propagate everywhere without copy-pasting client code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apps/
  web/          → React frontend
  http-backend/ → Express API
  ws-server/    → WebSocket server
packages/
  db/           → Prisma client + schema, shared
  ui/           → shared components
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-time sync: the core problem
&lt;/h2&gt;

&lt;p&gt;The obvious naive approach — write every shape straight to Postgres the moment it's drawn — falls apart fast. Every stroke, every drag, every resize would be a DB write. Multiply that by multiple users in a room and you get a database that can't keep up, plus laggy canvas feedback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix: WebSockets for sync, queue for persistence.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user draws a shape:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It's broadcast instantly over WebSocket to everyone else in the room (no DB round-trip in the critical path)&lt;/li&gt;
&lt;li&gt;The shape event is pushed onto a &lt;strong&gt;BullMQ&lt;/strong&gt; queue backed by Redis&lt;/li&gt;
&lt;li&gt;A worker consumes the queue and persists to Postgres asynchronously&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This keeps the canvas feeling instant for every connected client while the database gets written to at a sane, batched pace in the background.&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;useWebSocket&lt;/code&gt; hook and pub/sub
&lt;/h2&gt;

&lt;p&gt;One of the trickier bugs I hit was &lt;strong&gt;message duplication&lt;/strong&gt; — the same draw event getting processed twice on a client. Turned out to be a classic React stale-closure issue: my WebSocket message handler was capturing an old version of state due to how refs and &lt;code&gt;setState&lt;/code&gt; were timed relative to re-renders.&lt;/p&gt;

&lt;p&gt;The fix was building a proper &lt;strong&gt;pub/sub pattern&lt;/strong&gt; around the socket:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One actual WebSocket connection per client, held in a ref (not state, so it survives re-renders)&lt;/li&gt;
&lt;li&gt;A subscribe/unsubscribe interface so multiple components (canvas, chat, room presence) can all listen to the same socket without each one attaching its own raw &lt;code&gt;onmessage&lt;/code&gt; handler&lt;/li&gt;
&lt;li&gt;Handlers dispatch based on event type, so adding new event kinds doesn't mean rewiring the whole hook&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This one fix killed the duplication bug and made the codebase much easier to extend — adding chat messages as a new event type on the same socket was trivial afterward.&lt;/p&gt;

&lt;h2&gt;
  
  
  Canvas: shapes, infinite zoom, resize
&lt;/h2&gt;

&lt;p&gt;The frontend renders directly to an HTML5 &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; rather than SVG, for performance with many shapes. Current tool support:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rectangle, ellipse, triangle, straight line, and freehand draw&lt;/li&gt;
&lt;li&gt;Responsive resize handling so the canvas adapts to different screen sizes without shape positions drifting&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Infinite canvas with zoom/pan&lt;/strong&gt; — panning and zooming into an unbounded space instead of a fixed viewport&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Undo/redo&lt;/strong&gt; — needs an action history stack that stays consistent across clients, not just a local-only undo&lt;/li&gt;
&lt;li&gt;More shape types and a proper eraser&lt;/li&gt;
&lt;li&gt;Better reconnection handling for flaky connections mid-draw&lt;/li&gt;
&lt;li&gt;Room persistence so canvases survive server restarts, not just active sessions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Still very much in progress — but the real-time sync core taught me more about WebSockets, race conditions, and queue-based architecture than any tutorial could have. Happy to go deeper into any part of this (the pub/sub hook, the BullMQ setup, the Prisma schema) in the comments if anyone wants specifics.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>websocket</category>
      <category>programming</category>
    </item>
    <item>
      <title>I built Stashly — a full-stack content manager with a rich text editor published: false tags: react, node, mongodb, typescript</title>
      <dc:creator>Vivek</dc:creator>
      <pubDate>Mon, 25 May 2026 12:29:04 +0000</pubDate>
      <link>https://dev.to/vivek_z9/i-built-stashly-a-full-stack-content-manager-with-a-rich-text-editor-published-false-tags-45fj</link>
      <guid>https://dev.to/vivek_z9/i-built-stashly-a-full-stack-content-manager-with-a-rich-text-editor-published-false-tags-45fj</guid>
      <description>&lt;p&gt;I wanted one place to save links from YouTube, Twitter, and LinkedIn, and write notes alongside them. Nothing I found did both well, so I built Stashly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzt0p0qe78zyjmfc6e2um.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzt0p0qe78zyjmfc6e2um.png" alt=" " width="800" height="408"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fro9vnufnd8bvwi54eqhi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fro9vnufnd8bvwi54eqhi.png" alt=" " width="800" height="408"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Font25ob5plqdcbfwua91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Font25ob5plqdcbfwua91.png" alt=" " width="800" height="406"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Save links from YouTube, Twitter, LinkedIn — with auto-embeds&lt;/li&gt;
&lt;li&gt;Write and edit notes with a full rich text editor (Tiptap)&lt;/li&gt;
&lt;li&gt;Auto-saves notes with a 2s debounce&lt;/li&gt;
&lt;li&gt;Share any saved item via a public slug URL&lt;/li&gt;
&lt;li&gt;Sign in with Google or GitHub OAuth&lt;/li&gt;
&lt;li&gt;Works on mobile (pill nav) and desktop (sidebar)
## Tech stack&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Tech&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Frontend&lt;/td&gt;
&lt;td&gt;React 19, TypeScript, Vite, TailwindCSS v4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Editor&lt;/td&gt;
&lt;td&gt;Tiptap 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State&lt;/td&gt;
&lt;td&gt;Redux Toolkit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend&lt;/td&gt;
&lt;td&gt;Express 5, TypeScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;MongoDB + Mongoose 9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;Better-Auth (Google / GitHub OAuth)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validation&lt;/td&gt;
&lt;td&gt;Zod&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The editor
&lt;/h2&gt;

&lt;p&gt;Tiptap handles the heavy lifting — headings, lists, code blocks, text alignment, color highlights, images, and links. Notes auto-save in the background so you never have to think about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Saving content
&lt;/h2&gt;

&lt;p&gt;Paste a YouTube, Twitter, or LinkedIn URL and Stashly stores it with an embed. You can filter your saved content by platform and delete anything you don't need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Auth
&lt;/h2&gt;

&lt;p&gt;Better-Auth handles OAuth for both Google and GitHub. The session flow was straightforward to set up and the library keeps things out of your way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it locally
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Backend&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;backend
npm &lt;span class="nb"&gt;install
cp&lt;/span&gt; .env.example .env
npm run dev

&lt;span class="c"&gt;# Frontend&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;frontend
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll need Node 18+ and a MongoDB instance (local or Atlas). The &lt;code&gt;.env.example&lt;/code&gt; covers all the required variables — DB URL, Better-Auth secrets, and OAuth credentials for both providers.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd improve
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Full-text search across notes and saved links&lt;/li&gt;
&lt;li&gt;Browser extension for one-click saving&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - Folders or tags for organizing content
&lt;/h2&gt;

&lt;p&gt;Source is on GitHub if you want to take a look or contribute. Feedback welcome.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>react</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
