<?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: Samuel</title>
    <description>The latest articles on DEV Community by Samuel (@oyis12).</description>
    <link>https://dev.to/oyis12</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%2F1054728%2F589b6cda-a137-43b1-a714-5b07c0ed4a24.jpg</url>
      <title>DEV Community: Samuel</title>
      <link>https://dev.to/oyis12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oyis12"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Samuel</dc:creator>
      <pubDate>Wed, 25 Nov 2026 07:46:47 +0000</pubDate>
      <link>https://dev.to/oyis12/-35mn</link>
      <guid>https://dev.to/oyis12/-35mn</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/oyis12/idempotency-in-software-development-what-it-is-and-why-every-backend-developer-should-understand-it-3n72" class="crayons-story__hidden-navigation-link"&gt;Idempotency in Software Development: What It Is and Why Every Backend Developer Should Understand It&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="/oyis12" 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%2F1054728%2F589b6cda-a137-43b1-a714-5b07c0ed4a24.jpg" alt="oyis12 profile" class="crayons-avatar__image" width="540" height="960"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/oyis12" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Samuel
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Samuel
                
                
              
              &lt;div id="story-author-preview-content-5114321" 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="/oyis12" 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%2F1054728%2F589b6cda-a137-43b1-a714-5b07c0ed4a24.jpg" class="crayons-avatar__image" alt="" width="540" height="960"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Samuel&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/oyis12/idempotency-in-software-development-what-it-is-and-why-every-backend-developer-should-understand-it-3n72" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Nov 25&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/oyis12/idempotency-in-software-development-what-it-is-and-why-every-backend-developer-should-understand-it-3n72" id="article-link-5114321"&gt;
          Idempotency in Software Development: What It Is and Why Every Backend Developer Should Understand It
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/node"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;node&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/backenddevelopment"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;backenddevelopment&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/mobile"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;mobile&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/oyis12/idempotency-in-software-development-what-it-is-and-why-every-backend-developer-should-understand-it-3n72#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>Idempotency in Software Development: What It Is and Why Every Backend Developer Should Understand It</title>
      <dc:creator>Samuel</dc:creator>
      <pubDate>Wed, 25 Nov 2026 07:45:27 +0000</pubDate>
      <link>https://dev.to/oyis12/idempotency-in-software-development-what-it-is-and-why-every-backend-developer-should-understand-it-3n72</link>
      <guid>https://dev.to/oyis12/idempotency-in-software-development-what-it-is-and-why-every-backend-developer-should-understand-it-3n72</guid>
      <description>&lt;p&gt;Imagine you're building a payment application.&lt;/p&gt;

&lt;p&gt;A user wants to transfer ₦50,000 to another account. They click the Transfer button, but the network is slow. Nothing seems to happen, so they click the button again.&lt;/p&gt;

&lt;p&gt;The first request actually reached your server and processed successfully, but the response never made it back to the user's device.&lt;/p&gt;

&lt;p&gt;Now your server receives the second request.&lt;/p&gt;

&lt;p&gt;What happens?&lt;/p&gt;

&lt;p&gt;If your backend isn't properly designed, the user might get charged twice.&lt;/p&gt;

&lt;p&gt;This is one of the problems that Idempotency helps us solve.&lt;/p&gt;

&lt;p&gt;It is a concept every backend developer should understand, especially when building APIs, payment systems, distributed applications, and services that depend on network communication.&lt;/p&gt;

&lt;p&gt;Let's break it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What Exactly Is Idempotency?
&lt;/h2&gt;

&lt;p&gt;In simple terms, idempotency means that performing the same operation multiple times produces the same result as performing it once.&lt;/p&gt;

&lt;p&gt;Think of it this way:&lt;/p&gt;

&lt;p&gt;You press an elevator button once. The elevator is called.&lt;/p&gt;

&lt;p&gt;You press the same button five more times. You don't get five elevators.&lt;/p&gt;

&lt;p&gt;The intended outcome remains the same.&lt;/p&gt;

&lt;p&gt;In software development, we want our operations to behave similarly.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Sending the same payment request multiple times should not result in multiple charges.&lt;/li&gt;
&lt;li&gt;Submitting the same order request repeatedly should not create duplicate orders.&lt;/li&gt;
&lt;li&gt;Retrying an API request should not accidentally perform the same action multiple times.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to make our systems predictable, even when requests are repeated.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Why Is Idempotency Important?
&lt;/h2&gt;

&lt;p&gt;Modern applications don't always operate under perfect conditions.&lt;/p&gt;

&lt;p&gt;We deal with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unstable internet connections.&lt;/li&gt;
&lt;li&gt;Network timeouts.&lt;/li&gt;
&lt;li&gt;Server failures.&lt;/li&gt;
&lt;li&gt;Automatic retries.&lt;/li&gt;
&lt;li&gt;Users clicking buttons multiple times.&lt;/li&gt;
&lt;li&gt;Distributed systems communicating with one another.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Consider this scenario:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A frontend sends a request to create an order.&lt;/li&gt;
&lt;li&gt;The backend receives the request.&lt;/li&gt;
&lt;li&gt;The backend successfully creates the order.&lt;/li&gt;
&lt;li&gt;The response gets lost because of a network issue.&lt;/li&gt;
&lt;li&gt;The frontend assumes the request failed and retries it.&lt;/li&gt;
&lt;li&gt;The backend receives the same request again.&lt;/li&gt;
&lt;li&gt;Without proper protection, the backend might create two orders.&lt;/li&gt;
&lt;li&gt;This is why idempotency matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some of its major benefits include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prevents duplicate operations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It protects your application against repeated actions such as duplicate payments, orders, and account transactions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improves API reliability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Clients can safely retry supported operations without worrying about unintentionally repeating side effects.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handles network failures&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your application can recover from uncertain network conditions more safely.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improves user experience&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Users don't have to worry about being charged twice simply because they clicked a button more than once.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Makes distributed systems more predictable&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When multiple services communicate over unreliable networks, idempotency helps control repeated requests and side effects. &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Understanding Idempotency Through HTTP Methods
&lt;/h2&gt;

&lt;p&gt;You might have already encountered idempotency without realizing it.&lt;/p&gt;

&lt;p&gt;HTTP defines certain methods as idempotent. Let's look at some examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  GET — Idempotent
&lt;/h3&gt;

&lt;p&gt;GET requests retrieve data without changing the server's state.&lt;/p&gt;

&lt;p&gt;Sending the same GET request multiple times should produce the same intended result.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  PUT — Idempotent
&lt;/h3&gt;

&lt;p&gt;PUT requests replace a resource with the provided representation.&lt;/p&gt;

&lt;p&gt;Sending the same PUT request multiple times should leave the resource in the same state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;PUT&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Samuel"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  DELETE — Idempotent
&lt;/h3&gt;

&lt;p&gt;DELETE requests remove a resource.&lt;/p&gt;

&lt;p&gt;Deleting the same resource multiple times has the same intended effect: the resource remains deleted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;DELETE&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  POST — Not inherently idempotent
&lt;/h3&gt;

&lt;p&gt;POST requests are commonly used to create resources or trigger operations.&lt;/p&gt;

&lt;p&gt;Sending the same POST request multiple times can create multiple records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;orders&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, sending this request five times could create five different orders.&lt;/p&gt;

&lt;h3&gt;
  
  
  PATCH — Depends on the operation
&lt;/h3&gt;

&lt;p&gt;PATCH requests partially modify resources.&lt;/p&gt;

&lt;p&gt;Whether a PATCH request is idempotent depends on what the operation actually does.&lt;/p&gt;

&lt;p&gt;For example, setting a user's name to "Samuel" repeatedly is idempotent.&lt;/p&gt;

&lt;p&gt;However, increasing an account balance by ₦5,000 on every request is not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Idempotency is about the intended effect on server state, not necessarily identical HTTP responses. A repeated DELETE, for example, might return a different status code after the resource has already been deleted.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How Do We Implement Idempotency in a Backend?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One common approach is using something called an Idempotency Key.&lt;/p&gt;

&lt;p&gt;An idempotency key is a unique identifier generated by the client and sent alongside a request.&lt;/p&gt;

&lt;p&gt;The backend uses this key to identify requests that represent the same operation.&lt;/p&gt;

&lt;p&gt;Let's use a payment application as an example.&lt;/p&gt;

&lt;p&gt;The frontend generates a unique key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;crypto&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then sends it to the backend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;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="s2"&gt;"/api/payments"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&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="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"Idempotency-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&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;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;accountNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1234567890"&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="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Now let's look at what happens on the backend.&lt;/p&gt;

&lt;p&gt;Step 1: Receive the request&lt;/p&gt;

&lt;p&gt;Your Express.js backend receives the payment request and extracts the idempotency key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&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="s2"&gt;"idempotency-key"&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;idempotencyKey&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;)&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="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Idempotency key is required"&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;Step 2: Check whether the request has already been processed&lt;/p&gt;

&lt;p&gt;Before initiating the payment, the backend checks its database for an existing record associated with that key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;existingRequest&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;Idempotency&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;userId&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="n"&gt;user&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="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;If the request has already completed, return its previously stored result instead of processing the payment again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;existingRequest&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"completed"&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;existingRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responseStatus&lt;/span&gt;&lt;span class="p"&gt;)&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="n"&gt;existingRequest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;responseBody&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;Step 3: Process the operation&lt;/p&gt;

&lt;p&gt;If the key hasn't been used before, the backend proceeds with the payment.&lt;/p&gt;

&lt;p&gt;After successful processing, it stores the result associated with the idempotency key.&lt;/p&gt;

&lt;p&gt;The next time the same request arrives with that key, the backend can return the original result.&lt;/p&gt;

&lt;p&gt;Note: This is a simplified illustration. A production implementation must also handle concurrent requests, in-progress operations, request payload validation, database transactions, and payment-provider behavior.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What Does a Production-Ready Implementation Need?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simply checking whether a key exists is not enough.&lt;/p&gt;

&lt;p&gt;Imagine two identical requests arrive at almost exactly the same time.&lt;/p&gt;

&lt;p&gt;Both requests check the database before either one has stored its idempotency record.&lt;/p&gt;

&lt;p&gt;Both might conclude that the operation hasn't been processed.&lt;/p&gt;

&lt;p&gt;And just like that, you have a duplicate operation.&lt;/p&gt;

&lt;p&gt;A production implementation should consider the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Database uniqueness constraints&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Enforce uniqueness on the appropriate scope, such as the combination of user ID, endpoint, and idempotency key.&lt;/p&gt;

&lt;p&gt;Don't rely on application-level checks alone.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Handle concurrent requests&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use atomic database operations, transactions, or another coordination mechanism to ensure only one request claims a particular key.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Track request status&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A useful lifecycle could look like:&lt;/p&gt;

&lt;p&gt;processing&lt;/p&gt;

&lt;p&gt;completed&lt;/p&gt;

&lt;p&gt;failed&lt;/p&gt;

&lt;p&gt;Be careful with failed operations: a timeout doesn't necessarily mean the payment failed. You may need to reconcile its status with the payment provider before retrying.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validate request payloads&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If a client reuses the same idempotency key with a different payment amount, you shouldn't silently return the previous result or process a different payment.&lt;/p&gt;

&lt;p&gt;Store a request fingerprint and reject conflicting reuse.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Store and reuse the original response&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When an operation succeeds, persist the relevant response status and body so subsequent retries can receive the original result.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define an expiration policy&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Idempotency records shouldn't necessarily live forever. Define a retention period based on the business requirements and the payment provider's idempotency policy.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Idempotency Is Not Just for Payment Systems&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Although payment processing is one of the easiest places to understand this concept, idempotency is useful in many other areas.&lt;/p&gt;

&lt;p&gt;Here are a few examples:&lt;/p&gt;

&lt;p&gt;E-commerce: Preventing duplicate orders when customers retry checkout.&lt;/p&gt;

&lt;p&gt;Authentication: Preventing repeated processing of the same one-time operation.&lt;/p&gt;

&lt;p&gt;File uploads: Avoiding duplicate file records when upload requests are retried.&lt;/p&gt;

&lt;p&gt;Notifications: Preventing the same notification from being sent repeatedly.&lt;/p&gt;

&lt;p&gt;Background jobs: Ensuring a retried job doesn't repeat an already completed business operation.&lt;/p&gt;

&lt;p&gt;Inventory management: Preventing duplicate stock deductions when an order request is retried.&lt;/p&gt;

&lt;p&gt;Whenever an operation can be repeated and has side effects, you should think about whether it needs idempotency protection.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Final Thoughts&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Idempotency might seem like a small concept, but it plays a significant role in building reliable software.&lt;/p&gt;

&lt;p&gt;As developers, we shouldn't assume that every request will arrive only once, every response will reach the client, or every network connection will work perfectly.&lt;/p&gt;

&lt;p&gt;We should design our applications with these failures in mind.&lt;/p&gt;

&lt;p&gt;The next time you're building a payment endpoint, an order creation API, or a background job, ask yourself:&lt;/p&gt;

&lt;p&gt;"What happens if this exact operation runs twice?"&lt;/p&gt;

&lt;p&gt;If the answer could cause duplicate payments, records, or unwanted side effects, you probably need to think about idempotency.&lt;/p&gt;

&lt;p&gt;Build systems that can handle retries gracefully. Don't just build systems that work when everything goes perfectly.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

&lt;p&gt;I'd love to hear from other developers:&lt;/p&gt;

&lt;p&gt;Have you ever encountered a duplicate payment, order, or database operation because of repeated API requests?&lt;/p&gt;

&lt;p&gt;How did you handle it?&lt;/p&gt;

&lt;p&gt;Let's discuss in the comments!&lt;/p&gt;

&lt;h1&gt;
  
  
  javascript #nodejs #backend #webdev
&lt;/h1&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>backenddevelopment</category>
      <category>mobile</category>
    </item>
    <item>
      <title>I built a private ingredient-label reader for my cousin with open-source OCR</title>
      <dc:creator>Samuel</dc:creator>
      <pubDate>Fri, 02 Oct 2026 11:15:51 +0000</pubDate>
      <link>https://dev.to/oyis12/i-built-a-private-ingredient-label-reader-for-my-cousin-with-open-source-ocr-1o67</link>
      <guid>https://dev.to/oyis12/i-built-a-private-ingredient-label-reader-for-my-cousin-with-open-source-ocr-1o67</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-weekend-2026-10-01"&gt;Hacktoberfest Weekend Challenge: Build for a Friend&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;At the grocery store, an ingredient label is a tiny block of text that can matter a lot. My cousin has to pay close attention to food labels, so I built &lt;strong&gt;LabelKind&lt;/strong&gt; as a second pair of eyes: choose what you want to check, take a photo of a packaged-food label, and review any possible matches.&lt;/p&gt;

&lt;p&gt;I didn't want to make another app that points a camera at a meal and guesses what is in it. A photo can't show every ingredient, sauce, or cross-contact risk. LabelKind reads the printed ingredient list instead, shows the exact terms it matched, and leaves the decision with the person holding the package.&lt;/p&gt;

&lt;p&gt;The avoid list starts empty. Your choices live only for the current browser session; I did not put my cousin's profile into the app or the repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://oyis12.github.io/foodAllergies/" rel="noopener noreferrer"&gt;Try the live demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose &lt;strong&gt;Try a sample&lt;/strong&gt; to see the matching flow without using a personal food label. Or scan a clear package photo or paste the ingredient text.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://github.com/oyis12/foodAllergies" rel="noopener noreferrer"&gt;View the source on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;LabelKind is a React app built with Vite. For a label photo, &lt;a href="https://github.com/naptha/tesseract.js" rel="noopener noreferrer"&gt;Tesseract.js&lt;/a&gt; runs Tesseract's open-source LSTM neural-network OCR engine in the browser through WebAssembly. That OCR model is the AI at the center of the photo-to-text step.&lt;/p&gt;

&lt;p&gt;After OCR, a small matching layer checks the recognized words against the terms the person selected. This part is deliberately transparent: it displays the matching words, distinguishes allergy terms from intolerance terms, and lets the user edit the OCR text. If the photo is hard to read, the ingredient list can be pasted instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;Food and health information is personal. Running open-source OCR in the browser lets LabelKind read a label without uploading the photo to a closed AI API. There is no account or server-side profile, and the model and matching behavior can be inspected and changed. I could make this without paying per scan or sending a photo to a vendor to get words back.&lt;/p&gt;

&lt;p&gt;There is a trade-off: the first scan needs an internet connection to download the OCR worker, WebAssembly runtime, and English language data. The photo is processed in the browser; the app does not send it to a model service.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned / Next Step
&lt;/h2&gt;

&lt;p&gt;LabelKind is a screening aid, never a food-safety guarantee. OCR can miss small print or misread a word. It can't detect cross-contact, recipe changes, or undeclared ingredients. For severe allergies, people still need to check the original package and contact the manufacturer if anything is unclear.&lt;/p&gt;

&lt;p&gt;After trying the demo, my cousin said he thought it was awesome. He also suggested a useful next step: let each person create a profile with the ingredients they want to avoid, then use that profile to check label text or receipts they provide. The current version doesn't have accounts or saved profiles. Adding persistent allergy data would require clear consent, strong data protection, and a delete control before I'd ship it.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>weekendchallenge</category>
      <category>hf26challenge</category>
    </item>
    <item>
      <title>Ai to get UI/ux</title>
      <dc:creator>Samuel</dc:creator>
      <pubDate>Wed, 29 Mar 2023 11:49:16 +0000</pubDate>
      <link>https://dev.to/oyis12/ai-to-get-uiux-5h6i</link>
      <guid>https://dev.to/oyis12/ai-to-get-uiux-5h6i</guid>
      <description>&lt;p&gt;Hello devs please is there any Ai that can generate UI/UX for an ecommerc website, am currently working on a personal project&lt;/p&gt;

</description>
      <category>uiweekly</category>
      <category>aigenerate</category>
    </item>
  </channel>
</rss>
