<?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: Khoa Nguyen</title>
    <description>The latest articles on DEV Community by Khoa Nguyen (@yunkhngn).</description>
    <link>https://dev.to/yunkhngn</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%2F892676%2Fe52c1453-11d7-42d1-9a5a-de846a89489c.png</url>
      <title>DEV Community: Khoa Nguyen</title>
      <link>https://dev.to/yunkhngn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yunkhngn"/>
    <language>en</language>
    <item>
      <title>The More I Learn About Programming, the Less I Feel I Know</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:29:34 +0000</pubDate>
      <link>https://dev.to/yunkhngn/the-more-i-learn-about-programming-the-less-i-feel-i-know-2n88</link>
      <guid>https://dev.to/yunkhngn/the-more-i-learn-about-programming-the-less-i-feel-i-know-2n88</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When I first wrote my initial lines of code, the world of software felt deceptively simple. I remember fixing a basic bug and feeling an unwarranted surge of absolute mastery. I thought the horizon of programming was finite, a collection of syntax rules and design patterns that could be fully memorized given enough time. Years later, sitting in front of terminal windows and architectural diagrams, that early confidence has entirely evaporated. The more I learn about programming, the less I feel I know.&lt;/p&gt;

&lt;p&gt;This essay is a reflection on that shift. It is an exploration of the Dunning-Kruger effect in software development, the vertigo of an ever-expanding ecosystem, and why true engineering maturity begins the moment we accept our own perpetual ignorance.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Illusion of Competence
&lt;/h2&gt;

&lt;p&gt;Every developer likely remembers their early days of unearned confidence. Psychologically, this is well-documented as the Dunning-Kruger effect: a cognitive bias where people with limited knowledge in a domain overestimate their own expertise. In programming, this phase is dangerous yet strangely comforting.&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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJJbml0aWFsIExlYXJuaW5nIl0gLS0-IEJbIk1vdW50IFN0dXBpZDogUGVhayBDb25maWRlbmNlIl0KICAgIEIgLS0-IENbIlZhbGxleSBvZiBEZXNwYWlyOiBSZWFsaXppbmcgRGVwdGgiXQogICAgQyAtLT4gRFsiU2xvcGUgb2YgRW5saWdodGVubWVudDogU3VzdGFpbmFibGUgTGVhcm5pbmciXQogICAgRCAtLT4gRVsiUGxhdGVhdSBvZiBTdXN0YWluYWJsZSBQcmFjdGljZSJdCgogICAgc3R5bGUgQSBmaWxsOiNmOWYsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgQiBmaWxsOiNiYmYsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgQyBmaWxsOiNmYmIsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgRCBmaWxsOiNiZmIsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgRSBmaWxsOiNmZjksc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweA%3FbgColor%3D%21white" 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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJJbml0aWFsIExlYXJuaW5nIl0gLS0-IEJbIk1vdW50IFN0dXBpZDogUGVhayBDb25maWRlbmNlIl0KICAgIEIgLS0-IENbIlZhbGxleSBvZiBEZXNwYWlyOiBSZWFsaXppbmcgRGVwdGgiXQogICAgQyAtLT4gRFsiU2xvcGUgb2YgRW5saWdodGVubWVudDogU3VzdGFpbmFibGUgTGVhcm5pbmciXQogICAgRCAtLT4gRVsiUGxhdGVhdSBvZiBTdXN0YWluYWJsZSBQcmFjdGljZSJdCgogICAgc3R5bGUgQSBmaWxsOiNmOWYsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgQiBmaWxsOiNiYmYsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgQyBmaWxsOiNmYmIsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgRCBmaWxsOiNiZmIsc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweAogICAgc3R5bGUgRSBmaWxsOiNmZjksc3Ryb2tlOiMzMzMsc3Ryb2tlLXdpZHRoOjJweA%3FbgColor%3D%21white" alt="Diagram" width="168" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During that initial peak—often called 'Mount Stupid'—a few tutorials on web frameworks or basic data structures are enough to convince someone that they understand how systems work under the hood. You write scripts that function, push code to repositories, and assume that complexity is merely a byproduct of poor planning by others.&lt;/p&gt;

&lt;p&gt;Reality strikes the first time a system fails silently in production under a subtle race condition, or when you are tasked with debugging a codebase written five years prior without documentation. That is when you descend rapidly into the valley of despair. You realize that knowing how to invoke a function is vastly different from understanding memory management, network partitions, or compiler optimizations.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Weight of the Ecosystem
&lt;/h2&gt;

&lt;p&gt;Part of what fuels this feeling of inadequacy is the sheer velocity of the modern software ecosystem. New languages, build tools, paradigms, and infrastructure abstractions emerge faster than any single human can reasonably parse, let alone master.&lt;/p&gt;

&lt;p&gt;In the span of a career, the industry shifts from monolithic servers to microservices, then to serverless functions, edge computing, and back toward pragmatic modular monoliths. Each paradigm shift introduces a new vocabulary and a fresh set of accidental complexities.&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%2Fimages.unsplash.com%2Fphoto-1629904853893-c2c8981a1dc5%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8ZGV2ZWxvcGVyJTIwbG9va2luZyUyMGF0JTIwY29tcGxleCUyMG11bHRpLW1vbml0b3IlMjBjb2RlJTIwYW5kJTIwYXJjaGl0ZWN0dXJlJTIwZGlhZ3JhbXN8ZW58MHwwfHx8MTc5NjM1ODU0NHww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" 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%2Fimages.unsplash.com%2Fphoto-1629904853893-c2c8981a1dc5%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8ZGV2ZWxvcGVyJTIwbG9va2luZyUyMGF0JTIwY29tcGxleCUyMG11bHRpLW1vbml0b3IlMjBjb2RlJTIwYW5kJTIwYXJjaGl0ZWN0dXJlJTIwZGlhZ3JhbXN8ZW58MHwwfHx8MTc5NjM1ODU0NHww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="Two people working on computer code at monitors in a bright office workspace — Photo by Compagnons on Unsplash" width="1080" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When faced with this endless horizon of tools, it is easy to fall into the trap of FOMO (Fear Of Missing Out). We feel pressured to keep up with every new framework release, database engine, or orchestration tool. Yet, trying to stay current on everything is a fool's errand. True engineering depth requires selective ignorance—deliberately choosing what not to learn so that you can focus on the timeless fundamentals.&lt;/p&gt;

&lt;h2&gt;
  
  
  Moving Past Imposter Syndrome
&lt;/h2&gt;

&lt;p&gt;Insecurity in software engineering is practically an occupational hazard. When your daily job involves solving problems you have never encountered before, you spend a significant portion of your working hours feeling like you do not know what you are doing.&lt;/p&gt;

&lt;p&gt;Over time, I have learned to reframe imposter syndrome. It is rarely a sign that you do not belong in the room; rather, it is a reliable compass pointing directly at the boundary of your current knowledge. If you never feel a slight sense of intellectual discomfort, you are likely working on problems that are too trivial for growth.&lt;/p&gt;

&lt;p&gt;The antidote to this anxiety is intellectual humility. Experienced engineers are rarely the ones who claim to know all the answers. Instead, they are comfortable saying three powerful words: 'I do not know.' More importantly, they know how to systematically investigate the problem until they find out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embracing Lifelong Curiosity
&lt;/h2&gt;

&lt;p&gt;Accepting that you will never know everything is liberating. It shifts your relationship with programming from an exhausting race to maintain perfection into a lifelong practice of exploration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Focus on fundamentals: Compilers, operating systems, networking protocols, and data structures change very slowly compared to web frameworks.&lt;/li&gt;
&lt;li&gt;Write for humans: Code is read far more often than it is written. Clarity trumps cleverness every time.&lt;/li&gt;
&lt;li&gt;Cultivate patience: Mastery is accumulated in micro-increments over decades, not weeks.&lt;/li&gt;
&lt;/ul&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%2Fimages.unsplash.com%2Fphoto-1768282768629-3b1cf331892f%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8b2xkJTIwYm9va3MlMjBhbmQlMjBtb2Rlcm4lMjBsYXB0b3AlMjBvbiUyMGElMjB3b29kZW4lMjBkZXNrfGVufDB8MHx8fDE3OTYzNTg1NDR8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" 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%2Fimages.unsplash.com%2Fphoto-1768282768629-3b1cf331892f%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8b2xkJTIwYm9va3MlMjBhbmQlMjBtb2Rlcm4lMjBsYXB0b3AlMjBvbiUyMGElMjB3b29kZW4lMjBkZXNrfGVufDB8MHx8fDE3OTYzNTg1NDR8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="Open book with bookmark next to keyboard — Photo by Wenzy Wong on Unsplash" width="1080" height="810"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Programming is an infinite game. There is no final level to beat, no ultimate certification that grants permanent omniscience. Once we let go of the ego-driven need to appear infallible, we can genuinely enjoy the craft. The realization that I know very little is not a source of despair anymore; it is the primary reason I find software engineering endlessly fascinating.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>career</category>
      <category>psychology</category>
      <category>learning</category>
    </item>
    <item>
      <title>Being a Developer in Your Early 20s Is Weird</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:28:15 +0000</pubDate>
      <link>https://dev.to/yunkhngn/being-a-developer-in-your-early-20s-is-weird-4jn9</link>
      <guid>https://dev.to/yunkhngn/being-a-developer-in-your-early-20s-is-weird-4jn9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;There is a very specific kind of disorientation that comes with writing code for a living or for ambition while your prefrontal cortex is still under construction. Being a developer in your early twenties means straddling two distinct worlds. On one side, you have the academic or foundational structures of university, where theory rules and timelines span semesters. On the other, you have the fast-moving, often chaotic reality of the software industry, where frameworks churn every six months and production outages do not care about your midterms.&lt;/p&gt;

&lt;p&gt;I wanted to write down some thoughts on this phase of life not because I have figured it out, but precisely because I haven't. If you are navigating the weird crosswinds of early career uncertainty, financial anxiety, and the endless pursuit of technical competence, you are definitely not alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Balancing Act: University and the Real World
&lt;/h2&gt;

&lt;p&gt;Balancing a degree with actual software development work feels less like multitasking and more like context-switching every single hour. You might spend your morning proving time complexities in a discrete mathematics lecture and your afternoon debugging an asynchronous race condition in a production database.&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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJVbml2ZXJzaXR5IFRoZW9yeSJdIC0tPiBDWyJFYXJseSAyMHMgRGV2ZWxvcGVyIl0KICAgIEJbIlJlYWwtV29ybGQgUHJvZHVjdGlvbiJdIC0tPiBDCiAgICBDIC0tPiBEWyJDb250ZXh0IFN3aXRjaGluZyBGYXRpZ3VlIl0KICAgIEMgLS0-IEVbIkltcG9zdGVyIFN5bmRyb21lIl0KICAgIEMgLS0-IEZbIlNraWxsIFN5bnRoZXNpcyJd%3FbgColor%3D%21white" 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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJVbml2ZXJzaXR5IFRoZW9yeSJdIC0tPiBDWyJFYXJseSAyMHMgRGV2ZWxvcGVyIl0KICAgIEJbIlJlYWwtV29ybGQgUHJvZHVjdGlvbiJdIC0tPiBDCiAgICBDIC0tPiBEWyJDb250ZXh0IFN3aXRjaGluZyBGYXRpZ3VlIl0KICAgIEMgLS0-IEVbIkltcG9zdGVyIFN5bmRyb21lIl0KICAgIEMgLS0-IEZbIlNraWxsIFN5bnRoZXNpcyJd%3FbgColor%3D%21white" alt="Diagram" width="552" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While universities teach you how computers work at a fundamental level—compilers, operating systems, network protocols—they rarely prepare you for the human side of software engineering. They don't teach you how to read a messy codebase written by someone who left the company two years ago, nor do they teach you how to write a pull request description that makes sense to a tired reviewer.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Cost of Context Switching
&lt;/h3&gt;

&lt;p&gt;The mental overhead of jumping between abstract computer science concepts and concrete software engineering tasks is exhausting. You find yourself asking whether the time spent grinding through theoretical assignments could be better used building real projects, or conversely, whether skipping the theory will leave you with fragile foundational knowledge later on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Financial Pressure and Career Uncertainty
&lt;/h2&gt;

&lt;p&gt;Let's address the elephant in the room: money. For many of us, entering the tech industry in our early twenties is driven as much by economic survival and upward mobility as it is by a genuine passion for building things.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"stressors"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"tuition payments"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"market saturation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"interview loops"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"rent inflation"&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"coping_mechanisms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"focusing on fundamentals"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"building small utilities"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"accepting linear growth"&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;The pressure to secure internships, land full-time roles, and achieve financial stability can turn a hobby you love into an anxious race. You look at the job market—marked by shifting economic cycles and aggressive interview loops—and it is easy to feel like one wrong career move will derail your entire trajectory.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Trap of Constant Upskilling
&lt;/h3&gt;

&lt;p&gt;When you worry about job security, the natural reaction is to consume more tutorials, learn more frameworks, and check off every trending tool on developer job descriptions. But this often leads to tutorial hell, where you consume endless content without building deep, resilient technical conviction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison Culture in the Age of Public Portfolios
&lt;/h2&gt;

&lt;p&gt;GitHub contribution graphs, LinkedIn announcements, and Twitter feeds make it dangerously easy to measure your worth by someone else's output. You see twenty-year-olds shipping venture-backed startups, contributing to the Linux kernel, or maintaining open-source libraries with millions of downloads.&lt;/p&gt;

&lt;p&gt;It creates a persistent background hum of inadequacy. &lt;em&gt;Should I be posting more? Should I be building in public? Am I falling behind because I spent my weekend resting instead of writing code?&lt;/em&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%2Fimages.unsplash.com%2Fphoto-1555963153-11ff60182d08%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8ZGV2ZWxvcGVyJTIwd29ya2luZyUyMGxhdGUlMjBhdCUyMGElMjBtaW5pbWFsaXN0JTIwZGVzayUyMHdpdGglMjB3YXJtJTIwbGlnaHRpbmd8ZW58MHwwfHx8MTc5NjM1ODQ3Nnww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" 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%2Fimages.unsplash.com%2Fphoto-1555963153-11ff60182d08%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8ZGV2ZWxvcGVyJTIwd29ya2luZyUyMGxhdGUlMjBhdCUyMGElMjBtaW5pbWFsaXN0JTIwZGVzayUyMHdpdGglMjB3YXJtJTIwbGlnaHRpbmd8ZW58MHwwfHx8MTc5NjM1ODQ3Nnww%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="man using computer inside room — Photo by Oğuzhan Akdoğan on Unsplash" width="1080" height="810"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Combatting this requires a deliberate shift in perspective. Software engineering is not a sprint where everyone runs the same track. It is a long-term practice. The peers who seem to be moving at lightspeed often burn out just as quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding Your Direction: What Kind of Engineer Do You Want to Be?
&lt;/h2&gt;

&lt;p&gt;Early on, the sheer breadth of the field is paralyzing. Do you want to go deep into systems programming and write memory-safe Rust? Do you want to build distributed cloud architectures? Are you drawn to frontend ergonomics, developer tooling, or data engineering?&lt;/p&gt;

&lt;p&gt;I have spent countless hours oscillating between different tracks, suffering from severe FOMO whenever I commit to one path over another. But I am slowly realizing that the specific stack matters far less than the mental models you develop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cultivating First Principles
&lt;/h3&gt;

&lt;p&gt;Regardless of whether you write TypeScript, Go, or C++, the underlying principles remain remarkably consistent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand how data moves across boundaries.&lt;/li&gt;
&lt;li&gt;Respect failure modes and edge cases.&lt;/li&gt;
&lt;li&gt;Write code that other human beings can read, maintain, and debug.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you focus on mastering these fundamentals, pivoting between domains later in your career becomes an exercise in learning syntax rather than learning how to think.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: Giving Yourself Permission to Figure It Out
&lt;/h2&gt;

&lt;p&gt;Being a developer in your early twenties is inherently contradictory. You are expected to make decisions that could shape your professional life while you are still figuring out who you are on a personal level.&lt;/p&gt;

&lt;p&gt;If you take away anything from my own trial and error, let it be this: give yourself permission to not know everything. Build things that genuinely interest you, take breaks before you hit a wall, and remember that a career in software is measured in decades, not quarters.&lt;/p&gt;

</description>
      <category>career</category>
      <category>reflection</category>
      <category>juniordev</category>
      <category>university</category>
    </item>
    <item>
      <title>I'm a Developer, But Sometimes I Don't Want to Code</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:26:47 +0000</pubDate>
      <link>https://dev.to/yunkhngn/im-a-developer-but-sometimes-i-dont-want-to-code-3ifg</link>
      <guid>https://dev.to/yunkhngn/im-a-developer-but-sometimes-i-dont-want-to-code-3ifg</guid>
      <description>&lt;h2&gt;
  
  
  The Quiet Silence of an Empty IDE
&lt;/h2&gt;

&lt;p&gt;There are mornings when sitting down at the desk feels less like starting a day of creative work and more like facing an insurmountable wall. The monitor glows with its familiar layout: terminal windows, dark-themed code editors, and a browser tab open to a documentation page I have read a dozen times. Yet, my fingers refuse to move. The cursor blinks rhythmically, almost mockingly, waiting for instructions I cannot formulate.&lt;/p&gt;

&lt;p&gt;We enter this industry because of a fascination with creation. There is a distinct, undeniable magic in typing text into a file and watching a machine execute it to build entirely new realities. For years, that magic fuels us. We spend our evenings side-tracking into side projects, reading technical specifications for fun, and losing track of time while debugging elusive race conditions.&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%2Fimages.unsplash.com%2Fphoto-1719400471588-575b23e27bd7%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8ZGV2ZWxvcGVyJTIwbG9va2luZyUyMGF0JTIwZ2xvd2luZyUyMG1vbml0b3IlMjBpbiUyMGRhcmslMjByb29tfGVufDB8MHx8fDE3OTYzNTgzNDB8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" 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%2Fimages.unsplash.com%2Fphoto-1719400471588-575b23e27bd7%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8ZGV2ZWxvcGVyJTIwbG9va2luZyUyMGF0JTIwZ2xvd2luZyUyMG1vbml0b3IlMjBpbiUyMGRhcmslMjByb29tfGVufDB8MHx8fDE3OTYzNTgzNDB8MA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="A man sitting in front of three computer monitors — Photo by Abu Saeid on Unsplash" width="1080" height="810"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, slowly or abruptly, the friction begins. The joy of building gets crowded out by the mechanics of delivery. Tickets pile up, technical debt demands interest we never intended to borrow, and the sheer velocity of the ecosystem starts to feel less like an playground and more like a relentless treadmill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Anatomy of Developer Fatigue
&lt;/h2&gt;

&lt;p&gt;It is easy to conflate physical tiredness with mental exhaustion, but the fatigue that settles into a software engineer's mind is of a different texture entirely. Programming requires a very specific brand of cognitive load. We are constantly holding abstract systems in our heads, predicting edge cases, and translating human intent into rigid, unforgiving logic.&lt;/p&gt;

&lt;p&gt;When we do this for forty, fifty, or sixty hours a week, the brain's buffering capacity reaches its limit. &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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJDb250aW51b3VzIENvZ25pdGl2ZSBMb2FkIl0gLS0-IEJbIldvcmtpbmcgTWVtb3J5IFNhdHVyYXRpb24iXQogICAgQiAtLT4gQ1siRGVjaXNpb24gRmF0aWd1ZSJdCiAgICBDIC0tPiBEWyJMb3NzIG9mIENyZWF0aXZlIEZsb3ciXQogICAgRCAtLT4gRVsiQXBhdGh5IGFuZCBBdm9pZGFuY2UiXQ%3FbgColor%3D%21white" 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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJDb250aW51b3VzIENvZ25pdGl2ZSBMb2FkIl0gLS0-IEJbIldvcmtpbmcgTWVtb3J5IFNhdHVyYXRpb24iXQogICAgQiAtLT4gQ1siRGVjaXNpb24gRmF0aWd1ZSJdCiAgICBDIC0tPiBEWyJMb3NzIG9mIENyZWF0aXZlIEZsb3ciXQogICAgRCAtLT4gRVsiQXBhdGh5IGFuZCBBdm9pZGFuY2UiXQ%3FbgColor%3D%21white" alt="Diagram" width="168" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This exhaustion rarely announces itself with a dramatic crash. Instead, it manifests in subtle ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Staring at a simple bug for an hour without making progress.&lt;/li&gt;
&lt;li&gt;Dreading the morning stand-up.&lt;/li&gt;
&lt;li&gt;Opening social media or news sites out of pure avoidance.&lt;/li&gt;
&lt;li&gt;A lingering sense of guilt whenever the code editor is closed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We begin to mistake this cognitive saturation for a personal failing. We tell ourselves we are just lazy, or that we picked the wrong career, or that we are falling behind our peers who seem to constantly ship open-source libraries and write architectural essays.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Guilt of the Unproductive Maker
&lt;/h2&gt;

&lt;p&gt;In our culture, especially within tech, our identity is dangerously tethered to our output. We are what we ship. If we are not coding, what are we? &lt;/p&gt;

&lt;p&gt;This creates a peculiar psychological trap. When we want to code, we feel fulfilled. When we don't want to code, we feel guilty. Even during weekends or time off, the mental overhead of unfinished tasks hums in the background like a refrigerator compressor. We sit on the couch trying to read a book or watch a film, but part of our mind is still debugging that production deployment or worrying about the pull request review waiting in our inbox.&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%2Fimages.unsplash.com%2Fphoto-1749390002163-0d151e3550d8%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8cGVyc29uJTIwcmVzdGluZyUyMG9uJTIwY291Y2glMjBsb29raW5nJTIwdGhvdWdodGZ1bHxlbnwwfDB8fHwxNzk2MzU4MzQwfDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" 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%2Fimages.unsplash.com%2Fphoto-1749390002163-0d151e3550d8%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8cGVyc29uJTIwcmVzdGluZyUyMG9uJTIwY291Y2glMjBsb29raW5nJTIwdGhvdWdodGZ1bHxlbnwwfDB8fHwxNzk2MzU4MzQwfDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="A woman relaxes on a brown couch — Photo by Polina Kuzovkova on Unsplash" width="1080" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This guilt prevents true rest. Because we feel we &lt;em&gt;should&lt;/em&gt; be productive, our downtime becomes tainted by anxiety. We end up neither working effectively nor resting deeply, lingering in a grey zone of perpetual low-grade stress.&lt;/p&gt;

&lt;h2&gt;
  
  
  Redefining Our Relationship with Technology
&lt;/h2&gt;

&lt;p&gt;To survive this career path without losing our sanity, we have to separate our self-worth from our git contribution graph. Technology is a tool, not a master. It is entirely normal to love building things while simultaneously needing extended periods away from the screen.&lt;/p&gt;

&lt;p&gt;Over time, I have learned to recognize the warning signs of burnout and respond with boundaries rather than self-flagellation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stepping away without an agenda:&lt;/strong&gt; Giving myself permission to spend a Saturday without touching a keyboard, without feeling the need to 'learn something new' or 'build a portfolio piece.'&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Valuing analogue experiences:&lt;/strong&gt; Cooking, walking in nature, reading physical books, or working with physical materials. These activities engage the senses in ways that computer screens simply cannot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accepting seasons of low output:&lt;/strong&gt; Just as nature has seasons of dormancy, creative work fluctuates. Not every month requires the same intensity of focus.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Finding Hope in the Mundane
&lt;/h2&gt;

&lt;p&gt;Rediscovering the joy of programming often requires lowering the stakes. When we stop viewing every line of code as a metric of our professional competence, we can start to enjoy the craft again on our own terms.&lt;/p&gt;

&lt;p&gt;Sometimes, getting back the spark isn't about pushing through the fatigue with more caffeine or discipline. It is about honoring the fatigue, stepping back, and remembering who we are when the monitor is turned off. The code will still be there tomorrow. The bugs will still wait. But our mental well-being is the only infrastructure we have that truly cannot be easily replaced.&lt;/p&gt;

</description>
      <category>engineering</category>
      <category>burnout</category>
      <category>mentalhealth</category>
      <category>career</category>
    </item>
    <item>
      <title>Building Reliable Background Jobs in Node.js with BullMQ and Redis</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:19:30 +0000</pubDate>
      <link>https://dev.to/yunkhngn/building-reliable-background-jobs-in-nodejs-with-bullmq-and-redis-16a6</link>
      <guid>https://dev.to/yunkhngn/building-reliable-background-jobs-in-nodejs-with-bullmq-and-redis-16a6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Background processing is a fundamental requirement for modern web applications. Offloading heavy computations, external API calls, or email delivery to asynchronous workers keeps HTTP response times fast and improves overall system resilience. In the Node.js ecosystem, BullMQ built on top of Redis has become a standard choice for managing background jobs.&lt;/p&gt;

&lt;p&gt;In this article, we will examine how to set up a robust background job architecture using TypeScript, BullMQ, and Redis. We will cover queue creation, worker configuration, handling retries with exponential backoff, managing concurrency, and monitoring job lifecycles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture Overview
&lt;/h2&gt;

&lt;p&gt;Before writing code, let us look at the high-level data flow between the producer application, Redis, and the background worker processes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dot"&gt;&lt;code&gt;&lt;span class="n"&gt;flowchart&lt;/span&gt; &lt;span class="no"&gt;TD&lt;/span&gt;
    &lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Producer Application"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;|&lt;/span&gt;&lt;span class="s2"&gt;"Add Job"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Redis Queue"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;B&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;|&lt;/span&gt;&lt;span class="s2"&gt;"Fetch Job"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;C&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Worker Process"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;C&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;|&lt;/span&gt;&lt;span class="s2"&gt;"Process"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;D&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Success?"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="no"&gt;D&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;|&lt;/span&gt;&lt;span class="s2"&gt;"Yes"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;E&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Mark Completed"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;D&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;|&lt;/span&gt;&lt;span class="s2"&gt;"No"&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;F&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Retry with Backoff"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;F&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;|&lt;/span&gt;&lt;span class="nc"&gt;Exhausted&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;G&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Move to Failed"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting Up the Queue and Worker
&lt;/h2&gt;

&lt;p&gt;To begin, we need a reliable connection to Redis and a defined queue. We will use TypeScript to ensure type safety across job data structures.&lt;/p&gt;

&lt;p&gt;First, install the required packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install bullmq ioredis
npm install -D typescript @types/node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let us define our queue and worker initialization logic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Queue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Job&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'bullmq'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'localhost'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6379&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Define the queue&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;emailQueue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Queue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'email-processing'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Define the worker&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;worker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'email-processing'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Job&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="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Processing job ${job.id} for ${job.data.email}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Simulate work&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;concurrency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'completed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&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="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Job ${job.id} completed successfully.`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&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="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Job ${job?.id} failed with error: ${err.message}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&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;h2&gt;
  
  
  Configuring Retries and Exponential Backoff
&lt;/h2&gt;

&lt;p&gt;Failures are inevitable in distributed systems. Network partitions, rate limits, and database timeouts will occur. BullMQ allows us to define retry strategies declaratively when adding a job to the queue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;emailQueue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'send-welcome-email'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'user@example.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Jane Doe'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;backoff&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'exponential'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&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;With this configuration, if the worker throws an error, BullMQ will wait 2 seconds before the first retry, 4 seconds before the second, and so on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Managing Concurrency and Rate Limiting
&lt;/h2&gt;

&lt;p&gt;Controlling how many jobs execute concurrently prevents your workers from overwhelming downstream services like third-party APIs or databases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;restrictedWorker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Worker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'api-sync'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&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;// Sync data with external service&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;concurrency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Process max 2 jobs simultaneously per worker instance&lt;/span&gt;
    &lt;span class="n"&gt;limiter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Max 10 jobs per second&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcRdcy6XwoFa0M7Vgp2PtJ8OoHsHVe_LYKTTQoRikVkmvg%26s%3D10" 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%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcRdcy6XwoFa0M7Vgp2PtJ8OoHsHVe_LYKTTQoRikVkmvg%26s%3D10" alt="image: developer monitoring server dashboard and metrics in terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Failure Handling and Dead Letter Queues
&lt;/h2&gt;

&lt;p&gt;When a job exhausts all its retry attempts, BullMQ moves it to the 'failed' state. In a production environment, you should monitor these failures and implement alerting or a mechanism to inspect and manually retry dead jobs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;worker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'failed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&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="n"&gt;job&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Job ${job.id} failed permanently after ${job.attemptsMade} attempts.`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// [add alert integration, e.g., Sentry or PagerDuty]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&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;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Building resilient background job pipelines requires careful consideration of retries, concurrency, and error handling. By leveraging BullMQ and Redis, you get a robust foundation that scales horizontally as your application grows. Always monitor your queues in production to catch bottlenecks early.&lt;/p&gt;

&lt;p&gt;Documentation: &lt;a href="https://docs.bullmq.io/" rel="noopener noreferrer"&gt;https://docs.bullmq.io/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>typescript</category>
      <category>bullmq</category>
      <category>redis</category>
    </item>
    <item>
      <title>Building a Production-Ready RAG System: Beyond Basic Vector Search</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:15:48 +0000</pubDate>
      <link>https://dev.to/yunkhngn/building-a-production-ready-rag-system-beyond-basic-vector-search-2gi6</link>
      <guid>https://dev.to/yunkhngn/building-a-production-ready-rag-system-beyond-basic-vector-search-2gi6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Most Retrieval-Augmented Generation (RAG) tutorials stop at a naive implementation: load a PDF, split it into arbitrary 500-character chunks, generate embeddings with a standard model, store them in a vector database, and pass the top-k results to an LLM. While this works for a local prototype or a simple FAQ bot, it frequently fails in production. Real-world documents have complex structures, user queries rarely match keyword-for-keyword semantic distributions, and naive top-k retrieval often introduces noise that degrades generation quality.&lt;/p&gt;

&lt;p&gt;Building a production-grade RAG system requires treating retrieval as a rigorous data engineering and search problem. This article outlines a systematic approach to document ingestion, hybrid retrieval, reranking, hallucination reduction, and evaluation.&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%2Fknsbamr7wxi58kmaqgam.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fknsbamr7wxi58kmaqgam.jpeg" alt="image: system architecture diagram for production rag pipeline"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Document Ingestion and Chunking Strategies
&lt;/h2&gt;

&lt;p&gt;The foundation of any RAG system is how raw data is parsed and segmented. Treating documents as flat text streams destroys hierarchical context.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semantic vs. Fixed-Size Chunking
&lt;/h3&gt;

&lt;p&gt;Fixed-size chunking (e.g., splitting every 500 tokens with a 50-token overlap) is easy to implement but dangerous. It frequently cuts sentences in half, separates tables from their headers, or groups unrelated paragraphs together.&lt;/p&gt;

&lt;p&gt;A better approach is structural chunking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Markdown or HTML Parsing:&lt;/strong&gt; Parse documents into hierarchical trees based on header tags (&lt;code&gt;H1&lt;/code&gt;, &lt;code&gt;H2&lt;/code&gt;, &lt;code&gt;H3&lt;/code&gt;). Keep sections intact unless they exceed token limits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recursive Character Splitting:&lt;/strong&gt; Fallback to splitting by paragraphs, then sentences, maintaining semantic boundaries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parent-Child Chunking:&lt;/strong&gt; Index small chunks (e.g., 128 tokens) for precise vector matching, but return the larger parent chunk (e.g., 512 tokens) to the LLM to provide adequate context.&lt;/li&gt;
&lt;/ul&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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJSYXcgRG9jdW1lbnQiXSAtLT4gQlsiUGFyc2UgU3RydWN0dXJlIChIZWFkZXJzL1RhYmxlcykiXQogICAgQiAtLT4gQ1siUmVjdXJzaXZlIENodW5raW5nIl0KICAgIEMgLS0-IERbIkdlbmVyYXRlIFNtYWxsIENoaWxkIEVtYmVkZGluZ3MiXQogICAgQyAtLT4gRVsiU3RvcmUgUGFyZW50LUNoaWxkIE1hcHBpbmdzIl0KICAgIEQgLS0-IEZbIlZlY3RvciBEYXRhYmFzZSJd%3FbgColor%3D%21white" 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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJSYXcgRG9jdW1lbnQiXSAtLT4gQlsiUGFyc2UgU3RydWN0dXJlIChIZWFkZXJzL1RhYmxlcykiXQogICAgQiAtLT4gQ1siUmVjdXJzaXZlIENodW5raW5nIl0KICAgIEMgLS0-IERbIkdlbmVyYXRlIFNtYWxsIENoaWxkIEVtYmVkZGluZ3MiXQogICAgQyAtLT4gRVsiU3RvcmUgUGFyZW50LUNoaWxkIE1hcHBpbmdzIl0KICAgIEQgLS0-IEZbIlZlY3RvciBEYXRhYmFzZSJd%3FbgColor%3D%21white" alt="Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hybrid Retrieval: Combining Sparse and Dense Search
&lt;/h2&gt;

&lt;p&gt;Dense vector search excels at capturing semantic intent, but it often struggles with exact keyword matches, such as product SKU numbers, proper nouns, or specific technical terminology. Conversely, sparse search (like BM25) excels at exact matches but fails to understand synonyms or conceptual similarity.&lt;/p&gt;

&lt;p&gt;Production systems use hybrid search, combining both approaches:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Dense Retrieval:&lt;/strong&gt; Vector similarity search using cosine distance or inner product over embeddings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sparse Retrieval:&lt;/strong&gt; BM25 or TF-IDF indexing for keyword matching.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reciprocal Rank Fusion (RRF):&lt;/strong&gt; Combine the ranked lists from both search algorithms without needing to normalize disparate score distributions.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reciprocal_rank_fusion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dense_results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sparse_results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;fused_scores&lt;/span&gt; &lt;span class="o"&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;for&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dense_results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;fused_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fused_scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sparse_results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;fused_scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fused_scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rank&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fused_scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reranking for Precision
&lt;/h2&gt;

&lt;p&gt;Retrieving the top 50 candidates via hybrid search is cheap and fast, but passing all 50 to an LLM is expensive and introduces noise (the "lost in the middle" phenomenon). Inserting a cross-encoder reranker solves this.&lt;/p&gt;

&lt;p&gt;Bi-encoders (used for vector embeddings) encode the query and document independently, making them fast for initial retrieval. Cross-encoders process the query and document together through a transformer network, allowing full attention between query and context terms at the cost of higher latency.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Initial Pool:&lt;/strong&gt; Retrieve top 50 documents using hybrid search.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reranking:&lt;/strong&gt; Pass the query and each document pair through a cross-encoder model (e.g., Cohere Rerank or BGE-Reranker).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Final Selection:&lt;/strong&gt; Keep the top 3-5 documents for the generation step.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Mitigating Hallucinations and Managing Context
&lt;/h2&gt;

&lt;p&gt;Even with optimal retrieval, LLMs can hallucinate or extrapolate beyond the provided text. To enforce groundedness:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Explicit Prompt Instructions:&lt;/strong&gt; Instruct the model to rely &lt;em&gt;only&lt;/em&gt; on the provided context. If the answer is not present, it must state that it does not know.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source Citation:&lt;/strong&gt; Require the model to output the citation ID for every factual claim, allowing automated verification against the retrieved chunks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Guardrails:&lt;/strong&gt; Implement output validation layers to check if the generated claims are supported by the source text using secondary lightweight models or NLI (Natural Language Inference) classifiers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Production Architecture
&lt;/h2&gt;

&lt;p&gt;A production RAG pipeline must handle asynchronous ingestion, low-latency querying, and observability.&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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IExSCiAgICBzdWJncmFwaCBJbmdlc3Rpb24KICAgICAgICBBWyJTb3VyY2UgRG9jcyJdIC0tPiBCWyJQYXJzZXIiXQogICAgICAgIEIgLS0-IENbIkNodW5rZXIiXQogICAgICAgIEMgLS0-IERbIkVtYmVkZGluZyBBUEkiXQogICAgICAgIEQgLS0-IEVbIlZlY3RvciBEQiAmIEJNMjUgSW5kZXgiXQogICAgZW5kCiAgICBzdWJncmFwaCBRdWVyeSBGbG93CiAgICAgICAgRlsiVXNlciBRdWVyeSJdIC0tPiBHWyJIeWJyaWQgU2VhcmNoIl0KICAgICAgICBHIC0tPiBIWyJDcm9zcy1FbmNvZGVyIFJlcmFua2VyIl0KICAgICAgICBIIC0tPiBJWyJMTE0gR2VuZXJhdGlvbiJdCiAgICAgICAgSSAtLT4gSlsiUmVzcG9uc2UgKyBDaXRhdGlvbnMiXQogICAgZW5k%3FbgColor%3D%21white" 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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IExSCiAgICBzdWJncmFwaCBJbmdlc3Rpb24KICAgICAgICBBWyJTb3VyY2UgRG9jcyJdIC0tPiBCWyJQYXJzZXIiXQogICAgICAgIEIgLS0-IENbIkNodW5rZXIiXQogICAgICAgIEMgLS0-IERbIkVtYmVkZGluZyBBUEkiXQogICAgICAgIEQgLS0-IEVbIlZlY3RvciBEQiAmIEJNMjUgSW5kZXgiXQogICAgZW5kCiAgICBzdWJncmFwaCBRdWVyeSBGbG93CiAgICAgICAgRlsiVXNlciBRdWVyeSJdIC0tPiBHWyJIeWJyaWQgU2VhcmNoIl0KICAgICAgICBHIC0tPiBIWyJDcm9zcy1FbmNvZGVyIFJlcmFua2VyIl0KICAgICAgICBIIC0tPiBJWyJMTE0gR2VuZXJhdGlvbiJdCiAgICAgICAgSSAtLT4gSlsiUmVzcG9uc2UgKyBDaXRhdGlvbnMiXQogICAgZW5k%3FbgColor%3D%21white" alt="Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key architectural considerations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous Updates:&lt;/strong&gt; Ingestion pipelines should run via message queues (e.g., Celery, RabbitMQ) so document updates do not block the API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching:&lt;/strong&gt; Cache frequent queries and their corresponding retrieved context blocks to reduce latency and API costs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate Limiting and Fallbacks:&lt;/strong&gt; Handle upstream LLM provider rate limits gracefully with exponential backoff and fallback models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Evaluation Frameworks
&lt;/h2&gt;

&lt;p&gt;Measuring RAG performance requires decomposing the system into retrieval and generation metrics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Context Recall:&lt;/strong&gt; Did the retrieval system fetch all necessary information to answer the query?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Precision:&lt;/strong&gt; Are the retrieved chunks relevant, or is there unnecessary noise?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Faithfulness:&lt;/strong&gt; Is the generated response derived entirely from the retrieved context without hallucinated additions?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Answer Relevance:&lt;/strong&gt; Does the response actually address the user's initial prompt?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using frameworks like Ragas or TruLens allows continuous evaluation against a test dataset of golden queries during CI/CD pipelines.&lt;/p&gt;

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

&lt;p&gt;Moving from a basic prototype to a production-ready RAG system requires replacing shortcuts with robust engineering practices. By implementing structural chunking, hybrid search, cross-encoder reranking, and rigorous evaluation frameworks, you can build reliable systems that scale predictably in production. For further reading, consult.&lt;/p&gt;

</description>
      <category>rag</category>
      <category>vectorsearch</category>
      <category>embeddings</category>
      <category>architecture</category>
    </item>
    <item>
      <title>NestJS vs Spring Boot: Choosing the Right Backend Framework</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:10:00 +0000</pubDate>
      <link>https://dev.to/yunkhngn/nestjs-vs-spring-boot-choosing-the-right-backend-framework-18hj</link>
      <guid>https://dev.to/yunkhngn/nestjs-vs-spring-boot-choosing-the-right-backend-framework-18hj</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Choosing the right backend framework shapes the long-term maintainability, performance, and developer velocity of any software system. Two prominent contenders in modern enterprise architecture are NestJS, a TypeScript-based framework for Node.js, and Spring Boot, the established Java-based ecosystem standard. While both advocate for modularity, dependency injection, and clean separation of concerns, their foundational runtimes and philosophies differ significantly.&lt;/p&gt;

&lt;p&gt;This article provides a rigorous, objective comparison of NestJS and Spring Boot to help you select the optimal tool for your next backend service.&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%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcSjZJFmaMS8DKJ7clKkaQgQ0dnQ8TmahfNWAWCHVmg-VoycmTqOKane4fc%26s%3D10" 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%2Fencrypted-tbn0.gstatic.com%2Fimages%3Fq%3Dtbn%3AANd9GcSjZJFmaMS8DKJ7clKkaQgQ0dnQ8TmahfNWAWCHVmg-VoycmTqOKane4fc%26s%3D10" width="739" height="415"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Architectural Foundations
&lt;/h2&gt;

&lt;p&gt;At their core, NestJS and Spring Boot target different language ecosystems and execution environments, which immediately impacts their operational characteristics.&lt;/p&gt;

&lt;h3&gt;
  
  
  NestJS
&lt;/h3&gt;

&lt;p&gt;NestJS is built on top of TypeScript and JavaScript (Node.js). It heavily borrows architectural concepts from Angular, organizing code into modules, controllers, and providers. By default, NestJS uses Express as its underlying HTTP server, but it can be easily switched to Fastify for improved throughput.&lt;/p&gt;

&lt;h3&gt;
  
  
  Spring Boot
&lt;/h3&gt;

&lt;p&gt;Spring Boot simplifies the configuration and deployment of Java applications within the broader Spring ecosystem. It relies on the Java Virtual Machine (JVM), utilizing annotation-based configuration and convention-over-configuration principles to bootstrap enterprise-grade applications quickly.&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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJDbGllbnQgUmVxdWVzdCJdIC0tPiBCeyJGcmFtZXdvcmsgU2VsZWN0aW9uIn0KICAgIEIgLS0-fCJUeXBlU2NyaXB0IC8gTm9kZS5qcyJ8IENbIk5lc3RKUyBDb250cm9sbGVyIl0KICAgIEIgLS0-fCJKYXZhIC8gS290bGluIC8gSlZNInwgRFsiU3ByaW5nIEJvb3QgUmVzdENvbnRyb2xsZXIiXQogICAgQyAtLT4gRVsiTmVzdEpTIFNlcnZpY2UgLyBESSJdCiAgICBEIC0tPiBGWyJTcHJpbmcgQmVhbiAvIERJIl0KICAgIEUgLS0-IEdbIkRhdGFiYXNlIC8gUGVyc2lzdGVuY2UiXQogICAgRiAtLT4gRw%3FbgColor%3D%21white" 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%2Fmermaid.ink%2Fimg%2FZmxvd2NoYXJ0IFRECiAgICBBWyJDbGllbnQgUmVxdWVzdCJdIC0tPiBCeyJGcmFtZXdvcmsgU2VsZWN0aW9uIn0KICAgIEIgLS0-fCJUeXBlU2NyaXB0IC8gTm9kZS5qcyJ8IENbIk5lc3RKUyBDb250cm9sbGVyIl0KICAgIEIgLS0-fCJKYXZhIC8gS290bGluIC8gSlZNInwgRFsiU3ByaW5nIEJvb3QgUmVzdENvbnRyb2xsZXIiXQogICAgQyAtLT4gRVsiTmVzdEpTIFNlcnZpY2UgLyBESSJdCiAgICBEIC0tPiBGWyJTcHJpbmcgQmVhbiAvIERJIl0KICAgIEUgLS0-IEdbIkRhdGFiYXNlIC8gUGVyc2lzdGVuY2UiXQogICAgRiAtLT4gRw%3FbgColor%3D%21white" alt="Diagram" width="360" height="702"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency Injection Systems
&lt;/h2&gt;

&lt;p&gt;Both frameworks place dependency injection (DI) at the center of their design, allowing for decoupled components and testable codebases.&lt;/p&gt;

&lt;h3&gt;
  
  
  NestJS DI
&lt;/h3&gt;

&lt;p&gt;NestJS has a built-in container that resolves relationships between providers using TypeScript metadata.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Injectable&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@nestjs/common'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Injectable&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;class&lt;/span&gt; &lt;span class="nc"&gt;UsersService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&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="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Alice'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Bob'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&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;h3&gt;
  
  
  Spring Boot DI
&lt;/h3&gt;

&lt;p&gt;Spring Boot relies on the Spring IoC (Inversion of Control) container, managing beans via annotations like &lt;code&gt;@Component&lt;/code&gt;, &lt;code&gt;@Service&lt;/code&gt;, and &lt;code&gt;@Autowired&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;springframework&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stereotype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Service&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;util&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UsersService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getUsers&lt;/span&gt;&lt;span class="p"&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="kt"&gt;List&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Bob"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&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;h2&gt;
  
  
  Performance and Resource Utilization
&lt;/h2&gt;

&lt;p&gt;Performance characteristics depend heavily on the underlying runtime environment.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Node.js (NestJS):&lt;/strong&gt; Excels at I/O-bound operations, asynchronous processing, and lightweight microservices. Startup times are exceptionally fast, and memory footprints are generally small.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JVM (Spring Boot):&lt;/strong&gt; Optimized for heavy CPU-bound tasks, complex data processing, and massive enterprise workloads. While modern JVMs and GraalVM native images have drastically reduced startup times and memory consumption, Spring Boot traditionally requires more RAM than Node.js.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ecosystem and Libraries
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NestJS:&lt;/strong&gt; Leverages the vast npm ecosystem. Developers can integrate any JavaScript or TypeScript library seamlessly, though this occasionally introduces variance in package quality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spring Boot:&lt;/strong&gt; Backed by the mature Spring ecosystem (Spring Cloud, Spring Data, Spring Security). It provides a standardized, highly cohesive suite of tools for distributed systems, security, and data persistence.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Decision Framework
&lt;/h2&gt;

&lt;p&gt;To choose between NestJS and Spring Boot, evaluate the following criteria:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Team Expertise:&lt;/strong&gt; What language does your team write more fluently—TypeScript or Java/Kotlin?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain Complexity:&lt;/strong&gt; Are you building standard CRUD APIs and real-time gateways (favor NestJS) or complex domain-driven enterprise systems with heavy transactional requirements (favor Spring Boot)?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Infrastructure Constraints:&lt;/strong&gt; What are your memory and startup time limits?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For further reading on architectural patterns, consult [add link]. [add result] regarding benchmark tests.&lt;/p&gt;

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

&lt;p&gt;Both NestJS and Spring Boot are world-class frameworks. NestJS brings the flexibility and speed of TypeScript to modern web services, while Spring Boot offers unmatched maturity and robustness for enterprise Java environments.&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>springboot</category>
      <category>architecture</category>
      <category>backend</category>
    </item>
    <item>
      <title>How to Design a Multi-Tenant SaaS Architecture with Spring Boot</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 04:06:05 +0000</pubDate>
      <link>https://dev.to/yunkhngn/how-to-design-a-multi-tenant-saas-architecture-with-spring-boot-22ef</link>
      <guid>https://dev.to/yunkhngn/how-to-design-a-multi-tenant-saas-architecture-with-spring-boot-22ef</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Building a multi-tenant SaaS application requires careful planning around data isolation, security, and scalability. When multiple customers share the same application instance, ensuring that tenant data remains strictly segregated is the primary architectural challenge.&lt;/p&gt;

&lt;p&gt;In this article, we will explore how to implement a robust multi-tenant architecture using Spring Boot. We will cover database isolation patterns, request-scoped tenant context propagation, and authorization strategies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tenant Isolation Strategies
&lt;/h2&gt;

&lt;p&gt;Before writing any code, you must decide on your data isolation strategy. There are three common patterns in multi-tenant architecture:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Database-per-tenant&lt;/strong&gt;: Complete physical separation. Maximum security, higher infrastructure cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Schema-per-tenant&lt;/strong&gt;: Shared database, separate schemas. A good balance of isolation and resource efficiency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shared database with tenant discriminator&lt;/strong&gt;: All tenants share tables, distinguished by a &lt;code&gt;tenant_id&lt;/code&gt; column. Lowest cost, highest implementation complexity.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For this guide, we will focus on the &lt;strong&gt;schema-per-tenant&lt;/strong&gt; approach using PostgreSQL and Hibernate, which offers a strong isolation boundary without the overhead of managing thousands of database instances.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dot"&gt;&lt;code&gt;&lt;span class="n"&gt;flowchart&lt;/span&gt;
    &lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Incoming Request"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Tenant Resolution Filter"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;B&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;C&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Tenant Context Holder"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;C&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;D&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Hibernate Connection Provider"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="no"&gt;D&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;E&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Target Database Schema"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Resolving and Propagating Tenant Context
&lt;/h2&gt;

&lt;p&gt;The first step in handling a multi-tenant request is identifying the tenant. This is typically done via a subdomain (e.g., &lt;code&gt;tenant1.app.com&lt;/code&gt;) or an HTTP header (&lt;code&gt;X-Tenant-ID&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;We capture this identifier using a Spring Web Filter and store it in a thread-safe &lt;code&gt;ThreadLocal&lt;/code&gt; wrapper called &lt;code&gt;TenantContext&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TenantContext&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;ThreadLocal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;CURRENT_TENANT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ThreadLocal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;span class="p"&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;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setCurrentTenant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="no"&gt;CURRENT_TENANT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tenantId&lt;/span&gt;&lt;span class="p"&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;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getCurrentTenant&lt;/span&gt;&lt;span class="p"&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="no"&gt;CURRENT_TENANT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&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;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="no"&gt;CURRENT_TENANT&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&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;Next, implement a &lt;code&gt;OncePerRequestFilter&lt;/code&gt; to intercept incoming HTTP requests, extract the tenant identifier, and populate the context.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Component&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;TenantFilter&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;OncePerRequestFilter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;doFilterInternal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpServletRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;HttpServletResponse&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                    &lt;span class="nc"&gt;FilterChain&lt;/span&gt; &lt;span class="n"&gt;filterChain&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;ServletException&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;IOException&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;tenantId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Tenant-ID"&lt;/span&gt;&lt;span class="p"&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="n"&gt;tenantId&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;TenantContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setCurrentTenant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tenantId&lt;/span&gt;&lt;span class="p"&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;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpServletResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SC_BAD_REQUEST&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getWriter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-Tenant-ID header is missing"&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;}&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;filterChain&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;doFilter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&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;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nc"&gt;TenantContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1558494949-ef010cbdcc31%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8c2VydmVyJTIwcmFjayUyMGRhdGFjZW50ZXIlMjBpbmZyYXN0cnVjdHVyZSUyMGFyY2hpdGVjdHVyZXxlbnwwfDB8fHwxNzk2MzU3MDY3fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" 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%2Fimages.unsplash.com%2Fphoto-1558494949-ef010cbdcc31%3Fcrop%3Dentropy%26cs%3Dtinysrgb%26fit%3Dmax%26fm%3Djpg%26ixid%3DM3wxMTM1NjE4fDB8MXxzZWFyY2h8MXx8c2VydmVyJTIwcmFjayUyMGRhdGFjZW50ZXIlMjBpbmZyYXN0cnVjdHVyZSUyMGFyY2hpdGVjdHVyZXxlbnwwfDB8fHwxNzk2MzU3MDY3fDA%26ixlib%3Drb-4.1.0%26q%3D80%26w%3D1080" alt="cable network — Photo by Taylor Vick on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Dynamic Schema Routing with Hibernate
&lt;/h2&gt;

&lt;p&gt;To route database queries to the correct PostgreSQL schema dynamically, we implement a custom &lt;code&gt;MultiTenantConnectionProvider&lt;/code&gt; and a &lt;code&gt;CurrentTenantIdentifierResolver&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Component&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CurrentTenantIdentifierResolverImpl&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;CurrentTenantIdentifierResolver&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;resolveCurrentTenantIdentifier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TenantContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getCurrentTenant&lt;/span&gt;&lt;span class="p"&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="n"&gt;tenant&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;tenant&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"public"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;validateExistingCurrentSessions&lt;/span&gt;&lt;span class="p"&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="kc"&gt;true&lt;/span&gt;&lt;span class="p"&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;When executing queries, Hibernate consults the resolver to determine which schema context to apply to the active database connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authorization and Security Considerations
&lt;/h2&gt;

&lt;p&gt;Tenant isolation at the database layer is not enough. You must also ensure that users cannot access resources belonging to other tenants through application endpoints, even if they guess or manipulate identifiers.&lt;/p&gt;

&lt;p&gt;Integrate tenant checks into your Spring Security configuration or method-level security expressions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@PreAuthorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"@tenantSecurity.hasAccess(#tenantId, principal)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Document&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getDocuments&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt; &lt;span class="n"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// fetch documents safely&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&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;h2&gt;
  
  
  Common Pitfalls to Avoid
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Leaking ThreadLocal State&lt;/strong&gt;: Always clear your &lt;code&gt;TenantContext&lt;/code&gt; in a &lt;code&gt;finally&lt;/code&gt; block or filter cleanup phase. Failing to do so in a thread-pool environment (like Tomcat) will cause cross-tenant data leaks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background Jobs and Async Processing&lt;/strong&gt;: &lt;code&gt;ThreadLocal&lt;/code&gt; variables do not propagate automatically to new threads. When using &lt;code&gt;@Async&lt;/code&gt; or &lt;code&gt;CompletableFuture&lt;/code&gt;, explicitly copy the tenant context to the asynchronous task.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global Caching&lt;/strong&gt;: Ensure caches like Redis are properly namespaced with the &lt;code&gt;tenant_id&lt;/code&gt; to prevent data collision between tenants.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Designing a multi-tenant architecture in Spring Boot requires diligence around context propagation and connection management. By implementing schema-per-tenant isolation and strict request filtering, you can build a secure, scalable SaaS foundation.&lt;/p&gt;

&lt;p&gt;For further reading, consult the &lt;a href="https://docs.spring.io/spring-framework/reference/index.html" rel="noopener noreferrer"&gt;Spring framework documentation&lt;/a&gt; on multi-tenancy.&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>architecture</category>
      <category>saas</category>
    </item>
    <item>
      <title>Intergrate an AI Kitchen</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 03:53:11 +0000</pubDate>
      <link>https://dev.to/yunkhngn/ai-kitchen-35f0</link>
      <guid>https://dev.to/yunkhngn/ai-kitchen-35f0</guid>
      <description>&lt;h2&gt;
  
  
  From Idea to Product: The Philosophy of AI Kitchen
&lt;/h2&gt;

&lt;p&gt;Throughout my software development journey, I have always sought to optimize not just my code, but my 'thought process'. People often talk about AI as a content generation tool, but to me, AI is a tireless colleague within a complex information processing machine. I call this system 'AI Kitchen'.&lt;/p&gt;

&lt;p&gt;AI Kitchen is not a single tool. It is an ecosystem of prompts, scripts, and workflows connecting various models (such as Claude Sonnet, GPT) to process input data. Much like a kitchen, the input is 'raw ingredients' and the output is refined 'dishes' (technical products).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why AI Kitchen?
&lt;/h2&gt;

&lt;p&gt;Most engineers today use AI in a 'chat-and-go' manner: ask a question, get an answer, copy-paste code. This works well for isolated tasks, but becomes extremely risky when building large systems. AI Kitchen focuses on three core principles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Modularization:&lt;/strong&gt; Breaking down complex tasks into small 'recipes'. Each prompt is a single step in the workflow.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation:&lt;/strong&gt; Every AI output must pass through a verification filter.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Awareness:&lt;/strong&gt; Keeping AI aligned with the project context instead of sending isolated prompts.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Operational Workflow: How are 'ingredients' processed?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Preprocessing
&lt;/h3&gt;

&lt;p&gt;Before feeding any request to Claude, I always clean the data first. I usually use Python scripts to extract essential structures from documents (markdown, codebases, logs) and remove noise. This is similar to prepping vegetables before cooking. AI performs much better when it doesn't have to read redundant information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Task Separation (Chain-of-Thought Prompting)
&lt;/h3&gt;

&lt;p&gt;Instead of asking: 'Write an API service for me', I break down the process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Persona Definition:&lt;/strong&gt; Define the role of the AI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Architectural Guidelines:&lt;/strong&gt; Provide architectural principles (e.g., Hexagonal Architecture, Clean Code).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Implementation Phase:&lt;/strong&gt; Write detailed code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review Phase:&lt;/strong&gt; Self-review code and spot potential bugs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of a 'Recipe' (prompt recipe) structure that I often use for code refactoring tasks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Role]: Senior Software Engineer
[Context]: Project uses TypeScript and Next.js 14
[Task]: Refactor the current fetch logic into a React Query hook.
[Guidelines]:
- Use functional components
- Ensure proper error handling
- Type all interfaces strictly
- No magic strings
[Step-by-step]:
1. Analyze existing code structure.
2. Identify side effects.
3. Propose the new hook implementation.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building the Evaluation System (The Taste Test)
&lt;/h2&gt;

&lt;p&gt;In a real kitchen, the chef tastes the food before serving. In AI Kitchen, I apply a Self-Correction mechanism. When receiving AI feedback, instead of accepting it immediately, I ask the AI to perform a re-check using an adversarial prompt:&lt;/p&gt;

&lt;p&gt;'Act as a Security Auditor and find security vulnerabilities in the code written above.'&lt;/p&gt;

&lt;p&gt;This significantly reduces basic logic errors that AI typically makes. We should never blindly trust the first returned result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrating into Personal Workflow
&lt;/h2&gt;

&lt;p&gt;For AI Kitchen to be truly effective, it needs to live right inside the workflow. I have integrated supporting tools like VS Code extensions, combined with custom scripts to send requests directly via the Claude API. This allows me to avoid constant context switching between the IDE and the browser.&lt;/p&gt;

&lt;p&gt;Storing 'prompt templates' as a code library on GitHub is also how I manage 'ingredients' for the system. Whenever there is a new project, I simply clone this library, change the context, and start the workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges and Limitations
&lt;/h2&gt;

&lt;p&gt;Of course, AI Kitchen is not a cure-all. There are limitations you should keep in mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hallucinations:&lt;/strong&gt; AI may invent non-existent libraries or impractical solutions. Human validation is mandatory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Window Constraints:&lt;/strong&gt; Although current models support very large contexts, providing too many unnecessary details still reduces AI performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost Management:&lt;/strong&gt; Continuous API calls for small tasks can become costly if not properly controlled.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Future of AI Kitchen: Towards Agentic Workflow
&lt;/h2&gt;

&lt;p&gt;Currently, AI Kitchen still requires my active participation (Human-in-the-loop). However, I am moving towards building 'AI Agents' capable of autonomously operating preprocessing and validation steps without heavy manual intervention.&lt;/p&gt;

&lt;p&gt;In the future, I want to integrate AI Kitchen with [CI/CD tool name] so that dishes (code) are pushed directly to the staging environment after passing automated tests. That is when this kitchen becomes a fully automated production line.&lt;/p&gt;

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

&lt;p&gt;AI does not replace engineers, but engineers who use AI effectively will undoubtedly surpass the rest. Building a systematic workflow (like how I am building AI Kitchen) is the only way to maintain speed and quality in today's rapidly changing tech environment.&lt;/p&gt;

&lt;p&gt;What about you? What is your workflow with AI? Feel free to share below.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/yunkhngn/AI-kitchen-code-delivering" rel="noopener noreferrer"&gt;https://github.com/yunkhngn/AI-kitchen-code-delivering&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aiworkflow</category>
      <category>claude</category>
      <category>ai</category>
      <category>engineering</category>
    </item>
    <item>
      <title>Beautiful on the Surface, Engineered Underneath - My Legacy Website</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 03:51:40 +0000</pubDate>
      <link>https://dev.to/yunkhngn/beautiful-on-the-surface-engineered-underneath-my-legacy-website-ddn</link>
      <guid>https://dev.to/yunkhngn/beautiful-on-the-surface-engineered-underneath-my-legacy-website-ddn</guid>
      <description>&lt;h2&gt;
  
  
  01. It was supposed to be just a personal website
&lt;/h2&gt;

&lt;p&gt;I have always believed that a personal website should be more than a collection of links and project cards.&lt;/p&gt;

&lt;p&gt;It is a place where you can express how you think, what you create, and how you see the digital world. I wanted mine to feel intentional - not just visually, but also in the way people interacted with it.&lt;/p&gt;

&lt;p&gt;The initial motivation was simple: build a personal space to showcase my work, share what I was learning, and experiment with ideas that I couldn't quite explore in academic projects.&lt;/p&gt;

&lt;p&gt;But I have a habit of taking things further than originally planned.&lt;/p&gt;

&lt;p&gt;I started spending more time thinking about interactions, transitions, layouts, and the overall visual language. I wanted every element to feel like it belonged there. The interface needed to be beautiful, but it also needed to feel coherent and effortless to navigate.&lt;/p&gt;

&lt;p&gt;Then came the engineering questions.&lt;/p&gt;

&lt;p&gt;What should happen behind the interface? How should content be managed? Could different capabilities operate independently? How could I introduce AI-powered features without making the core application unnecessarily complicated?&lt;/p&gt;

&lt;p&gt;Eventually, the project evolved into something much bigger than a personal website.&lt;/p&gt;

&lt;p&gt;It became a microservice-based platform that I designed, developed, deployed, and maintained independently.&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%2Fcur2vmn9a2byf3qiyu54.jpg" 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%2Fcur2vmn9a2byf3qiyu54.jpg" alt="595114204_2558378084543398_3918302419840635096_n" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  02. Design was never an afterthought
&lt;/h2&gt;

&lt;p&gt;One of the most memorable aspects of this project was the feedback I received after sharing it with the developer community.&lt;/p&gt;

&lt;p&gt;People noticed the UI, the visual design, and the technology stack behind it. Seeing developers appreciate both the appearance and the engineering was particularly rewarding.&lt;/p&gt;

&lt;p&gt;That meant a lot to me because the visual experience was never something I added at the end.&lt;/p&gt;

&lt;p&gt;I wanted the website to have its own identity.&lt;/p&gt;

&lt;p&gt;Rather than simply following a conventional portfolio layout, I approached it as a product. I paid attention to visual hierarchy, spacing, typography, component consistency, interaction states, and motion.&lt;/p&gt;

&lt;p&gt;I wanted the experience to feel polished without becoming unnecessarily complicated.&lt;/p&gt;

&lt;p&gt;There was also an interesting challenge here: a technically sophisticated system does not automatically produce a good user experience.&lt;/p&gt;

&lt;p&gt;The complexity should remain behind the scenes. Visitors should not need to understand the architecture, databases, or APIs to enjoy using the website.&lt;/p&gt;

&lt;p&gt;That became one of the principles I tried to follow throughout development:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make the experience simple. Let the engineering do the heavy lifting.&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%2Fo72iam3d1l2a1c1ffc9k.jpg" 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%2Fo72iam3d1l2a1c1ffc9k.jpg" alt="594067999_2558378037876736_5676423884743418348_n" width="799" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  03. From a website to a distributed system
&lt;/h2&gt;

&lt;p&gt;As the platform grew, its responsibilities became increasingly diverse.&lt;/p&gt;

&lt;p&gt;The frontend needed to serve different types of content and interactions. The backend handled business logic, content management, and data access. Authentication needed its own boundaries. I also wanted to experiment with computer vision without tightly coupling Python-based processing to the main application.&lt;/p&gt;

&lt;p&gt;Instead of putting everything into a single codebase and runtime, I gradually separated the system into dedicated services.&lt;/p&gt;

&lt;p&gt;The architecture eventually consisted of five main components:&lt;/p&gt;

&lt;p&gt;ComponentTechnologyResponsibilityFrontendNext.js, ReactPublic website, interactive experiences and admin interfaceBackendNestJS, PrismaCore APIs, business logic and data managementAuthenticationNestJS, Firebase Admin SDKAuthentication and authorizationAI ServicePython, FastAPI, OpenCVImage processing and computer visionInfrastructureDocker Compose, CaddyContainer orchestration, routing and deployment&lt;/p&gt;

&lt;p&gt;The backend was organized around different application domains, including blogs, galleries, projects, comments, and other content-related features.&lt;/p&gt;

&lt;p&gt;I also worked with repository patterns to keep data access separate from business logic, making individual modules easier to maintain and extend.&lt;/p&gt;

&lt;p&gt;The interesting part was not simply having multiple services.&lt;/p&gt;

&lt;p&gt;It was learning how to define responsibilities, manage communication between components, and understand the operational implications of distributing an application across different runtimes.&lt;/p&gt;

&lt;p&gt;A microservice architecture looks attractive on a diagram, but maintaining one is a different experience entirely.&lt;/p&gt;

&lt;p&gt;Every service introduces another deployment unit, another configuration boundary, and another potential point of failure.&lt;/p&gt;

&lt;p&gt;I learned that separation creates flexibility, but it also creates responsibility.&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%2F7ofa2sfiiczd2tc53ut9.jpg" 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%2F7ofa2sfiiczd2tc53ut9.jpg" alt="594051237_2558378131210060_5185652358888048308_n" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  04. The technology behind the experience
&lt;/h2&gt;

&lt;p&gt;One of the reasons this project became such an interesting engineering playground was the variety of technologies involved.&lt;/p&gt;

&lt;p&gt;I wanted to explore tools that solved different problems rather than choosing a stack simply because it was popular.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frontend
&lt;/h3&gt;

&lt;p&gt;The frontend was built around Next.js and React.&lt;/p&gt;

&lt;p&gt;It handled the public-facing experience, content presentation, interactive components, and administrative workflows.&lt;/p&gt;

&lt;p&gt;My focus was on keeping the application responsive and maintaining a consistent design system while allowing different parts of the website to have their own interaction patterns.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backend
&lt;/h3&gt;

&lt;p&gt;NestJS provided the structure for the backend services.&lt;/p&gt;

&lt;p&gt;I used Prisma for database access and organized the application into modules with relatively clear responsibilities.&lt;/p&gt;

&lt;p&gt;The backend also integrated with external services for media management, email delivery, authentication, and AI-powered functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  Infrastructure and supporting services
&lt;/h3&gt;

&lt;p&gt;Docker became the foundation for packaging and running the application.&lt;/p&gt;

&lt;p&gt;The platform also used several supporting technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Redis:&lt;/strong&gt; Caching and supporting application workflows.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft SQL Server:&lt;/strong&gt; Relational data storage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ChromaDB:&lt;/strong&gt; Vector storage for AI-related experiments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caddy:&lt;/strong&gt; Reverse proxy and automatic HTTPS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudinary:&lt;/strong&gt; Image hosting and media transformation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firebase:&lt;/strong&gt; Authentication infrastructure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Gemini:&lt;/strong&gt; AI-powered functionality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resend:&lt;/strong&gt; Transactional email delivery.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="http://Socket.IO" rel="noopener noreferrer"&gt;Socket.IO&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt;:&lt;/strong&gt; Real-time communication.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each technology served a particular purpose within the ecosystem.&lt;/p&gt;

&lt;p&gt;More importantly, integrating them gave me experience working with different types of systems and understanding how they fit together in a real application.&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%2Faj0c93k5nrlqpyn5lihh.jpg" 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%2Faj0c93k5nrlqpyn5lihh.jpg" alt="594063814_2558378277876712_7802523475896852988_n" width="800" height="431"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  05. An unexpected experiment with computer vision
&lt;/h2&gt;

&lt;p&gt;One of my favorite parts of this project was an experiment involving handwritten letters.&lt;/p&gt;

&lt;p&gt;I wanted to create a more personal reading experience — something that could reveal handwriting progressively, almost as if someone were writing the letter in front of the visitor.&lt;/p&gt;

&lt;p&gt;A conventional text animation would not achieve the effect I wanted.&lt;/p&gt;

&lt;p&gt;The animation needed to understand the actual structure of the handwriting.&lt;/p&gt;

&lt;p&gt;So I built a dedicated image-processing service using Python, FastAPI, and OpenCV.&lt;/p&gt;

&lt;p&gt;The idea was to analyze a handwritten image and generate a corresponding reveal map that the frontend could use to control the animation.&lt;/p&gt;

&lt;p&gt;The processing pipeline involved several techniques:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Contrast enhancement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I used CLAHE (Contrast Limited Adaptive Histogram Equalization) to improve local contrast and make faint handwriting more distinguishable from the background.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Image thresholding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I experimented with Otsu thresholding and Gaussian Adaptive Thresholding to separate ink strokes from the paper background.&lt;/p&gt;

&lt;p&gt;This was important because handwritten images are rarely perfectly clean. Lighting conditions, paper texture, and scanning quality can all affect the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Line detection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using horizontal projection analysis, I identified text-line regions and their approximate positions.&lt;/p&gt;

&lt;p&gt;This helped the system understand the spatial structure of the handwriting instead of treating the entire image as one continuous shape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Reveal map generation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The processed image was converted into a normalized grayscale map containing values from 1 to 255.&lt;/p&gt;

&lt;p&gt;The frontend could then use these values to control how individual regions of the handwriting became visible over time.&lt;/p&gt;

&lt;p&gt;I also designed the processing flow to work asynchronously, allowing the service to accept a processing request and return the result through a webhook once the work was completed.&lt;/p&gt;

&lt;p&gt;This feature was particularly interesting because it connected several areas I enjoyed exploring: computer vision, backend architecture, asynchronous processing, and frontend animation.&lt;/p&gt;

&lt;p&gt;It was a good reminder that sometimes a great interaction begins with understanding the data underneath it.&lt;/p&gt;

&lt;h2&gt;
  
  
  06. Automating the journey to production
&lt;/h2&gt;

&lt;p&gt;Building the application was only half of the experience.&lt;/p&gt;

&lt;p&gt;I also wanted to understand how to operate it in a real production environment.&lt;/p&gt;

&lt;p&gt;I deployed the platform to a DigitalOcean Droplet and built an automated deployment workflow around GitHub Actions and Docker.&lt;/p&gt;

&lt;p&gt;Rather than manually building images and transferring them to the server, I wanted the build process to be repeatable.&lt;/p&gt;

&lt;p&gt;The pipeline worked roughly as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Changes were pushed to GitHub.&lt;/li&gt;
&lt;li&gt;GitHub Actions triggered the relevant build workflow.&lt;/li&gt;
&lt;li&gt;Docker images were built for the corresponding services.&lt;/li&gt;
&lt;li&gt;Successfully built images were published as Docker packages to GitHub Container Registry (GHCR).&lt;/li&gt;
&lt;li&gt;The production environment pulled the published images and updated the running containers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach separated the build process from the production runtime.&lt;/p&gt;

&lt;p&gt;The server did not need to build the application from source every time a new version was released. It could simply retrieve the prepared Docker images and run them.&lt;/p&gt;

&lt;p&gt;I also used Docker Compose to manage the services and Caddy to handle reverse proxy configuration and automatic HTTPS through Let's Encrypt.&lt;/p&gt;

&lt;p&gt;Other infrastructure considerations included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Container health checks and service dependencies.&lt;/li&gt;
&lt;li&gt;Persistent volumes for application data.&lt;/li&gt;
&lt;li&gt;Internal Docker networking.&lt;/li&gt;
&lt;li&gt;Reverse proxy configuration.&lt;/li&gt;
&lt;li&gt;Database backup scripts.&lt;/li&gt;
&lt;li&gt;Security headers and request handling.&lt;/li&gt;
&lt;li&gt;Service lifecycle and deployment management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For me, this was one of the biggest steps forward in the project.&lt;/p&gt;

&lt;p&gt;I went from thinking about how to make an application work to thinking about how to build, ship, and operate it consistently.&lt;/p&gt;

&lt;p&gt;The deployment pipeline was not the most visible part of the website, but it was one of the things that made the whole system feel like a real engineering project.&lt;/p&gt;

&lt;h2&gt;
  
  
  07. Building in public
&lt;/h2&gt;

&lt;p&gt;At some point, I started sharing the project with other developers.&lt;/p&gt;

&lt;p&gt;I was particularly happy to receive positive feedback from people in the Vietnamese developer community, including J2TEAM Community.&lt;/p&gt;

&lt;p&gt;What stood out to me was that people were interested in different aspects of the project.&lt;/p&gt;

&lt;p&gt;Some appreciated the visual design and UI/UX. Others were surprised by the technology stack and the amount of engineering behind what was, at first glance, just a personal website.&lt;/p&gt;

&lt;p&gt;That combination was exactly what I had been trying to achieve.&lt;/p&gt;

&lt;p&gt;I didn't want to build something that was technically impressive but difficult to use.&lt;/p&gt;

&lt;p&gt;Neither did I want to create a beautiful interface that was only a static presentation with no meaningful engineering behind it.&lt;/p&gt;

&lt;p&gt;I wanted both sides to complement each other.&lt;/p&gt;

&lt;p&gt;Receiving that kind of feedback gave me a lot of motivation to continue experimenting and improving the platform.&lt;/p&gt;

&lt;p&gt;It also reminded me why sharing personal projects matters. Sometimes, putting something you have built out into the world gives you a perspective that you cannot get from working on it alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  08. More than 1,700 commits later
&lt;/h2&gt;

&lt;p&gt;The project eventually reached a point where its original repository structure no longer reflected how I wanted to preserve and present it.&lt;/p&gt;

&lt;p&gt;The services had initially been developed in separate repositories, each with its own history and development workflow.&lt;/p&gt;

&lt;p&gt;I later consolidated the project into a single repository for archival purposes, preserving the development history across its different components.&lt;/p&gt;

&lt;p&gt;The repository now contains more than 1,700 commits.&lt;/p&gt;

&lt;p&gt;For me, preserving that history was important.&lt;/p&gt;

&lt;p&gt;I didn't want the project to exist only as a final snapshot of the codebase. I wanted to keep the iterations, experiments, and decisions that shaped it.&lt;/p&gt;

&lt;p&gt;Looking through the history is a reminder of how much the project changed from its original idea.&lt;/p&gt;

&lt;p&gt;Some decisions were good. Some were unnecessarily complicated. Some features existed simply because I wanted to find out whether I could build them.&lt;/p&gt;

&lt;p&gt;And I think that is what makes a personal engineering project interesting.&lt;/p&gt;

&lt;p&gt;It doesn't always follow the most efficient path. Sometimes the journey itself is the point.&lt;/p&gt;

&lt;h2&gt;
  
  
  09. What I would do differently today
&lt;/h2&gt;

&lt;p&gt;Looking back, there are several things I would approach differently if I were rebuilding the platform today.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not every boundary needs to be a microservice
&lt;/h3&gt;

&lt;p&gt;Separating responsibilities is valuable, but introducing independently deployed services too early can create more complexity than necessary.&lt;/p&gt;

&lt;p&gt;I would spend more time identifying domain boundaries before deciding which components should become separate services.&lt;/p&gt;

&lt;h3&gt;
  
  
  Observability should come earlier
&lt;/h3&gt;

&lt;p&gt;Health checks are useful, but knowing whether a container is running is not the same as understanding the behavior of a distributed system.&lt;/p&gt;

&lt;p&gt;I would invest earlier in centralized logging, metrics, tracing, and better operational visibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  Infrastructure costs matter
&lt;/h3&gt;

&lt;p&gt;Running multiple services, databases, caches, and supporting infrastructure introduces costs.&lt;/p&gt;

&lt;p&gt;For a personal project, these decisions need to be evaluated carefully.&lt;/p&gt;

&lt;p&gt;A more sophisticated architecture is not automatically a better architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Design and engineering should evolve together
&lt;/h3&gt;

&lt;p&gt;Perhaps the most important lesson was that neither design nor engineering should be treated as a finishing step for the other.&lt;/p&gt;

&lt;p&gt;The architecture should support the experience, while the experience should influence architectural decisions.&lt;/p&gt;

&lt;p&gt;A technically impressive system is only meaningful when it serves a real purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Looking back
&lt;/h2&gt;

&lt;p&gt;This project started with a simple desire: I wanted a personal website that represented me.&lt;/p&gt;

&lt;p&gt;Somewhere along the way, it became a much larger engineering experiment involving distributed services, computer vision, databases, automated Docker builds, cloud infrastructure, and production deployment.&lt;/p&gt;

&lt;p&gt;It also became one of the projects that received some of the most memorable feedback from the developer community.&lt;/p&gt;

&lt;p&gt;Looking back, I don't think the most important achievement was using a particular framework, implementing a microservice architecture, or running everything on a cloud server.&lt;/p&gt;

&lt;p&gt;It was learning how different disciplines could come together to create one cohesive experience.&lt;/p&gt;

&lt;p&gt;Design taught me to care about what people see and feel.&lt;/p&gt;

&lt;p&gt;Engineering taught me to care about what happens underneath.&lt;/p&gt;

&lt;p&gt;And building this project gave me the opportunity to explore both.&lt;/p&gt;

&lt;p&gt;Would I make the same architectural decisions today? Probably not. I have learned enough to recognize where I could simplify things.&lt;/p&gt;

&lt;p&gt;But I am glad I went through the process.&lt;/p&gt;

&lt;p&gt;Because sometimes, a personal project doesn't need to become a business or a product to be worth building.&lt;/p&gt;

&lt;p&gt;Sometimes, it just needs to challenge you enough to become something you are proud of.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Beautiful on the surface. Engineered underneath.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Project archive
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Case Study:&lt;/strong&gt; &lt;a href="http://yunkhngn.dev/work/yunkhngn-microservice-platform" rel="noopener noreferrer"&gt;yunkhngn.dev/work/yunkhngn-microservice-platform&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="http://github.com/yunkhngn/legacy-yunkhngn-microservice-website" rel="noopener noreferrer"&gt;github.com/yunkhngn/legacy-yunkhngn-microservice-website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer:&lt;/strong&gt; &lt;a href="http://yunkhngn.dev" rel="noopener noreferrer"&gt;yunkhngn.dev&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Designed, engineered, and deployed independently by yunkhngn.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>engineering</category>
      <category>systemdesign</category>
      <category>microservices</category>
      <category>uiux</category>
    </item>
    <item>
      <title>Building Distributed Systems: From Monolith to Microservices</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 03:51:29 +0000</pubDate>
      <link>https://dev.to/yunkhngn/building-distributed-systems-from-monolith-to-microservices-ogm</link>
      <guid>https://dev.to/yunkhngn/building-distributed-systems-from-monolith-to-microservices-ogm</guid>
      <description>&lt;h2&gt;
  
  
  Why do we talk about distributed systems?
&lt;/h2&gt;

&lt;p&gt;In recent years, the shift from traditional Monolithic applications to Microservices is no longer just a trend; it has become the standard for many large-scale systems. However, the trade-off is clear: we exchange the simplicity of centralized development and deployment for high scalability and flexibility. When your system exceeds the capacity of a single server, you officially step into the world of distributed systems.&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%2Fok5nslymjbsnh84n0jf7.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%2Fok5nslymjbsnh84n0jf7.png" width="626" height="336"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Core challenges
&lt;/h2&gt;

&lt;p&gt;When working with distributed systems, the CAP theorem (Consistency, Availability, Partition Tolerance) always looms overhead. You can never achieve all three elements perfectly at the same time. In a distributed system, Partition Tolerance is mandatory. Therefore, practical choices usually lie with CP or AP.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Consistency vs Availability
&lt;/h3&gt;

&lt;p&gt;This is the hardest question: Do you accept the system returning stale data to ensure uptime, or pause processing while waiting for data to sync? For example, with a payment system, Consistency is the top priority (CP). But with a social media news feed, Availability is generally more important (AP).&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Service Discovery and Load Balancing
&lt;/h3&gt;

&lt;p&gt;In a Monolith architecture, components call each other via in-memory calls. With Microservices, they must communicate over a network (usually HTTP/gRPC). At this point, Service Discovery (such as Consul or Kubernetes Service) becomes essential. You need to know which service is alive, what its IP address is, and how to balance requests fairly.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Distributed Tracing
&lt;/h3&gt;

&lt;p&gt;This is a debugging nightmare. A user request may pass through 5-10 different services. If the system reports an error, how do you know where it lies? Without Distributed Tracing (such as Jaeger or Zipkin), tracing takes hours of checking logs for each service. You are forced to attach a Correlation ID to every request right at the Gateway and pass it throughout the entire system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data management strategy: Database per Service
&lt;/h2&gt;

&lt;p&gt;One of the most common mistakes is splitting code into services while still sharing a single Database. This leads to tight coupling at the database level, meaning that changing the schema of one service can break others.&lt;/p&gt;

&lt;p&gt;The correct philosophy is Database per Service. Each microservice owns its own data. But what is the next challenge? It is handling related data across services. How do you maintain data integrity when you cannot use &lt;code&gt;BEGIN TRANSACTION&lt;/code&gt; and &lt;code&gt;COMMIT&lt;/code&gt; across different services?&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%2Ficlp5ysq31pg1bgfw66i.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%2Ficlp5ysq31pg1bgfw66i.png" width="731" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Saga Pattern is a lifesaver
&lt;/h3&gt;

&lt;p&gt;Instead of Distributed Transactions (which are slow and hard to scale), we use the Saga Pattern. This is a sequence of local transactions. If a step fails, the system executes compensating transactions to undo previous steps, bringing the system back to a consistent state. It resembles a tightly coordinated workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you &lt;em&gt;not&lt;/em&gt; use Microservices yet?
&lt;/h2&gt;

&lt;p&gt;I often see engineering teams jump into Microservices too early. If your team is small, or your product lacks clear scaling requirements, a Modular Monolith is a much wiser choice.&lt;/p&gt;

&lt;p&gt;Microservices introduce infrastructure complexity. You will need a firm grasp of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docker and Kubernetes for container orchestration.&lt;/li&gt;
&lt;li&gt;Complex CI/CD pipelines to ensure seamless deployment.&lt;/li&gt;
&lt;li&gt;Large-scale Monitoring and Alerting (Prometheus/Grafana).&lt;/li&gt;
&lt;li&gt;Inter-service security (mTLS, API Gateways).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion: Don't complicate things unnecessarily
&lt;/h2&gt;

&lt;p&gt;Technology is merely a tool to solve business problems. Microservices architecture is a solution to a scale problem, not an end goal. Do not try to apply it just because it is cool. Start small, modularize your code, and when the pressure from actual scaling becomes heavy, consider gradually extracting components into independent services.&lt;/p&gt;

&lt;p&gt;Ultimately, whatever architecture you choose, the human factor and observability remain the most critical. A robust distributed system is not one that never fails, but one where when it does fail, you know precisely why and how long it takes to fix.&lt;/p&gt;

&lt;p&gt;I hope these insights help on your engineering journey. Leave your thoughts if you have a different experience with Microservices architecture!&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>distributedsystems</category>
      <category>architecture</category>
      <category>backend</category>
    </item>
    <item>
      <title>Engineering Lawise: Building an AI-Powered LegalTech Platform</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 03:49:23 +0000</pubDate>
      <link>https://dev.to/yunkhngn/engineering-lawise-building-an-ai-powered-legaltech-platform-3bfc</link>
      <guid>https://dev.to/yunkhngn/engineering-lawise-building-an-ai-powered-legaltech-platform-3bfc</guid>
      <description>&lt;h2&gt;
  
  
  01. Introduction
&lt;/h2&gt;

&lt;p&gt;Building an AI-powered product is not simply about connecting an application to an LLM API.&lt;/p&gt;

&lt;p&gt;The real engineering challenge lies in transforming complex domain knowledge into reliable, accessible, and actionable intelligence.&lt;/p&gt;

&lt;p&gt;Lawise is a LegalTech platform designed to make legal knowledge more accessible and simplify contract-related workflows through artificial intelligence.&lt;/p&gt;

&lt;p&gt;The platform focuses on three primary capabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AI Contract Review:&lt;/strong&gt; Analyzing contracts, identifying potentially risky clauses, explaining legal implications, and suggesting improvements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Legal Assistant:&lt;/strong&gt; Helping users navigate Vietnamese legal information through natural-language interactions and legal references.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI Contract Generation:&lt;/strong&gt; Assisting users in creating structured contracts based on their requirements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The project explores an interesting intersection of software engineering, artificial intelligence, information retrieval, and domain-specific product design.&lt;/p&gt;

&lt;p&gt;Rather than approaching Lawise as another AI chatbot, I approached it as an engineering challenge: building a system that connects legal knowledge, intelligent processing, and a practical user experience.&lt;/p&gt;

&lt;p&gt;This article explores the architecture, technical decisions, and engineering considerations behind building Lawise.&lt;/p&gt;

&lt;h2&gt;
  
  
  02. Understanding the Product
&lt;/h2&gt;

&lt;p&gt;Before discussing the architecture, it is important to understand the problems Lawise is designed to solve.&lt;/p&gt;

&lt;p&gt;Legal documents are inherently complex. Contracts often contain lengthy provisions, interconnected clauses, formal terminology, and legal references that require contextual understanding.&lt;/p&gt;

&lt;p&gt;For individuals and small businesses, reviewing these documents can become a time-consuming process.&lt;/p&gt;

&lt;p&gt;Some common challenges include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identifying potentially unfavorable contractual terms.&lt;/li&gt;
&lt;li&gt;Understanding legal terminology and implications.&lt;/li&gt;
&lt;li&gt;Finding relevant legal provisions.&lt;/li&gt;
&lt;li&gt;Comparing contractual clauses against applicable regulations.&lt;/li&gt;
&lt;li&gt;Drafting and revising documents without introducing inconsistencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lawise aims to reduce this friction by combining AI capabilities with legal-domain workflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Core Product Experience
&lt;/h3&gt;

&lt;p&gt;The distinction between these capabilities is important.&lt;/p&gt;

&lt;p&gt;A legal assistant primarily helps users explore and understand legal information. Contract review, on the other hand, requires working with an existing document, identifying specific clauses, and presenting actionable findings.&lt;/p&gt;

&lt;p&gt;These are different problems and require different processing workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  03. System Architecture
&lt;/h2&gt;

&lt;p&gt;One of the most important decisions in building Lawise was adopting a distributed backend architecture.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Next.js&lt;/strong&gt; for the frontend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Polyglot Microservices&lt;/strong&gt; for backend services implemented in multiple programming languages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PostgreSQL&lt;/strong&gt; as the primary relational database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pgvector&lt;/strong&gt; for vector storage and similarity search.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI&lt;/strong&gt; for language-model capabilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The architecture separates the presentation layer, application services, data persistence, and AI integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  High-Level Architecture
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;High-level architecture illustrating the major technology layers.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    USER["Users"]
    WEB["Next.js Frontend"]

    subgraph BACKEND["Polyglot Microservices"]
        API["Application APIs"]
        CONTRACT["Contract Workflows"]
        LEGAL["Legal Intelligence"]
        AI["AI Integration"]
    end

    subgraph DATA["Data Layer"]
        DB[("PostgreSQL")]
        VECTOR[("pgvector")]
    end

    LLM["OpenAI API"]

    USER --&amp;gt; WEB
    WEB --&amp;gt; API

    API --&amp;gt; CONTRACT
    API --&amp;gt; LEGAL

    CONTRACT --&amp;gt; AI
    LEGAL --&amp;gt; AI

    CONTRACT --&amp;gt; DB
    LEGAL --&amp;gt; DB
    LEGAL --&amp;gt; VECTOR

    AI --&amp;gt; LLM&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Conceptual architecture diagram. Individual service boundaries and communication paths should be aligned with the deployed implementation.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Polyglot Microservices?
&lt;/h3&gt;

&lt;p&gt;Instead of concentrating all backend responsibilities into a single application, Lawise adopts a multi-language microservices approach.&lt;/p&gt;

&lt;p&gt;This architectural direction provides flexibility when different backend capabilities have different technical requirements.&lt;/p&gt;

&lt;p&gt;It also encourages clearer separation of responsibilities.&lt;/p&gt;

&lt;p&gt;However, microservices introduce additional engineering complexity.&lt;/p&gt;

&lt;p&gt;Each service needs well-defined interfaces, communication contracts, error-handling strategies, and clear ownership of its responsibilities.&lt;/p&gt;

&lt;p&gt;The important lesson is that service separation should solve an actual architectural problem rather than introduce unnecessary infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  04. Building the Data Layer: PostgreSQL and pgvector
&lt;/h2&gt;

&lt;p&gt;AI-powered legal applications need to work with different types of information.&lt;/p&gt;

&lt;p&gt;Some information is structured:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User accounts.&lt;/li&gt;
&lt;li&gt;Contracts and document metadata.&lt;/li&gt;
&lt;li&gt;Application records.&lt;/li&gt;
&lt;li&gt;Business-related entities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other information is semantic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Legal provisions.&lt;/li&gt;
&lt;li&gt;Regulatory content.&lt;/li&gt;
&lt;li&gt;Contextual relationships between legal concepts.&lt;/li&gt;
&lt;li&gt;Textual information used during AI-assisted retrieval.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PostgreSQL provides the relational foundation, while pgvector extends that foundation with vector storage and similarity search.&lt;/p&gt;

&lt;h3&gt;
  
  
  From Text to Vector Representations
&lt;/h3&gt;

&lt;p&gt;The general vector retrieval process consists of several steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extract textual content from legal documents.&lt;/li&gt;
&lt;li&gt;Normalize and prepare the text.&lt;/li&gt;
&lt;li&gt;Divide content into meaningful segments.&lt;/li&gt;
&lt;li&gt;Generate vector embeddings.&lt;/li&gt;
&lt;li&gt;Store embeddings alongside relevant document metadata.&lt;/li&gt;
&lt;li&gt;Retrieve semantically similar content when processing a query.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simplified representation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Legal Documents
      |
      v
Text Extraction
      |
      v
Text Processing
      |
      v
Document Chunking
      |
      v
Embedding Generation
      |
      v
PostgreSQL + pgvector
      |
      v
Semantic Retrieval
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why pgvector?
&lt;/h3&gt;

&lt;p&gt;Choosing pgvector allows vector representations to coexist within the PostgreSQL ecosystem.&lt;/p&gt;

&lt;p&gt;This provides several architectural advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduced infrastructure fragmentation.&lt;/li&gt;
&lt;li&gt;Relational data and vector data can be managed together.&lt;/li&gt;
&lt;li&gt;SQL-based data management.&lt;/li&gt;
&lt;li&gt;Support for vector similarity operations.&lt;/li&gt;
&lt;li&gt;A unified database environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, vector similarity alone does not guarantee legal relevance.&lt;/p&gt;

&lt;p&gt;Two passages may be semantically similar while having different legal meanings or applicability.&lt;/p&gt;

&lt;p&gt;For legal applications, retrieval quality must be evaluated in the context of the actual legal question.&lt;/p&gt;

&lt;h2&gt;
  
  
  05. AI Engineering: Integrating OpenAI
&lt;/h2&gt;

&lt;p&gt;The AI layer is one of the most interesting parts of Lawise.&lt;/p&gt;

&lt;p&gt;Large language models provide powerful language-understanding and generation capabilities, but their outputs are not inherently reliable.&lt;/p&gt;

&lt;p&gt;This is especially important in legal applications.&lt;/p&gt;

&lt;p&gt;A fluent answer is not necessarily a correct answer. A convincing explanation does not automatically establish legal validity.&lt;/p&gt;

&lt;p&gt;Therefore, the engineering challenge is not simply generating responses. It is building workflows that provide useful information while preserving context and making limitations clear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Retrieval-Augmented Generation
&lt;/h3&gt;

&lt;p&gt;A retrieval-oriented architecture can help ground model responses in relevant legal information.&lt;/p&gt;

&lt;p&gt;A typical RAG workflow looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    Q["User Question"]
    E["Query Embedding"]
    R["Vector Retrieval"]
    C["Relevant Legal Context"]
    P["Prompt Construction"]
    L["OpenAI"]
    A["Generated Response"]
    U["User"]

    Q --&amp;gt; E
    E --&amp;gt; R
    R --&amp;gt; C
    C --&amp;gt; P
    P --&amp;gt; L
    L --&amp;gt; A
    A --&amp;gt; U&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The general idea is to retrieve relevant information before asking the language model to generate a response.&lt;/p&gt;

&lt;p&gt;This changes the role of the LLM.&lt;/p&gt;

&lt;p&gt;Instead of relying exclusively on its internal knowledge, the model can work with additional contextual information supplied by the application.&lt;/p&gt;

&lt;p&gt;For a legal assistant, this approach is particularly valuable because users often need explanations grounded in specific legal provisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Importance of Context
&lt;/h3&gt;

&lt;p&gt;Legal interpretation depends heavily on context.&lt;/p&gt;

&lt;p&gt;A clause cannot always be evaluated independently from the rest of a contract or the applicable legal framework.&lt;/p&gt;

&lt;p&gt;This creates several engineering considerations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retrieval relevance.&lt;/li&gt;
&lt;li&gt;Context selection.&lt;/li&gt;
&lt;li&gt;Token limitations.&lt;/li&gt;
&lt;li&gt;Prompt construction.&lt;/li&gt;
&lt;li&gt;Source traceability.&lt;/li&gt;
&lt;li&gt;Handling incomplete or conflicting information.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The objective is not to make the model appear more confident.&lt;/p&gt;

&lt;p&gt;It is to make its responses more useful, understandable, and appropriately grounded.&lt;/p&gt;

&lt;h2&gt;
  
  
  06. AI Contract Review: From Documents to Actionable Insights
&lt;/h2&gt;

&lt;p&gt;Contract review is a particularly interesting workflow because it requires more than natural-language generation.&lt;/p&gt;

&lt;p&gt;The system needs to process document content, understand individual provisions, identify potential issues, and communicate findings in a format users can act upon.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Review Workflow
&lt;/h3&gt;

&lt;p&gt;A conceptual contract review pipeline can be represented as follows:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Contract Upload"]
    B["Document Content Extraction"]
    C["Content Preparation"]
    D["Clause Analysis"]
    E["AI-Assisted Evaluation"]
    F["Risk Identification"]
    G["Explanation &amp;amp; Recommendations"]
    H["User Review"]

    A --&amp;gt; B
    B --&amp;gt; C
    C --&amp;gt; D
    D --&amp;gt; E
    E --&amp;gt; F
    F --&amp;gt; G
    G --&amp;gt; H&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The workflow highlights an important distinction between analyzing a document and generating a response.&lt;/p&gt;

&lt;p&gt;A useful contract review experience should make findings understandable and actionable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Risk Identification
&lt;/h3&gt;

&lt;p&gt;Rather than returning an unrestricted block of text, a contract review interface benefits from presenting findings in a structured manner.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The relevant contractual provision.&lt;/li&gt;
&lt;li&gt;The identified concern.&lt;/li&gt;
&lt;li&gt;An explanation of why it may be problematic.&lt;/li&gt;
&lt;li&gt;Relevant legal context.&lt;/li&gt;
&lt;li&gt;A suggested improvement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure helps users understand not only what the system has identified, but also why the finding matters.&lt;/p&gt;

&lt;p&gt;It also makes the output easier to review and evaluate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Structured Outputs Matter
&lt;/h3&gt;

&lt;p&gt;AI-generated content is difficult to integrate into complex document workflows when everything is returned as plain text.&lt;/p&gt;

&lt;p&gt;Structured outputs create a more predictable interface between AI processing and application logic.&lt;/p&gt;

&lt;p&gt;For example, a conceptual representation of a review finding could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"clause"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Penalty for breach of contract"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"risk_level"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"high"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"issue"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Potentially unfavorable penalty provision"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"explanation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Requires further legal evaluation."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"recommendation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Review the penalty provision against applicable regulations."&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an illustrative data structure, not a representation of the production API schema.&lt;/p&gt;

&lt;p&gt;The broader principle is that AI should produce information that the application can organize, display, and process consistently.&lt;/p&gt;

&lt;h2&gt;
  
  
  07. Frontend Engineering: Turning AI Capabilities into a Product
&lt;/h2&gt;

&lt;p&gt;An AI system can be technically sophisticated and still fail as a product if users cannot understand or interact with its outputs.&lt;/p&gt;

&lt;p&gt;This is particularly relevant to LegalTech.&lt;/p&gt;

&lt;p&gt;The target audience may include individuals and business owners who do not have extensive legal knowledge.&lt;/p&gt;

&lt;p&gt;The frontend therefore plays an important role in translating technical capabilities into understandable workflows.&lt;/p&gt;

&lt;p&gt;Using Next.js provides the foundation for building the web application and organizing the user-facing experience.&lt;/p&gt;

&lt;p&gt;Some important product considerations include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Making complex legal information easier to navigate.&lt;/li&gt;
&lt;li&gt;Presenting AI findings in a structured format.&lt;/li&gt;
&lt;li&gt;Distinguishing risk levels visually.&lt;/li&gt;
&lt;li&gt;Keeping contract-related workflows understandable.&lt;/li&gt;
&lt;li&gt;Providing clear feedback during AI processing.&lt;/li&gt;
&lt;li&gt;Making generated suggestions easy to review.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to make the technology feel approachable without oversimplifying the underlying legal complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  08. Engineering Challenges and Trade-offs
&lt;/h2&gt;

&lt;p&gt;Building Lawise involves several architectural and technical trade-offs.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.1. AI Reliability vs. Model Flexibility
&lt;/h3&gt;

&lt;p&gt;LLMs are flexible, but legal workflows require consistency.&lt;/p&gt;

&lt;p&gt;A system must account for incomplete context, unsupported conclusions, and potentially misleading generated content.&lt;/p&gt;

&lt;p&gt;The application should communicate uncertainty appropriately and avoid presenting AI-generated information as definitive legal advice.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.2. Microservices vs. Operational Complexity
&lt;/h3&gt;

&lt;p&gt;Polyglot microservices provide flexibility and separation of responsibilities.&lt;/p&gt;

&lt;p&gt;However, they also introduce:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More deployment units.&lt;/li&gt;
&lt;li&gt;Distributed debugging.&lt;/li&gt;
&lt;li&gt;Network communication overhead.&lt;/li&gt;
&lt;li&gt;Service availability dependencies.&lt;/li&gt;
&lt;li&gt;More complex observability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The architectural benefits must justify the additional operational cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.3. Semantic Retrieval vs. Legal Precision
&lt;/h3&gt;

&lt;p&gt;Vector search is useful for discovering semantically related content.&lt;/p&gt;

&lt;p&gt;However, legal correctness depends on more than textual similarity.&lt;/p&gt;

&lt;p&gt;The challenge is to ensure that retrieved information is relevant to the actual legal context, not simply close in embedding space.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.4. AI Cost and Latency
&lt;/h3&gt;

&lt;p&gt;AI-powered workflows can involve multiple processing stages.&lt;/p&gt;

&lt;p&gt;Document analysis and retrieval-heavy workflows can increase token consumption and response latency.&lt;/p&gt;

&lt;p&gt;Some important optimization directions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoiding unnecessary model calls.&lt;/li&gt;
&lt;li&gt;Retrieving only relevant context.&lt;/li&gt;
&lt;li&gt;Controlling prompt size.&lt;/li&gt;
&lt;li&gt;Selecting models based on task complexity.&lt;/li&gt;
&lt;li&gt;Reusing suitable intermediate results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These considerations become increasingly important as an AI application moves beyond experimentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  09. Technology Stack
&lt;/h2&gt;

&lt;p&gt;LayerTechnologyPurposeFrontendNext.jsWeb application and user experienceBackendPolyglot MicroservicesDistributed application servicesPrimary DatabasePostgreSQLRelational data persistenceVector SearchpgvectorVector storage and similarity searchAI ProviderOpenAILanguage-model capabilities&lt;/p&gt;

&lt;p&gt;The technology choices reflect an architectural approach that separates application responsibilities while keeping the data and AI layers integrated into the overall product.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Working on Lawise reinforced several important lessons about building AI-powered software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI is only one component of an AI product.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The quality of the overall system depends on much more than the model itself. Data organization, retrieval, backend architecture, and user experience all contribute to the final result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architecture should reflect the problem domain.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Contract review and legal assistance are related capabilities, but they solve different problems. Treating their workflows as distinct concerns creates opportunities for clearer system design.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vector search is not a replacement for domain understanding.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Similarity search helps locate potentially relevant information, but relevance is not equivalent to legal correctness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microservices introduce both flexibility and responsibility.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Distributed architecture creates opportunities for independent development, but it also requires discipline around interfaces, observability, and service boundaries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A useful AI product needs to be designed around its users.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most impressive model output is not necessarily the most useful one. What matters is whether users can understand the result, evaluate it, and take appropriate action.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Conclusion
&lt;/h2&gt;

&lt;p&gt;Lawise represents my exploration of building software at the intersection of artificial intelligence, information retrieval, and domain-specific applications.&lt;/p&gt;

&lt;p&gt;The project challenged me to think beyond implementing individual features and consider how different engineering layers work together to deliver a coherent product.&lt;/p&gt;

&lt;p&gt;From a Next.js frontend and polyglot microservices backend to PostgreSQL, pgvector, and OpenAI integration, the architecture reflects an attempt to balance flexibility, maintainability, and practical AI capabilities.&lt;/p&gt;

&lt;p&gt;More importantly, it reinforced a principle I find increasingly important in software engineering:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Building an AI-powered product is not about making an application that can talk. It is about engineering a system that can turn information into something genuinely useful.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project:&lt;/strong&gt; Lawise*&lt;em&gt;Website:&lt;/em&gt;* &lt;a href="https://lawisevn.com/" rel="noopener noreferrer"&gt;https://lawisevn.com/&lt;/a&gt;&lt;strong&gt;Domain:&lt;/strong&gt; LegalTech · AI Engineering · Backend Architecture · Information Retrieval*&lt;em&gt;Core Technologies:&lt;/em&gt;* Next.js · Polyglot Microservices · PostgreSQL · pgvector · OpenAI&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lawise — AI-powered legal assistance and contract review for the Vietnamese market.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>lawise</category>
      <category>legaltech</category>
      <category>llm</category>
      <category>engineering</category>
    </item>
    <item>
      <title>Optimizing a blog system by leveraging free tier infrastructure</title>
      <dc:creator>Khoa Nguyen</dc:creator>
      <pubDate>Fri, 04 Dec 2026 03:43:44 +0000</pubDate>
      <link>https://dev.to/yunkhngn/optimizing-a-blog-system-by-leveraging-free-tier-infrastructure-11a9</link>
      <guid>https://dev.to/yunkhngn/optimizing-a-blog-system-by-leveraging-free-tier-infrastructure-11a9</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Running a personal system on free or hobby tiers offers significant cost savings, but it also pushes engineers into strict resource limitation challenges. The tech stack includes Next.js deployed on Vercel Hobby, a NestJS backend on Render Hobby, MongoDB Atlas M0 database, and Upstash Redis combined with BullMQ for background tasks.&lt;/p&gt;

&lt;p&gt;Everything ran smoothly until the system started experiencing modest growth and free-tier quotas were reached. This article dives into the causes and solutions for each specific bottleneck.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Vercel ISR and the Write Units nightmare
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Cause
&lt;/h3&gt;

&lt;p&gt;The Next.js system is currently using Incremental Static Regeneration (ISR) with SSR. But the misuse of the &lt;code&gt;cookies()&lt;/code&gt; function on pages that appear to be public effectively turns these requests into dynamic renders, forcing Vercel to perform constant recalculations.&lt;br&gt;
Additionally, the habit of releasing code multiple times a day along with caching bloated objects due to directly embedding base64 data pushed Write Units to a peak of about 32,000 requests per day, exceeding the allowed Vercel Hobby limit.&lt;/p&gt;
&lt;h3&gt;
  
  
  Solutions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Move public routes entirely to Static or standard ISR instead of relying on &lt;code&gt;cookies()&lt;/code&gt; at the render layer.&lt;/li&gt;
&lt;li&gt;Use a CSS auth toggle pattern: render the static UI on the server, then use client-side fetching combined with tokens stored in localStorage to show or hide components reserved for logged-in users.&lt;/li&gt;
&lt;li&gt;Separate heavy files like &lt;code&gt;.gp&lt;/code&gt; and &lt;code&gt;.pdf&lt;/code&gt; format documents from the main payload, store them directly on AWS S3, and return only the file path along with slim projection optimization from MongoDB.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Problem 2: BullMQ and Upstash Redis burning through the 500k commands quota
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Cause
&lt;/h3&gt;

&lt;p&gt;BullMQ defaults to continuous polling mechanisms in Redis to check for new jobs. With default configurations, workers maintain connections and constantly send commands even in an idle state.&lt;/p&gt;

&lt;p&gt;As a result, the free limit of 500,000 commands on Upstash Redis was depleted in a short time, causing a series of background processing pipelines to grind to a halt.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    A["NestJS Worker"] --&amp;gt;|"Polling 24/7 (Default)"| B["Upstash Redis"]
    B --&amp;gt;|"Reach 500k commands"| C["Rate Limit Exceeded"]
    C --&amp;gt; D["System Crash"]&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Solutions
&lt;/h3&gt;

&lt;p&gt;Optimize BullMQ connection configurations by fine-tuning polling time parameters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increase &lt;code&gt;drainDelay&lt;/code&gt; and &lt;code&gt;stalledInterval&lt;/code&gt; to reduce the frequency of workers pinging Redis when the queue is empty.&lt;/li&gt;
&lt;li&gt;Apply an exponential backoff strategy for retrying jobs to avoid bombarding the system with failed requests.&lt;/li&gt;
&lt;li&gt;Build a temporary in-memory fallback mechanism so the system does not crash completely when Redis hits its limits.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;queue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Queue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'pet-tasks'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;redisConnection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;defaultJobOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;backoff&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'exponential'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;drainDelay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;stalledInterval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&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;h2&gt;
  
  
  Optimization checklist for Free/Hobby Tier
&lt;/h2&gt;

&lt;p&gt;Distilled from practical experience, here is a quick checklist to help maintain a stable system without spending money:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Review all usage of &lt;code&gt;cookies()&lt;/code&gt; and &lt;code&gt;headers()&lt;/code&gt; in Next.js to avoid accidentally forcing static pages to become dynamic.&lt;/li&gt;
&lt;li&gt;Avoid embedding heavy base64 strings into state or cache; push large files to object storage like S3.&lt;/li&gt;
&lt;li&gt;Reconfigure &lt;code&gt;drainDelay&lt;/code&gt; for BullMQ workers to save Redis commands during idle time.&lt;/li&gt;
&lt;li&gt;Set up alerts close to quota limits for Vercel, Render, and Upstash to address issues early before the system goes down.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Running a system on free/hobby tiers requires great care in architectural design and resource management. By refining the Next.js caching strategy and optimizing the BullMQ polling lifecycle, the cat-raising management system is running smoothly again [add result].&lt;/p&gt;

</description>
      <category>infrastructure</category>
      <category>web</category>
      <category>architecture</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
