<?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: Divyanshi Narang</title>
    <description>The latest articles on DEV Community by Divyanshi Narang (@divyanshi_narang16).</description>
    <link>https://dev.to/divyanshi_narang16</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%2F1835128%2F856843e1-baaa-443d-bb18-58e4e0886971.png</url>
      <title>DEV Community: Divyanshi Narang</title>
      <link>https://dev.to/divyanshi_narang16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/divyanshi_narang16"/>
    <language>en</language>
    <item>
      <title>Authorization vs Authentication</title>
      <dc:creator>Divyanshi Narang</dc:creator>
      <pubDate>Mon, 07 Sep 2026 13:43:00 +0000</pubDate>
      <link>https://dev.to/divyanshi_narang16/authorization-vs-authentication-mof</link>
      <guid>https://dev.to/divyanshi_narang16/authorization-vs-authentication-mof</guid>
      <description>&lt;h2&gt;
  
  
  Authentication (AuthN)
&lt;/h2&gt;

&lt;p&gt;It verifies the identity of the user.&lt;/p&gt;

&lt;p&gt;Who are you? → Verify identity → Establish authenticated user&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login with email/password&lt;/li&gt;
&lt;li&gt;OTP verification&lt;/li&gt;
&lt;li&gt;Google login&lt;/li&gt;
&lt;li&gt;Session/JWT used to maintain the authenticated state&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Authorization (AuthZ)
&lt;/h2&gt;

&lt;p&gt;It determines the user's permissions and access rights.&lt;/p&gt;

&lt;p&gt;What are you allowed to do? → Check permissions/access → Allow or deny action&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Roles — Admin, Manager, User&lt;/li&gt;
&lt;li&gt;Permissions — delete_user, approve_leave&lt;/li&gt;
&lt;li&gt;Resource ownership — user can edit their own profile&lt;/li&gt;
&lt;li&gt;Policies/attributes — e.g. a manager can approve requests only for their team&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Can you have authorization without authentication?
&lt;/h2&gt;

&lt;p&gt;Yes.&lt;/p&gt;

&lt;p&gt;For public resources, authentication isn't required because the access policy allows everyone to access them.&lt;/p&gt;

&lt;p&gt;GET /products → Public → No authentication required → Access allowed&lt;/p&gt;

&lt;p&gt;For protected resources:&lt;/p&gt;

&lt;p&gt;GET /profile → Authentication required → Identify user → Check authorization → Allow/Deny&lt;/p&gt;

&lt;p&gt;So, authentication is not always required for authorization, but it is generally required when authorization depends on the user's identity, role, or permissions.&lt;/p&gt;




&lt;h2&gt;
  
  
  TLDR ;)
&lt;/h2&gt;

&lt;p&gt;“Authentication verifies the identity of user, while authorization determines what that authenticated user is allowed to access or perform a particular action.”&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>softwareengineering</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>CP vs AP</title>
      <dc:creator>Divyanshi Narang</dc:creator>
      <pubDate>Sun, 06 Sep 2026 16:31:41 +0000</pubDate>
      <link>https://dev.to/divyanshi_narang16/cp-vs-ap-3dci</link>
      <guid>https://dev.to/divyanshi_narang16/cp-vs-ap-3dci</guid>
      <description>&lt;p&gt;As we discussed,&lt;/p&gt;

&lt;p&gt;In distributed systems, &lt;strong&gt;CAP theorem is not simply about choosing any two out of three. It describes the trade-off between Consistency and Availability when a network Partition occurs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the network itself has failed, we can't always guarantee both simultaneously.&lt;/p&gt;




&lt;h2&gt;
  
  
  What about CA?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;CA means Consistency + Availability, without Partition Tolerance.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That means the system provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; Every request sees a consistent/current view of the data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Availability:&lt;/strong&gt; Every request receives a response.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Partition Tolerance:&lt;/strong&gt; The system does not account for network partitions between nodes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But in a real distributed system, network partitions can happen. So &lt;strong&gt;Partition Tolerance is generally something we need to account for&lt;/strong&gt;, making the practical trade-off between &lt;strong&gt;CP and AP&lt;/strong&gt; during a partition.&lt;/p&gt;

&lt;p&gt;This leads us to two common approaches in distributed systems.&lt;/p&gt;




&lt;h2&gt;
  
  
  CP — Consistency + Partition Tolerance
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;CP system prioritizes consistency when a partition occurs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;During a partition, if the system cannot guarantee that the data is consistent, it may reject or delay the request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Network Partition
       ↓
Cannot guarantee consistent data
       ↓
Don't return potentially stale data
       ↓
Consistency preserved
Availability sacrificed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The priority is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"I'd rather fail the request than return incorrect or stale data."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This can be useful for systems where incorrect information is worse than being temporarily unavailable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples where strong consistency may be important:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Money transfers&lt;/li&gt;
&lt;li&gt;Account balances&lt;/li&gt;
&lt;li&gt;Payment authorization&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  AP — Availability + Partition Tolerance
&lt;/h2&gt;

&lt;p&gt;An &lt;strong&gt;AP system prioritizes availability when a partition occurs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It continues responding even if some nodes might temporarily have different versions of the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Network Partition
       ↓
Nodes cannot communicate
       ↓
Still respond to requests
       ↓
Availability preserved
Consistency may temporarily suffer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The priority becomes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"I'd rather give the user an answer and resolve the inconsistency later."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This can be useful when temporary inconsistency or stale data is acceptable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples where temporary inconsistency may be acceptable:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shopping carts&lt;/li&gt;
&lt;li&gt;Product recommendations&lt;/li&gt;
&lt;li&gt;Likes&lt;/li&gt;
&lt;li&gt;View counts&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;As a developer, I don't think the important part is memorizing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"CP for this database, AP for that database."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The more important part is understanding the &lt;strong&gt;trade-off&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Whenever we're designing a distributed system, we should ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What should happen when our servers cannot communicate with each other?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Should we:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Stop serving requests to protect correctness?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Or continue serving requests and potentially return stale data?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That decision can affect the architecture of the entire system.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>computerscience</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>CAP Theorem Finally Made Sense to Me</title>
      <dc:creator>Divyanshi Narang</dc:creator>
      <pubDate>Sat, 05 Sep 2026 13:23:47 +0000</pubDate>
      <link>https://dev.to/divyanshi_narang16/cap-theorem-finally-made-sense-to-me-2aei</link>
      <guid>https://dev.to/divyanshi_narang16/cap-theorem-finally-made-sense-to-me-2aei</guid>
      <description>&lt;p&gt;While studying system design, I came across something called CAP theorem.&lt;/p&gt;

&lt;p&gt;At first, it sounded simple: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt; A distributed system can choose any two out of Consistency, Availability, and Partition Tolerance.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But the more I read about it, the more I realized that this explanation can be a little misleading.&lt;/p&gt;

&lt;p&gt;So I tried to understand it through a simple real-world example: a single restaurant inventory with two branches.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is CAP theorem?
&lt;/h2&gt;

&lt;p&gt;CAP theorem describes fundamental trade-off that exists in &lt;strong&gt;distributed systems&lt;/strong&gt;. It was introduced by &lt;strong&gt;Eric Brewer in 2000&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;CAP stands for:&lt;/p&gt;

&lt;p&gt;C - Consistency&lt;br&gt;
A - Availability&lt;br&gt;
P - Partition Tolerance&lt;/p&gt;

&lt;p&gt;But before understanding the theorem, let's understand what these three terms actually mean.&lt;/p&gt;

&lt;p&gt;Suppose you have a restaurant named PizzaPazi having two branches and sharing a single inventory.&lt;/p&gt;

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



&lt;ol&gt;
&lt;li&gt;Consistency - 
A customer buys the last Pizza from Branch A.
Branch A knows Pizza left = 0.
For system to be consistent, Branch B should also reflect the latest state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In simple terms:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;All nodes should agree on the current state of the data.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Availability - 
Now imagine, Branch A is temporarily unavailable.
Should Branch B also stop serving customers? -&amp;gt; Not necessarily.
Branch B should continue responding to requests.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's Availability:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;The system continues responding to requests even when some parts of the system in unavailable.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Partition Tolerance - 
Due to some reasons, the network connecting A and B breaks. Both branches are running, but they cannot communicate. This is a network partition.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Partition Tolerance means:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;The distributed system continues operating despite nodes being unable to communicate with each other.&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;


&lt;h2&gt;
  
  
  Where does the CAP problem come in?
&lt;/h2&gt;

&lt;p&gt;Suppose Branch A sells the last Pizza while the network is down.&lt;/p&gt;

&lt;p&gt;Branch A -&amp;gt; 0 available&lt;br&gt;
Branch B -&amp;gt; 1 available&lt;/p&gt;

&lt;p&gt;A customer now asks Branch B for the Pizza.&lt;/p&gt;

&lt;p&gt;Branch B has a choice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Stop and wait for Branch A&lt;/strong&gt; → preserve the latest consistent state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continue serving the customer&lt;/strong&gt; → remain available, but potentially use stale data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that's the core idea of CAP: &lt;br&gt;
** When a network partition occurs, you cannot guarantee both Consistency, and Availability at the same time.**&lt;/p&gt;

&lt;p&gt;The biggest thing I learned is that CAP isn't just about memorizing three words.&lt;/p&gt;

&lt;p&gt;It's about asking:&lt;br&gt;
&lt;strong&gt;What should my system do when two parts of it can no longer communicate?&lt;/strong&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  TLDR ;)
&lt;/h2&gt;

&lt;p&gt;CAP theorem states that in a distributed system, when a network partition occurs between nodes, we cannot guarantee both strong Consistency and Availability at the same time.&lt;/p&gt;

&lt;p&gt;Consistency means every request gets the latest, correct data.&lt;br&gt;
Availability means every request receives a response.&lt;br&gt;
Partition Tolerance means the system continues operating even when nodes cannot communicate with each other.&lt;/p&gt;

&lt;p&gt;Since network partitions are inevitable in distributed systems, the practical trade-off is usually between Consistency and Availability during a partition — resulting in CP or AP systems.&lt;/p&gt;



&lt;p&gt;Resources I used&lt;/p&gt;

&lt;p&gt;While learning this topic, these were particularly useful:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ksat.me/a-plain-english-introduction-to-cap-theorem" rel="noopener noreferrer"&gt;A Plain English Introduction to CAP Theorem — Kaushik Sathupadi&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=VdrEq0cODu4&amp;amp;list=PL5q3E8eRUieUHnsz0rh0W6AzwdVJBwEK6&amp;amp;index=7" rel="noopener noreferrer"&gt;Hello Interview's video explanation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@ngneha090/understanding-the-cap-theorem-balancing-consistency-availability-and-partition-cb11c2b97e2b" rel="noopener noreferrer"&gt;Understanding the CAP Theorem — Neha&lt;/a&gt;&lt;/p&gt;




&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/divyanshi_narang16/cp-vs-ap-3dci" class="crayons-story__hidden-navigation-link"&gt;CP vs AP&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="/divyanshi_narang16" 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%2F1835128%2F856843e1-baaa-443d-bb18-58e4e0886971.png" alt="divyanshi_narang16 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="/divyanshi_narang16" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Divyanshi Narang
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Divyanshi Narang
                
                
              
              &lt;div id="story-author-preview-content-4582508" 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="/divyanshi_narang16" 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%2F1835128%2F856843e1-baaa-443d-bb18-58e4e0886971.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;Divyanshi Narang&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/divyanshi_narang16/cp-vs-ap-3dci" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Sep 6&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/divyanshi_narang16/cp-vs-ap-3dci" id="article-link-4582508"&gt;
          CP vs AP
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/architecture"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;architecture&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/backend"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;backend&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/computerscience"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;computerscience&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/systemdesign"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;systemdesign&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/divyanshi_narang16/cp-vs-ap-3dci#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;
            2 min read
          &lt;/small&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>systemdesign</category>
      <category>distributedsystems</category>
      <category>softwareengineering</category>
    </item>
  </channel>
</rss>
