<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shivam Soni  on Medium]]></title>
        <description><![CDATA[Stories by Shivam Soni  on Medium]]></description>
        <link>https://medium.com/@shivam.soni.webdev?source=rss-8a4806b9091a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qtj-fdNPQBKlWS-2</url>
            <title>Stories by Shivam Soni  on Medium</title>
            <link>https://medium.com/@shivam.soni.webdev?source=rss-8a4806b9091a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:51:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shivam.soni.webdev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Blue-Green Deployment: The Strategy That Changed How I Think About Production Releases]]></title>
            <link>https://medium.com/@shivam.soni.webdev/blue-green-deployment-the-strategy-that-changed-how-i-think-about-production-releases-9f9e0db04ebd?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f9e0db04ebd</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 14:31:01 GMT</pubDate>
            <atom:updated>2026-07-19T14:31:01.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_y6M3kSGTYZYRp5xaaYwrw.png" /></figure><p>In my previous article, I shared how working with two different engineering teams completely changed the way I viewed deployments.</p><p>One question naturally followed:</p><p><strong>What made one team so much more confident when deploying to production?</strong></p><p>The answer wasn’t a better programming language, a different cloud provider, or a smaller codebase.</p><p>It was the deployment strategy.</p><h3>What is Blue-Green Deployment?</h3><p>Imagine having two identical production environments.</p><p>One environment, let’s call it <strong>Blue</strong>, is currently serving all of your users.</p><p>The second environment, <strong>Green</strong>, sits quietly in the background.</p><p>When a new version of the application is ready, it isn’t deployed directly to the live environment.</p><p>Instead, it’s deployed to the Green environment first.</p><p>While users continue using the Blue environment, the engineering team can verify that the new version is healthy by checking application logs, monitoring dashboards, API responses, database connectivity, and other critical services.</p><p>Only after everything looks good is traffic switched from Blue to Green.</p><p>From the user’s perspective, nothing appears to have changed.</p><h3>Why is this approach so powerful?</h3><p>The biggest advantage isn’t faster deployments.</p><p>It’s confidence.</p><p>Instead of wondering whether a deployment might break production, teams can validate the new environment before exposing it to users.</p><p>Even more importantly, if something unexpected happens after the switch, recovery is straightforward.</p><p>Traffic can simply be routed back to the previous environment while the issue is investigated.</p><p>That ability to recover quickly changes the entire deployment experience.</p><h3>Is it perfect?</h3><p>Not quite.</p><p>Blue-Green Deployment also comes with trade-offs.</p><p>Running two production environments during deployment increases infrastructure costs.</p><p>Database changes must be planned carefully so both application versions remain compatible.</p><p>Teams also need reliable automation and monitoring to make the switch safely.</p><p>Like every engineering decision, it’s a balance between cost, complexity, and reliability.</p><h3>Where is it used?</h3><p>Blue-Green Deployment is commonly used in systems where minimizing downtime and enabling fast rollbacks are important.</p><p>Many organizations implement it using load balancers, reverse proxies, container platforms, or cloud-native infrastructure.</p><p>It isn’t the only deployment strategy available, but it’s one of the most effective when safe releases are a priority.</p><h3>My biggest takeaway</h3><p>Before learning about Blue-Green Deployment, I assumed successful deployments were mostly about writing bug-free code.</p><p>Now I think differently.</p><p>Great deployments are built on great engineering practices.</p><p>The more I work on production systems, the more I realize that software engineering doesn’t end when the code is merged.</p><p>It ends when users receive that change safely and reliably.</p><p>In my next article, I’ll compare <strong>Rolling Deployments, Blue-Green Deployments, and Canary Releases</strong> to explore where each strategy shines and the trade-offs teams should consider.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f9e0db04ebd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Two Companies. Two Deployment Cultures. A Lesson That Changed My Perspective.]]></title>
            <link>https://medium.com/@shivam.soni.webdev/two-companies-two-deployment-cultures-a-lesson-that-changed-my-perspective-c6ced89c6776?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6ced89c6776</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 12:41:28 GMT</pubDate>
            <atom:updated>2026-07-19T12:41:28.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUneK3yA9UJ39-_wNXZEww.png" /></figure><p>One of the biggest lessons in my career didn’t come from learning a new programming language or framework.</p><p>It came from watching how two different engineering teams approached deployments.</p><p>At my previous organization, deployment day always felt different.</p><p>Production deployments were usually planned for <strong>Friday night</strong>. It wasn’t just about releasing code - it was about minimizing the impact if something went wrong. If an issue appeared, the entire weekend was available to investigate, fix it, and ensure everything was stable before Monday.</p><p>Deployments involved careful planning, maintenance windows, stakeholder communication, production validation, and continuous monitoring. Everyone understood the responsibility that came with pushing changes to production.</p><p>For the engineering team, deployment day was often the most stressful day of the week.</p><p>When I moved to another organization, I expected deployment days to feel the same.</p><p>Instead, I noticed something completely different.</p><p>There would often be a long list of completed features and fixes waiting in the deployment pipeline. Yet when it was time to release them, there wasn’t the same tension I had experienced before.</p><p>That surprised me.</p><p>The team wasn’t taking production lightly. They still performed checks, monitored the release, and were prepared for anything unexpected.</p><p>The difference was the confidence.</p><p>It wasn’t confidence because the software was simpler.</p><p>It wasn’t confidence because the team cared less about quality.</p><p>It was confidence in the deployment process itself.</p><p>That realization completely changed the way I think about software delivery.</p><p>As engineers, we spend countless hours learning how to write better code, design better systems, and build better products.</p><p>But we spend far less time talking about <strong>how those changes safely reach production</strong>.</p><p>Looking back, both organizations were solving the same problem: delivering reliable software.</p><p>They simply approached that problem differently.</p><p>And that taught me something important.</p><p>Sometimes, the biggest difference between two engineering teams isn’t the code they write - it’s the confidence with which they release it.</p><p>In my next article, I’ll explore the deployment strategy that helped me understand where that confidence comes from and why it’s become such a valuable practice in modern software engineering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6ced89c6776" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Sharding in DBMS: A Guide to Scaling Databases Effectively]]></title>
            <link>https://medium.com/@shivam.soni.webdev/understanding-sharding-in-dbms-a-guide-to-scaling-databases-effectively-c900672a3929?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c900672a3929</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[sharding]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 08:04:02 GMT</pubDate>
            <atom:updated>2025-07-02T10:39:36.328Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*qBjAxfrjylS5O6G_VVwAgQ.png" /></figure><p>As digital applications grow, so does their data. From social media platforms to e-commerce giants, handling vast amounts of data while maintaining performance, availability, and scalability is critical. One solution that emerges as a hero in this scenario is <strong>sharding</strong>.</p><p>In this blog, we’ll dive deep into the concept of <strong>sharding in databases</strong>, its working mechanism, benefits, features, and implementation across various popular databases like MySQL, PostgreSQL, and MongoDB.</p><h3>What is Sharding?</h3><p><strong>Sharding</strong> is a type of database partitioning that separates large databases into smaller, faster, more easily managed parts called <strong>shards</strong>. Each shard holds a subset of the total data, and all shards together make up the complete dataset.</p><p>Think of it as slicing a giant pizza into pieces — everyone gets a piece, and no one has to handle the whole pie at once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*pq6SMe6OV8-Q8N55IdzEGA.png" /></figure><h3>Why Do We Need Sharding?</h3><p>As databases grow, traditional vertical or horizontal scaling methods start to hit limits:</p><ul><li><strong>Read/Write Bottlenecks</strong>: With huge data volume, a single machine struggles to handle concurrent read/write operations.</li><li><strong>Storage Constraints</strong>: Disk size limits and IOPS (Input/Output Operations Per Second) can become bottlenecks.</li><li><strong>Performance Issues</strong>: Queries slow down as the dataset becomes massive.</li><li><strong>Fault Tolerance</strong>: A single point of failure in monolithic databases leads to complete downtime.</li></ul><p><strong>Sharding addresses all of these by:</strong></p><ul><li>Distributing the load across multiple servers.</li><li>Reducing query response time.</li><li>Allowing individual shards to be replicated for fault tolerance.</li></ul><h3>How Does Sharding Work?</h3><p>Sharding splits a dataset based on a <strong>shard key</strong>, which determines how data is distributed.</p><h3>Types of Sharding:</h3><p><strong>1. Horizontal Sharding</strong></p><ul><li>Rows are split across multiple tables/databases.</li><li>Example: Users A–M in Shard 1, N–Z in Shard 2.</li></ul><p><strong>2. Vertical Sharding</strong></p><ul><li>Columns are split across databases.</li><li>Example: User login info in Shard 1, order history in Shard 2.</li></ul><p><strong>3. Directory-Based Sharding</strong></p><ul><li>A lookup table maintains the mapping of data to shards.</li></ul><h3>Features of Sharding</h3><ul><li><strong>Scalability</strong>: Each shard can be scaled independently.</li><li><strong>Parallelism</strong>: Query load is distributed across shards.</li><li><strong>Fault Isolation</strong>: Failure in one shard doesn’t crash the entire system.</li><li><strong>Cost Optimization</strong>: Use commodity hardware instead of high-end machines.</li></ul><h3>Benefits of Sharding</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*uy0BN67wZjNp48t7QCPGVg.png" /></figure><h3>Sharding in MySQL vs PostgreSQL vs MongoDB</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*crDP1vX-jIgSx6I9-AdBDA.png" /><figcaption>Sharding in MySQL vs PostgreSQL vs MongoDB</figcaption></figure><h3>Challenges in Sharding</h3><p>While powerful, sharding isn’t a silver bullet. You might encounter:</p><ul><li><strong>Complex Joins</strong>: Joins across shards are tricky or slow.</li><li><strong>Rebalancing</strong>: Moving data between shards is operationally complex.</li><li><strong>Shard Key Selection</strong>: Poor choice leads to data skew or hotspots.</li><li><strong>Operational Overhead</strong>: Monitoring and backups are more complex.</li></ul><h3>Real-Life Use Cases</h3><ul><li><strong>Facebook</strong>: Uses sharding for user data to ensure low-latency access.</li><li><strong>Amazon</strong>: Shards order and product data across multiple services.</li><li><strong>YouTube</strong>: Stores video metadata and comments in shards.</li></ul><h3>Best Practices for Sharding</h3><ul><li><strong>Choose the right shard key</strong>: It should evenly distribute data and queries.</li><li><strong>Automate shard management</strong>: Use tools where available.</li><li><strong>Monitor shard health</strong>: CPU, memory, disk, and query metrics.</li><li><strong>Use connection pooling</strong>: To manage open connections across shards.</li><li><strong>Plan for growth</strong>: Design your system to easily add shards.</li></ul><h3>When Not to Shard?</h3><p>You might not need sharding if:</p><ul><li>Your data fits well on a single server.</li><li>You don’t have heavy read/write load.</li><li>Your query patterns are unpredictable or involve complex joins.</li></ul><p>In these cases, consider <strong>replication</strong>, <strong>caching</strong>, or <strong>vertical scaling</strong> instead.</p><h3>Final Thoughts</h3><p>Sharding is a powerful strategy for scaling databases, but it brings operational complexity and architectural considerations. Choose it only when your application’s growth truly demands it.</p><p>Whether you’re building a microservices system, a large-scale web application, or just planning for scale from day one — understanding sharding gives you a strong foundation to architect data systems that perform and scale reliably.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c900672a3929" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Docker in 2025: The Ultimate Guide — What, Why, and How?]]></title>
            <link>https://medium.com/@shivam.soni.webdev/docker-in-2025-the-ultimate-guide-what-why-and-how-cea04fb9c1eb?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cea04fb9c1eb</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Thu, 15 May 2025 15:22:11 GMT</pubDate>
            <atom:updated>2025-05-15T15:22:11.491Z</atom:updated>
            <content:encoded><![CDATA[<h3>🐳 Docker in 2025: The Ultimate Guide — What, Why, and How?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*GCmC1PF9CsMSp6w2sbTKUw.png" /><figcaption>docker</figcaption></figure><p>In the ever-evolving world of software development and DevOps, <strong>Docker</strong> has emerged as a game-changer. Whether you’re a developer, DevOps engineer, tester, or just exploring modern deployment workflows, understanding Docker is no longer optional — it’s essential.</p><p>In this comprehensive blog post, we’ll dive deep into:</p><ul><li>What Docker is</li><li>Why Docker is important</li><li>Whether it’s really necessary to learn in 2025</li><li>Docker architecture and components</li><li>Common Docker commands</li><li>Real-world use cases</li><li>Docker vs virtual machines</li><li>Docker in CI/CD pipelines</li><li>How to get started with Docker</li></ul><p>Let’s break it all down!</p><h3>📌 What is Docker?</h3><p><strong>Docker</strong> is an open-source platform that enables developers to <strong>build, ship, and run applications in containers</strong>. These containers are lightweight, portable units that bundle your application code along with all its dependencies and runtime environment.</p><p>Think of a container as a self-contained box that runs exactly the same anywhere — on your laptop, on a production server, or in the cloud.</p><blockquote><em>💡 </em><strong><em>In short:</em></strong><em> Docker ensures “It works on my machine” actually works </em><strong><em>everywhere</em></strong><em>.</em></blockquote><h3>🔥 Why is Docker Important?</h3><h4>✅ 1. Consistency Across Environments</h4><p>Containers eliminate the “works on my machine” problem. Your app behaves the same regardless of where it runs.</p><h4>✅ 2. Lightweight and Fast</h4><p>Unlike Virtual Machines, containers <strong>don’t need a full OS</strong> — just the essentials. That makes them <strong>lightweight, fast to boot</strong>, and resource-efficient.</p><h4>✅ 3. Easy Deployment and Scalability</h4><p>With Docker, deploying updates or scaling apps becomes painless. It’s widely used in <strong>microservices</strong> and <strong>Kubernetes</strong> environments.</p><h4>✅ 4. Isolation</h4><p>Each container runs in isolation, so multiple apps and services can run on the same host without interfering with each other.</p><h4>✅ 5. CI/CD Integration</h4><p>Modern DevOps workflows heavily rely on Docker for consistent builds, testing, and deployment in CI/CD pipelines.</p><h3>📅 Is Docker Still Relevant in 2025?</h3><p>Absolutely — <strong>more than ever</strong>.</p><ul><li>With the rise of <strong>cloud-native</strong>, <strong>microservices</strong>, and <strong>DevOps-first</strong> development, Docker is a core skill.</li><li>Tools like <strong>Kubernetes</strong>, <strong>AWS ECS</strong>, and <strong>GitHub Actions</strong> often rely on Docker containers.</li><li>Even AI and ML projects use containers to ensure reproducibility across environments.</li></ul><blockquote><em>🎯 </em><strong><em>In 2025, Docker is not just useful — it’s a foundational tool in modern development workflows.</em></strong></blockquote><h3>Docker Architecture</h3><p>Let’s demystify how Docker works under the hood.</p><h4>1. Docker Engine</h4><p>The core part of Docker, responsible for building and running containers.</p><p>Docker Engine components:</p><ul><li><strong>Docker Daemon (</strong><strong>dockerd)</strong>: Runs in the background, managing images, containers, networks, volumes.</li><li><strong>Docker CLI</strong>: The command-line tool to interact with Docker.</li><li><strong>Docker API</strong>: Used to programmatically access Docker functionalities.</li></ul><h4>2. Docker Image</h4><p>A <strong>read-only blueprint</strong> of your application and its dependencies (like a snapshot).</p><p>Example: node:18-alpine, python:3.12</p><h4>3. Docker Container</h4><p>A <strong>running instance</strong> of a Docker image. It is isolated, secure, and ephemeral (you can recreate it anytime).</p><h4>4. Dockerfile</h4><p>A text file containing instructions to build a Docker image.</p><p>Example:</p><pre>FROM node:18-alpine<br>WORKDIR /app<br>COPY . .<br>RUN npm install<br>CMD [&quot;node&quot;, &quot;index.js&quot;]</pre><h4>5. Docker Hub</h4><p>A public registry to share Docker images. You can pull prebuilt images from Docker Hub or push your own.</p><h3><strong>🧠 Docker Terminology: Learn Every Term</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*nIajyybCvkMLAqIGSX5L6w.png" /></figure><h3><strong>🧰 Common Docker Commands</strong></h3><pre># Check Docker version<br>docker --version<br><br># Run a container from an image<br>docker run -d -p 3000:3000 my-app<br><br># List all running containers<br>docker ps<br><br># Stop a container<br>docker stop &lt;container_id&gt;<br><br># Remove container/image<br>docker rm &lt;container_id&gt;<br>docker rmi &lt;image_id&gt;<br><br># Build an image from Dockerfile<br>docker build -t my-app .<br><br># List images<br>docker images<br><br># Run command inside container<br>docker exec -it &lt;container_id&gt; bash</pre><h3><strong>🔗 Docker vs Virtual Machines</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*RJOmbht-hGq9k98J51HtOg.png" /></figure><h3>⚙️ Docker Compose — Multi-Container Magic</h3><p>Use Docker Compose when you have <strong>multiple services</strong> (e.g., a React frontend, Node.js backend, and MongoDB).</p><p>Example docker-compose.yml:</p><pre>version: &#39;3&#39;<br>services:<br>  web:<br>    build: .<br>    ports:<br>      - &quot;3000:3000&quot;<br>  db:<br>    image: mongo<br>    ports:<br>      - &quot;27017:27017&quot;</pre><p>Then run:</p><pre>docker-compose up</pre><h3>🚀 Docker in CI/CD Pipelines</h3><p>Docker enables seamless integration in CI/CD:</p><ul><li><strong>CI Tools</strong> like GitHub Actions, GitLab CI, CircleCI use Docker to build and test apps in isolated containers.</li><li><strong>CD Tools</strong> like Jenkins, ArgoCD, Spinnaker deploy Docker containers to staging/production.</li></ul><p>Sample GitHub Action:</p><pre>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v2<br>      - name: Build Docker image<br>        run: docker build -t my-app .</pre><h3>🧪 Real-World Use Cases</h3><ul><li>🛍 <strong>E-commerce</strong> platforms using containerized microservices</li><li>🧬 <strong>AI/ML</strong> models packaged in containers for reproducibility</li><li>⚙️ <strong>CI/CD pipelines</strong> running tests and builds inside containers</li><li>🖥️ <strong>Legacy applications</strong> modernized using Docker</li></ul><h3>🧭 Getting Started with Docker (Beginner’s Checklist)</h3><p>✅ Install Docker Desktop (Windows/Mac) or Docker Engine (Linux)</p><p>✅ Learn basic CLI commands</p><p>✅ Write your first Dockerfile</p><p>✅ Build and run a container</p><p>✅ Push to Docker Hub</p><p>✅ Use Docker Compose for multi-container apps</p><p>✅ Try deploying with Docker on a cloud server (e.g., DigitalOcean, AWS, GCP)</p><h3>🏁 Final Thoughts</h3><p>Docker isn’t just a buzzword — it’s a foundational tool shaping how software is built, shared, and deployed.</p><p>✅ It simplifies complex environments<br>✅ Boosts developer productivity<br>✅ Powers modern DevOps and cloud-native stacks</p><blockquote><em>💬 If you’re serious about software engineering, DevOps, or backend development in </em><strong><em>2025</em></strong><em>, </em><strong><em>Docker is a must-know skill</em></strong><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cea04fb9c1eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ JSON Web Tokens (JWT) — Everything You Need to Know]]></title>
            <link>https://medium.com/@shivam.soni.webdev/json-web-tokens-jwt-everything-you-need-to-know-47a6c304ab0a?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/47a6c304ab0a</guid>
            <category><![CDATA[security-token]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[json-web-token]]></category>
            <category><![CDATA[jwt]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Fri, 04 Apr 2025 04:45:08 GMT</pubDate>
            <atom:updated>2025-04-04T04:45:08.290Z</atom:updated>
            <content:encoded><![CDATA[<h3>🔐 JSON Web Tokens (JWT) — Everything You Need to Know</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*bCB7hmw4TYOFLrr1.png" /></figure><p>In the age of modern web apps, <strong>secure and efficient communication</strong> between systems is crucial. That’s where <strong>JSON Web Tokens (JWT)</strong> come in. Whether you’re building an API, implementing authentication, or just want to transmit user information securely, JWT is a <strong>go-to standard</strong>. In this blog, we’ll explore <strong>everything about JWT</strong>, from the basics to advanced concepts, so you walk away fully equipped.</p><h3>What is a JSON Web Token (JWT)?</h3><p>A <strong>JSON Web Token (JWT)</strong> is a compact, URL-safe token that securely transmits information between parties as a <strong>JSON object</strong>. These tokens are digitally signed so that the integrity and authenticity of the data can be verified.</p><p>JWTs are:</p><ul><li><strong>Self-contained</strong>: The token itself contains all the necessary data.</li><li><strong>Stateless</strong>: The server doesn’t need to store session data</li><li><strong>Signed</strong>: With HMAC or public/private key pairs.</li></ul><h3>🚦 Why JWT?</h3><p>Here are the two most common scenarios where JWTs shine:</p><h4>1. Authorization</h4><p>After a user logs in, the server issues a JWT. On every subsequent request, the client sends this token — usually in the <strong>Authorization header</strong> — to access protected routes.</p><p>Example:</p><pre>Authorization: Bearer &lt;your_jwt_token&gt;</pre><h4>2. Information Exchange</h4><p>JWTs can be used to <strong>safely transmit information</strong> between parties because they can be <strong>digitally signed</strong> (so you know it’s from the right source) and <strong>verified</strong> (so you know it hasn’t been tampered with).</p><h3>JWT Structure Explained</h3><p>A JWT is made of <strong>three parts</strong>, separated by dots (.):</p><pre>xxxxx.yyyyy.zzzzz</pre><h4>1. Header</h4><p>The header typically consists of two parts: the type of the token (JWT), and the signing algorithm being used, such as HS256 or RS256.</p><pre>{<br>  &quot;alg&quot;: &quot;HS256&quot;,<br>  &quot;typ&quot;: &quot;JWT&quot;<br>}</pre><h4>2. Payload</h4><p>The payload contains the <strong>claims</strong>, which are statements about an entity (typically, the user) and additional metadata.</p><pre>{<br>  &quot;sub&quot;: &quot;1234567890&quot;,<br>  &quot;name&quot;: &quot;Shivam Soni&quot;,<br>  &quot;iat&quot;: 1712176237,<br>  &quot;role&quot;: &quot;admin&quot;<br>}</pre><p>Common claim types:</p><ul><li>iss – issuer</li><li>sub – subject</li><li>iat – issued at</li><li>exp – expiration time</li><li>Store actual token in HTTP-only cookie or encrypted store</li></ul><blockquote>⚠️ The payload is <strong>not encrypted</strong>, just base64-encoded. Never store sensitive data like passwords here.</blockquote><h4>3. Signature</h4><p>The signature is used to verify that the message wasn’t changed along the way. It is created using the <strong>encoded header, payload, and a secret key</strong> or private key.</p><pre>HMACSHA256(<br>  base64UrlEncode(header) + &quot;.&quot; + base64UrlEncode(payload),<br>  secret<br>)</pre><h3>🔐 Where Should You Store JWTs on the Client?</h3><p>Security is <strong>key</strong> when storing JWTs. Here are the options:</p><h4>1. HTTP-Only Cookies ✅ (Recommended)</h4><ul><li>Secure from XSS attacks</li><li>Can be set to expire</li><li>Sent automatically with each request</li></ul><h4>2. Local Storage ❌</h4><ul><li>Persistent</li><li>Vulnerable to XSS attacks</li></ul><h4>3. Session Storage</h4><ul><li>Lives until the tab is closed</li><li>Safer than local storage but still vulnerable to XSS</li></ul><h4>4. Hybrid Approach</h4><ul><li>Store token identifier in cookie</li><li>Store actual token in HTTP-only cookie or encrypted store</li></ul><blockquote><em>Avoid storing JWTs in local/session storage if security is a top concern.</em></blockquote><h3>🛠️ Common Use Cases of JWT</h3><ul><li>User Authentication &amp; Authorization</li><li>API security</li><li>Single Sign-On (SSO)</li><li>Stateless session management</li><li>Mobile app authentication</li></ul><h3>How to Invalidate a JWT?</h3><p>Since JWTs are stateless, invalidating them isn’t as simple as destroying a session. Here are some strategies:</p><h4>1. Short Expiry + Refresh Tokens</h4><p>Set the access token to expire in a short time (e.g., 15 minutes), and issue a refresh token stored securely (e.g., HTTP-only cookie).</p><h4>2. Server-Side Blacklisting</h4><p>Maintain a blacklist of invalidated tokens (by jti claim or user ID). This adds state, which slightly defeats the purpose of JWTs, but works.</p><h4>3. Change Secret Keys</h4><p>If your secret key is compromised, rotate it and all previously issued tokens will be invalid.</p><h3>Final Thoughts</h3><p>JWTs are powerful when used correctly. They bring <strong>performance</strong>, <strong>security</strong>, and <strong>scalability</strong> — but must be implemented wisely to avoid pitfalls. Use them when appropriate, follow best practices, and always consider the security implications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47a6c304ab0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ever Wondered About Redux vs Context API? Here’s the Answer!]]></title>
            <link>https://medium.com/@shivam.soni.webdev/ever-wondered-about-redux-vs-context-api-heres-the-answer-4ec54b2403b9?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ec54b2403b9</guid>
            <category><![CDATA[context]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[context-api]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 14:15:54 GMT</pubDate>
            <atom:updated>2025-04-02T14:15:54.284Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*RnzNU8qASidXf6Su.png" /></figure><p>When I first started learning React, I came across two terms: <strong>Context API</strong> and <strong>Redux</strong>. Both claimed to solve the annoying problem of <strong>prop drilling</strong>, but that left me wondering — if both prevent prop drilling, what’s the difference? Do I really need Redux when Context API exists?</p><p>This confusion stuck with me until I dug deep and explored their real-world use cases. If you’ve had the same question, this blog will clear up the confusion and help you decide which one fits your project best.</p><h3>What is Context API?</h3><p>Context API is a built-in feature of React that allows you to pass data through the component tree without manually passing props at every level.</p><h3>How Context API Works</h3><ol><li>Create a Context using React.createContext().</li><li>Provide a value using a Provider component.</li><li>Consume the value using useContext in child components.</li></ol><h3>Pros of Context API</h3><ul><li>Built into React, so no external library is required.</li><li>Simple to implement for small to medium applications.</li><li>Reduces prop drilling effectively.</li></ul><h3>Cons of Context API</h3><ul><li>Can cause unnecessary re-renders if not optimized.</li><li>Lacks built-in middleware support for handling side effects.</li><li>Debugging can be difficult as it doesn’t have dedicated dev tools.</li></ul><h3>What is Redux?</h3><p>Redux is a state management library that provides a centralized store to manage the entire application’s state predictably.</p><h3>How Redux Works</h3><ol><li>Store: Holds the global state.</li><li>Actions: Define what should happen (e.g., adding an item to the cart).</li><li>Reducers: Determine how the state should change based on the action.</li><li>Dispatch: Sends an action to update the store.</li></ol><h3>Pros of Redux</h3><ul><li>Centralized state management improves maintainability.</li><li>Predictable state updates using pure functions (reducers).</li><li>Redux DevTools provide powerful debugging features.</li><li>Supports middleware (e.g., Redux Thunk, Redux Saga) for handling asynchronous operations.</li></ul><h3>Cons of Redux</h3><ul><li>Requires more boilerplate code than Context API.</li><li>Learning curve can be steep for beginners.</li><li>Overhead for small applications where simpler solutions might work.</li></ul><h3>Key Differences Between Redux and Context API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*fl5-lqFeo256dvqvAXM5Xw.png" /></figure><h3>When to Use Context API?</h3><ul><li>When you need a simple, lightweight solution for state sharing.</li><li>When your app has minimal state management needs.</li><li>When you want to avoid external dependencies.</li></ul><h3>When to Use Redux?</h3><ul><li>When your application has complex state logic.</li><li>When you need predictable state updates and debugging tools.</li><li>When handling asynchronous operations (e.g., API calls) efficiently is required.</li></ul><h3>Final Thoughts</h3><p>Both Redux and Context API have their strengths and weaknesses. If you’re building a small to medium application and want a simple state management solution, Context API is a great choice. However, if your project is large and requires structured, predictable state management, Redux is the better option.</p><p>The key is to choose the right tool for the right job. What has been your experience with Redux and Context API? Let’s discuss in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ec54b2403b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frontend-Only Pagination in React: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@shivam.soni.webdev/frontend-only-pagination-in-react-a-step-by-step-guide-386a229a4787?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/386a229a4787</guid>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Tue, 25 Feb 2025 17:58:04 GMT</pubDate>
            <atom:updated>2025-02-25T17:58:04.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*569nDovJUov-ITJnuI3ggA.png" /></figure><h4>Introduction</h4><p>Pagination is an essential feature for handling large datasets in web applications. Instead of displaying hundreds or thousands of items at once, we break the data into smaller, manageable chunks. While many applications rely on <strong>backend pagination</strong> to fetch only a subset of data, <strong>frontend pagination</strong> can be useful when working with a static dataset or caching large amounts of data client-side.</p><p>In this guide, we’ll build a <strong>frontend-only pagination</strong> system in React using a dataset of 200 products fetched from an API. We’ll also explore how to optimize navigation, improve performance, and enhance user experience.</p><h3>Why Frontend-Only Pagination?</h3><p>Frontend pagination is beneficial when:</p><ul><li>The dataset is <strong>static</strong> or rarely updated.</li><li>You want to <strong>avoid making multiple API calls</strong> for each page.</li><li>Your application needs <strong>fast navigation</strong> between pages without network latency.</li><li>You <strong>cache data</strong> for offline access.</li></ul><p>However, for large-scale applications with real-time updates, <strong>server-side pagination</strong> (fetching a small set of records at a time) is recommended.</p><h3>Setting Up the React Component</h3><p>First, create a new React component called FrontendHeavyPagination.js. This will manage data fetching, pagination logic, and rendering.</p><h4>1. Fetching Data from API</h4><p>We’ll fetch product data from dummyjson.com and store it in state:</p><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>import &#39;../styles/product.css&#39;;<br><br>const FrontendHeavyPagination = () =&gt; {<br>  const Page_Size = 10;<br>  const [data, setData] = useState([]);<br>  const [currentPage, setCurrentPage] = useState(0);<br><br>  const loadDataFetch = async () =&gt; {<br>    const response = await fetch(&quot;https://dummyjson.com/products?limit=200&quot;);<br>    const json = await response.json();<br>    setData(json.products);<br>  };<br><br>  useEffect(() =&gt; {<br>    loadDataFetch();<br>  }, []);</pre><p>Here, useEffect ensures that data is fetched only once when the component mounts.</p><h4>2. Implementing Pagination Logic</h4><p>Pagination requires slicing the dataset and tracking the current page.</p><pre>  const totalProducts = data.length;<br>  const totalPages = Math.ceil(totalProducts / Page_Size);<br>  const start = currentPage * Page_Size;<br>  const end = start + Page_Size;</pre><p>Now, we create <strong>page navigation buttons</strong>:</p><pre>const handlePageClick = (e) =&gt; {<br>    const pageNumber = Number(e.target.textContent);<br>    setCurrentPage(pageNumber - 1);<br>  }<br><br>  const handlePage = (e) =&gt; {<br>    if (e.target.textContent === &#39;&lt;&#39;) {<br>      setCurrentPage((prev) =&gt; prev  - 1);<br>    } else {<br>      setCurrentPage((prev) =&gt; prev + 1);<br>    }<br>  }</pre><h4>3. Rendering the Paginated Data</h4><p>Use the slice() method to display only the current page’s items:</p><pre>return (<br>    &lt;div className=&quot;container&quot;&gt;<br>      &lt;h1 className=&quot;title&quot;&gt;Frontend Heavy Pagination&lt;/h1&gt;<br>      &lt;div className=&#39;pagination-container&#39;&gt;<br>        &lt;button className=&#39;page-number&#39; onClick={handlePage} disabled={currentPage==0}&gt;&amp;lt;&lt;/button&gt;<br>        {[...Array(totalPages).keys()].map((index) =&gt; (<br>          &lt;span key={index} className={&quot;page-number&quot; + (currentPage===index ? &quot; active&quot;:&quot;&quot;)} onClick={handlePageClick}&gt;{index + 1}&lt;/span&gt;<br>        ))}<br>        &lt;button className=&#39;page-number&#39; onClick={handlePage} disabled={currentPage == totalPages-1}&gt;&amp;gt;&lt;/button&gt;<br>      &lt;/div&gt;<br><br>      &lt;div className=&quot;grid&quot;&gt;<br>        {data.slice(start, end).map((product) =&gt; (<br>          &lt;ProductCard key={product.id} title={product.title} image={product.thumbnail} price={product.price} /&gt;<br>        ))}<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};</pre><p>Here, we:</p><ul><li>Display <strong>pagination controls</strong> (previous, next, numbered pages).</li><li>Render <strong>only a subset of products</strong> based on the selected page.</li><li>Highlight the <strong>active page</strong> for better user experience.</li></ul><h4>4. Improving Performance and UX</h4><p>✅ <strong>Active Page Styling</strong>: Highlight the current page with CSS.<br>✅ <strong>Disable Navigation Buttons</strong>: Prevent moving beyond the first or last page.<br>✅ <strong>Optimize Rendering</strong>: If handling thousands of records, consider <strong>virtualized lists</strong> (e.g., React Virtualized or React Window).<br>✅ <strong>Infinite Scrolling</strong>: Instead of pagination buttons, load more products on scroll.</p><h4>5. Key Takeaways</h4><ul><li>Frontend pagination is <strong>fast</strong> and eliminates extra API calls.</li><li>Works best for <strong>static</strong> datasets or cached data.</li><li>Performance optimizations are necessary for <strong>very large datasets</strong>.</li><li><strong>Consider backend pagination</strong> if data is dynamic and constantly changing</li></ul><h4>Conclusion</h4><p>In this guide, we built a <strong>fully functional frontend pagination system</strong> in React using the useState and useEffect hooks. We also optimized the UI for better navigation and user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=386a229a4787" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Implement CRUD in React Native with SQLite (Step-by-Step Guide)]]></title>
            <link>https://medium.com/@shivam.soni.webdev/how-to-implement-crud-in-react-native-with-sqlite-step-by-step-guide-843a8e1d7777?source=rss-8a4806b9091a------2</link>
            <guid isPermaLink="false">https://medium.com/p/843a8e1d7777</guid>
            <category><![CDATA[database-management]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native-sqlite]]></category>
            <category><![CDATA[crud-operations]]></category>
            <category><![CDATA[localstorage]]></category>
            <dc:creator><![CDATA[Shivam Soni ]]></dc:creator>
            <pubDate>Sun, 23 Feb 2025 10:51:56 GMT</pubDate>
            <atom:updated>2025-02-25T18:01:31.693Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QG3GG7fymfFTCO-ZuUVgYQ.png" /></figure><h3>Introduction</h3><p>Managing local data efficiently is crucial for mobile applications, especially when offline functionality is required. <strong>SQLite</strong> is a lightweight, fast, and reliable database widely used in mobile development. In this guide, we’ll explore how to integrate <strong>SQLite</strong> in a React Native app and implement <strong>Create, Read, Update, and Delete (CRUD)</strong> operations using the react-native-sqlite-storage package.</p><p>By the end of this tutorial, you’ll have a working CRUD implementation and an understanding of best practices for handling local storage in React Native.</p><h3>1. Setting Up SQLite in React Native</h3><h4>Install SQLite Package</h4><p>To use SQLite in a React Native project, install the react-native-sqlite-storage package:</p><pre>npm install react-native-sqlite-storage</pre><p>For iOS, you may need to run:</p><pre>cd ios &amp;&amp; pod install</pre><h3>2. Creating a Database and Table</h3><h4>Opening the Database Connection</h4><p>Create a utility file database.js to initialize the SQLite database:</p><pre>import SQLite from &#39;react-native-sqlite-storage&#39;;<br><br>const db = SQLite.openDatabase(<br>  { name: &#39;users.db&#39;, location: &#39;default&#39; },<br>  () =&gt; console.log(&#39;Database opened&#39;),<br>  error =&gt; console.log(&#39;Error opening database&#39;, error)<br>);<br><br>export default db;</pre><h4>Creating a Table</h4><p>Use the following function to create a table for storing users:</p><pre>const createTable = () =&gt; {<br>  db.transaction(tx =&gt; {<br>    tx.executeSql(<br>      &#39;CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, email TEXT);&#39;<br>    );<br>  });<br>};<br><br>export { createTable };</pre><p>Call createTable() when the app starts to ensure the table exists.</p><h3>3. Implementing CRUD Operations</h3><h4>a. Inserting Data (Create)</h4><pre>const addUser = (name, email) =&gt; {<br>  db.transaction(tx =&gt; {<br>    tx.executeSql(&#39;INSERT INTO users (name, email) VALUES (?, ?);&#39;, [name, email],<br>      () =&gt; console.log(&#39;User added&#39;),<br>      error =&gt; console.log(&#39;Error adding user&#39;, error)<br>    );<br>  });<br>};</pre><h4>b. Fetching Data (Read)</h4><pre>const getUsers = callback =&gt; {<br>  db.transaction(tx =&gt; {<br>    tx.executeSql(&#39;SELECT * FROM users;&#39;, [],<br>      (_, results) =&gt; callback(results.rows.raw()),<br>      error =&gt; console.log(&#39;Error fetching users&#39;, error)<br>    );<br>  });<br>};</pre><h4>c. Updating Data (Update)</h4><pre>const addUser = (name, email) =&gt; {<br>  db.transaction(tx =&gt; {<br>    tx.executeSql(&#39;INSERT INTO users (name, email) VALUES (?, ?);&#39;, [name, email],<br>      () =&gt; console.log(&#39;User added&#39;),<br>      error =&gt; console.log(&#39;Error adding user&#39;, error)<br>    );<br>  });<br>};</pre><h4>d. Deleting Data (Delete)</h4><pre>const deleteUser = id =&gt; {<br>  db.transaction(tx =&gt; {<br>    tx.executeSql(&#39;DELETE FROM users WHERE id = ?;&#39;, [id],<br>      () =&gt; console.log(&#39;User deleted&#39;),<br>      error =&gt; console.log(&#39;Error deleting user&#39;, error)<br>    );<br>  });<br>};</pre><h3>4. Displaying Data in the UI</h3><p>Use the FlatList component to display fetched users:</p><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>import { View, Text, FlatList, Button } from &#39;react-native&#39;;<br>import { getUsers, deleteUser } from &#39;./database&#39;;<br><br>const UsersList = () =&gt; {<br>  const [users, setUsers] = useState([]);<br><br>  useEffect(() =&gt; {<br>    getUsers(setUsers);<br>  }, []);<br><br>  return (<br>    &lt;View&gt;<br>      &lt;FlatList<br>        data={users}<br>        keyExtractor={item =&gt; item.id.toString()}<br>        renderItem={({ item }) =&gt; (<br>          &lt;View&gt;<br>            &lt;Text&gt;{item.name} - {item.email}&lt;/Text&gt;<br>            &lt;Button title=&quot;Delete&quot; onPress={() =&gt; deleteUser(item.id)} /&gt;<br>          &lt;/View&gt;<br>        )}<br>      /&gt;<br>    &lt;/View&gt;<br>  );<br>};<br><br>export default UsersList;</pre><h3>5. Best Practices for Using SQLite in React Native</h3><ul><li><strong>Use transactions</strong> to ensure atomic operations.</li><li><strong>Close database connections</strong> when not needed to free up resources.</li><li><strong>Handle errors properly</strong> to prevent unexpected crashes.</li><li><strong>Optimize queries</strong> for better performance with indexing and batching.</li></ul><h3>Conclusion</h3><p>In this guide, we implemented CRUD operations using <strong>SQLite</strong> in React Native. We covered:</p><p>✔ Setting up SQLite in a React Native app.<br>✔ Creating a database and tables.<br>✔ Implementing Create, Read, Update, and Delete operations.<br>✔ Displaying data using FlatList.<br>✔ Best practices for handling SQLite efficiently.</p><p>As a next step, consider <strong>syncing SQLite with an external API</strong> to persist data beyond the device. If you found this guide helpful, share your thoughts in the comments or ask questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=843a8e1d7777" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>