<?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: Pritam Patra</title>
    <description>The latest articles on DEV Community by Pritam Patra (@pritam_patra_429a25dedae6).</description>
    <link>https://dev.to/pritam_patra_429a25dedae6</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%2F4024964%2F55fd503a-2224-4f8e-8a04-bdce433dddf9.jpg</url>
      <title>DEV Community: Pritam Patra</title>
      <link>https://dev.to/pritam_patra_429a25dedae6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pritam_patra_429a25dedae6"/>
    <language>en</language>
    <item>
      <title>From 2.0 MB to 471 KB: Debugging Rawbee with Sentry + Gemini</title>
      <dc:creator>Pritam Patra</dc:creator>
      <pubDate>Sun, 16 Aug 2026 21:37:22 +0000</pubDate>
      <link>https://dev.to/pritam_patra_429a25dedae6/from-20-mb-to-471-kb-debugging-rawbee-with-sentry-gemini-363g</link>
      <guid>https://dev.to/pritam_patra_429a25dedae6/from-20-mb-to-471-kb-debugging-rawbee-with-sentry-gemini-363g</guid>
      <description>&lt;h1&gt;
  
  
  I Thought Rawbee Was Slow — Then I Opened the Network Tab
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/bugsmash"&gt;DEV's Summer Bug Smash: Smash Stories&lt;/a&gt; powered by &lt;a href="https://sentry.io/" rel="noopener noreferrer"&gt;Sentry&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Project
&lt;/h2&gt;

&lt;p&gt;Rawbee is a full-stack video-sharing and real-time streaming platform that I built as a YouTube-inspired application.&lt;/p&gt;

&lt;p&gt;It currently includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Video uploads&lt;/li&gt;
&lt;li&gt;Video discovery&lt;/li&gt;
&lt;li&gt;Subscriptions&lt;/li&gt;
&lt;li&gt;Watch history&lt;/li&gt;
&lt;li&gt;Live streaming&lt;/li&gt;
&lt;li&gt;WebRTC-based functionality&lt;/li&gt;
&lt;li&gt;Screen sharing&lt;/li&gt;
&lt;li&gt;Socket.IO communication&lt;/li&gt;
&lt;li&gt;Cloudinary media delivery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The stack includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend:&lt;/strong&gt; React 18, TypeScript, Tailwind CSS, Vite&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend:&lt;/strong&gt; Node.js, Express&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database:&lt;/strong&gt; MongoDB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Media:&lt;/strong&gt; Cloudinary&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time:&lt;/strong&gt; Socket.IO, WebRTC&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability:&lt;/strong&gt; Sentry&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI debugging:&lt;/strong&gt; Google Gemini&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Repository:&lt;/strong&gt; &lt;a href="https://github.com/Pritam-mb/rawbee" rel="noopener noreferrer"&gt;View Rawbee on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug Smash PR:&lt;/strong&gt; &lt;a href="https://github.com/Pritam-mb/rawbee/pull/1" rel="noopener noreferrer"&gt;View the Pull Request&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this Bug Smash, I deliberately stopped adding new features and focused on one question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Where is Rawbee doing unnecessary work, and can I prove that my fixes actually made it better?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Moment I Realized Something Was Wrong
&lt;/h2&gt;

&lt;p&gt;Nothing was obviously broken.&lt;/p&gt;

&lt;p&gt;The homepage loaded. Videos appeared. Search worked.&lt;/p&gt;

&lt;p&gt;But the application felt heavier than it should.&lt;/p&gt;

&lt;p&gt;My first instinct was to blame React.&lt;/p&gt;

&lt;p&gt;When I typed into the search bar, the parent component updated and the video-card tree was being evaluated again.&lt;/p&gt;

&lt;p&gt;So I opened React DevTools and started profiling.&lt;/p&gt;

&lt;p&gt;The profiler showed repeated &lt;code&gt;VideoCard&lt;/code&gt; renders during a simple interaction, even when the underlying video data had not changed.&lt;/p&gt;

&lt;p&gt;That was the first bug.&lt;/p&gt;

&lt;p&gt;Then I opened the Network tab.&lt;/p&gt;

&lt;p&gt;And I found a much bigger problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Network Tab Changed Everything
&lt;/h2&gt;

&lt;p&gt;The production homepage was transferring approximately:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.0 MB&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some individual image assets were enormous for their displayed size:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;834 KB
433 KB
160 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An 834 KB thumbnail for a relatively small video card immediately looked wrong.&lt;/p&gt;

&lt;p&gt;At that point, the problem stopped being:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The page feels slow."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and became:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The browser is downloading far more data than this UI should need."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Before: Production Baseline
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;📸 SCREENSHOT 1 — BEFORE NETWORK&lt;/strong&gt;&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%2Ft1um3ilrj881amyorbw8.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft1um3ilrj881amyorbw8.png" alt="Chrome DevTools Network panel showing the unoptimized production build with 30 requests, 2.0 MB transferred, 2.3 MB of resources, and a 2.61 second Load time" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Production baseline before optimization. The homepage transferred approximately 2.0 MB, with individual image assets reaching 834 KB, 433 KB, and 160 KB.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The baseline showed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;30 requests&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2.0 MB transferred&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2.3 MB resources&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;593 ms DOMContentLoaded&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2.61 s Load&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2.82 s Finish&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the first time, I had a real baseline instead of a vague feeling that the application was slow.&lt;/p&gt;

&lt;h1&gt;
  
  
  Fix #1 — Stopping Unnecessary React Renders
&lt;/h1&gt;

&lt;p&gt;The first fix was &lt;code&gt;React.memo()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The problem looked roughly like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Search state changes
        ↓
Home re-renders
        ↓
VideoCard renders again
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But if the video's data hasn't changed, that child component doesn't necessarily need to render again.&lt;/p&gt;

&lt;p&gt;I changed the component to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;memo&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formatDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formatViews&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;VideoCard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;VideoCard&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;video&lt;/span&gt;
&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;VideoCardProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"group cursor-pointer"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Video card UI */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;VideoCard&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also moved pure formatting helpers outside the component so their definitions weren't recreated during every component execution.&lt;/p&gt;

&lt;p&gt;The important optimization, however, was &lt;code&gt;React.memo()&lt;/code&gt; combined with stable props.&lt;/p&gt;

&lt;p&gt;When the &lt;code&gt;video&lt;/code&gt; prop remains referentially equal, React can skip rendering the component.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Profiler — Before
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;📸 SCREENSHOT 2 — REACT PROFILER BEFORE&lt;/strong&gt;&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%2Fjnywt9afuyjg96g9fekf.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjnywt9afuyjg96g9fekf.png" alt="React DevTools Profiler showing VideoCard rendering repeatedly during the unoptimized search interaction" width="799" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before memoization: &lt;code&gt;VideoCard&lt;/code&gt; renders repeatedly during the recorded interaction as parent state changes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The profiler gave me a concrete reason to make the optimization instead of blindly applying &lt;code&gt;React.memo()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  React Profiler — After
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;📸 SCREENSHOT 3 — REACT PROFILER AFTER&lt;/strong&gt;&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%2Fnphg2snr595qiuuhlt5j.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnphg2snr595qiuuhlt5j.png" alt="React DevTools Profiler showing the memoized VideoCard component being skipped during the optimized interaction" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After memoization: the Profiler explicitly reports "Did not render on the client during this profiling session." The memoized component is skipped when its props remain unchanged.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The important result wasn't the raw number of React commits.&lt;/p&gt;

&lt;p&gt;It was seeing React actually skip the component when its props remained unchanged.&lt;/p&gt;

&lt;h1&gt;
  
  
  Fix #2 — The 834 KB Thumbnail
&lt;/h1&gt;

&lt;p&gt;The React optimization removed unnecessary rendering work.&lt;/p&gt;

&lt;p&gt;But the Network tab was still pointing at the much larger problem:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;image delivery.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The original application requested full-size images from Cloudinary even when the UI only needed a relatively small thumbnail.&lt;/p&gt;

&lt;p&gt;I created a helper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getOptimizedCloudinaryUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cloudinary.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/upload/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;`/upload/w_&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/f_auto/q_auto/`&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt;
  &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;getOptimizedCloudinaryUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;video&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;thumbnail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="mi"&gt;500&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;video&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The transformation uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;w_500&lt;/code&gt; to resize the image&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;f_auto&lt;/code&gt; to let Cloudinary select an appropriate format&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;q_auto&lt;/code&gt; to optimize quality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before optimization, some image responses were approximately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;834 KB
433 KB
160 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After optimization, examples included:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7.3 KB
2.0 KB
22.0 KB
2.6 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This became the biggest contributor to the overall network improvement.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.0 MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the optimized production build transferred:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;471 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's a:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;76.5% reduction in transferred data.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  After: Optimized Production Build
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;📸 SCREENSHOT 4 — AFTER NETWORK&lt;/strong&gt;&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%2Fq9lnkkegq42kh1rejyyj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9lnkkegq42kh1rejyyj.png" alt="Chrome DevTools Network panel showing the optimized production build with 32 requests, 471 KB transferred, 767 KB resources, and a 1.60 second Load time" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same page, same throttling, same cache-disabled conditions. Payload dropped from 2.0 MB to 471 KB and Load time from 2.61 s to 1.60 s.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Fix #3 — Why Load JavaScript for Pages the User Hasn't Opened?
&lt;/h1&gt;

&lt;p&gt;Rawbee contains multiple routes.&lt;/p&gt;

&lt;p&gt;But a user visiting the homepage doesn't need every page's JavaScript immediately.&lt;/p&gt;

&lt;p&gt;So I introduced route-level code splitting using &lt;code&gt;React.lazy()&lt;/code&gt; and &lt;code&gt;Suspense&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Login&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex h-screen items-center justify-center"&lt;/span&gt; &lt;span class="na"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"{"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            Loading...
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        }
      &amp;gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Routes&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Route&lt;/span&gt; &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"{&amp;lt;Login"&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/login"&lt;/span&gt;&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;}
          /&amp;gt;

          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Route&lt;/span&gt; &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"{&amp;lt;Home"&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;}
          /&amp;gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Routes&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="na"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
    ↓
Everything loads immediately
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the browser can now load:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Current route
    ↓
Current route chunk
    ↓
User navigates
    ↓
Additional route chunk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps the initial JavaScript workload focused on the route the user is actually visiting.&lt;/p&gt;

&lt;h1&gt;
  
  
  Fix #4 — Cleaning Up Sentry Configuration
&lt;/h1&gt;

&lt;p&gt;While working on observability, I also found that the Sentry DSN was hardcoded in the source.&lt;/p&gt;

&lt;p&gt;I moved it to environment configuration.&lt;/p&gt;

&lt;p&gt;Before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;Sentry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;dsn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your_dsn_here&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;Sentry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;dsn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;VITE_SENTRY_DSN&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VITE_SENTRY_DSN=your_dsn_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the configuration easier to manage across environments and keeps environment-specific configuration outside application source.&lt;/p&gt;

&lt;h1&gt;
  
  
  Fix #5 — When MongoDB Stopped Connecting
&lt;/h1&gt;

&lt;p&gt;While working on the frontend, I encountered a completely different problem.&lt;/p&gt;

&lt;p&gt;MongoDB stopped connecting and the backend reported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;querySrv ECONNREFUSED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, I treated it as a MongoDB problem.&lt;/p&gt;

&lt;p&gt;But the failure was occurring during DNS/SRV resolution.&lt;/p&gt;

&lt;p&gt;I investigated the DNS behavior using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Resolve-DnsName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;mongodb-host&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After confirming the DNS resolution problem in my Windows environment, I changed the MongoDB connection strategy to a direct connection configuration as a workaround.&lt;/p&gt;

&lt;p&gt;The backend then reconnected successfully.&lt;/p&gt;

&lt;h1&gt;
  
  
  Best Use of Sentry
&lt;/h1&gt;

&lt;p&gt;Sentry became part of my debugging workflow rather than something I added only after the application was finished.&lt;/p&gt;

&lt;p&gt;My process became:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Runtime problem
      ↓
Sentry captures the event
      ↓
Inspect issue + stack trace + context
      ↓
Locate affected code
      ↓
Fix
      ↓
Verify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One concrete example happened during a refactor.&lt;/p&gt;

&lt;p&gt;I accidentally removed an import for &lt;code&gt;VideoSkeleton&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The application could still build successfully.&lt;/p&gt;

&lt;p&gt;But when the loading path executed at runtime, the browser threw:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReferenceError: VideoSkeleton is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sentry captured the runtime failure and provided the stack trace and surrounding debugging context.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Something is broken."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I now had:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This exact runtime path is throwing this exact error."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;📸 SCREENSHOT 5 — SENTRY ISSUE&lt;/strong&gt;&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%2Fo9hbila26fx96lrq5vwy.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo9hbila26fx96lrq5vwy.png" alt="Sentry issue page showing the ReferenceError VideoSkeleton is not defined with its stack trace and debugging context" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sentry captured the runtime failure with the stack trace and execution context used during debugging.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Sentry and React Profiler Answered Different Questions
&lt;/h2&gt;

&lt;p&gt;One of the biggest lessons from the project was that different debugging tools answer different questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sentry&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What is failing?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;React Profiler&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What is rendering?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Chrome Network&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What is the browser downloading?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Using separate tools for separate questions made the investigation much clearer.&lt;/p&gt;

&lt;h1&gt;
  
  
  Best Use of Google AI
&lt;/h1&gt;

&lt;p&gt;I used &lt;strong&gt;Google Gemini 3.1 Pro&lt;/strong&gt; as a debugging partner rather than simply asking it to generate code.&lt;/p&gt;

&lt;p&gt;The MongoDB DNS error was the clearest example.&lt;/p&gt;

&lt;p&gt;I provided Gemini with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;querySrv ECONNREFUSED&lt;/code&gt; error&lt;/li&gt;
&lt;li&gt;My Windows environment&lt;/li&gt;
&lt;li&gt;Node.js information&lt;/li&gt;
&lt;li&gt;The MongoDB connection behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Gemini helped investigate possible causes involving DNS resolution, MongoDB SRV records, and IPv4/IPv6 behavior.&lt;/p&gt;

&lt;p&gt;One useful diagnostic was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Resolve-DnsName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;_mongodb._tcp.cluster0.x3qwygg.mongodb.net&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran the command myself.&lt;/p&gt;

&lt;p&gt;That distinction was important:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;I treated Gemini's response as a hypothesis, not as proof.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I independently verified the behavior before changing the connection configuration.&lt;/p&gt;

&lt;p&gt;The debugging loop became:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MongoDB querySrv ECONNREFUSED
        ↓
Gemini analysis
        ↓
DNS / IPv4-IPv6 hypothesis
        ↓
Resolve-DnsName verification
        ↓
Connection configuration workaround
        ↓
Backend restored
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;📸 SCREENSHOT 6 — GEMINI DEBUGGING&lt;/strong&gt;&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%2Fxjiirxdbgbbofewggcow.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxjiirxdbgbbofewggcow.png" alt="Gemini 3.1 Pro conversation analyzing the MongoDB querySrv ECONNREFUSED DNS and IPv4 IPv6 issue" width="799" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Gemini helped narrow down the MongoDB connection failure; I independently verified the suggested diagnostic path before implementing the workaround.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The useful part of AI debugging wasn't:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"AI wrote code for me."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"AI helped me turn an unfamiliar error into a testable hypothesis."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  The Final Benchmark
&lt;/h1&gt;

&lt;p&gt;After applying the fixes, I repeated the production benchmark under the same conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chrome&lt;/li&gt;
&lt;li&gt;Fast 4G throttling&lt;/li&gt;
&lt;li&gt;Browser cache disabled&lt;/li&gt;
&lt;li&gt;Same homepage&lt;/li&gt;
&lt;li&gt;Same machine&lt;/li&gt;
&lt;li&gt;Same production preview workflow&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;Metric&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Network transferred&lt;/td&gt;
&lt;td&gt;2.0 MB&lt;/td&gt;
&lt;td&gt;471 KB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;−76.5%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Resources loaded&lt;/td&gt;
&lt;td&gt;2.3 MB&lt;/td&gt;
&lt;td&gt;767 KB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;−66.7%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Load event&lt;/td&gt;
&lt;td&gt;2.61 s&lt;/td&gt;
&lt;td&gt;1.60 s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;−38.7%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Finish&lt;/td&gt;
&lt;td&gt;2.82 s&lt;/td&gt;
&lt;td&gt;1.81 s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;−35.8%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requests&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;+2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DOMContentLoaded&lt;/td&gt;
&lt;td&gt;593 ms&lt;/td&gt;
&lt;td&gt;624 ms&lt;/td&gt;
&lt;td&gt;+31 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The two numbers I cared about most were:&lt;/p&gt;

&lt;h3&gt;
  
  
  2.0 MB → 471 KB
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;76.5% less network data transferred&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;and:&lt;/p&gt;

&lt;h3&gt;
  
  
  2.61 s → 1.60 s
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;38.7% faster Load event&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Didn't Improve
&lt;/h2&gt;

&lt;p&gt;Not every metric improved.&lt;/p&gt;

&lt;p&gt;The request count changed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;30 → 32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and DOMContentLoaded changed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;593 ms → 624 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also had a stale thumbnail returning a 404, which I flagged as follow-up work.&lt;/p&gt;

&lt;p&gt;I don't want to turn a benchmark into:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Everything got better."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It didn't.&lt;/p&gt;

&lt;p&gt;The meaningful result was the large reduction in transferred data and the improvement in the Load event.&lt;/p&gt;

&lt;p&gt;Those are the results I can actually demonstrate.&lt;/p&gt;

&lt;h1&gt;
  
  
  What I'm Most Proud Of
&lt;/h1&gt;

&lt;p&gt;The thing I'm most proud of isn't a particular line of code.&lt;/p&gt;

&lt;p&gt;It's the change in how I approached the problem.&lt;/p&gt;

&lt;p&gt;Before this work, my instinct would have been:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The application feels slow. I should optimize the code."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now the process is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Observe
   ↓
Measure
   ↓
Hypothesize
   ↓
Test
   ↓
Fix
   ↓
Measure again
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I thought React rendering was the main problem.&lt;/p&gt;

&lt;p&gt;Then the Network tab showed me that an &lt;strong&gt;834 KB thumbnail&lt;/strong&gt; was a much bigger issue.&lt;/p&gt;

&lt;p&gt;That was a useful reminder:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The thing that feels slow isn't always the thing that is actually expensive.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  What I Learned
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Profile before optimizing
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;React.memo()&lt;/code&gt; is useful when you can identify unnecessary renders.&lt;/p&gt;

&lt;p&gt;The profiler gave me evidence to make the change.&lt;/p&gt;

&lt;h3&gt;
  
  
  Network payload matters
&lt;/h3&gt;

&lt;p&gt;A frontend can have clean React code and still feel slow if the browser downloads unnecessary data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Observability changes debugging
&lt;/h3&gt;

&lt;p&gt;Sentry turned runtime errors into actionable issues instead of vague UI failures.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI works best with verification
&lt;/h3&gt;

&lt;p&gt;Gemini helped me investigate the MongoDB problem faster, but I still tested the hypothesis myself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not every metric needs to improve
&lt;/h3&gt;

&lt;p&gt;A useful benchmark should report the actual result, including the numbers that didn't move in the desired direction.&lt;/p&gt;

&lt;h1&gt;
  
  
  What's Next for Rawbee?
&lt;/h1&gt;

&lt;p&gt;The Bug Smash focused on performance, reliability, and debugging.&lt;/p&gt;

&lt;p&gt;But Rawbee is still evolving.&lt;/p&gt;

&lt;p&gt;The next direction is a more interactive social streaming experience.&lt;/p&gt;

&lt;p&gt;Future work includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Live Rooms&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WebRTC video/audio&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Screen sharing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Real-time Socket.IO chat&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Synchronized watch parties&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-user co-streaming&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Host controls&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is eventually to let users watch, communicate, and participate together without needing a separate application for every part of the experience.&lt;/p&gt;

&lt;p&gt;These are &lt;strong&gt;future roadmap features&lt;/strong&gt; and are not included in the performance measurements above.&lt;/p&gt;

&lt;h1&gt;
  
  
  Final Result
&lt;/h1&gt;

&lt;p&gt;The most important transformation was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.0 MB → 471 KB&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A &lt;strong&gt;76.5% reduction in network transfer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Load event changed from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.61 s → 1.60 s&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A &lt;strong&gt;38.7% improvement&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Along the way I also:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduced unnecessary &lt;code&gt;VideoCard&lt;/code&gt; rendering&lt;/li&gt;
&lt;li&gt;Optimized Cloudinary image delivery&lt;/li&gt;
&lt;li&gt;Added route-level code splitting&lt;/li&gt;
&lt;li&gt;Improved Sentry configuration&lt;/li&gt;
&lt;li&gt;Diagnosed a MongoDB DNS/SRV failure&lt;/li&gt;
&lt;li&gt;Used Sentry for runtime observability&lt;/li&gt;
&lt;li&gt;Used Gemini to accelerate debugging&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No rewrite.&lt;/p&gt;

&lt;p&gt;No new framework.&lt;/p&gt;

&lt;p&gt;Just:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Measure → Understand → Fix → Verify&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Links
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Rawbee Repository:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/Pritam-mb/rawbee" rel="noopener noreferrer"&gt;https://github.com/Pritam-mb/rawbee&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bug Smash Pull Request:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/Pritam-mb/rawbee/pull/1" rel="noopener noreferrer"&gt;https://github.com/Pritam-mb/rawbee/pull/1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

&lt;p&gt;And thanks to DEV and Sentry for giving me a reason to stop adding features for a moment and ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How well does the application I've already built actually work?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>devchallenge</category>
      <category>bugsmash</category>
    </item>
    <item>
      <title>Slashing Network Payload by 76%: How I Used Sentry and Gemini to Optimize a Real-Time Streaming Platform</title>
      <dc:creator>Pritam Patra</dc:creator>
      <pubDate>Sun, 16 Aug 2026 19:21:13 +0000</pubDate>
      <link>https://dev.to/pritam_patra_429a25dedae6/slashing-network-payload-by-76-how-i-used-sentry-and-gemini-to-optimize-a-real-time-streaming-fnd</link>
      <guid>https://dev.to/pritam_patra_429a25dedae6/slashing-network-payload-by-76-how-i-used-sentry-and-gemini-to-optimize-a-real-time-streaming-fnd</guid>
      <description>&lt;h1&gt;
  
  
  From 20+ Unnecessary Renders to a 76.5% Smaller Network Payload — How I Optimized Rawbee with Sentry + Gemini
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/bugsmash"&gt;DEV's Summer Bug Smash: Clear the Lineup&lt;/a&gt; powered by &lt;a href="https://sentry.io/" rel="noopener noreferrer"&gt;Sentry&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Project:&lt;/strong&gt; Rawbee —  Collaborative Real-Time Streaming Platform &lt;br&gt;
&lt;strong&gt;Implementation:&lt;/strong&gt; &lt;a href="https://github.com/Pritam-mb/rawbee/pull/1" rel="noopener noreferrer"&gt;View the GitHub Pull Request&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Repository:&lt;/strong&gt; &lt;a href="https://github.com/Pritam-mb/rawbee" rel="noopener noreferrer"&gt;View the GitHub Repository&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rawbee is a full-stack video sharing and live streaming platform with traditional VOD features (uploads, subscriptions, watch history) alongside a WebRTC-based collaborative streaming engine for co-streaming, screen sharing, and in-browser voice/video chat.&lt;/p&gt;

&lt;p&gt;The current stack includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend:&lt;/strong&gt; React 18, TypeScript, Tailwind CSS, Vite&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend:&lt;/strong&gt; Node.js, Express&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database:&lt;/strong&gt; MongoDB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Media:&lt;/strong&gt; Cloudinary&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability:&lt;/strong&gt; Sentry&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI debugging assistant:&lt;/strong&gt; Google Gemini&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the Summer Bug Smash, I focused on improving the existing application rather than adding a new feature.&lt;/p&gt;

&lt;p&gt;My goal was simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Find real problems → measure them → understand the root cause → fix them → measure again.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;During the Bug Smash, I addressed frontend performance issues, a backend reliability problem, and runtime errors surfaced through Sentry.&lt;/p&gt;


&lt;h2&gt;
  
  
  Bug Fix or Performance Improvement
&lt;/h2&gt;

&lt;p&gt;As Rawbee grew, the homepage started doing more work than necessary.&lt;/p&gt;

&lt;p&gt;The first issue appeared while using the search bar. Updating the search state caused the parent component to re-render, and the video-card grid was repeatedly evaluated even when individual video data had not changed. React Profiler confirmed repeated &lt;code&gt;VideoCard&lt;/code&gt; renders during the interaction, which led me to investigate whether those renders were actually necessary.&lt;/p&gt;

&lt;p&gt;The second problem was visible directly in Chrome DevTools. The homepage was transferring a surprisingly large amount of data, with several individual image assets reaching hundreds of kilobytes.&lt;/p&gt;

&lt;p&gt;The original production trace contained images such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;834 KB PNG
433 KB JPEG
160 KB JPEG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also found that the frontend was loading more JavaScript up front than necessary because page-level code was not being split efficiently.&lt;/p&gt;

&lt;p&gt;On the backend, MongoDB was failing to connect in my Windows environment with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;querySrv ECONNREFUSED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, Sentry was capturing frontend runtime errors that gave me useful visibility into failures occurring inside the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Controlled Before/After Benchmark
&lt;/h2&gt;

&lt;p&gt;To make the performance comparison meaningful, I benchmarked the &lt;strong&gt;before and after production builds&lt;/strong&gt; using the same setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chrome&lt;/li&gt;
&lt;li&gt;Fast 4G throttling&lt;/li&gt;
&lt;li&gt;Browser cache disabled&lt;/li&gt;
&lt;li&gt;Same homepage&lt;/li&gt;
&lt;li&gt;Same machine&lt;/li&gt;
&lt;li&gt;Same production preview workflow&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;Metric&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;th&gt;Improvement&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Network transferred&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2.0 MB&lt;/td&gt;
&lt;td&gt;471 KB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;76.5% reduction&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Resources loaded&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2.3 MB&lt;/td&gt;
&lt;td&gt;767 KB&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;66.7% reduction&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Load event&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2.61 s&lt;/td&gt;
&lt;td&gt;1.60 s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;38.7% faster&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Finish&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;2.82 s&lt;/td&gt;
&lt;td&gt;1.81 s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;35.8% faster&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requests&lt;/td&gt;
&lt;td&gt;30&lt;/td&gt;
&lt;td&gt;32&lt;/td&gt;
&lt;td&gt;No improvement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DOMContentLoaded&lt;/td&gt;
&lt;td&gt;593 ms&lt;/td&gt;
&lt;td&gt;624 ms&lt;/td&gt;
&lt;td&gt;Slightly higher&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I am deliberately reporting the metrics that actually improved instead of dressing every measurement as a win. Request count went slightly up, partly because of a stale thumbnail returning 404, and DOMContentLoaded shifted marginally within measurement noise.&lt;/p&gt;

&lt;p&gt;The headline result is the &lt;strong&gt;76.5% payload reduction&lt;/strong&gt;.&lt;br&gt;
The biggest measurable gain came from reducing the amount of image data transferred to the browser.&lt;/p&gt;
&lt;h3&gt;
  
  
  Before: Production Benchmark
&lt;/h3&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%2Ft1um3ilrj881amyorbw8.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft1um3ilrj881amyorbw8.png" alt="Chrome DevTools Network panel showing the unoptimized production build with 30 requests, 2.0 MB transferred, 2.3 MB of resources, and a 2.61 second Load time" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Production baseline before optimization. The homepage transferred approximately 2.0 MB, dominated by unoptimized image assets — including an 834 KB PNG, a 433 KB JPG, and a 160 KB JPG.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  After: Production Benchmark
&lt;/h3&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%2Fq9lnkkegq42kh1rejyyj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9lnkkegq42kh1rejyyj.png" alt="Chrome DevTools Network panel showing the optimized production build with reduced image payload and improved loading performance" width="800" height="519"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same page, same throttling, same cache-disabled conditions. Payload dropped from 2.0 MB to 471 KB and Load time from 2.61 s to 1.60 s.&lt;/em&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;The complete implementation is available in the &lt;a href="https://github.com/Pritam-mb/rawbee/pull/1" rel="noopener noreferrer"&gt;GitHub Pull Request&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The main changes covered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;React.memo
Cloudinary image transformations
React.lazy / Suspense
MongoDB connection workaround
Sentry configuration improvements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. Memoizing &lt;code&gt;VideoCard&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;memo&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formatDuration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formatViews&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;views&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;VideoCard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;VideoCard&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;video&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;VideoCardProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"group cursor-pointer"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* Video card UI */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;VideoCard&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important optimization here is &lt;code&gt;React.memo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When the parent component updates, React can skip rendering the memoized &lt;code&gt;VideoCard&lt;/code&gt; if the &lt;code&gt;video&lt;/code&gt; prop remains referentially equal.&lt;/p&gt;

&lt;p&gt;I also moved pure formatting helpers outside the component so they are not recreated as part of each component execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Cloudinary Image Optimization
&lt;/h3&gt;

&lt;p&gt;This was the single biggest performance win in the benchmark. An 834 KB PNG for a card thumbnail was far larger than necessary for the displayed dimensions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getOptimizedCloudinaryUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cloudinary.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/upload/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;`/upload/w_&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/f_auto/q_auto/`&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt;
  &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;getOptimizedCloudinaryUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;video&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;thumbnail&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;video&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The w_500 resizes to display dimensions, f_auto serves modern formats (WebP/AVIF) where supported, and q_auto picks quality intelligently.&lt;/p&gt;

&lt;p&gt;The before trace contained image responses of 834 KB, 433 KB, and 160 KB. The after trace shows the same images at 7.3 KB, 2.0 KB, 22.0 KB, and 2.6 KB. This single change is the primary contributor to the 2.0 MB → 471 KB reduction.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Route-Level Code Splitting
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Home&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Home&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./pages/Login&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt;
        &lt;span class="na"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex h-screen items-center justify-center"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            Loading application...
          &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Routes&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/login"&lt;/span&gt; &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Login&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Route&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt; &lt;span class="na"&gt;element&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Home&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Routes&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Router&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This moved page-specific JavaScript into route-level chunks instead of requiring every page to be part of the initial route workload.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Sentry Environment Configuration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;// frontend/.env
&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="gi"&gt;+ VITE_SENTRY_DSN=your_dsn_here
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;// frontend/src/main.tsx
&lt;span class="err"&gt;
&lt;/span&gt;&lt;span class="p"&gt;Sentry.init({
&lt;/span&gt;&lt;span class="gd"&gt;-  dsn: "your_dsn_here",
&lt;/span&gt;&lt;span class="gi"&gt;+  dsn: import.meta.env.VITE_SENTRY_DSN,
&lt;/span&gt;});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the configuration easier to manage across different environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. MongoDB DNS Failure
&lt;/h3&gt;

&lt;p&gt;The backend was failing with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;querySrv ECONNREFUSED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I investigated the DNS behavior in the Windows environment and used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Resolve-DnsName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;mongodb-host&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to verify the DNS resolution problem.&lt;/p&gt;

&lt;p&gt;I then switched to a direct MongoDB connection configuration as a workaround for the affected environment, restoring database connectivity.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Improvements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Eliminating unnecessary React work
&lt;/h3&gt;

&lt;p&gt;The first performance problem was component-level rendering.&lt;/p&gt;

&lt;p&gt;A search update causes the &lt;code&gt;Home&lt;/code&gt; component to update, but an individual video card does not necessarily need to update with it.&lt;/p&gt;

&lt;p&gt;Before optimization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Search state changes
        ↓
Home updates
        ↓
VideoCard repeatedly renders
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After optimization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Search state changes
        ↓
Home updates
        ↓
React.memo checks props
        ↓
VideoCard render skipped when props are unchanged
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  React Profiler Evidence
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;React Profiler evidence — before:&lt;/strong&gt;&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%2Fryav79n2bb1ripr0qrds.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fryav79n2bb1ripr0qrds.png" alt="React DevTools Profiler showing VideoCard rendering repeatedly during the unoptimized search interaction" width="799" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Before memoization: VideoCard renders repeatedly across the profiling session as parent state updates.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React Profiler evidence — after:&lt;/strong&gt;&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%2Fo9x96aqdpi88xg6nsw6c.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo9x96aqdpi88xg6nsw6c.png" alt="React DevTools Profiler showing VideoCard2 as a memoized component that did not render during the optimized interaction" width="800" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After memoization: the Profiler explicitly reports "Did not render on the client during this profiling session." The memoized component is skipped entirely when props are unchanged.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;React Profiler evidence for the memoized component. The optimized &lt;code&gt;VideoCard&lt;/code&gt; was skipped during the recorded interaction when its props remained unchanged.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I am intentionally not presenting the React commit count itself as the number of renders. The important result is that the profiler directly shows the memoized component being skipped.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Reducing image payload
&lt;/h3&gt;

&lt;p&gt;The largest measurable performance improvement came from image delivery.&lt;/p&gt;

&lt;p&gt;The original production trace contained image resources such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;834 KB
433 KB
160 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After applying Cloudinary transformations, the optimized trace contained much smaller responses, including examples around:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7.3 KB
2.0 KB
22.0 KB
2.6 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This change was the main contributor to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.0 MB → 471 KB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or a &lt;strong&gt;76.5% reduction in transferred data&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Reducing initial JavaScript work
&lt;/h3&gt;

&lt;p&gt;The route-level &lt;code&gt;React.lazy()&lt;/code&gt; change means that the browser no longer needs to load code for every page before the current route can operate.&lt;/p&gt;

&lt;p&gt;Before:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Initial application
├── Home
├── Login
├── other route code
└── dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Initial route
├── shared dependencies
└── current page chunk

Additional page
└── loaded on demand
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps the initial route focused on the code it actually needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Backend reliability improvement
&lt;/h3&gt;

&lt;p&gt;The MongoDB issue was not treated as a performance metric because it was fundamentally a reliability problem.&lt;/p&gt;

&lt;p&gt;The debugging process was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MongoDB connection fails
        ↓
querySrv ECONNREFUSED
        ↓
DNS investigation
        ↓
Resolve-DnsName verification
        ↓
Direct connection workaround
        ↓
Backend connectivity restored
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This fix removed a development blocker that was preventing the API from connecting to the database.&lt;/p&gt;




&lt;h2&gt;
  
  
  Best Use of Sentry
&lt;/h2&gt;

&lt;p&gt;I am submitting this project for the &lt;strong&gt;Best Use of Sentry&lt;/strong&gt; category.&lt;/p&gt;

&lt;p&gt;Sentry became part of the debugging workflow rather than simply being another dependency.&lt;/p&gt;

&lt;p&gt;The workflow was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Runtime problem
      ↓
Sentry captures the event
      ↓
Inspect issue + stack trace
      ↓
Locate affected code
      ↓
Fix
      ↓
Verify application behavior
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During development, Sentry captured frontend runtime errors including:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReferenceError: VideoSkeleton is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sentry provided:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;issue details&lt;/li&gt;
&lt;li&gt;event information&lt;/li&gt;
&lt;li&gt;stack trace&lt;/li&gt;
&lt;li&gt;browser/environment context&lt;/li&gt;
&lt;li&gt;affected execution path&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That helped me move from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Something is broken."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;to:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This specific code path is failing for this specific reason."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Sentry Evidence
&lt;/h3&gt;

&lt;p&gt;Sentry became part of my debugging loop, not just a dependency in package.json. The workflow was consistent throughout the Bug Smash:&lt;/p&gt;

&lt;p&gt;Runtime failure → Sentry captures event → inspect issue + stack trace + context → locate affected code → fix → verify.&lt;/p&gt;

&lt;p&gt;One concrete example: during a refactor, I accidentally removed an import for VideoSkeleton. It didn't crash the build — it only threw at runtime when the loading state triggered. Without Sentry I'd have found it eventually when a user reported a blank page. With Sentry, I had it within minutes:&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%2Fo9hbila26fx96lrq5vwy.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo9hbila26fx96lrq5vwy.png" alt="Sentry issue page showing the ReferenceError VideoSkeleton is not defined with its stack trace and debugging context" width="800" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sentry captured the ReferenceError with the full stack trace, release hash, browser and OS context, and event breadcrumbs. This turned "the page is broken sometimes" into a single actionable issue with a direct line to the failing code path.&lt;/p&gt;

&lt;p&gt;What Sentry gave me that my terminal couldn't: the release hash tying the error to a specific build, the browser and OS the user hit it on, the URL and route where it happened, and the trace ID linking to surrounding events. That context is what turned a five-word error into a five-minute fix.&lt;/p&gt;

&lt;p&gt;Importantly, I used Sentry for runtime observability and React Profiler for component rendering analysis — I didn't conflate them. Sentry told me what was failing; the Profiler told me how components were rendering. Keeping those two evidence streams separate gave me a cleaner picture of the application's actual behavior.&lt;/p&gt;




&lt;h2&gt;
  
  
  Best Use of Google AI
&lt;/h2&gt;

&lt;p&gt;I am also submitting this project for the &lt;strong&gt;Best Use of Google AI&lt;/strong&gt; category.&lt;/p&gt;

&lt;p&gt;I used &lt;strong&gt;Gemini 3.1 Pro&lt;/strong&gt; as a debugging partner during the Bug Smash rather than simply asking it to generate the implementation.&lt;/p&gt;

&lt;p&gt;The clearest example was the MongoDB connection problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Problem
&lt;/h3&gt;

&lt;p&gt;The backend returned:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;querySrv ECONNREFUSED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the application could not establish its database connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Gemini investigation
&lt;/h3&gt;

&lt;p&gt;I provided Gemini with the error and information about my Windows environment.&lt;/p&gt;

&lt;p&gt;Gemini analyzed the failure and suggested investigating DNS and IPv4/IPv6 resolution behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Independent verification
&lt;/h3&gt;

&lt;p&gt;I did not blindly copy the recommendation.&lt;/p&gt;

&lt;p&gt;I ran the diagnostic myself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Resolve-DnsName&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;mongodb-host&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and verified the DNS resolution problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Implementation
&lt;/h3&gt;

&lt;p&gt;After confirming the issue, I changed the MongoDB connection strategy to use a direct connection configuration that avoided the failing SRV-resolution path.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Result
&lt;/h3&gt;

&lt;p&gt;The backend was able to reconnect to MongoDB and resume normal operation.&lt;/p&gt;

&lt;p&gt;The overall debugging loop became:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;querySrv ECONNREFUSED
        ↓
Gemini analysis
        ↓
DNS hypothesis
        ↓
Resolve-DnsName verification
        ↓
Connection workaround
        ↓
Backend restored
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;I treated Gemini's response as a hypothesis, not as the final answer. I independently verified the DNS behavior before changing the MongoDB connection strategy.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Gemini Evidence
&lt;/h3&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%2Fxjiirxdbgbbofewggcow.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxjiirxdbgbbofewggcow.png" alt="Gemini 3.1 Pro conversation analyzing the MongoDB querySrv ECONNREFUSED DNS and IPv4 IPv6 issue" width="799" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the screenshot showing Gemini analyzing the &lt;code&gt;querySrv ECONNREFUSED&lt;/code&gt; problem and discussing the DNS/connection investigation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Suggested caption: Gemini helped narrow down the MongoDB connection failure; I independently verified the suggested diagnostic path before implementing the workaround.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The important part for me was not simply generating code faster. It was shortening the path from an unfamiliar error to a testable hypothesis.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Impact
&lt;/h2&gt;

&lt;p&gt;The clearest measured result was the reduction in network transfer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.0 MB → 471 KB&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a &lt;strong&gt;76.5% reduction&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Load event changed from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.61 s → 1.60 s&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;which is a &lt;strong&gt;38.7% reduction in Load time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The total resource footprint changed from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.3 MB → 767 KB&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;which is a &lt;strong&gt;66.7% reduction&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The React Profiler also showed that the optimized &lt;code&gt;VideoCard&lt;/code&gt; could be skipped during the recorded search interaction when its props remained unchanged.&lt;/p&gt;

&lt;p&gt;The MongoDB issue was resolved as a backend reliability fix, while Sentry and Gemini made the debugging workflow more observable and efficient.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Deliberately Did Not Claim
&lt;/h2&gt;

&lt;p&gt;Not every metric improved.&lt;/p&gt;

&lt;p&gt;Request count moved from 30 to 32, partly because a stale thumbnail returned 404. DOMContentLoaded moved from 593 ms to 624 ms, which I consider within the noise of this benchmark.&lt;/p&gt;

&lt;p&gt;The strongest measured result is the reduction in transferred data from 2.0 MB to 471 KB, followed by the Load improvement from 2.61 s to 1.60 s.&lt;/p&gt;

&lt;p&gt;The Sentry runtime event shown in this post was captured in development; validating the same workflow against production traffic is a next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Roadmap for Rawbee
&lt;/h2&gt;

&lt;p&gt;The Bug Smash was focused on performance and reliability, but I also have a larger direction planned for Rawbee.&lt;/p&gt;

&lt;p&gt;The next stage is to turn Rawbee from a traditional video-sharing application into a more interactive, social streaming platform.&lt;/p&gt;

&lt;p&gt;Planned future work includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live Rooms&lt;/strong&gt; where users can create and join shared sessions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WebRTC video/audio calling&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Screen sharing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Real-time room chat using Socket.io&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Synchronized watch experiences&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multi-user collaborative streaming&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Host controls and participant management&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to let users watch and interact together without needing a separate Discord or video-call application.&lt;/p&gt;

&lt;p&gt;These real-time features are &lt;strong&gt;future work&lt;/strong&gt; and are not included in the performance measurements reported in this Bug Smash submission.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This Bug Smash started with a simple observation: Rawbee was getting slower as the application grew.&lt;/p&gt;

&lt;p&gt;Instead of rewriting large parts of the project, I used measurement and debugging tools to identify where the actual problems were.&lt;/p&gt;

&lt;p&gt;The result was a focused set of improvements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;React.memo
      ↓
Less unnecessary rendering

Cloudinary transformations
      ↓
Smaller image payloads

React.lazy + Suspense
      ↓
Route-level code splitting

DNS investigation + MongoDB workaround
      ↓
Backend reliability restored

Sentry
      ↓
Runtime visibility

Gemini
      ↓
Faster debugging investigation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The biggest measurable performance improvement was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.0 MB → 471 KB transferred&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;with the production Load event improving from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;2.61 s → 1.60 s&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The main takeaway is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Before optimizing code, measure what the application is actually doing.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is what I tried to do throughout this Bug Smash: identify the real bottlenecks, fix them deliberately, and verify the results instead of relying on assumptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub Pull Request:&lt;/strong&gt; &lt;a href="https://github.com/Pritam-mb/rawbee/pull/1" rel="noopener noreferrer"&gt;View PR #1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repository:&lt;/strong&gt; &lt;a href="https://github.com/Pritam-mb/rawbee" rel="noopener noreferrer"&gt;View Rawbee on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for checking out my submission!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>bugsmash</category>
      <category>ai</category>
      <category>sentry</category>
    </item>
  </channel>
</rss>
