<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vamshi Bachaneboina on Medium]]></title>
        <description><![CDATA[Stories by Vamshi Bachaneboina on Medium]]></description>
        <link>https://medium.com/@vamshi.bachaneboina?source=rss-748afdd8fe8e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*E3Z20GbU54vb1_YtjPKAbA.jpeg</url>
            <title>Stories by Vamshi Bachaneboina on Medium</title>
            <link>https://medium.com/@vamshi.bachaneboina?source=rss-748afdd8fe8e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:36:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vamshi.bachaneboina/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing Transformers in dope.security’s Code Saga]]></title>
            <link>https://medium.com/dopesecurity/introducing-transformers-in-dope-securitys-code-saga-eadff6cddf86?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/eadff6cddf86</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react-query]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 20:32:57 GMT</pubDate>
            <atom:updated>2023-10-23T14:51:59.184Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RL9N6K-c5BmfFCrll_9hNw.jpeg" /></figure><p>Once upon a code time in <a href="https://dope.security/">dope.security</a>, frontend components and backend data responses were like cats and dogs. Backend tossed over data as per its whims, while frontend caught it, often grumbling. They needed a mediator, <em>a hero</em>. Enter <strong>Optimus Prime</strong>, not with a cape, but with a knack for <strong>tuning data</strong>.</p><p>He eyed the code war, rolled up his sleeves, and whipped out his secret sauce: <strong>the Transformers layer</strong>. This wasn’t about morphing cars, but morphing data, right between the <em>Service</em> and <em>Data</em> layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEBm22adn_g47CobHnKfvg.png" /><figcaption>Frontend Multilayers</figcaption></figure><p>Here is the sample code of how our Optimus implemented the Transformers layer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09BKs0WMNgSyh5d7IpwEUA.png" /><figcaption>Service Layer Code</figcaption></figure><p>Here, <strong>morphData</strong> was where Optimus performed his magic, turning grumpy backend data into happy frontend-friendly data. This happy data then trotted down to the Data layer, ready to play nice with the frontend components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zd9SH7pAuBVgFKGdO0ac1A.png" /><figcaption>Data Layer</figcaption></figure><p>And thus, with a sprinkle of code magic, Optimus Prime bridged the backend-frontend feud, making data dance to the frontend’s tune. The Transformers layer became the playground where data shed its rigid backend cloak and donned a flexible frontend attire, ready to jive with the UI components.</p><h3>Transformers with React Query</h3><p>After the initial victory of architecting the Transformers Layer, Optimus Prime wasn’t just going to drop the mic. He knew there were smarter ways to conduct the data orchestra. His eyes gleamed as he stumbled upon React Query’s <a href="https://tanstack.com/query/v4/docs/react/guides/infinite-queries#what-if-i-want-to-show-the-pages-in-reversed-order"><strong>select</strong></a>. It was like finding a sharper, lighter sword.</p><p>As our dope.security’s code saga continued, a new frontier beckoned — the API Credentials screen. This was a realm where API keys were to be managed with finesse, and Optimus Prime saw select to shine in this case as Bumble Bee did this with <a href="https://blog.dope.security/what-is-a-secure-web-gateway-swg-89eb7b1da9a1"><strong>SWG Analytics</strong></a>, <a href="https://blog.dope.security/shadow-it-we-made-it-dope-22a80d1cf866"><strong>Shadow IT</strong></a> and <a href="https://blog.dope.security/real-time-policy-updates-for-secure-web-gateway-fd91011c9f61"><strong>Policies</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJ9TXvWVKwQncqiqtjCN6w.png" /><figcaption>Transform API Keys data</figcaption></figure><p>With <strong>morphCredentials</strong>, Optimus had crafted a spell to prep the data for the sorting and filtering jamboree that awaited on the API Credentials screen. The <strong>useCredentials</strong> hook was the chariot that bore this prepped data into the frontend realm.</p><h3>Advantages with Decoupling</h3><p>In the evolving digital landscape, data schemas are bound to change. However, with the Transformers layer in place, such changes don’t spell a code calamity at dope.security. When a schema morphs, Optimus Prime simply fine-tunes the transformation logic within the Transformers layer, keeping the ripples away from the other frontend layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e_K7QlI-yBaazc-DLIx1fQ.png" /><figcaption>Reset Transformation Layer</figcaption></figure><p>This insulation ensures that the <em>Presentation</em>, <em>Logical</em>, and <em>Service</em> layers remain untouched, their tranquility undisturbed. The Transformers layer acts as a buffer, absorbing the schema shocks, and keeping the frontend codebase stable and serene.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eadff6cddf86" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dopesecurity/introducing-transformers-in-dope-securitys-code-saga-eadff6cddf86">Introducing Transformers in dope.security’s Code Saga</a> was originally published in <a href="https://medium.com/dopesecurity">dope.security</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consistent JSON Structure with OpenAI API]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/consistent-json-structure-with-openai-api-1c091e0b7de6?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c091e0b7de6</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Sat, 24 Jun 2023 11:19:13 GMT</pubDate>
            <atom:updated>2023-06-24T11:19:13.745Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcpEVzwFyxiiitkWpfKi7g.jpeg" /></figure><p>Once upon a time, in the heart of the tech-jungle, lived a curious and clever fox named <strong>Finn</strong>. With his fiery red fur and gleaming eyes full of intrigue, Finn was known for his knack for solving complex problems. The other inhabitants of the tech-jungle looked up to him for his keen intellect and creative solutions. Recently, Finn had developed an interest in <strong>OpenAI’s</strong> <strong>GPT</strong>, a powerful language model that could understand and generate human-like text. His latest challenge? To leverage this mighty AI for <strong>grammar correction</strong>.</p><p>This has been one of the issues challenging developers using OpenAI API. Join us on this exciting journey as we delve into Finn’s first interaction with the GPT model. Watch as he begins to unravel the vast capabilities of this advanced language model, formulating a simple prompt and requesting a response in a specific format. This is just the beginning of Finn’s adventure, a stage set for challenges, discoveries, and innovations yet to come.</p><h4>Act-1: Naive Approach with Davinci text model</h4><p>Finn started off with a simple approach, crafting a method to feed paragraphs into OpenAI and request corrections. He structured his request as a JSON object, specifying the incorrect sentences and expecting the correct ones in return. His method looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MP4X7-qt6-e6U7810jLh4Q.png" /><figcaption>Davinci model</figcaption></figure><p>His initial results were promising; the AI returned the correct grammar about <strong>70% of the time</strong>. However, the Finn soon ran into a couple of thorny issues. Sometimes, OpenAI’s output strayed from the <strong>ECMA404 JSON</strong> standard, causing <strong>parsing errors</strong>. Other times, OpenAI would add <strong>extra context or explanation</strong> to the JSON output. This led Finn to implement retries and <strong>regular expressions</strong> to extract the JSON, a workaround that, while effective, was far from ideal and sometimes failed. Here is an example of validation, can be extended accordingly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MnRKdA_TzTx4vN0vAeyTBA.png" /><figcaption>validate json</figcaption></figure><h4>Act-2: OpenAI Functions(new)</h4><p>After his initial foray into using the OpenAI API, Finn heard about the new features introduced with GPT. These included the ability to specify a format for the AI’s output by providing a ‘<strong>functions</strong>’ array in the API call.</p><p>Intrigued, Finn decided to try this new approach. His goal was to have the AI provide spelling and grammar corrections in a structured format. He defined a function called `<strong>get_grammar_corrected_sentences</strong>`, which was expected to return an array of objects. Each object would have two properties — an incorrect sentence and its corrected version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmKn-PFxAZ75Fk916gE9Sw.png" /><figcaption>OpenAI Functions</figcaption></figure><p>This setup provided clear instructions to the AI model, specified the expected output format, and promised to improve the accuracy and relevance of the AI’s responses.</p><p>However, Finn soon ran into a new issue. He found that the new approach <strong>increased the token count</strong> of the AI’s responses. The AI would output a corrected version for every sentence, even if no corrections were needed. This was because the function parameters required the ‘incorrect’ and ‘correct’ properties to be filled out for every sentence. Consequently, Finn was billed for additional tokens, and the responses became unnecessarily long. The challenge was whether this issue could be resolved while still using the new approach.</p><h4>Act-3: Series of Instructions</h4><p>After some consideration, Finn had an idea to mitigate the issue. He decided to <strong>instruct the AI</strong> to return an empty object with ‘incorrect’ and ‘correct’ keys having empty string values whenever no corrections were necessary. This way, he could avoid the extra tokens and maintain the structure of the response.</p><p>To do this, he had to change the way he was interacting with the AI. Instead of giving a single message, he started a conversation with a series of instructions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXdPfeWCL4qNw-0fI5IgDA.png" /><figcaption>Series of Instructions</figcaption></figure><p>With this method, Finn was able to maintain the structure of the response, avoid unnecessary token charges, and ensure the correct behavior of the AI model. This not only improved the efficiency of his work but also opened up a new way to communicate and instruct AI, paving the way for more complex and detailed interactions in the future.</p><p>This story illustrates the importance of persistence and creativity in the face of technological challenges. Just like Finn, developers often need to try different strategies and think outside the box to find the best solution. And sometimes, the answer lies not in more complex code but in better communication with the tools we use.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c091e0b7de6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turtoo figures out Lazy Initializer in React to improve performance]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/turtoo-figures-out-lazy-initializer-in-react-to-improve-performance-dec449a99dff?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/dec449a99dff</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Sat, 03 Jun 2023 05:57:40 GMT</pubDate>
            <atom:updated>2023-06-03T07:42:02.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fc1xVqiqFS_uhBqHVmVVfQ.jpeg" /><figcaption>Turtoo happy in finding lazy initializer in ReactJS</figcaption></figure><p><strong>Turtoo</strong>(turtle) is a software engineer at <a href="https://wisedoc.net/">Wisedoc AI</a>, a leading AI-powered resume, cover letter builder, and analyzer. His coding skills were as steady and reliable as his pace.</p><p>One sunny afternoon, Turtoo was assigned a new task: to optimize one of the component of Wisedoc’s Resume Builder, a component that was <strong>rendering slower</strong> than the rest. The component was using a function calculateInitialResumeState() to set its initial state using React&#39;s useState hook.</p><p>The function looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkiemQFLXi70zLVq_maQ3Q.png" /><figcaption>Function as a param and without callback in state</figcaption></figure><p>calculateInitialResumeState() was a complex function that took quite a bit of processing power. Turtoo noticed that it was being called every time the ResumeBuilder component rendered, not just the first time. <em>This is because </em><em>useState evaluates its argument immediately, just like a regular JavaScript function.</em></p><p>Being the methodical turtle that he was, Turtoo immediately saw a chance to improve the performance. He remembered that useState could also take a function as an argument, which would only be executed during the first render. This feature is known as &quot;<strong>lazy initialization</strong>&quot;.</p><p>Turtoo decided to refactor the useState call in ResumeBuilder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjjZFck-AOqWNPOeLuNXlg.png" /><figcaption>Lazy initializer</figcaption></figure><p>By passing a function to useState, he ensured that calculateInitialResumeState() was only called once, during the initial render. This simple change made the ResumeBuilder component significantly <strong>faster</strong>, especially when it <strong>re-rendered frequently</strong>.</p><p>Turtoo’s colleagues were impressed by the dramatic performance improvement. They learned from Turtoo’s methodical approach and started using the “<strong>lazy initialization</strong>” feature of useState whenever they needed to set an expensive initial state.</p><p>And so, Turtoo the Turtle continued to steadily improve Wisedoc’s Resume Builder, one line of code at a time, reminding everyone that sometimes, small changes which we tend to ignore can impact huge performance improvements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dec449a99dff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why React is performance efficient - Event Driven, Event Pooling, Synthetic Events]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/why-react-is-performance-efficient-event-driven-event-pooling-synthetic-events-ba457c9172dc?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba457c9172dc</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 13:52:28 GMT</pubDate>
            <atom:updated>2023-06-02T13:54:36.812Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OevXzOWY5dT2ZFGcXwpAjA.jpeg" /></figure><blockquote><strong>Chase</strong> the Cheetah, known among his peers for his lightning-fast coding skills, was working on enhancing <a href="https://wisedoc.net/">Wisedoc AI</a>, a powerful tool for analyzing and editing <strong>resumes</strong> and <strong>cover letters</strong>. As he delved deeper into his work, he found himself increasingly intrigued by a key feature of <strong>React.js: synthetic events</strong>.</blockquote><p>Synthetic events are a <strong>cross-browser wrapper</strong> around the browser’s <strong>native events</strong>, part of React’s efforts to ensure <strong>consistent</strong> <strong>behavior</strong> across different browsers. They work exactly like the events you are familiar with, but with some additional features and benefits, including <strong>performance enhancements</strong> like <strong>event pooling</strong>.</p><p><strong>Event pooling</strong> is a technique where React reuses event objects to improve performance. After an event handler has been called, all properties of the event object are <strong>nullified</strong>, thus reducing the load on the <strong>garbage collector</strong> and making React apps faster and more efficient.</p><p>Curious about this system, Chase decided to experiment with React’s synthetic event system and event pooling. He created a simple handleInput method within a ResumeEditor component to test out how React handles events:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LR4UrYHcjkoB_nljakawGg.png" /></figure><p>Intrigued by the concept of synthetic events and their pooling, Chase wondered what would happen if he tried accessing an event object <strong>asynchronously</strong>. For this, he decided to update his handleInput method to use a setTimeout function, which is asynchronous:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5DueE5ELUJzSrYkzcXhyHQ.png" /></figure><p>When he checked the <strong>console log</strong> after triggering an input event, he found that all the properties of the event object were <strong>null</strong>! That was <strong><em>event pooling in action</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukfthg0lOfilzNxP8tQAhA.png" /></figure><p>Chase then remembered event.persist(). This method could be used to remove the synthetic event object from the pool, allowing it to retain its properties. However, he also knew that overusing event.persist() could lead to memory issues, as it negates the benefits of event pooling. He updated his handleInput method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FYrN7llus9dzhvN6NOZ3qw.png" /></figure><p>This time, when he triggered an input event and checked the console log, he saw the event object with all its properties intact. Now, Chase had a deep understanding of <strong>React’s synthetic event system</strong> and how to handle events in asynchronous scenarios. He was thrilled with his discovery and couldn’t wait to share it with his colleagues at the next Wisers Standup</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba457c9172dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mimic Multithreading in Javascript with Web Workers]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/mimic-multithreading-in-javascript-with-web-workers-b3cf60238d57?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3cf60238d57</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Wed, 31 May 2023 10:20:50 GMT</pubDate>
            <atom:updated>2023-05-31T10:24:12.536Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Tale of Speedy the Squirrel and the Web Workers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LwdcT-lEDhTVU2qgnwZH3Q.jpeg" /></figure><blockquote>Once upon a time, in the vast landscape of the internet, there was a diligent squirrel named <strong>Speedy</strong>. Speedy was the chief architect of <a href="https://wisedoc.net/">Wisedoc</a> AI, an innovative online platform for editing, analysing and crafting professional resumes.</blockquote><p>Speedy had a major challenge: Wisedoc was popular, and its users were continuously editing their documents on the platform. Every <strong>keystroke</strong> in the <strong>editor </strong>debouncing would trigger an update to the state of the application via <strong>Redux</strong>, and this state was then read by a process called the <strong>Generator</strong>. The Generator’s job was to convert the raw editor data (let’s call it format <strong>X</strong>) into a format that could be easily displayed in the preview pane (format <strong>Y</strong>). This operation, especially for large documents, was quite intensive and occasionally resulted in <strong>sluggish performance</strong>.</p><p>One day, Speedy had an idea. “What if we could move the Generator’s work to a <strong>separate thread</strong>?” he thought. “That way, the main thread could stay responsive, even when the Generator is working on a large document.” That’s when he discovered <strong>JavaScript’s Web Workers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ycKvyBKUOVgIVCkhYPl3g.jpeg" /><figcaption>Speedy got the idea of web workers</figcaption></figure><h4>Web Workers to the Rescue</h4><p>Web Workers are a tool that allows JavaScript code to run on a separate thread, meaning long-running operations can be offloaded to a worker, freeing up the main thread to handle user interactions. Speedy realized this could be the solution to his problem.</p><p>Speedy set about creating a new <strong>Web Worker for the Generator</strong>. <em>Instead of running the Generator directly in response to a Redux state update, he had the main thread send a message to the worker with the new state</em>. The worker would run the Generator, transforming the editor data into the preview format, and send a message back to the main thread with the result.</p><p>Here’s how he set up the worker:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ML3XVKOvu3d7Fz-GFuDUQg.png" /><figcaption>Create worker for generator</figcaption></figure><p>In the worker (generator-worker.js), he set up the Generator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mXwe2LsCtK6NUnA_BXlcA.png" /><figcaption>generator worker</figcaption></figure><h4>A New Dawn for Wisedoc</h4><p>With the Generator now running in a Web Worker, Wisedoc’s preview performance improved significantly. No matter how large the document, the UI stayed responsive, providing a smooth user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*viuqqW7-4FV-bI4zQm8mow.jpeg" /></figure><p>This is just one use case of Web Workers, there are many such as image properties update at client such as filters or processing the image on client, complex calculations which need compute power or avoiding API calls - not necessary for rendering but blocking rendering etc.,</p><h4>The Moral of the Story</h4><p>Speedy the Squirrel’s tale is a testament to the power of Web Workers. By enabling long-running operations to be performed in the background, Web Workers can help ensure your JavaScript applications remain responsive and performant, even under heavy load. Whether you’re generating complex data structures like Speedy, managing network requests, or performing other intensive tasks, consider whether a Web Worker could help keep your main thread free and your UI smooth.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3cf60238d57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unminifying bundle in Sentry error tracking without ejecting Creat React App(CRA): An Eagle’s Eye]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/unminifying-bundle-in-sentry-error-tracking-without-ejecting-creat-react-app-cra-an-eagles-eye-5fc78d69ea45?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fc78d69ea45</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sentry]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[sentryio]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Tue, 30 May 2023 03:01:01 GMT</pubDate>
            <atom:updated>2023-05-30T03:01:01.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*taM0dd-DXeoltAwqFtjV-g.jpeg" /></figure><h4>Introduction</h4><p>In the vast expanse of the coding universe, a young and ambitious eaglet named <strong>Eddy</strong> was building <a href="https://wisedoc.net/">Wisedoc AI</a> using Create React App (<strong>CRA</strong>). Eddy had a sharp eye, much like the eagle he was, and used <a href="https://sentry.io/welcome/?utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=9657410528&amp;utm_content=g&amp;utm_term=sentry&amp;gclid=Cj0KCQjwmtGjBhDhARIsAEqfDEefhagTdVPk_veABX4IGVoQybiW2AZO5K-1tWuGErRP4OaruoaOq6oaAgG7EALw_wcB"><strong>Sentry</strong></a> to <strong>track errors</strong> and ensure his code was running smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcO5R5f6HSJXunytTRF-kw.png" /><figcaption>Minified JS code from Sentry Logger</figcaption></figure><h4>Problem 1: Eddy cracking his head to understand minified code in Sentry:</h4><p>One day, as he was soaring high above his code, he noticed his JavaScript code bundle in Sentry was minified. He knew he needed to unminify the bundle to trace back the errors to his source code, but he didn’t want to <strong>eject CRA</strong> to configure <strong>Webpack</strong> for <a href="https://www.npmjs.com/package/@sentry/react"><strong>Sentry</strong></a>.</p><p><strong>Solution 1</strong>: <a href="https://www.npmjs.com/package/react-app-rewired">react-app-rewired</a> &amp; <a href="https://www.npmjs.com/package/@sentry/webpack-plugin">@sentry/webpack-plugin</a></p><p>But Eddy was resourceful. He remembered <a href="https://www.npmjs.com/package/react-app-rewired">react-app-rewired</a>, a tool he’d heard about from the wise owls of the coding forest. This tool would allow him to customize his configurations without ejecting CRA.</p><p>Eddy set to work. He installed react-app-rewired and <a href="https://www.npmjs.com/package/@sentry/webpack-plugin">@sentry/webpack-plugin</a> using the following commands:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PrM6Rl8qxn4KYcXRZhX47w.png" /></figure><p>Then, he updated his package.json scripts to use react-app-rewired:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKppjca2VWRH7O5RQgpzhQ.png" /></figure><p>Now he was ready to override the Webpack configurations. After customizing the configuration, he still need to address the challenge of generating and managing source maps, especially when we want to integrate with Sentry.</p><p>To address this issue, we use the Sentry Webpack plugin, a tool that automatically creates releases and uploads source maps to Sentry when bundling our app. Here is how, Eddy configured Sentry Webpack plugin in config-overrides . Eddy got his auth token from settings page of Sentry dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y8Ud515LUeUI0TI-PunU6w.png" /></figure><h4>Problem 2: Source Maps Not Un-minifying</h4><p>After setting up the plugin, we encounter an issue where Sentry is unable to un-minify our source code. This is because Sentry needs to match the uploaded source maps to the correct files in our application.</p><p><strong>Solution 2</strong>: Ensuring Artifact Names Match</p><p>We adjust the include and ignore options in our configuration to align with our source map paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMAM6GHx06HbKx-q0wQaQw.png" /></figure><h4>Conclusion: Unminified Success</h4><p>By overcoming these challenges, we can now see unminified code in Sentry issues, making it much easier to trace and resolve bugs. And all of this was achieved without ejecting our Create-React-App setup.</p><p>Sure, let’s adjust the code example to match a resume builder scenario, using Wisedoc’s naming convention:</p><h4>Before unminification:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcO5R5f6HSJXunytTRF-kw.png" /></figure><p>In this minified code, it’s quite challenging to comprehend the issue, as the function names are generic and there’s no clarity about the purpose of these functions or the context of the error.</p><h4>After unminification:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfYzZbYEcUwTmbh9QQLk_A.png" /><figcaption>Unminified JS from Sentry logger</figcaption></figure><p>After unminification, Sentry’s error logs become significantly clearer. The function names now reflect their purpose, the code’s structure is evident, and it’s <strong>much easier to spot where the error is thrown</strong>. This greatly simplifies the debugging process and allows you to swiftly trace the error back to its origin in your source code.</p><p>Remember, every error message is a challenge to be overcome, and every bug is an opportunity to learn. Happy debugging!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fc78d69ea45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Deadly Sins of Programming: Sin 2 — Ignoring SOLID Principles]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/7-deadly-sins-of-programming-sin-2-ignoring-solid-principles-d9d0ac192dcd?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9d0ac192dcd</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[solid]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Mon, 29 May 2023 04:16:45 GMT</pubDate>
            <atom:updated>2023-05-29T04:16:45.843Z</atom:updated>
            <content:encoded><![CDATA[<h3>7 Deadly Sins of Programming: Chapter 2 — Ignoring SOLID Principles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDMmooLpPLnbuJDiZzSzoQ.jpeg" /></figure><p>Previously, we learned about the <strong>first sin</strong> of programming: <strong>Not following standard ways</strong> of writing code. Today, we’ll learn about another sin: Not following <strong>SOLID principles</strong>, the mistakes we’ve done and rectifying it…</p><blockquote>Meet <strong>Elle</strong>, a baby elephant. She’s trying to learn programming for <a href="https://wisedoc.net/"><strong>Wisedoc AI</strong></a>, a service that helps people make their not just resume but good resume.</blockquote><h4>Single Responsibility Principle (SRP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E3UARvygSWY0H4-hn0_qnA.jpeg" /></figure><p>She is in charge of the “<strong>Create Resume</strong>” feature. In the beginning, she wrote a class that not only <em>created a resume</em>, but also <em>saved it to the database</em>, <em>sent it to printers</em>, and even <em>emailed it to recruiters</em>.</p><p>In a nutshell, Elle was juggling <strong>multiple tasks</strong>, and as the codebase grew, it became hard for her to manage. Whenever she wanted to change how resumes were saved, she risked breaking the emailing feature. Or when the printer setup needed to be updated, she could accidentally mess up the resume creation process. This was because her “Create Resume” class was not following the Single Responsibility Principle. It was trying to do too much!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2lPUYs437R564kKlYKDTg.png" /></figure><p>So, Elle decided to <strong>refactor</strong> her code. She made each class <strong>responsible for just one thing</strong>. The ResumeCreator only creates resumes. A new class, ResumeSaver, handles saving resumes to the database. ResumePrinter takes care of printing, and ResumeEmailer is in charge of emailing. Now, each class has just one reason to change, which makes Elle’s code easier to understand, maintain, and update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTtulg2VmT075N0AQAROnw.png" /></figure><p>By making sure that each part of her code has a single responsibility, Elle has made her work at Wisedoc much easier and her code much more efficient. This is the power of the Single Responsibility Principle!</p><h4>Open-Closed Principle (OCP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*RiQ4Jeb-Gys4mWpbgzMKzQ.jpeg" /></figure><p>When Elle started working on the resume creation feature, she initially wrote a class that could only handle creating resumes in <strong>PDF</strong> format. It worked perfectly for a while. But then Wisedoc decided they wanted to support other formats like <strong>Word</strong> and <strong>HTML</strong>. Elle realized that she would have to modify her ResumeCreator class to support each new format.</p><p>Imagine the tree she’s standing next to represents her ResumeCreator class. Every time a new format is introduced, it&#39;s like adding a new type of fruit to the tree. The more types of fruits are added, the harder it becomes for Elle to reach them all without shaking the tree or breaking branches, which can cause other fruits to fall or branches to break – in other words, other parts of her code might stop working correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2nx1XWvEXBxLBYHVhlLdgg.png" /></figure><p>Elle realized she needed a better way to handle this. She remembered the Open-Closed Principle — software entities should be open for extension, but closed for modification. Instead of modifying the ResumeCreator class every time a new format is needed, she decided to make the class extendable.</p><p>She created an interface Resume and made ResumeCreator depend on it. Now, for each new format, she can just create a new class that implements the Resume interface. The ResumeCreator class doesn&#39;t need to be modified; it&#39;s closed for modification but open for extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sOaZIUh_I9IddmQPnyoJ9g.png" /></figure><p>By using the Open-Closed Principle, Elle has made her code more flexible and easier to maintain. Now, adding support for a new format is as easy as picking a fruit from a low-hanging branch. She doesn’t need to shake the tree or worry about breaking anything!</p><h4>Liskov Substitution Principle (LSP)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*mqW6HsNI2mK07-71RDnzBw.jpeg" /></figure><p>Elle has been tasked to add a new feature to the application, a cover letter generation component to go along with the resumes. She has a DocumentCreator class that already generates resumes, and because a cover letter is also a document, she thought she could simply extend the DocumentCreator class and override some methods to achieve the desired result.</p><p>In Elle’s mind, it seemed like a good idea: a CoverLetterCreator is a DocumentCreator, just like a baby elephant is a mammal. But soon, she started encountering issues. The CoverLetterCreator class didn&#39;t quite behave the same way as the DocumentCreator class. The DocumentCreator class had a getNumberOfPages method which didn&#39;t make sense for a CoverLetterCreator since a cover letter is typically only one page.</p><p>This is like Elle trying to use a giraffe’s long neck to reach the fruits from a tall tree. Sure, a giraffe’s neck is great for reaching high branches, but it doesn’t work well for an elephant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7v_2vak6wzcm-sv7NpGjoA.png" /></figure><p>Elle realized her mistake: she was violating the Liskov Substitution Principle. This principle states that if a program is using a base class, it should be able to use any of its subclasses without the program knowing it.</p><p>To fix this, Elle decided to create a separate CoverLetterCreator class that doesn&#39;t inherit from DocumentCreator, but rather implements a Document interface along with the Resume class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*45im_6Gd_dTbtZhA8TfEJA.png" /></figure><p>By following the Liskov Substitution Principle, Elle ensured that any class implementing the Document interface could be used interchangeably in the program, without causing unexpected behavior or error</p><h3>Interface Segregation Principle (ISP)</h3><p>Elle was having a great time working on the Wisedoc codebase when she bumped into a new problem. She found a ResumeBuilder interface with a ton of methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUFnMfZEqpCn-hpoZmwZrQ.png" /></figure><p>Many components of the application implemented this ResumeBuilder interface, but not all components used all the methods. Some components only needed to set personal info and work experience, while others only required setting education and skills. Having all these methods in one interface was like asking Elle to lift a tree trunk when she only wanted a twig.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fN7CxScn3yTmN8FDPvBQvQ.jpeg" /></figure><p>To fix this, Elle decided to break the ResumeBuilder interface into smaller, more specific interfaces:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwaYzUhoQPtH1Qc96ZLhbw.png" /></figure><p>Now, each component could implement only the interfaces it needed, making the code cleaner and easier to understand.</p><p>This is the Interface Segregation Principle (ISP) in action. ISP suggests that no client should be forced to depend on interfaces they do not use. By dividing the ResumeBuilder interface into smaller interfaces, Elle made the code more flexible and maintainable.</p><h4>Dependency Inversion Principle (DIP)</h4><p>Elle was on a roll now. She had fixed many issues in the Wisedoc codebase by applying the SOLID principles. But there was one last challenge she needed to address.</p><p>Elle noticed that the ResumeRenderer class was directly dependent on the JSONResume class to get the resume data. This was a problem because if the team decided to introduce a new type of resume, say XMLResume, they would have to modify the ResumeRenderer class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Adb5aay9E9R7R5cb1sSEVQ.png" /></figure><p>This was similar to Elle depending on a specific type of tree for her acorns. If that tree species went extinct, she would be in trouble!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOgpngkaSrXIR7gXi7Tkzg.jpeg" /></figure><p>To solve this issue, Elle introduced an interface Resume that could be implemented by any type of resume. The ResumeRenderer class was then updated to depend on the Resume interface, not on a specific class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G663VEeOlhVtVKsWoAMFEA.png" /></figure><p>Now, the ResumeRenderer could work with any type of resume as long as it implemented the Resume interface. This was like Elle being able to find acorns in any type of tree.</p><p>Elle’s work on the Wisedoc codebase is turning out to be a great success. She showed that by following the <strong>SOLID</strong> principles, the code became more <strong>maintainable</strong>, <strong>flexible</strong>, and <strong>robust</strong>. And remember, even if it seems easier to ignore these principles in the short term, the long-term benefits make it worth the effort!</p><p>Stay tuned for the next chapter in our series where we will uncover another deadly sin of programming —<strong> Ignoring Design Patterns</strong>. Until then, happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9d0ac192dcd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Deadly Sins: Chapter 1 — Standardization in React]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/7-deadly-sins-chapter-1-standardization-in-react-6b6c3371e247?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b6c3371e247</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Wed, 24 May 2023 20:33:44 GMT</pubDate>
            <atom:updated>2023-05-24T20:33:44.787Z</atom:updated>
            <content:encoded><![CDATA[<h3>7 Deadly Sins: Chapter 1 — Standardization in React</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EtOAvKCNeVwP3AabuhnKcw.jpeg" /></figure><p>At the heart of <strong>Beaver Dam</strong>, a team of developer beavers were hard at work building <a href="https://wisedoc.net/"><strong>Wisedoc</strong></a>, an AI-driven resume builder. Among them was <strong>Barry</strong>, an experienced developer who would soon face a common but underappreciated challenge in software development.</p><h4>The Sin: Ignoring Standardization in a Collaborative React Project</h4><p>As the team dove into their <strong>React development</strong>, a subtle issue surfaced: the <em>lack of code standardization</em>. This seemingly innocent oversight started causing real headaches, turning their React codebase into a hotpot of varying coding styles and conventions.</p><p><strong>War 1:- The Heterogeneous Codebase</strong>: Each developer had a unique way of writing code. <strong>Barry</strong> favored <em>functional components and hooks</em>, while <strong>Betty</strong> preferred <em>class components</em>. The resulting codebase was a tangled mess, with everyone’s individual coding styles interwoven without any clear structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*goydX-vMODtFYoWlJFds9g.png" /></figure><p>This lack of standardization had far-reaching consequences. <strong>Debugging</strong> became a daunting task, reading a teammate’s code felt like deciphering a foreign language, and resolving merge conflicts became a frequent and time-consuming chore.</p><h4>The Redemption: Implementing Standardization</h4><p><strong>Barry</strong>, recognizing the escalating issue, decided to champion code standardization. The objective was to <strong>unify</strong> their <em>coding styles</em>, <em>conventions</em>, and <em>practices</em>, to shape a more coherent and <strong>maintainable</strong> React codebase.</p><p>Barry addressed the issue of inconsistent use of React features head-on. After a team discussion, they agreed to use <strong>functional</strong> components and hooks consistently, putting aside class components. This decision was made based on the benefits of functional components and hooks, such as easier testing and better reusability as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gskwNNjxMlF6kU1eQupJbQ.png" /></figure><h4>War 2:- Consistent Syntax Styling</h4><p>Barry and Betty are two enthusiastic developers but they overlooked a crucial aspect. For the same logic, their approaches were dramatically different. Here’s how they each wrote a function to calculate the total experience from an array of jobs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VReIzRMd1JQm7V3URbGf1Q.png" /></figure><p>Realising it, they introduced <strong>ESLint</strong> and <strong>Prettier</strong> into their workflow to enforce consistent syntax and coding styles. They used ESLint to help spot and fix potential issues in their code and Prettier for automatic code formatting. Here’s a glimpse of their ESLint and Prettier configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4PAiyghjEoVLMcH0bGj_cw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1piVioH9ZOmLJraTRvjfQ.png" /></figure><p>With these in place, Betty and Barry’s function started to look the same, and the previously divergent code styles converged to one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwFNI_DIT2kRFNXGEsyzPQ.png" /></figure><blockquote>These standardization efforts began to bear fruit. Debugging no longer felt like a wild goose chase, understanding each other’s code became straightforward, and merge conflicts were fewer and far between. The team could now focus more on developing exciting new features for Wisedoc.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otXTs_Tx-htIeZTuiDDArw.jpeg" /></figure><p>By addressing the first deadly sin of ignoring standardization, Barry and his team are now set for smoother collaboration. But as with any development project, more challenges lie ahead. Stay tuned to find out how they tackle the next JavaScript sin — <strong>SOLID Principles</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b6c3371e247" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Docker Mystery: The Sudden Failure in spaCy(NLP) and the Unseen Dependency]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/a-docker-mystery-the-sudden-failure-in-spacy-nlp-and-the-unseen-dependency-94a7b6800455?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/94a7b6800455</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[spacy]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Tue, 23 May 2023 11:23:32 GMT</pubDate>
            <atom:updated>2023-05-23T11:23:32.225Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Investing docker issue" src="https://cdn-images-1.medium.com/max/1024/1*fyBfxdI6Pvm0uSb73dSFkw.jpeg" /></figure><p>Just yesterday, everything was humming along smoothly in <a href="https://wisedoc.net/"><strong>Wisedoc AI</strong></a>. Lines of code danced gracefully to the tune of a well-orchestrated symphony. The <strong>Dockerfile</strong>, the conductor of this symphony, directed each component flawlessly, building the perfect environment for our application.</p><blockquote>One of the key performers in this concert was <strong>spaCy</strong>, a stalwart in the realm of Natural Language Processing in Python. With a wave of the Dockerfile’s baton, the command `<strong>python -m spacy download en_core_web_lg</strong>` would spring into action, fetching and installing the essential spaCy language model.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duF6YA4vgOVUyxli7Hse1Q.png" /></figure><p>But then, suddenly, the music halted. Without any apparent reason or change in configuration, our Dockerfile started throwing a fit. The command that had performed flawlessly just a day ago now stumbled, tripping over an ominous error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OnnYtpS-UXF9FYkXU8QVUw.png" /></figure><blockquote>Puzzled and intrigued, I decided to investigate.</blockquote><p>My journey took me through the vast landscapes of Docker and spaCy, and into the complex labyrinth of Python dependencies. I examined the recent Docker Desktop update, scrutinized spaCy’s interactions, and delved into <strong>Pydantic</strong>, a data validation library used by spaCy.</p><p>After countless hours and many dead ends, I finally stumbled upon an inconspicuous package — `<strong><em>typing_extensions</em></strong>`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JG1lEq6F9WjU2qlsMXcrzw.jpeg" /></figure><p>In this grand symphony of software, this side player had recently undergone a transformation, upgrading to version <strong>4.6.0</strong>. This upgrade, unbeknownst to us, had introduced discord into our previously harmonious melody.</p><p>The fix was disarmingly simple — restrict `<strong><em>typing_extensions</em></strong>` to versions less than 4.6.0 in the `<strong><em>requirements.txt</em></strong>` file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a3ctxd8Ywt0a-k1mQgWZ6w.png" /></figure><p>And with this small adjustment, the music began once again, resuming its harmonious tune. The Dockerfile, regaining its composure, continued directing the flow of commands without a hitch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vch0dVJfouTVOefU2o2CAQ.jpeg" /></figure><p>This unexpected journey served as a profound reminder of the delicacy of our software ecosystems. The interplay of countless packages and their respective versions is a delicate dance, where even a minor step out of line can send ripples across the system. As developers, we’re not only architects and builders but also detectives and problem-solvers, navigating this intricate dance of dependencies with agility and precision.</p><p>So, to all the coders out there solving mysteries and wrangling dependencies: remember that behind every sudden error lies a tale waiting to be unraveled. Each challenge is an opportunity to learn, to adapt, and to deepen our understanding of the rich tapestry that is software development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94a7b6800455" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Lambda Serverless Deployments: Overcoming the Upload Limit with Webpack]]></title>
            <link>https://medium.com/@vamshi.bachaneboina/optimizing-lambda-serverless-deployments-overcoming-the-upload-limit-with-webpack-61a12f633c12?source=rss-748afdd8fe8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/61a12f633c12</guid>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Vamshi Bachaneboina]]></dc:creator>
            <pubDate>Tue, 23 May 2023 06:01:15 GMT</pubDate>
            <atom:updated>2023-05-23T06:13:57.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Illustration of giraffe in tea cup: Unzipped bundle trying to fit into lambda" src="https://cdn-images-1.medium.com/max/1024/1*6DPfnQxq8Y08LVtPFp-LwA.png" /></figure><h4>Introduction:</h4><p>In the ever-evolving environment of <a href="https://wisedoc.net/"><strong>Wisedoc’s Documents API</strong></a>, our microservices network developed rapidly. With advanced features such as <strong><em>Document imports</em></strong>, <strong><em>AI-generated cover letters</em></strong>, and <strong><em>Resume analysis tools</em></strong>, we encountered a significant challenge — the <strong>upload limit</strong>. This is the story of how we creatively addressed the issue, improved our deployments, and had some fun along the way.</p><h4>Chapter 1: The Problem — The Predicament of Size</h4><p>As our application grew, we started to face issues with the upload limit. Deploying individual functions was becoming difficult, like trying to fit a large object into a tiny box. We knew we needed a smarter approach to keep our deployments efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RkaSgOJVYgyLGs8-XGYedg.png" /></figure><h4>Chapter 2: The Solution — Webpack for Code Bundling</h4><p>We found a solution in <strong>Webpack</strong>, a powerful bundling tool that helped us manage our code better. By using Webpack’s ability to bundle dependencies, we aimed to reduce our deployment package sizes.</p><p>Before proceeding any further, please install these dependencies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKwDxZ87c5cXMkix9Kk4sA.png" /><figcaption>npm packages</figcaption></figure><p>Now, let’s add the following configurations into webpack.config.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DDSqPGakxHdTD7Ar8Jk_0A.png" /><figcaption>Webpack Configuration</figcaption></figure><h4>Let’s understand — what it does!!!</h4><ol><li><strong>Code Bundling: </strong>Webpack is primarily used for bundling JavaScript files for usage in a browser, yet it’s perfectly capable of bundling server-side code. This is especially important when dealing with microservices and serverless functions where you need to package your function and all its dependencies in one deployable unit.</li><li><strong>Tree Shaking:</strong> Webpack only includes the parts of the imported libraries that are actually used in your code. This can greatly reduce the size of your bundles and therefore the size of your deployment.</li><li><strong>Minification and Optimization:</strong> When used with appropriate plugins, Webpack can minify your JavaScript and CSS assets. Minification can significantly reduce the size of your deployment package by eliminating unnecessary characters (like spaces and comments) from the code.</li><li><strong>Transpiling</strong>: With the help of Babel, Webpack can transpile your code, meaning it can transform your modern JavaScript code into a version of JavaScript that can run across different platforms. This ensures compatibility and can often result in more optimized code.</li><li><strong>Modular Code:</strong> Webpack enforces a modular coding approach by treating every file as a module. This makes your codebase more organized and maintainable.</li></ol><h4>Chapter 3: Enhancing Efficiency — Serverless Framework</h4><p>To further leverage Webpack’s potential within our serverless ecosystem, we allied with the Serverless Framework. This platform, renowned for its capability to define microservices, manage configurations, and maintain operational cleanliness, became our strategic partner in combatting deployment challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKTwshVO6qFS0jmQewzn0g.png" /></figure><h4>Chapter 4: The Dance of Customization and Efficiency</h4><p>Armed with Webpack and the Serverless Framework, we journeyed into the land of customization. We fine-tuned our Webpack configuration to ensure optimal performance, and, with <strong>Babel</strong> at our side, we employed <strong>modern</strong> <strong>JavaScript(ES6)</strong> features while assuring platform compatibility. This experience was akin to blending the grace of a symphony with the joviality of a carnival — a perfect mix of the serious and the playful.</p><p><strong>Chapter 5: Triumphing Over the Upload Limit — The Slaying of Goliath</strong><br>With our streamlined deployment packages and finely-tuned Webpack configuration, we ventured forth to challenge the upload limit. Each deployment felt like a victorious battle, akin to persuading a stubborn mule to perform a graceful ballet — undoubtedly challenging, yet immensely rewarding when accomplished.</p><figure><img alt="Lifting Boulder" src="https://cdn-images-1.medium.com/max/612/0*-rOzRF0aDShnWTfD" /></figure><p>Our deployments began to seamlessly conform to the upload limit, as if whispering a gentle lullaby to soothe the server’s reservations. The experience was akin to a beautifully choreographed ballet — complex yet flawlessly executed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61a12f633c12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>