<?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: Sidharth Devaraj</title>
    <description>The latest articles on DEV Community by Sidharth Devaraj (@sidharthd).</description>
    <link>https://dev.to/sidharthd</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F371000%2F87a52512-878b-4886-b074-77082362933b.jpeg</url>
      <title>DEV Community: Sidharth Devaraj</title>
      <link>https://dev.to/sidharthd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sidharthd"/>
    <language>en</language>
    <item>
      <title>Don't Skip DSA: A Real-World Optimisation Win</title>
      <dc:creator>Sidharth Devaraj</dc:creator>
      <pubDate>Fri, 29 Aug 2025 10:42:22 +0000</pubDate>
      <link>https://dev.to/sidharthd/dont-skip-dsa-a-real-world-optimisation-win-46fl</link>
      <guid>https://dev.to/sidharthd/dont-skip-dsa-a-real-world-optimisation-win-46fl</guid>
      <description>&lt;p&gt;There's a common sentiment in our web and mobile development world:  &lt;/p&gt;

&lt;p&gt;"Do I really need Data Structures and Algorithms (DSA)? Isn't that just for MAANG interviews?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My experience says yes&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;I want to share a story from one of my projects where a fundamental understanding of DSA saved my day in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: Optimising Our Cash Pool
&lt;/h2&gt;

&lt;p&gt;I was working on an application where we managed invoice payments. We had a specific, real-world optimisation problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Given a fixed pool of cash, how do we pay as many outstanding invoices as possible to maximise the total amount paid, without exceeding the available cash?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sounds like a fairly standard business requirement, right?  &lt;/p&gt;

&lt;p&gt;At first glance, one might start thinking about complex loops, sorting strategies, or even greedy approaches. Many developers might jump straight into writing custom, bespoke logic.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The "Aha!" Moment: Pattern Recognition
&lt;/h2&gt;

&lt;p&gt;But as I looked at the problem, something clicked. I realised this wasn't a unique, never-before-seen challenge.  &lt;/p&gt;

&lt;p&gt;This was a classic instance of the &lt;strong&gt;Knapsack Problem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's break down why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The "Knapsack":&lt;/strong&gt; Our fixed cash pool
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The "Items":&lt;/strong&gt; Each individual invoice
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The "Weight" / "Value":&lt;/strong&gt; The amount of each invoice (since our goal was to maximise the total amount paid, the invoice amount served as both its "weight" in the budget and its "value" towards our goal)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Constraint:&lt;/strong&gt; Invoices had to be paid in full (0/1 choice – either an invoice is paid or it's not; no partial payments)
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Solution: Leveraging Proven Algorithms
&lt;/h2&gt;

&lt;p&gt;Once I recognised this underlying pattern, the path forward became incredibly clear.  &lt;/p&gt;

&lt;p&gt;Instead of spending hours or days trying to invent a new, possibly inefficient algorithm, I knew I could leverage well-established solutions for the Subset Sum Problem.  &lt;/p&gt;

&lt;p&gt;This meant:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed of Development:&lt;/strong&gt; I wasn't reinventing the wheel. I could recall or quickly look up the optimal approaches for this class of problem.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Efficiency and Reliability:&lt;/strong&gt; I could implement an algorithm that was already proven for its performance characteristics, ensuring our cash allocation was truly optimised.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintainability:&lt;/strong&gt; Future developers (or even myself later) would recognise the pattern and the algorithmic choice, making the code easier to understand and maintain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allowed me to ship a critical feature quickly and with confidence in its efficiency.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters for Developers Like Us
&lt;/h2&gt;

&lt;p&gt;This experience solidified a key principle for me: a strong foundation in core computer science principles is an incredible superpower in real-world development. &lt;/p&gt;

&lt;p&gt;It's not about memorising every algorithm, but about:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pattern Recognition:&lt;/strong&gt; Learning to identify the fundamental structure of a problem, even when it's cloaked in business jargon.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leveraging Existing Knowledge:&lt;/strong&gt; Knowing that many problems have already been solved, and understanding which solutions apply.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Building Robust Solutions:&lt;/strong&gt; Choosing algorithms with known performance characteristics rather than creating ad-hoc, potentially inefficient ones.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, next time you're wondering if that DSA course or LeetCode challenge is really worth it, remember that it's training your brain to be a better, more efficient problem-solver in the long run.  &lt;/p&gt;




&lt;h2&gt;
  
  
  What About You?
&lt;/h2&gt;

&lt;p&gt;Have you had a similar &lt;strong&gt;"aha!" moment&lt;/strong&gt; where a seemingly &lt;em&gt;academic&lt;/em&gt; concept from DSA (or another CS theory) was the perfect solution to a real-world problem in your projects?  &lt;/p&gt;

&lt;p&gt;👉 Share your stories in the comments below!  &lt;/p&gt;

</description>
      <category>dsa</category>
      <category>algorithms</category>
      <category>softwaredevelopment</category>
      <category>programming</category>
    </item>
    <item>
      <title>Beyond CRUD: System Design Lessons From a Video Re-Streaming Control Platform</title>
      <dc:creator>Sidharth Devaraj</dc:creator>
      <pubDate>Thu, 28 Aug 2025 08:46:29 +0000</pubDate>
      <link>https://dev.to/sidharthd/beyond-crud-system-design-lessons-from-a-video-re-streaming-control-platform-1n5i</link>
      <guid>https://dev.to/sidharthd/beyond-crud-system-design-lessons-from-a-video-re-streaming-control-platform-1n5i</guid>
      <description>&lt;p&gt;Most web apps boil down to CRUD - Create, Read, Update, Delete.&lt;/p&gt;

&lt;p&gt;But every now and then, a project comes along that breaks the monotony. Instead of just wiring up endpoints and database rows, you need to start thinking about systems — processes, configs, orchestration, resilience.&lt;/p&gt;

&lt;p&gt;This post is a reflection on one such project I worked on. A client in the video re-streaming¹ space wanted a control dashboard for their customers — something simple on the surface:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Let users toggle their streams on and off."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sounds easy, right? Just a button, an API call, done.&lt;/p&gt;

&lt;p&gt;Except… those toggles had to orchestrate system processes, job queues, config updates, and real-time feedback loops — all while hiding that complexity behind a clean web UI.&lt;/p&gt;

&lt;p&gt;It turned out to be one of the most fascinating technical problems I’ve worked on. Let me walk you through the challenges we hit and the solutions we designed.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. State Management: Database vs. System
&lt;/h2&gt;

&lt;p&gt;Most web apps can treat the database as the ultimate source of truth. Not here.&lt;/p&gt;

&lt;p&gt;The streaming process only respected its &lt;strong&gt;configuration file&lt;/strong&gt;, which lived on disk. That file dictated whether a stream was active or not.&lt;/p&gt;

&lt;p&gt;This raised a tricky problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the database said "stream = on" but the file said otherwise, who do we believe?
&lt;/li&gt;
&lt;li&gt;How do we keep both in sync without introducing drift?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We treated the configuration file as the source of truth.
&lt;/li&gt;
&lt;li&gt;The API server became a translation layer:
&lt;code&gt;user actions → update config file → reflect state in DB&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;On startup, the system reconciled the DB against the file to re-establish a consistent state.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This ensured that if the process restarted or a manual change occurred, we didn’t blindly trust stale DB values.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Multi-Step Orchestration
&lt;/h2&gt;

&lt;p&gt;Toggling a stream wasn’t as simple as flipping a flag. The real sequence looked like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update the configuration file.
&lt;/li&gt;
&lt;li&gt;Restart the streaming process.
&lt;/li&gt;
&lt;li&gt;Wait until the process stabilized and confirmed readiness.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each step could fail. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;File write errors (permissions, disk issues).
&lt;/li&gt;
&lt;li&gt;Process restart failure.
&lt;/li&gt;
&lt;li&gt;Process enters a crash loop.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We built an &lt;strong&gt;asynchronous job queue&lt;/strong&gt; with retries and compensation.
&lt;/li&gt;
&lt;li&gt;Each toggle request became a background job.
&lt;/li&gt;
&lt;li&gt;Jobs moved through states: &lt;code&gt;PENDING → RUNNING → COMPLETED/FAILED&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;If a step failed, the job queue retried or rolled back gracefully (e.g., restore old config).
&lt;/li&gt;
&lt;li&gt;The system ensured no two jobs interfered, keeping operations &lt;strong&gt;atomic&lt;/strong&gt; from the user’s perspective.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was crucial for stability—otherwise a single half-completed toggle could corrupt the live state.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Real-Time Feedback to Users
&lt;/h2&gt;

&lt;p&gt;Users didn’t want to "fire and forget." They wanted to know if their toggle request succeeded.&lt;/p&gt;

&lt;p&gt;A plain HTTP request wasn’t enough because the job was async. Returning "OK" immediately would lie — the process might still be restarting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We built a &lt;strong&gt;persistent WebSocket channel&lt;/strong&gt; between server and client.
&lt;/li&gt;
&lt;li&gt;When a toggle was requested, the client got back a &lt;code&gt;jobId&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;The UI subscribed over WebSocket to that job’s status.
&lt;/li&gt;
&lt;li&gt;As the background job progressed, the server pushed updates (&lt;code&gt;in progress…&lt;/code&gt;, &lt;code&gt;completed&lt;/code&gt;, or &lt;code&gt;failed&lt;/code&gt;).
&lt;/li&gt;
&lt;li&gt;The UI displayed real-time status, so customers always knew the outcome.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This turned a frustrating black box into a transparent, transactional experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.sidharthd.dev/video_stream_toggle.svg" rel="noopener noreferrer"&gt;Sequence diagram of the workflow can be viewed here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Key Takeaways
&lt;/h2&gt;

&lt;p&gt;This project was a reminder that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Source of truth matters.&lt;/strong&gt; Sometimes it’s not the database.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous orchestration is unavoidable&lt;/strong&gt; when dealing with external systems.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-time feedback builds trust.&lt;/strong&gt; Users don’t just want features—they want visibility into what’s happening.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architecture resilience &amp;gt; code cleverness.&lt;/strong&gt; The hardest part wasn’t writing code, it was designing a system that wouldn’t collapse under edge cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;What looked like a trivial feature—"toggle a stream"—actually turned into a system design problem, touching on &lt;strong&gt;state synchronisation, async orchestration, and real-time communication&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For me, this was one of the most rewarding technical challenges I’ve worked on. It taught me that the real engineering battles often happen at the intersection of web applications and the messy, stateful systems they control.&lt;/p&gt;

&lt;p&gt;💬 I’d love to hear from others:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Have you ever faced a "simple" feature request that turned into a full-on system design challenge?&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;¹ &lt;strong&gt;Video re-streaming:&lt;/strong&gt; The process of taking a live video feed from one source and re-broadcasting it to multiple platforms (e.g., streaming a live event to YouTube, Facebook, and Twitch simultaneously).&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>architecture</category>
      <category>webdev</category>
      <category>engineeringchallenges</category>
    </item>
    <item>
      <title>From Role-Based Chaos to Resource-Based Bliss: My REST API 'A-Ha!' Moment 💡</title>
      <dc:creator>Sidharth Devaraj</dc:creator>
      <pubDate>Tue, 26 Aug 2025 12:02:36 +0000</pubDate>
      <link>https://dev.to/sidharthd/from-role-based-chaos-to-resource-based-bliss-my-rest-api-a-ha-moment-1glb</link>
      <guid>https://dev.to/sidharthd/from-role-based-chaos-to-resource-based-bliss-my-rest-api-a-ha-moment-1glb</guid>
      <description>&lt;p&gt;Hey everyone,&lt;/p&gt;

&lt;p&gt;I want to share a confession from years ago, back when I was just starting out with REST API design.&lt;/p&gt;

&lt;p&gt;I thought I was being super clever and organised by designing my API endpoints around user roles. My brain went straight for &lt;code&gt;/admin/...&lt;/code&gt; for all things admin and &lt;code&gt;/customer/...&lt;/code&gt; for customer-related actions. Felt neat, right? 😅&lt;/p&gt;

&lt;p&gt;Then came the inevitable moment when both admins and customers needed to interact with the same data (users, for example), and my perfectly segmented system crumbled fast. 🤦‍♂️&lt;/p&gt;

&lt;p&gt;That's when the lightbulb finally went off: resource-based RESTful design isn't about &lt;em&gt;who&lt;/em&gt; is accessing the data, it's fundamentally about the &lt;em&gt;data itself&lt;/em&gt;. This simple but profound shift saved me from countless headaches and taught me a crucial lesson in API architecture.&lt;/p&gt;

&lt;p&gt;Instead of having separate, duplicated logic, focusing on &lt;strong&gt;resources&lt;/strong&gt; like &lt;code&gt;/users&lt;/code&gt;, &lt;code&gt;/products&lt;/code&gt;, and &lt;code&gt;/orders&lt;/code&gt;, and then implementing proper authentication and authorisation to control access based on roles, made everything so much cleaner and more maintainable.&lt;/p&gt;

&lt;p&gt;Anyone else have a similar early "a-ha!" moment in their dev journey? What's a mistake you made that ended up teaching you a valuable lesson? Share your stories below! 👇&lt;/p&gt;

</description>
      <category>restapi</category>
      <category>developerlife</category>
      <category>lessonslearned</category>
    </item>
  </channel>
</rss>
