<?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: Ameni Ben Saada</title>
    <description>The latest articles on DEV Community by Ameni Ben Saada (@amenibensaada).</description>
    <link>https://dev.to/amenibensaada</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%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png</url>
      <title>DEV Community: Ameni Ben Saada</title>
      <link>https://dev.to/amenibensaada</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amenibensaada"/>
    <language>en</language>
    <item>
      <title>Why did my Kubernetes change disappear? Argo CD Self-heal explained</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Mon, 23 Nov 2026 07:00:00 +0000</pubDate>
      <link>https://dev.to/amenibensaada/why-did-my-kubernetes-change-disappear-argo-cd-self-heal-explained-2db8</link>
      <guid>https://dev.to/amenibensaada/why-did-my-kubernetes-change-disappear-argo-cd-self-heal-explained-2db8</guid>
      <description>&lt;p&gt;You scale a Deployment directly in Kubernetes. Later, it returns to the replica count stored in Git.&lt;/p&gt;

&lt;p&gt;Before treating that as a failed command, check the Argo CD Application's sync policy. Self-heal may be restoring the desired configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  One setting, two different values
&lt;/h2&gt;

&lt;p&gt;Consider one Argo CD-managed Deployment named &lt;code&gt;demo-app&lt;/code&gt; in a disposable namespace named &lt;code&gt;gitops-demo&lt;/code&gt;. No autoscaler or other controller manages its replica count, and &lt;code&gt;/spec/replicas&lt;/code&gt; is included in Argo CD's comparison and synchronization.&lt;/p&gt;

&lt;p&gt;Git contains this fragment of the Deployment manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Deployment manifest fragment; not a complete manifest.
&lt;/span&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Someone changes the live Deployment to four replicas. Git still requests two. Kubernetes supports this kind of direct scaling through &lt;code&gt;kubectl scale&lt;/code&gt;; it changes the live resource rather than your source file. &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#scaling-a-deployment" rel="noopener noreferrer"&gt;Deployment scaling&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Location&lt;/th&gt;
&lt;th&gt;Replica setting&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Desired configuration in Git&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Live Deployment configuration&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Argo CD compares desired configuration with live resources. Here, the tracked difference is live drift. &lt;code&gt;OutOfSync&lt;/code&gt; identifies a mismatch; it doesn't tell you whether the manual change was useful, mistaken, or temporary. &lt;a href="https://argo-cd.readthedocs.io/en/stable/core_concepts/" rel="noopener noreferrer"&gt;Core concepts&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Self-heal adds
&lt;/h2&gt;

&lt;p&gt;Automated sync can apply changes from the tracked source without someone starting a manual sync. Self-heal enables automated synchronization in response to live-state deviations when that source hasn't changed.&lt;/p&gt;

&lt;p&gt;For this example, the Application policy fragment is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Argo CD Application fragment; not a Deployment setting.
&lt;/span&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;syncPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;automated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;enabled&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;selfHeal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that policy active, Argo CD can attempt to restore the Deployment's replica setting to two. This describes a configuration change, not a promise that the application becomes ready immediately.&lt;/p&gt;

&lt;p&gt;Self-heal does not write the manual value of four back to Git. See the &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync/" rel="noopener noreferrer"&gt;automated sync policy&lt;/a&gt; for the exact behavior and settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it in a disposable environment
&lt;/h2&gt;

&lt;p&gt;Use an existing demo Application named &lt;code&gt;demo-app&lt;/code&gt; that manages this Deployment. The commands below change cluster state; confirm your context and namespace first. Do not run them against a production workload.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Confirm the destination before changing anything.&lt;/span&gt;
kubectl config current-context
kubectl -n gitops-demo get deployment demo-app

&lt;span class="c"&gt;# Deliberately introduce drift in the demo environment.&lt;/span&gt;
kubectl -n gitops-demo scale deployment/demo-app --replicas=4

&lt;span class="c"&gt;# Inspect Argo CD's comparison and the Deployment setting.&lt;/span&gt;
argocd app get demo-app --refresh
argocd app diff demo-app
kubectl -n gitops-demo get deployment demo-app --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If reconciliation happens quickly, you may miss the temporary four-replica setting. Observe the Application's operation history as well. The diff command exits with code &lt;code&gt;1&lt;/code&gt; when differences exist, so a script should handle that result deliberately. &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_app_diff/" rel="noopener noreferrer"&gt;Diff command reference&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Make an intentional change durable
&lt;/h2&gt;

&lt;p&gt;If four replicas is the intended lasting configuration, change &lt;code&gt;spec.replicas&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt; in the source manifest, review it, and commit it to the revision Argo CD tracks. Then synchronize through your configured workflow.&lt;/p&gt;

&lt;p&gt;Now the desired setting itself is four. The deployment configuration carries the decision, instead of depending on an unrecorded live edit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check who owns the field
&lt;/h2&gt;

&lt;p&gt;An autoscaler may legitimately manage replicas. Don't apply this example unchanged to that situation. Argo CD supports comparison customization for fields owned elsewhere. Ignoring a field during comparison and omitting it during synchronization are distinct configuration choices; &lt;code&gt;RespectIgnoreDifferences&lt;/code&gt; affects the latter. &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/diffing/" rel="noopener noreferrer"&gt;Diff customization&lt;/a&gt;, &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#respect-ignore-differences-configs" rel="noopener noreferrer"&gt;sync options&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For urgent live edits, agree on the exception workflow before an incident. Record what changed, decide whether Git should adopt it, and restore the intended automation afterward.&lt;/p&gt;

&lt;p&gt;How does your team keep emergency cluster edits and Git aligned?&lt;/p&gt;




&lt;p&gt;I'm Ameni Ben Saada, a software engineer working across full-stack development and cloud delivery. My work: &lt;a href="https://amenibensaada.tn/" rel="noopener noreferrer"&gt;amenibensaada.tn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>argocd</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>gitops</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Fri, 13 Nov 2026 10:41:46 +0000</pubDate>
      <link>https://dev.to/amenibensaada/-175n</link>
      <guid>https://dev.to/amenibensaada/-175n</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n" class="crayons-story__hidden-navigation-link"&gt;A successful build is not a deployment: Argo CD from Git to live&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/amenibensaada" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png" alt="amenibensaada profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/amenibensaada" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Ameni Ben Saada
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Ameni Ben Saada
                
                
              
              &lt;div id="story-author-preview-content-5028886" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/amenibensaada" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Ameni Ben Saada&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 13&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n" id="article-link-5028886"&gt;
          A successful build is not a deployment: Argo CD from Git to live
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/argocd"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;argocd&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/gitops"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;gitops&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/kubernetes"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;kubernetes&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/devops"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;devops&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              1&lt;span class="hidden s:inline"&gt;&amp;nbsp;comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;/div&gt;


</description>
    </item>
    <item>
      <title>A successful build is not a deployment: Argo CD from Git to live</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Fri, 13 Nov 2026 09:42:06 +0000</pubDate>
      <link>https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n</link>
      <guid>https://dev.to/amenibensaada/a-successful-build-is-not-a-deployment-argo-cd-from-git-to-live-3o1n</guid>
      <description>&lt;p&gt;A successful build doesn't mean your new version is live.&lt;/p&gt;

&lt;p&gt;Suppose Git requests &lt;code&gt;v2&lt;/code&gt;, while the live Kubernetes Deployment still references &lt;code&gt;v1&lt;/code&gt;. The new image might already be in the registry, but the cluster configuration has not caught up.&lt;/p&gt;

&lt;p&gt;This is a useful way to understand Argo CD: follow one configuration change from Git to the cluster, then check what that change actually achieved.&lt;/p&gt;

&lt;p&gt;The example below is illustrative. The image names are placeholders, and the diff is not a complete Kubernetes manifest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate the responsibilities
&lt;/h2&gt;

&lt;p&gt;For this container-based example, the delivery workflow has three distinct parts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;th&gt;What happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CI&lt;/td&gt;
&lt;td&gt;Test the application, build a container image and publish it to a registry.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Git&lt;/td&gt;
&lt;td&gt;Store the deployment configuration that references the intended image version.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Argo CD&lt;/td&gt;
&lt;td&gt;Compare desired configuration with live resources and synchronize changes.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Kubernetes controllers then carry out the rollout after the resource configuration changes. Argo CD does not build the container image.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/ci_automation/" rel="noopener noreferrer"&gt;official CI integration guide&lt;/a&gt; describes this separation between publishing an image, updating manifests in Git and synchronizing the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the difference visible
&lt;/h2&gt;

&lt;p&gt;Imagine the image-reference change looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;- image: registry.example.com/demo-app:v1&lt;/span&gt;
&lt;span class="gi"&gt;+ image: registry.example.com/demo-app:v2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line represents the live configuration. The second represents the desired configuration in Git.&lt;/p&gt;

&lt;p&gt;Argo CD compares the application resources against the desired state from its configured source. If the tracked configuration differs, the application can be reported as &lt;code&gt;OutOfSync&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That is a comparison result. It does not, by itself, tell you whether the difference is an intended release, an unexpected manual edit or an application-health problem. The &lt;a href="https://argo-cd.readthedocs.io/en/stable/core_concepts/" rel="noopener noreferrer"&gt;core concepts&lt;/a&gt; distinguish target state, live state, sync status and health.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review, then synchronize
&lt;/h2&gt;

&lt;p&gt;For this walkthrough, use a manual sync so the change can be inspected before it is applied.&lt;/p&gt;

&lt;p&gt;Review the target application, destination, revision and resource diff. Check that the image reference and any accompanying changes are the ones you intend to release.&lt;/p&gt;

&lt;p&gt;For an existing Argo CD Application named &lt;code&gt;demo-app&lt;/code&gt;, with the CLI authenticated to the intended Argo CD instance, the basic commands are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Inspect the application and its status&lt;/span&gt;
argocd app get demo-app

&lt;span class="c"&gt;# Review the difference&lt;/span&gt;
argocd app diff demo-app

&lt;span class="c"&gt;# Apply the desired configuration when ready&lt;/span&gt;
argocd app sync demo-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;demo-app&lt;/code&gt; with your actual Application name. The diff command returns exit code &lt;code&gt;1&lt;/code&gt; when it finds differences, so account for that if you use it in scripts.&lt;/p&gt;

&lt;p&gt;References: &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_app_get/" rel="noopener noreferrer"&gt;&lt;code&gt;app get&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_app_diff/" rel="noopener noreferrer"&gt;&lt;code&gt;app diff&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/commands/argocd_app_sync/" rel="noopener noreferrer"&gt;&lt;code&gt;app sync&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Synced answers one question
&lt;/h2&gt;

&lt;p&gt;After synchronization, the live image reference can match the desired reference in Git.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Synced&lt;/code&gt; means Argo CD sees no differences in the configuration it tracks. It does not prove that the application is ready to serve users.&lt;/p&gt;

&lt;p&gt;Resource health is a separate assessment. For example, a Deployment's updated resource configuration and the readiness of its rollout are different things. See the &lt;a href="https://argo-cd.readthedocs.io/en/stable/operator-manual/health/" rel="noopener noreferrer"&gt;resource-health documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Before calling a release complete, I check both configuration and application behaviour:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is the expected revision and image reference applied?&lt;/li&gt;
&lt;li&gt;Are the relevant resources healthy and the rollout ready?&lt;/li&gt;
&lt;li&gt;Does the user-facing path work, including the dependencies it needs?&lt;/li&gt;
&lt;li&gt;Do logs and monitoring show errors after the change?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The exact checks depend on the application. A green sync status only answers the configuration part.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where automated sync fits
&lt;/h2&gt;

&lt;p&gt;Manual sync is a policy choice for this example. Argo CD can also synchronize automatically when configured to do so.&lt;/p&gt;

&lt;p&gt;Automatic self-healing is a separate setting for responding to live-state deviations. Avoid assuming that every direct cluster edit will automatically be reverted. The behaviour depends on the configured policy; the &lt;a href="https://argo-cd.readthedocs.io/en/stable/user-guide/auto_sync/" rel="noopener noreferrer"&gt;automated sync guide&lt;/a&gt; covers those options.&lt;/p&gt;

&lt;p&gt;Automation changes when synchronization starts. It does not remove the need to verify the rollout and application behaviour.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;Keep the sequence easy to explain: build the image, declare the desired configuration, review the difference, synchronize and verify.&lt;/p&gt;

&lt;p&gt;What do you check before calling a deployment complete?&lt;/p&gt;




&lt;p&gt;I'm Ameni Ben Saada, a software engineer working across full-stack development and cloud delivery. More about my work: &lt;a href="https://amenibensaada.tn/" rel="noopener noreferrer"&gt;amenibensaada.tn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>argocd</category>
      <category>gitops</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Mon, 15 Jun 2026 11:31:40 +0000</pubDate>
      <link>https://dev.to/amenibensaada/-45nb</link>
      <guid>https://dev.to/amenibensaada/-45nb</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2" class="crayons-story__hidden-navigation-link"&gt;Tracing Requests Across NestJS Services with Correlation IDs&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/amenibensaada" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png" alt="amenibensaada profile" class="crayons-avatar__image" width="500" height="500"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/amenibensaada" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Ameni Ben Saada
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Ameni Ben Saada
                
                
              
              &lt;div id="story-author-preview-content-3170952" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/amenibensaada" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png" class="crayons-avatar__image" alt="" width="500" height="500"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Ameni Ben Saada&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jan 14&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2" id="article-link-3170952"&gt;
          Tracing Requests Across NestJS Services with Correlation IDs
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/nestjs"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;nestjs&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/microservices"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;microservices&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/devops"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;devops&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/logging"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;logging&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/raised-hands-74b2099fd66a39f2d7eed9305ee0f4553df0eb7b4f11b01b6b1b499973048fe5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;6&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            6 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;/div&gt;


</description>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Mon, 15 Jun 2026 09:09:57 +0000</pubDate>
      <link>https://dev.to/amenibensaada/-5703</link>
      <guid>https://dev.to/amenibensaada/-5703</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc" class="crayons-story__hidden-navigation-link"&gt;Docker Compose vs Kubernetes: Which One Do You Actually Need?&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/amenibensaada" class="crayons-avatar  crayons-avatar--l  "&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%2Fuser%2Fprofile_image%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png" alt="amenibensaada profile" class="crayons-avatar__image" width="500" height="500"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/amenibensaada" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Ameni Ben Saada
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Ameni Ben Saada
                
                
              
              &lt;div id="story-author-preview-content-3864587" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/amenibensaada" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&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%2Fuser%2Fprofile_image%2F651361%2F321dfca1-f3b3-4e72-ab95-f9e232c7a852.png" class="crayons-avatar__image" alt="" width="500" height="500"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Ameni Ben Saada&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 11&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc" id="article-link-3864587"&gt;
          Docker Compose vs Kubernetes: Which One Do You Actually Need?
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/kubernetes"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;kubernetes&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/docker"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;docker&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/devops"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;devops&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/microservices"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;microservices&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;6&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            6 min read
          &lt;/small&gt;
          
          &lt;div class="only-sidebar-menu-item trusted-visible-block print-hidden align-center"&gt;
                
                    
                
          &lt;/div&gt;

        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Docker Compose vs Kubernetes: Which One Do You Actually Need?</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Thu, 11 Jun 2026 07:56:22 +0000</pubDate>
      <link>https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc</link>
      <guid>https://dev.to/amenibensaada/docker-compose-vs-kubernetes-which-one-do-you-actually-need-5cfc</guid>
      <description>&lt;p&gt;Everyone asks the same question: "Should I use Kubernetes?"&lt;/p&gt;

&lt;p&gt;The answer is simple: &lt;strong&gt;It depends.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After deploying both in production, here's what I learned about when to use each.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Real Question
&lt;/h2&gt;

&lt;p&gt;You don't need to choose between Docker Compose and Kubernetes.&lt;/p&gt;

&lt;p&gt;You need to choose the &lt;strong&gt;right tool for your problem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let me break it down.&lt;/p&gt;




&lt;h2&gt;
  
  
  Docker Compose: The Simple Choice
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Docker Compose?
&lt;/h3&gt;

&lt;p&gt;Docker Compose runs multiple containers on a single machine. It's defined by a simple YAML file and is the go-to for local development.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use Docker Compose
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Perfect for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Projects that fit comfortably on one host&lt;/li&gt;
&lt;li&gt;Development environments&lt;/li&gt;
&lt;li&gt;Simple production deployments&lt;/li&gt;
&lt;li&gt;Single-server applications&lt;/li&gt;
&lt;li&gt;Teams that want a simple operational setup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example scenario:&lt;/strong&gt;&lt;br&gt;
Your side project has a React frontend, Node.js backend, and PostgreSQL database? Docker Compose is perfect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker Compose Configuration Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;frontend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./frontend&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"3000:3000"&lt;/span&gt;

  &lt;span class="na"&gt;backend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./backend&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"8000:8000"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DATABASE_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql://app:local_dev_only@db:5432/myapp&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;service_healthy&lt;/span&gt;

  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:15&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;app&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;local_dev_only&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;myapp&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CMD-SHELL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pg_isready -U app -d myapp"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres_data:/var/lib/postgresql/data&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postgres_data&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 a local development example: it assumes Dockerfiles in &lt;code&gt;./frontend&lt;/code&gt; and &lt;code&gt;./backend&lt;/code&gt;, with applications listening on the listed ports. The password is a disposable example, not a production secret. Keep real credentials out of source control, configure the browser-facing API URL separately, and add backups, TLS and monitoring before production.&lt;/p&gt;

&lt;p&gt;The database healthcheck and &lt;code&gt;service_healthy&lt;/code&gt; condition wait for database readiness at startup. The backend still needs connection retries when the database becomes unavailable later.&lt;/p&gt;




&lt;h2&gt;
  
  
  Kubernetes: The Enterprise Choice
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Kubernetes?
&lt;/h3&gt;

&lt;p&gt;Kubernetes orchestrates containers across a cluster. It can restart and reschedule workloads, expose services and support autoscaling when the necessary metrics and policies are configured. Production readiness also depends on your application, security, storage, backups and operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to Use Kubernetes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Perfect for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applications that need multi-node scheduling or coordinated deployments&lt;/li&gt;
&lt;li&gt;High availability requirements&lt;/li&gt;
&lt;li&gt;Auto-scaling needs&lt;/li&gt;
&lt;li&gt;Multiple environments (dev/staging/prod)&lt;/li&gt;
&lt;li&gt;Teams able to own the operational complexity&lt;/li&gt;
&lt;li&gt;Production SaaS products&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example scenario:&lt;/strong&gt;&lt;br&gt;
Your SaaS handles 10,000+ concurrent users, has 30 microservices, and downtime costs money? Kubernetes is worth the complexity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes Configuration Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;myapp/backend:v1.0&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8000&lt;/span&gt;
        &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"256Mi"&lt;/span&gt;
            &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"500m"&lt;/span&gt;
          &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"512Mi"&lt;/span&gt;
            &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1000m"&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;
    &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8000&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LoadBalancer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;More complex?&lt;/strong&gt; Yes. &lt;strong&gt;More powerful?&lt;/strong&gt; Also yes.&lt;/p&gt;




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

&lt;h3&gt;
  
  
  You DON'T Need Kubernetes If:
&lt;/h3&gt;

&lt;p&gt;✅ Single server handles your traffic&lt;br&gt;&lt;br&gt;
✅ The team wants to minimize infrastructure overhead&lt;br&gt;&lt;br&gt;
✅ No complex scaling requirements&lt;br&gt;&lt;br&gt;
✅ Simple architecture&lt;br&gt;&lt;br&gt;
✅ Downtime is acceptable (briefly)&lt;br&gt;&lt;br&gt;
✅ Budget is tight  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stick with Docker Compose.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes May Be Worth Evaluating If:
&lt;/h3&gt;

&lt;p&gt;✅ Traffic spikes require auto-scaling&lt;br&gt;&lt;br&gt;
✅ Downtime costs real money&lt;br&gt;&lt;br&gt;
✅ Multiple teams deploying independently&lt;br&gt;&lt;br&gt;
✅ Service coordination is becoming difficult&lt;br&gt;&lt;br&gt;
✅ High availability is critical&lt;br&gt;&lt;br&gt;
✅ Need sophisticated deployment strategies (blue/green, canary)  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evaluate Kubernetes alongside managed application and container platforms.&lt;/strong&gt; Team size, service count and traffic alone do not decide the right platform.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Hidden Costs of Kubernetes
&lt;/h2&gt;

&lt;p&gt;Let's be honest about what Kubernetes actually requires:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Learning Curve&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Steep learning curve (weeks to months)&lt;/li&gt;
&lt;li&gt;New concepts: Pods, Services, Deployments, Ingress, etc.&lt;/li&gt;
&lt;li&gt;YAML debugging nightmares&lt;/li&gt;
&lt;li&gt;Understanding networking, storage, security&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Operational Overhead&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Cluster management&lt;/li&gt;
&lt;li&gt;Upgrades and patches&lt;/li&gt;
&lt;li&gt;Monitoring and logging setup&lt;/li&gt;
&lt;li&gt;Security configurations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Infrastructure Costs&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Capacity and redundancy sized for your availability goals; there is no universal three-worker-node minimum. Highly available control planes and worker capacity are separate concerns.&lt;/li&gt;
&lt;li&gt;Load balancers&lt;/li&gt;
&lt;li&gt;Persistent storage&lt;/li&gt;
&lt;li&gt;Managed Kubernetes (EKS/GKE/AKS) isn't cheap&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Time Investment&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Initial setup: 1-2 weeks&lt;/li&gt;
&lt;li&gt;Learning: Ongoing&lt;/li&gt;
&lt;li&gt;Maintenance: Weekly tasks&lt;/li&gt;
&lt;li&gt;Troubleshooting: Can take hours&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Is it worth it?&lt;/strong&gt; Only if you need what it provides.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Real Experience
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Starting Simple
&lt;/h3&gt;

&lt;p&gt;I started with Docker Compose for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local development &lt;/li&gt;
&lt;li&gt;Small internal tools&lt;/li&gt;
&lt;li&gt;Proof of concepts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Docker Compose advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Started coding in 5 minutes&lt;/li&gt;
&lt;li&gt;Less cluster administration, while still needing container, networking and security basics&lt;/li&gt;
&lt;li&gt;Easy to understand&lt;/li&gt;
&lt;li&gt;Fast iteration&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Graduating to Kubernetes
&lt;/h3&gt;

&lt;p&gt;We moved to Kubernetes when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual scaling became a daily task&lt;/li&gt;
&lt;li&gt;Downtime started impacting users&lt;/li&gt;
&lt;li&gt;Multiple services needed coordination&lt;/li&gt;
&lt;li&gt;Auto-scaling became essential&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Kubernetes advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Auto-scaling works beautifully&lt;/li&gt;
&lt;li&gt;Self-healing saved us multiple times&lt;/li&gt;
&lt;li&gt;Rolling updates that can avoid downtime when readiness checks, spare capacity and application behavior are configured correctly&lt;/li&gt;
&lt;li&gt;Better resource utilization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Kubernetes pain points:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First month was brutal&lt;/li&gt;
&lt;li&gt;Debugging is harder&lt;/li&gt;
&lt;li&gt;More moving parts&lt;/li&gt;
&lt;li&gt;Higher cloud costs&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Hybrid Approach
&lt;/h2&gt;

&lt;p&gt;Here's what actually works in practice:&lt;/p&gt;

&lt;h3&gt;
  
  
  Local Development
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Often Docker Compose&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast&lt;/li&gt;
&lt;li&gt;Simple&lt;/li&gt;
&lt;li&gt;Matches production enough&lt;/li&gt;
&lt;li&gt;Easy to onboard new developers&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Staging/Production
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Depends on requirements:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A single-host deployment may use Compose with appropriate operational safeguards.&lt;/li&gt;
&lt;li&gt;Managed container or application platforms can reduce infrastructure work.&lt;/li&gt;
&lt;li&gt;Kubernetes fits when its scheduling, availability and deployment controls justify the cost.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Migration Path
&lt;/h2&gt;

&lt;p&gt;If you're considering Kubernetes, here's the smart path:&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 1: Docker Compose
&lt;/h3&gt;

&lt;p&gt;Start here. Build your application. Prove the concept.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 2: Docker Compose in Production
&lt;/h3&gt;

&lt;p&gt;Deploy to a single VPS. Learn about production issues with simple tooling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 3: Evaluate
&lt;/h3&gt;

&lt;p&gt;Ask yourself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Am I manually scaling often?&lt;/li&gt;
&lt;li&gt;Is downtime costing money?&lt;/li&gt;
&lt;li&gt;Do I need multi-region deployment?&lt;/li&gt;
&lt;li&gt;Is my team ready for K8s complexity?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If yes to most → Kubernetes&lt;br&gt;&lt;br&gt;
If no to most → Stay with Docker Compose&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 4: Kubernetes (Maybe)
&lt;/h3&gt;

&lt;p&gt;Migrate when the pain of NOT having Kubernetes exceeds the pain of learning it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Mistake 1: Using K8s Too Early
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Added complexity before you needed it&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Start simple, graduate when necessary&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 2: Using Docker Compose Too Long
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Manual work becomes unsustainable&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Know when to graduate&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 3: Following Trends
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; "Big companies use K8s, so should we"&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Big companies have big company problems&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 4: Not Investing in Learning
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Half-learned Kubernetes is worse than Docker Compose&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Commit to learning or don't use it&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick Comparison Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Docker Compose&lt;/th&gt;
&lt;th&gt;Kubernetes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Straightforward for a single host&lt;/td&gt;
&lt;td&gt;Depends on managed services and team experience&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Typical fit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Local development and suitable single-host workloads&lt;/td&gt;
&lt;td&gt;Cluster scheduling and coordinated deployments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Autoscaling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;External tooling needed&lt;/td&gt;
&lt;td&gt;Requires metrics and configured autoscaling policies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Recovery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Container restart policies&lt;/td&gt;
&lt;td&gt;Restarts and rescheduling within configured limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multiple hosts&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Not native Compose orchestration&lt;/td&gt;
&lt;td&gt;Supported&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Availability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Limited by the host unless externally addressed&lt;/td&gt;
&lt;td&gt;Depends on cluster and workload configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Operations&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Host, backups, updates and monitoring&lt;/td&gt;
&lt;td&gt;Those concerns plus cluster operations&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  My Recommendation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  For Most Projects:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Start with Docker Compose&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a single-host application, Compose can be a practical starting point. Availability, compliance and delivery requirements can justify a different platform even for a small product.&lt;/p&gt;

&lt;h3&gt;
  
  
  Graduate to Kubernetes When:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You've outgrown a single server&lt;/li&gt;
&lt;li&gt;Downtime actually costs money&lt;/li&gt;
&lt;li&gt;Auto-scaling becomes essential&lt;/li&gt;
&lt;li&gt;You have time to learn it properly&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Never Use Kubernetes Because:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It's cool&lt;/li&gt;
&lt;li&gt;It's on your resume wishlist&lt;/li&gt;
&lt;li&gt;Everyone else is doing it&lt;/li&gt;
&lt;li&gt;You want to learn (use it for side projects, not production)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Tools That Help
&lt;/h2&gt;

&lt;h3&gt;
  
  
  For Docker Compose:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Portainer&lt;/strong&gt;: Web UI for Docker&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;docker-compose.override.yml&lt;/strong&gt;: Environment-specific configs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Swarm&lt;/strong&gt;: Middle ground between Compose and K8s&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For Kubernetes:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;k9s&lt;/strong&gt;: Terminal UI for K8s&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lens&lt;/strong&gt;: Desktop UI for K8s&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Helm&lt;/strong&gt;: Package manager&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ArgoCD&lt;/strong&gt;: GitOps deployments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Managed Kubernetes&lt;/strong&gt;: EKS, GKE, AKS (consider managed control planes unless self-management is justified)&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;The best tool is the one that solves your problem without creating new ones.&lt;/p&gt;

&lt;p&gt;There is no useful universal percentage here: choose based on failure tolerance, scaling needs and the team’s ability to operate the system.&lt;/p&gt;

&lt;p&gt;Don't over-engineer. Don't under-invest. Match your tools to your actual needs.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Your Experience?
&lt;/h2&gt;

&lt;p&gt;Are you using Docker Compose or Kubernetes? What made you choose one over the other?&lt;/p&gt;

&lt;p&gt;Drop a comment below - I'd love to hear your experience! 👇&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Want more DevOps and backend engineering content? Follow me here on DEV.to or connect with me on &lt;a href="https://www.linkedin.com/in/amenibensaada/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/compose/how-tos/startup-order/" rel="noopener noreferrer"&gt;Docker Compose startup order and readiness&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/compose/how-tos/production/" rel="noopener noreferrer"&gt;Docker Compose in production&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/docs/setup/production-environment/" rel="noopener noreferrer"&gt;Kubernetes production considerations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;I build software, AI integrations and cloud deployments. See my &lt;a href="https://amenibensaada.tn/" rel="noopener noreferrer"&gt;project portfolio&lt;/a&gt; if you’d like to work together.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>docker</category>
      <category>devops</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Tracing Requests Across NestJS Services with Correlation IDs</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Wed, 14 Jan 2026 08:03:07 +0000</pubDate>
      <link>https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2</link>
      <guid>https://dev.to/amenibensaada/debugging-microservices-how-correlation-ids-cut-our-debug-time-from-hours-to-minutes-1lp2</guid>
      <description>&lt;p&gt;Hey dev friends! 💻&lt;/p&gt;

&lt;p&gt;I'm back with a new article to share what I've recently learned. Today, we're going to talk about &lt;strong&gt;logging in microservices&lt;/strong&gt; and how structured logs and correlation IDs make a request’s journey easier to investigate. 🚀&lt;/p&gt;

&lt;p&gt;If you're working with microservices, you know the pain: something breaks in production, and you're jumping between different services trying to figure out what happened. Sound familiar? Let's fix that!&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 The Problem
&lt;/h2&gt;

&lt;p&gt;Picture this: You have 5 microservices running. A user reports an error. You start investigating.&lt;/p&gt;

&lt;p&gt;You check Service A → Nothing obvious.&lt;br&gt;&lt;br&gt;
You check Service B → Maybe something?&lt;br&gt;&lt;br&gt;
You check Service C → Still not sure.&lt;/p&gt;

&lt;p&gt;Instead of clear answers, you're piecing together a puzzle from scattered log files, trying to match timestamps and hoping you'll find the connection. &lt;strong&gt;Hours pass.&lt;/strong&gt; 😰&lt;/p&gt;

&lt;p&gt;This is a common reality. Many teams have logs, but they aren't useful. Each service logs independently with no way to track a request's journey through the system.&lt;/p&gt;


&lt;h2&gt;
  
  
  💡 The Solution: Correlation IDs
&lt;/h2&gt;

&lt;p&gt;The game changer? &lt;strong&gt;Correlation IDs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of correlation IDs like a tracking number for your package 📦. Just like you can track a package through every shipping center it passes through, a correlation ID lets you track a request through every microservice it touches.&lt;/p&gt;

&lt;p&gt;Every request gets a unique ID that follows it through your entire system. When something fails, you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search that one ID
&lt;/li&gt;
&lt;li&gt;See the complete request journey
&lt;/li&gt;
&lt;li&gt;Identify the exact failure point
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple, powerful, effective.&lt;/p&gt;


&lt;h2&gt;
  
  
  🛠️ Keep Request Context Separate
&lt;/h2&gt;

&lt;p&gt;A correlation ID is useful only if every log carries the correct one. One important correction: NestJS &lt;code&gt;Scope.TRANSIENT&lt;/code&gt; means a new instance per consumer, &lt;strong&gt;not per HTTP request&lt;/strong&gt;. Mutating a &lt;code&gt;correlationId&lt;/code&gt; property on a logger injected into a singleton controller can mix IDs between concurrent requests.&lt;/p&gt;

&lt;p&gt;For this example, let’s use Node’s &lt;code&gt;AsyncLocalStorage&lt;/code&gt; to carry a separate context through each request’s asynchronous work, and Pino for structured logs. This example targets NestJS 11 with the Express adapter and a supported Node.js LTS release.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Install Pino
&lt;/h3&gt;

&lt;p&gt;In an existing NestJS application:&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 pino
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pino includes its own TypeScript types. Keep production output as JSON; a pretty-print transport can be added separately for local development.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create the request context
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// request-context.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;AsyncLocalStorage&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;'node:async_hooks'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;randomUUID&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;'node:crypto'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;NextFunction&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;'express'&lt;/span&gt;&lt;span class="p"&gt;;&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;requestContext&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;AsyncLocalStorage&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;correlationId&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="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;correlationIdMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;NextFunction&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;incoming&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'x-correlation-id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// This example accepts a UUID-shaped ID; replace anything else.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;incoming&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'string'&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="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;9a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;incoming&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;correlationId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;incoming&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;randomUUID&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'x-correlation-id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;correlationId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;requestContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;correlationId&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;next&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;The format check keeps arbitrary header text out of the log field. The ID is for tracing, not authentication or authorization. &lt;code&gt;run()&lt;/code&gt; scopes the context to this request and the asynchronous operations created inside it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create a logger without mutable request state
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// logger.service.ts&lt;/span&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="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pino&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'pino'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;requestContext&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;'./request-context'&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;LoggerService&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;readonly&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;pino&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;LOG_LEVEL&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;'info'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;redact&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'authorization'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'cookie'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'password'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'token'&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="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&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="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Record&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="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&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;fields&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;correlationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;requestContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;correlationId&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;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="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&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="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Record&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="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logger&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="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;fields&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;correlationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;requestContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;correlationId&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;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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This assumes the usual NestJS TypeScript configuration with &lt;code&gt;esModuleInterop&lt;/code&gt; enabled. The singleton logger reads the current request context each time it logs, so it does not store one request’s ID for another to overwrite.&lt;/p&gt;

&lt;p&gt;The redaction list is only a small safeguard for those top-level keys. Prefer an allowlist of safe metadata such as operation names and status codes. Don’t log complete request bodies, credentials or personal data; review nested fields and error objects separately.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Register and use it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// users.controller.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Get&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;LoggerService&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;'./logger.service'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users'&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;UsersController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&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;readonly&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LoggerService&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="nd"&gt;@Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;async&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="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Fetching users'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'UsersController'&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;// Replace this empty result with your authorized application query.&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&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="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&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="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Users fetched'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&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;users&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app.module.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Module&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;LoggerService&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;'./logger.service'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;UsersController&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;'./users.controller'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;UsersController&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;LoggerService&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;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// main.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;NestFactory&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/core'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;AppModule&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;'./app.module'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;correlationIdMiddleware&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;'./request-context'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;bootstrap&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;NestFactory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AppModule&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;correlationIdMiddleware&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&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;void&lt;/span&gt; &lt;span class="nf"&gt;bootstrap&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;Only calls through this custom logger carry this context; Nest’s bootstrap logs are not automatically replaced. Background jobs need their own explicit context. An integration such as &lt;a href="https://github.com/iamolegga/nestjs-pino" rel="noopener noreferrer"&gt;nestjs-pino&lt;/a&gt; is another option if you want request logging and Nest logger integration together; check its version compatibility table.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Propagate the ID to the next service
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// downstream.service.ts&lt;/span&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;requestContext&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;'./request-context'&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;DownstreamService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;getStatus&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SERVICE_B_URL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'SERVICE_B_URL is required'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;correlationId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requestContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;correlationId&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;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;correlationId&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'x-correlation-id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;correlationId&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;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`Service B returned ${response.status}`&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;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;Configure the URL on the server, propagate the ID only to services you intend to trace, and apply the receiving middleware there too. For queues, carry the ID in message metadata and establish a new context in the consumer. A correlation ID is not a distributed trace: use OpenTelemetry and trace/span IDs when you need timing and parent-child relationships.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Centralize logs and add error tracking
&lt;/h3&gt;

&lt;p&gt;Structured JSON logs alone do not centralize anything. Collect stdout with your hosting platform or log collector, index the correlation ID, and configure retention, access control and alerts.&lt;/p&gt;

&lt;p&gt;Sentry can complement those logs. Use the &lt;a href="https://docs.sentry.io/platforms/javascript/guides/nestjs/" rel="noopener noreferrer"&gt;current NestJS SDK setup&lt;/a&gt; for your installed version, initialize instrumentation as documented, and attach the correlation ID as a tag in the request’s isolation scope. Avoid sharing mutable global Sentry tags between requests or copying sensitive payloads into events. The old &lt;code&gt;Sentry.Handlers&lt;/code&gt; middleware example is not the current integration.&lt;/p&gt;

&lt;p&gt;Before relying on this pattern, test overlapping requests with different IDs, invalid incoming headers, downstream propagation and log redaction. That catches the context mix-ups a sequential happy-path test misses.&lt;/p&gt;




&lt;h2&gt;
  
  
  📊 What This Looks Like in Practice
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Before (illustrative):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[2025-01-15 10:30:45] Request received
[2025-01-15 10:30:46] Processing data
[2025-01-15 10:30:47] Error: Operation failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which request? Which user? No idea. 🤷‍♀️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After (illustrative log records):&lt;/strong&gt;&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;"level"&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="nl"&gt;"msg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Request received"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"ApiController"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"correlationId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"550e8400-e29b-41d4-a716-446655440000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1736937045123&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"level"&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="nl"&gt;"msg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Processing data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"DataService"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"correlationId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"550e8400-e29b-41d4-a716-446655440000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1736937046456&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"level"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"msg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Operation failed: Validation error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"DataService"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"correlationId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"550e8400-e29b-41d4-a716-446655440000"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"time"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1736937047789&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can search for &lt;code&gt;550e8400-e29b-41d4-a716-446655440000&lt;/code&gt; and see the &lt;strong&gt;entire request journey&lt;/strong&gt; across all services! 🎯&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ What Changes in an Investigation
&lt;/h2&gt;

&lt;p&gt;Instead of manually matching timestamps from several services, you can search one correlation ID in the log system and inspect the related events. This can shorten the search, but it does not guarantee a fixed debugging time: missing propagation, incomplete logs and the underlying bug still matter.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Key Takeaways
&lt;/h2&gt;

&lt;p&gt;What separates good logging from great logging:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure&lt;/strong&gt; → JSON over plain text (searchable and parseable)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Context&lt;/strong&gt; → Correlation IDs tracking every request&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Proper levels&lt;/strong&gt; → Debug/info/error used correctly, not everything as info&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Centralization&lt;/strong&gt; → One place to search everything&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Alerts&lt;/strong&gt; → Configure error reporting and actionable thresholds; detection is not automatic for every failure  &lt;/p&gt;




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

&lt;p&gt;Setting up useful logging takes effort, but it makes production investigations easier to follow. Start with safe structured fields, isolated request context and consistent propagation, then verify the behavior under concurrency.&lt;/p&gt;

&lt;p&gt;Your future self will thank you! 😊&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/pinojs/pino" rel="noopener noreferrer"&gt;Pino Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.sentry.io/platforms/javascript/guides/nestjs/" rel="noopener noreferrer"&gt;Sentry for NestJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/api/async_context.html" rel="noopener noreferrer"&gt;Node.js AsyncLocalStorage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/fundamentals/injection-scopes" rel="noopener noreferrer"&gt;NestJS provider scopes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nestjs.com/techniques/logger" rel="noopener noreferrer"&gt;NestJS Logging&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;What about you?&lt;/strong&gt; 🤔 Have you implemented correlation IDs in your microservices? What challenges did you face? Share your experiences below!&lt;/p&gt;

&lt;p&gt;And if you found this helpful, follow me for more articles about web development, NestJS, and DevOps practices. Let's learn together ❤️&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>microservices</category>
      <category>devops</category>
      <category>logging</category>
    </item>
    <item>
      <title>A Beginner’s Guide to Building Dynamic User Interfaces with React</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Tue, 17 Dec 2024 14:34:43 +0000</pubDate>
      <link>https://dev.to/amenibensaada/a-beginners-guide-to-building-dynamic-user-interfaces-with-react-509c</link>
      <guid>https://dev.to/amenibensaada/a-beginners-guide-to-building-dynamic-user-interfaces-with-react-509c</guid>
      <description>&lt;p&gt;Hey dev friends! 💻 Are you ready to start your journey into the world of React? 🚀 In this introduction, we’ll explore the fundamentals of React, the popular JavaScript library that powers some of the world’s most dynamic web applications. Let’s dive in! 🌟&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;🖥️ What is React?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;React is a &lt;strong&gt;JavaScript library for building user interfaces&lt;/strong&gt;, used to create interactive applications. It’s designed to make creating interactive and reusable UI components easy and efficient.&lt;/p&gt;

&lt;p&gt;Think of React as your ultimate toolkit for building fast, modern, and scalable web applications. 🌐&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;⚡ Key Features of React&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Component-Based Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React lets you break down your UI into small, reusable pieces called components. Each component is like a Lego block 🧩, and you can combine them to build complex UIs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Virtual DOM&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React uses a lightweight copy of the actual DOM (Document Object Model) called the Virtual DOM. React reconciles the rendered output and applies necessary DOM updates; performance still depends on your components, data flow and workload. Think of it as React being super-efficient in the kitchen—only chopping what needs chopping! 👨‍🍳&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Declarative Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Describe &lt;em&gt;what&lt;/em&gt; you want the UI to look like, and React takes care of the &lt;em&gt;how&lt;/em&gt;. It’s intuitive, readable, and helps you focus on the “what” without worrying about low-level details.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;👩‍💻 Getting Started with React&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before diving into code, let’s set up your React environment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Install Node.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This Vite development setup requires a supported Node.js version. React runs in the browser after the app is built; Node.js is not required on a static production host. You can download it &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Set Up a React App&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For this introductory example, use Vite. Create React App has been deprecated; for a larger application, also evaluate the frameworks recommended in the &lt;a href="https://react.dev/learn/creating-a-react-app" rel="noopener noreferrer"&gt;React documentation&lt;/a&gt;. Check &lt;a href="https://vite.dev/guide/" rel="noopener noreferrer"&gt;Vite’s Node.js requirements&lt;/a&gt; before starting:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create vite@latest my-app -- --template react
&lt;span class="nb"&gt;cd&lt;/span&gt; my-app
npm install
npm run dev
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;🚀 You’ve just started your first React project!&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;📄 A Simple React Example&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let’s create a basic “Hello, World!” React component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;ReactDOM&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"react-dom/client"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;App&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Hello&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;World&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRoot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"root"&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;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What’s happening here?&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;We define a functional component (&lt;code&gt;App&lt;/code&gt;) that returns some JSX (a syntax extension for HTML in JavaScript).&lt;/li&gt;
&lt;li&gt;ReactDOM renders our &lt;code&gt;App&lt;/code&gt; component into the DOM, specifically into the element with the &lt;code&gt;id="root"&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;💡 Why Use React?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Reusable Components:&lt;/strong&gt; Write once, reuse anywhere!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Great Ecosystem:&lt;/strong&gt; Libraries like Redux, React Router, and Material-UI make development smoother.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strong Community:&lt;/strong&gt; Tons of tutorials, tools, and support.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;🎯 What’s Next?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can continue with &lt;a href="https://react.dev/learn" rel="noopener noreferrer"&gt;React’s guide to state and components&lt;/a&gt;. If you’re deciding how to render your pages, read my introductions to &lt;a href="https://dev.to/amenibensaada/a-friendly-guide-to-client-side-rendering-and-spas-in-web-development-217l"&gt;CSR&lt;/a&gt;, &lt;a href="https://dev.to/amenibensaada/server-side-rendering-ssr-boosting-seo-and-speed-in-modern-web-development-4l6h"&gt;SSR&lt;/a&gt; and &lt;a href="https://dev.to/amenibensaada/static-site-generation-ssg-unlocking-speed-and-seo-for-modern-websites-34m0"&gt;SSG&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;What about you? 🤔 Have you started working with React, or are you excited to dive in? Share your thoughts and questions below! Let’s learn together. ❤️&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>softwaredevelopment</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Static Site Generation (SSG): Unlocking Speed and SEO for Modern Websites</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Wed, 04 Dec 2024 12:28:12 +0000</pubDate>
      <link>https://dev.to/amenibensaada/static-site-generation-ssg-unlocking-speed-and-seo-for-modern-websites-34m0</link>
      <guid>https://dev.to/amenibensaada/static-site-generation-ssg-unlocking-speed-and-seo-for-modern-websites-34m0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey dev friends 💻&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We’re back with Part 3! 🎉 After exploring the wonders of Client-Side Rendering (CSR) and Server-Side Rendering (SSR), it’s time to dive into &lt;strong&gt;Static Site Generation (SSG)&lt;/strong&gt;—a useful approach for pre-rendering content. Ready to see how SSG can transform your web development workflow? Let’s go! 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🖥️ What is Static Site Generation (SSG)?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Static Site Generation pre-renders HTML pages at build time instead of during each user request. When a user visits your site, they’re served pre-generated static files straight from a Content Delivery Network (CDN).&lt;/p&gt;

&lt;p&gt;Think of it as preparing a batch of cookies beforehand and serving them instantly when someone asks for them! 🍪&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;📄 Why Choose SSG?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Blazing Fast Performance ⚡:&lt;/strong&gt; Since the content is pre-built and served from a CDN, the HTML can be delivered with low serving overhead. Images, JavaScript and cache behavior still affect loading speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability 🚀:&lt;/strong&gt; Static files can be cached and served at scale without rendering each request. Any APIs and dynamic services still need their own capacity planning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SEO-Friendly 🕵️‍♂️:&lt;/strong&gt; Pre-rendered content is immediately crawlable by search engines, making it available without client-side rendering. Rankings still depend on content quality, links, metadata and other signals.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;😎 When SSG Really Shines&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;SSG is an excellent choice for sites with mostly static content or content that doesn’t change frequently. Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blogs and Portfolios 📝&lt;/li&gt;
&lt;li&gt;Documentation Sites 📚&lt;/li&gt;
&lt;li&gt;Marketing Websites 🌟&lt;/li&gt;
&lt;li&gt;E-Commerce Stores with Static Product Pages 🛍️&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;👎 What to Consider with SSG?&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Content Freshness:&lt;/strong&gt; Build-time HTML can become stale. Static pages can still hydrate into interactive applications and fetch live data; choose how fresh each part of the page needs to be.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Longer Build Times:&lt;/strong&gt; For large sites with numerous pages, the build process can take significant time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personalized Content:&lt;/strong&gt; Authentication and user-specific data need appropriate client-side fetching or request-time rendering and authorization. &lt;strong&gt;ISR&lt;/strong&gt; refreshes cached pages; it is not a replacement for authentication or a safe way to cache one user’s private content for everyone.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🤔 Should You Use SSG?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If performance, scalability, and SEO are your top priorities and your content doesn’t require frequent updates, SSG could be your best bet! Tools like &lt;strong&gt;Next.js&lt;/strong&gt;, &lt;strong&gt;Gatsby&lt;/strong&gt;, and &lt;strong&gt;Hugo&lt;/strong&gt; make implementing SSG a breeze.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;📚 Continue reading&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/amenibensaada/a-friendly-guide-to-client-side-rendering-and-spas-in-web-development-217l"&gt;Part 1: CSR and SPAs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/amenibensaada/server-side-rendering-ssr-boosting-seo-and-speed-in-modern-web-development-4l6h"&gt;Part 2: Server-Side Rendering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/amenibensaada/a-beginners-guide-to-building-dynamic-user-interfaces-with-react-509c"&gt;React basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/learn/seo/rendering-strategies" rel="noopener noreferrer"&gt;Next.js rendering strategies&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What do you think? 🤔 Have you tried Static Site Generation in your projects? Let us know your experiences in the comments below. Let’s keep this web development journey going 🛠️&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Server-Side Rendering (SSR): Boosting SEO and Speed in Modern Web Development🌐</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Wed, 06 Nov 2024 14:07:22 +0000</pubDate>
      <link>https://dev.to/amenibensaada/server-side-rendering-ssr-boosting-seo-and-speed-in-modern-web-development-4l6h</link>
      <guid>https://dev.to/amenibensaada/server-side-rendering-ssr-boosting-seo-and-speed-in-modern-web-development-4l6h</guid>
      <description>&lt;p&gt;&lt;strong&gt;We’re back for Part 2!&lt;/strong&gt; Last time, we explored Client-Side Rendering (CSR) and Single-Page Applications (SPAs). Now, let's dive into Server-Side Rendering (SSR) and discover how it changes the game. Ready to see what makes SSR tick? Let's go! 🔍&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🖥️ What is Server-Side Rendering (SSR)?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With SSR, the server prepares a fully rendered page and sends it to the browser, so the initial response includes content rather than relying entirely on browser JavaScript. Server processing, data fetching and the network still affect how quickly that content appears. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📄 Why Choose SSR?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. SEO Boost 🚀:&lt;/strong&gt; Server-rendered HTML makes content available without waiting for client rendering. It can help crawlers access the page, but it does not guarantee better rankings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Faster First Impressions ⚡:&lt;/strong&gt; Users can see content before the application JavaScript finishes loading, provided server response and data-fetching times stay low. Measure the result rather than assuming SSR is always faster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Fresh or Request-Specific Content 🌐:&lt;/strong&gt; SSR is useful when a page needs data at request time. Mostly unchanged pages may be better served with static generation. SSR can also power highly interactive applications through hydration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;😎 When SSR Really Shines&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're building an e-commerce site, blog, or any platform with a content focus and need a boost in SEO, SSR can be a great choice. Consider it when request-time data is important, and compare its response time and hosting cost with static generation or a hybrid approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;👎 What to Consider with SSR?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Higher Server Load:&lt;/strong&gt; Because the server is handling rendering, heavy traffic can add stress to your server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Potentially More Complex Setup:&lt;/strong&gt; SSR can require more setup than CSR, especially if you're integrating with a framework like Next.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Delayed Interactivity:&lt;/strong&gt; Pages load visually fast, but interactive elements may take a moment to activate as JavaScript takes over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🤔 Should You Use SSR?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’re prioritizing SEO and quick content delivery, SSR might be the solution you’re looking for! But remember, for highly interactive apps, a mix of CSR and SSR (or even static generation) could be the way to go.&lt;/p&gt;

&lt;p&gt;Continue with &lt;a href="https://dev.to/amenibensaada/static-site-generation-ssg-unlocking-speed-and-seo-for-modern-websites-34m0"&gt;Part 3: Static Site Generation&lt;/a&gt;, or revisit &lt;a href="https://dev.to/amenibensaada/a-friendly-guide-to-client-side-rendering-and-spas-in-web-development-217l"&gt;Part 1: CSR and SPAs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more detail, see &lt;a href="https://nextjs.org/learn/seo/rendering-strategies" rel="noopener noreferrer"&gt;Next.js rendering strategies&lt;/a&gt; and &lt;a href="https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics" rel="noopener noreferrer"&gt;Google’s JavaScript SEO guidance&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What do you think? 🤔 Have you tried SSR in your projects? Let’s discuss your experiences in the comments below! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>seo</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Client-Side Rendering and SPAs in Web Development🌐</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Mon, 04 Nov 2024 14:33:03 +0000</pubDate>
      <link>https://dev.to/amenibensaada/a-friendly-guide-to-client-side-rendering-and-spas-in-web-development-217l</link>
      <guid>https://dev.to/amenibensaada/a-friendly-guide-to-client-side-rendering-and-spas-in-web-development-217l</guid>
      <description>&lt;p&gt;Hey dev friends💻 I’m back with a new blog, and this time we’re diving into the exciting world of Client-Side Rendering (CSR) and Single-Page Applications (SPAs). Think of this post as your caffeine boost for modern web dev concepts ☕&lt;/p&gt;

&lt;h2&gt;
  
  
  🖥️ What is Client-Side Rendering (CSR)?
&lt;/h2&gt;

&lt;p&gt;Client-side rendering (CSR) shifts the heavy lifting of rendering pages from the server to the user's browser. When you visit a website, the server sends a skeleton HTML file, and JavaScript steps in to render content right there in your browser. &lt;/p&gt;

&lt;p&gt;It’s like having your browser as the chef preparing the meal, rather than just serving it 👨‍🍳&lt;/p&gt;

&lt;h2&gt;
  
  
  📄 What are Single-Page Applications (SPAs)?
&lt;/h2&gt;

&lt;p&gt;Single-Page Applications (SPAs) handle navigation in the browser without requesting a whole new HTML document for every route. They can load route code and data on demand, rather than loading everything at once. Navigation speed still depends on the work each route needs.&lt;/p&gt;

&lt;p&gt;CSR and SPA describe different things: CSR describes where content is rendered; SPA describes how navigation works. A SPA can receive server-rendered HTML on its first visit and then use client-side navigation.&lt;/p&gt;

&lt;p&gt;This approach is why you see SPAs in popular sites like Facebook and Twitter.&lt;/p&gt;

&lt;h2&gt;
  
  
  😎 Why Use CSR &amp;amp; SPAs?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;User Experience:&lt;/strong&gt; Enjoy a seamless experience with fewer loading interruptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance:&lt;/strong&gt; While the initial load might be slower, CSR/SPA setups enhance navigation speed after the first load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Developer Perks:&lt;/strong&gt; Developers can create modular, reusable components and focus on the “single page” concept&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  👎 What are the Downsides?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SEO Challenges:&lt;/strong&gt; Google can render JavaScript, but rendering introduces additional dependencies and not every crawler runs it. Make sure routes have crawlable links, correct status codes and useful metadata, and check whether important content is accessible. See &lt;a href="https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics" rel="noopener noreferrer"&gt;Google’s JavaScript SEO guidance&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Initial Load Time:&lt;/strong&gt; CSR apps can take a bit longer to load initially as the browser fetches the code to get started. But hey, good things come to those who wait, right?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Should You Use CSR and SPAs?
&lt;/h2&gt;

&lt;p&gt;If you’re looking to build modern, fast, interactive web applications and don’t mind putting in a little extra work for SEO, they’re absolutely worth it 😀&lt;/p&gt;

&lt;p&gt;Continue with &lt;a href="https://dev.to/amenibensaada/server-side-rendering-ssr-boosting-seo-and-speed-in-modern-web-development-4l6h"&gt;Part 2: Server-Side Rendering&lt;/a&gt; and &lt;a href="https://dev.to/amenibensaada/static-site-generation-ssg-unlocking-speed-and-seo-for-modern-websites-34m0"&gt;Part 3: Static Site Generation&lt;/a&gt; to compare the tradeoffs. &lt;/p&gt;

&lt;p&gt;What about you?🤔 Have you tried CSR or SPAs in your projects? Share your experiences below! And be sure to follow for more web dev insights as we continue this journey together 🌐&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>frontend</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Integrating Stripe into Your Nest.js Application</title>
      <dc:creator>Ameni Ben Saada</dc:creator>
      <pubDate>Sun, 14 Jul 2024 16:33:58 +0000</pubDate>
      <link>https://dev.to/amenibensaada/integrating-stripe-into-your-nestjs-application-nf7</link>
      <guid>https://dev.to/amenibensaada/integrating-stripe-into-your-nestjs-application-nf7</guid>
      <description>&lt;p&gt;Hey dev friends! 💻 Today, let’s look at Stripe and how to wire its server-side SDK into a NestJS application. This guide covers configuration and a small product-listing endpoint, not a complete checkout or subscription implementation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is stripe ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stripe is a technology company that builds economic infrastructure for the internet. Businesses of all sizes—from new startups to public companies—use Stripe's software to accept payments and manage their businesses online.&lt;/p&gt;

&lt;p&gt;It was founded in 2010 by Patrick and John Collison and has quickly become one of the top payment processors globally. Stripe is known for its developer-friendly approach, making it easy to set up and use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use Stripe?&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ease of Use:&lt;/strong&gt; Stripe makes it easy to integrate payment processing into your website or app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payment Data Handling:&lt;/strong&gt; Stripe-hosted Checkout or Stripe Elements can keep raw card details away from your server. Your application still needs secure configuration, authorization and correct webhook handling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global Reach:&lt;/strong&gt; Stripe supports many currencies and payment methods, allowing businesses to operate internationally.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How stripe works ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We need to understand how Stripe works before writing any code.&lt;/p&gt;

&lt;p&gt;A typical subscription flow can use Stripe Checkout:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The authenticated customer chooses a plan.&lt;/li&gt;
&lt;li&gt;Your backend creates a Checkout Session using a trusted server-side price ID and associates it with the correct customer.&lt;/li&gt;
&lt;li&gt;The customer enters payment details on Stripe’s hosted page, or through an appropriate Stripe UI integration. Never send raw card details to your NestJS API.&lt;/li&gt;
&lt;li&gt;Your backend verifies signed webhook events and updates subscription access idempotently. A browser success redirect alone does not prove payment or ongoing entitlement.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The illustration below is an overview; the exact event flow depends on your chosen Stripe integration.&lt;/p&gt;

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

&lt;p&gt;The SDK setup below is one building block for that flow. Checkout creation, webhook verification, authorization and subscription lifecycle handling require additional implementation.&lt;/p&gt;

&lt;p&gt;Now moving to our favorite part, writing some code &lt;/p&gt;

&lt;h3&gt;
  
  
  Implementing Stripe in Nest.js
&lt;/h3&gt;

&lt;p&gt;Let's walk through setting up Stripe in a Nest.js application:&lt;/p&gt;

&lt;p&gt;If you haven't already, create a new Nest.js application and install the necessary packages then we need to create one using&amp;nbsp;&lt;a href="https://docs.nestjs.com/cli/overview" rel="noopener noreferrer"&gt;Nest’s CLI&lt;/a&gt;, install @&lt;a href="https://www.npmjs.com/package/@nestjs/config" rel="noopener noreferrer"&gt;nestjs/config&lt;/a&gt;&amp;nbsp;to get environment variables and&amp;nbsp;&lt;a href="https://www.npmjs.com/package/stripe" rel="noopener noreferrer"&gt;stripe’s npm package&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx @nestjs/cli@11 new nestjs-stripe
&lt;span class="nb"&gt;cd&lt;/span&gt; nestjs-stripe
npm install @nestjs/config@4 stripe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Once the installation is complete, the next step is to create a &lt;code&gt;stripe&lt;/code&gt; folder inside &lt;code&gt;*/src*&lt;/code&gt;. This structure is optional; you can organize it according to your preference.&lt;/p&gt;

&lt;p&gt;Create a module, controller, and service for Stripe. Remember to place your Stripe API key in the &lt;code&gt;.env&lt;/code&gt; file. You can name the key anything you like, but for consistency with the setup instructions, name it &lt;code&gt;STRIPE_API_KEY&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Let's begin with setting up the Stripe module. It should look something like this:&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="c1"&gt;// src/stripe/stripe.module.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Module&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;ConfigModule&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ConfigService&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/config'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Stripe&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'stripe'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;StripeController&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;'./stripe.controller'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;StripeService&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;'./stripe.service'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;STRIPE_CLIENT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'STRIPE_CLIENT'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ConfigModule&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;controllers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;StripeController&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;providers&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;provide&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;STRIPE_CLIENT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ConfigService&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;useFactory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ConfigService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Stripe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getOrThrow&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="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'STRIPE_API_KEY'&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="nc"&gt;StripeService&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StripeModule&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;For this NestJS 11 example, &lt;code&gt;@nestjs/config&lt;/code&gt; 4 is compatible. Use the matching package versions for your Nest major. Commit your lockfile and review Stripe SDK/API upgrades deliberately. This example uses the installed Stripe SDK’s default API version rather than copying a dated API version into a newer SDK; see &lt;a href="https://docs.stripe.com/sdks/set-version" rel="noopener noreferrer"&gt;Stripe’s versioning guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Register the module and load configuration:&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="c1"&gt;// src/app.module.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Module&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;ConfigModule&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/config'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;StripeModule&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;'./stripe/stripe.module'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Module&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;imports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;ConfigModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forRoot&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;StripeModule&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;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AppModule&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;Add &lt;code&gt;STRIPE_API_KEY=sk_test_your_key_here&lt;/code&gt; to your local &lt;code&gt;.env&lt;/code&gt;, keep &lt;code&gt;.env&lt;/code&gt; out of Git, and use your host’s secret configuration for deployed environments. &lt;code&gt;getOrThrow()&lt;/code&gt; makes the application fail at startup when the key is missing. Never expose a Stripe secret key in browser code or logs.&lt;/p&gt;

&lt;p&gt;Now let’s add the service:&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="c1"&gt;// src/stripe/stripe.service.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Inject&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="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Stripe&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'stripe'&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;StripeService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@Inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'STRIPE_CLIENT'&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;readonly&lt;/span&gt; &lt;span class="n"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Stripe&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;async&lt;/span&gt; &lt;span class="nf"&gt;getProducts&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="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;active&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="n"&gt;limit&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="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;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&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;This returns one page of active products. It does not fetch every page, prices or customer records. A real storefront should return an explicit DTO of public fields rather than exposing the whole Stripe object. Customer and billing endpoints need authentication, authorization and tenant isolation.&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="c1"&gt;// src/stripe/stripe.controller.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ServiceUnavailableException&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;StripeService&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;'./stripe.service'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Controller&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'stripe'&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;StripeController&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&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;readonly&lt;/span&gt; &lt;span class="n"&gt;stripeService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;StripeService&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="nd"&gt;@Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'products'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;getProducts&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;try&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;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stripeService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getProducts&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;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&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;id&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="n"&gt;description&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;id&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="n"&gt;description&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;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Add controlled server-side reporting without exposing secrets.&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ServiceUnavailableException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Product catalog unavailable'&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;The product route is public only if your catalog is intended to be public. Protect administrative operations and add caching/rate limits as appropriate. Use Stripe test mode or a sandbox while developing.&lt;/p&gt;

&lt;p&gt;That’s the SDK wiring in place. For a complete payment flow, continue with the official &lt;a href="https://docs.stripe.com/payments/checkout/build-subscriptions" rel="noopener noreferrer"&gt;Checkout subscription guide&lt;/a&gt; and &lt;a href="https://docs.stripe.com/webhooks/signature" rel="noopener noreferrer"&gt;webhook signature verification&lt;/a&gt;. Stripe signature verification requires the unmodified request body; NestJS documents its &lt;a href="https://docs.nestjs.com/faq/raw-body" rel="noopener noreferrer"&gt;raw-body support&lt;/a&gt;. Handle retries and duplicate events idempotently, validate your price IDs on the server, and update access from verified subscription state.&lt;/p&gt;

&lt;p&gt;I hope you learned something valuable from this article. If you have any feedback or notice anything that could be improved, please let me know. I'd love to hear your thoughts and make any necessary corrections.&lt;/p&gt;

</description>
      <category>nestjs</category>
      <category>stripe</category>
      <category>typescript</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
