<?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 Shivani Chaudhari on Medium]]></title>
        <description><![CDATA[Stories by Shivani Chaudhari on Medium]]></description>
        <link>https://medium.com/@iam.shivanic?source=rss-8c33016012b2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fwhazO4lCjb3GkmLcn2NYQ.png</url>
            <title>Stories by Shivani Chaudhari on Medium</title>
            <link>https://medium.com/@iam.shivanic?source=rss-8c33016012b2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:31:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iam.shivanic/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[Build Custom MCP Tools for ChatGPT in Minutes]]></title>
            <link>https://medium.com/@iam.shivanic/build-custom-mcp-tools-for-chatgpt-in-minutes-f201d46cfba9?source=rss-8c33016012b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/f201d46cfba9</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <category><![CDATA[mcp-protocol]]></category>
            <dc:creator><![CDATA[Shivani Chaudhari]]></dc:creator>
            <pubDate>Thu, 21 May 2026 07:30:07 GMT</pubDate>
            <atom:updated>2026-05-21T07:32:27.647Z</atom:updated>
            <content:encoded><![CDATA[<p>AI is evolving from simple chatbots into powerful assistants that can interact with APIs, databases, and business systems. One of the easiest ways to connect external tools with AI is through the <strong>Model Context Protocol (MCP)</strong>.</p><blockquote>In this blog, we’ll build a simple custom MCP tool and connect it to ChatGPT.</blockquote><h3>What is MCP?</h3><p>MCP (Model Context Protocol) is a standard that allows AI models like ChatGPT to communicate with external tools and services.</p><p>With MCP, your AI assistant can:</p><ul><li>Call APIs</li><li>Fetch live data</li><li>Execute workflows</li><li>Interact with databases</li><li>Use custom business logic</li><li>Query your database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*0eAsEy2xe5ZaNjKdzMG3mQ.png" /></figure><h3>Example: Create a Simple MCP Tool</h3><p>Step 1. Install uv and Create Virtual Environment.</p><pre># Install uv<br>pip install uv <br><br># Initialize uv project<br>uv init<br><br># Create Virtual Environment<br>uv venv<br><br># Activate Virtual environment<br>source .venv/bin/activate   # Mac/Linux<br>.venv\Scripts\activate    # Windows<br><br># Install packages and sync<br>uv add mcp httpx<br>uv sync</pre><p>Step 2. Create MCP Server</p><pre># create server.py file<br>import os<br>from datetime import datetime<br><br>import httpx<br>from mcp.server.fastmcp import FastMCP<br>from mcp.server.transport_security import TransportSecuritySettings<br><br><br># ---------------------------------------------------------------------------<br># Server configuration<br># ---------------------------------------------------------------------------<br>_host = os.environ.get(&quot;HOST&quot;, &quot;127.0.0.1&quot;)<br>_port = int(os.environ.get(&quot;PORT&quot;, &quot;8000&quot;))<br><br>mcp = FastMCP(<br>    &quot;simple-mcp&quot;,<br>    host=_host,<br>    port=_port,<br>    transport_security=TransportSecuritySettings(<br>        enable_dns_rebinding_protection=False<br>    ),<br>)<br><br>@mcp.tool()<br>async def current_weather(location: str) -&gt; dict:<br>    &quot;&quot;&quot;<br>    Fetch the current weather for any location using two chained free APIs.<br><br>    Args:<br>        location (str): City or place name to look up.<br>                        Examples: &#39;Tokyo&#39;, &#39;New York&#39;, &#39;Mumbai&#39;, &#39;Paris&#39;<br>                        Partial names work (e.g. &#39;London&#39; resolves to<br>                        &#39;London, United Kingdom&#39;).<br>                        No API key required.<br><br>    Returns:<br>        dict: A dictionary with the following keys:<br>            location      (str)   — Resolved city name + country<br>                                    e.g. &quot;Mumbai, India&quot;<br>            latitude      (float) — Geographic latitude of the city<br>            longitude     (float) — Geographic longitude of the city<br>            time          (str)   — Timestamp of the weather reading (ISO 8601)<br>            temperature_2m (float)— Air temperature at 2 metres above ground<br>            wind_speed_10m (float)— Wind speed at 10 metres above ground<br>            units (dict):<br>                temperature (str) — Unit for temperature, default &quot;°C&quot;<br>                wind_speed  (str) — Unit for wind speed, default &quot;km/h&quot;<br><br>    Raises:<br>        ValueError: If the location string does not match any known place<br>                    in the Open-Meteo geocoding database.<br>        httpx.HTTPStatusError: If either upstream API returns a non-2xx<br>                               HTTP status code.<br><br>    Internal flow:<br>        Step 1 — Geocoding API (geocoding-api.open-meteo.com):<br>                 Converts location name → latitude + longitude.<br>        Step 2 — Forecast API (api.open-meteo.com):<br>                 Uses lat/lon to fetch current temperature and wind speed.<br><br>    Example:<br>        AI prompt  : &quot;What&#39;s the weather in Tokyo right now?&quot;<br>        Tool call  : current_weather(location=&quot;Tokyo&quot;)<br>        Response   : {<br>                       &quot;location&quot;: &quot;Tokyo, Japan&quot;,<br>                       &quot;latitude&quot;: 35.6895,<br>                       &quot;longitude&quot;: 139.6917,<br>                       &quot;time&quot;: &quot;2026-05-05T14:00&quot;,<br>                       &quot;temperature_2m&quot;: 22.3,<br>                       &quot;wind_speed_10m&quot;: 11.5,<br>                       &quot;units&quot;: {&quot;temperature&quot;: &quot;°C&quot;, &quot;wind_speed&quot;: &quot;km/h&quot;}<br>                     }<br>    &quot;&quot;&quot;<br>    async with httpx.AsyncClient() as client:<br>        # Step 1: resolve city name → lat/lon<br>        geo = await client.get(<br>            &quot;https://geocoding-api.open-meteo.com/v1/search&quot;,<br>            params={&quot;name&quot;: location, &quot;count&quot;: 1, &quot;language&quot;: &quot;en&quot;, &quot;format&quot;: &quot;json&quot;},<br>            timeout=10,<br>        )<br>        geo.raise_for_status()<br>        results = geo.json().get(&quot;results&quot;)<br>        if not results:<br>            raise ValueError(f&quot;Location &#39;{location}&#39; not found&quot;)<br><br>        lat = results[0][&quot;latitude&quot;]<br>        lon = results[0][&quot;longitude&quot;]<br>        resolved_name = results[0].get(&quot;name&quot;, location)<br>        country = results[0].get(&quot;country&quot;, &quot;&quot;)<br><br>        # Step 2: fetch current weather using the resolved coordinates<br>        weather = await client.get(<br>            &quot;https://api.open-meteo.com/v1/forecast&quot;,<br>            params={<br>                &quot;latitude&quot;: lat,<br>                &quot;longitude&quot;: lon,<br>                &quot;current&quot;: &quot;temperature_2m,wind_speed_10m&quot;,<br>                &quot;hourly&quot;: &quot;temperature_2m,relative_humidity_2m,wind_speed_10m&quot;,<br>            },<br>            timeout=10,<br>        )<br>        weather.raise_for_status()<br>        data = weather.json()<br><br>    current = data.get(&quot;current&quot;, {})<br>    current_units = data.get(&quot;current_units&quot;, {})<br>    return {<br>        &quot;location&quot;: f&quot;{resolved_name}, {country}&quot;.strip(&quot;, &quot;),<br>        &quot;latitude&quot;: lat,<br>        &quot;longitude&quot;: lon,<br>        &quot;time&quot;: current.get(&quot;time&quot;),<br>        &quot;temperature_2m&quot;: current.get(&quot;temperature_2m&quot;),<br>        &quot;wind_speed_10m&quot;: current.get(&quot;wind_speed_10m&quot;),<br>        &quot;units&quot;: {<br>            &quot;temperature&quot;: current_units.get(&quot;temperature_2m&quot;, &quot;°C&quot;),<br>            &quot;wind_speed&quot;: current_units.get(&quot;wind_speed_10m&quot;, &quot;km/h&quot;),<br>        },<br>    }<br><br># ---------------------------------------------------------------------------<br># Server entrypoint<br># ---------------------------------------------------------------------------<br>if __name__ == &quot;__main__&quot;:<br>    mcp.run()</pre><p>Step 3. Run with uv and expose via ngrok</p><pre>uv run python server.py<br># MCP server running on http://localhost:3000<br><br>ngrok http 8000 # <br># You will get https://xxxxx.ngrok-free.app</pre><p>Step 4. Add your custom tool in ChatGPT</p><pre>1)  Open ChatGPT<br>2) Go to Settings<br>→ Apps / Connectors / Developer Tools<br>→ MCP Servers<br>3) Click Add MCP Server<br>4) Add the ngrok URL<br>5) Restart ChatGPT (if required)<br>6) Test in chat:<br>E.g. Get weather in Mumbai</pre><h3>🧠 How It Works Internally</h3><p><strong>User Prompt</strong> →<strong> ChatGPT decides tool</strong> → <strong>MCP call over ngrok </strong>→<strong> FastMCP </strong>→<strong> Server executes Python function </strong>→<strong> Response returned to ChatGPT</strong></p><p><em>When a user asks something, ChatGPT can decide to call a tool exposed through your MCP server.</em></p><p>So, you can create your own tools, connect them through MCP, and turn ChatGPT into a system that not only talks — but actually gets things done.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f201d46cfba9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating SSL Certificates for Secure Apache Kafka (CA, Broker & Client Keys)]]></title>
            <link>https://medium.com/@iam.shivanic/creating-ssl-certificates-for-secure-apache-kafka-ca-broker-client-keys-4670d32f936b?source=rss-8c33016012b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4670d32f936b</guid>
            <category><![CDATA[ca-certificates]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[broker]]></category>
            <category><![CDATA[truststore]]></category>
            <category><![CDATA[kafka-ssl-certificates]]></category>
            <dc:creator><![CDATA[Shivani Chaudhari]]></dc:creator>
            <pubDate>Fri, 08 May 2026 13:31:00 GMT</pubDate>
            <atom:updated>2026-05-08T13:31:00.562Z</atom:updated>
            <content:encoded><![CDATA[<p>Securing a Kafka cluster is essential when running production-grade event streaming systems. SSL/TLS ensures encrypted communication, while SASL adds authentication on top of it. In most secure setups, Kafka uses <strong>SASL_SSL</strong> for both encryption and identity verification.</p><p>This guide walks through a simple and practical way to generate certificates using <strong>OpenSSL</strong> and prepare them for Kafka brokers and clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*JFu3hp7UNDYVR-8E4P37DA.png" /></figure><h4><strong>Step 1: Create Certificate Authority (CA)</strong></h4><p>The CA signs all Kafka certificates.</p><pre># Generate CA private key<br>openssl genrsa -out ca.key 4096<br><br># Create CA certificate<br>openssl req -new -x509 -key ca.key -out ca.crt -days 3650</pre><h4>Step 2: Create Broker Certificate</h4><p>Each broker MUST have a unique certificate and sign broker certificates with CA.</p><pre># Generate broker private key<br>openssl genrsa -out broker1.key 2048<br><br># Create CSR<br>openssl req -new -key broker1.key -out broker1.csr -subj &quot;/CN=broker1&quot;<br><br># Sign broker certificate with CA<br>openssl x509 -req -in broker1.csr \<br>  -CA ca.crt -CAkey ca.key -CAcreateserial \<br>  -out broker1.crt -days 1095</pre><h4>Step 3: Create Client Certificate</h4><p>Clients also need certificates to connect securely.</p><pre># Generate client key<br>openssl genrsa -out client.key 2048<br><br># Create CSR<br>openssl req -new -key client.key -out client.csr -subj &quot;/CN=kafka-client&quot;<br><br># Sign with CA<br>openssl x509 -req -in client.csr \<br>  -CA ca.crt -CAkey ca.key -CAcreateserial \<br>  -out client.crt -days 730</pre><h4>Step 4: Convert to Keystore &amp; Truststore</h4><p>Kafka (Java-based) requires JKS or PKCS12 format.</p><ol><li>Convert Broker Certificate to PKCS12</li></ol><pre>openssl pkcs12 -export \<br>  -in broker1.crt -inkey broker1.key \<br>  -out broker1.p12 \<br>  -name broker1 \<br>  -CAfile ca.crt -caname root -chain</pre><p>2. Import into Java Keystore</p><pre>keytool -importkeystore \<br>  -destkeystore broker1.keystore.jks \<br>  -srckeystore broker1.p12 \<br>  -srcstoretype PKCS12 \<br>  -alias broker1</pre><p>3. Create Truststore (CA Certificate)</p><pre># For Brokers<br>keytool -import \<br>  -alias CARoot \<br>  -file ca.crt \<br>  -keystore broker.truststore.jks \<br>  -noprompt<br><br><br># For Clients<br>keytool -import \<br>  -alias CARoot \<br>  -file ca.crt \<br>  -keystore client.truststore.jks \<br>  -noprompt</pre><h4>Step 5: Verification</h4><p>To confirm certificates are correctly imported:</p><pre>keytool -list -v -keystore ca.truststore.jks</pre><p><strong>📁 Project Structure</strong> — A typical secure Kafka setup stores all credentials and stores in a structured directory:</p><pre>kafka-secure/<br>├── ca/<br>│   ├── ca.key<br>│   ├── ca.crt<br>│   └── ca.srl<br>│<br>├── brokers/<br>│   ├── broker1/<br>│   │   ├── broker1.key<br>│   │   ├── broker1.crt<br>│   │   ├── broker1.p12<br>│   │   └── broker1.keystore.jks<br>│   │<br>│   └── broker2/<br>│       ├── ...<br>│<br>├── clients/<br>│   ├── client.key<br>│   ├── client.crt<br>│   ├── client.p12<br>│   └── client.keystore.jks<br>│<br>├── truststores/<br>│   ├── broker.truststore.jks<br>│   ├── client.truststore.jks<br>│<br>└── secrets/<br>    └── creds.txt</pre><p>⏳<strong>Certificate Validity Guidelines<br></strong>CA Certificate: 5–10 years<br>Broker Certificate: 1–3 years<br>Client Certificate: 1–2 years</p><p><strong>🔒 Final Thoughts — </strong>With these steps, you now have:</p><ul><li>A trusted <strong>Certificate Authority (CA)</strong></li><li>Secure <strong>broker certificates</strong></li><li>Secure <strong>client certificates</strong></li><li>Proper keystore &amp; truststore configuration</li></ul><p>This forms the foundation for enabling <strong>SSL/TLS encrypted Kafka communication</strong>, which can later be extended with <strong>SASL authentication for stronger security</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4670d32f936b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Environment Schemes in Xcode for React Native]]></title>
            <link>https://medium.com/@iam.shivanic/managing-environment-schemes-in-xcode-for-react-native-e71914f574ce?source=rss-8c33016012b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e71914f574ce</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[scheme-configuration]]></category>
            <category><![CDATA[xcode-scheme]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Shivani Chaudhari]]></dc:creator>
            <pubDate>Wed, 29 Apr 2026 13:31:01 GMT</pubDate>
            <atom:updated>2026-04-29T13:31:01.440Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Streamline your iOS workflow without juggling multiple environment files.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*9qtTVVsaVpB_-KR7dGgRQg.png" /></figure><p>Most React Native apps need multiple environments like <strong>Dev, UAT, and Prod</strong>, but managing separate <em>.env</em> files can quickly become messy and hard to maintain.</p><p>A cleaner approach is to use <strong>Xcode schemes to switch environments</strong>, while keeping <strong>just one <em>.env</em> file</strong> as the single source of configuration. This keeps your setup simple, avoids duplication, and makes builds easier to manage.</p><p>In this blog, we’ll set up a practical workflow where Xcode handles environment switching and React Native reads the correct values dynamically.</p><h4><strong>📁 Step 1: Create .env File</strong></h4><p>Place this in your project root. Store all three environments together — the scheme will tell the app which one to use at runtime.</p><pre># Dev environment<br>DEV_API_URL=https://dev.api.com<br><br># UAT environment<br>UAT_API_URL=https://uat.api.com<br><br># Production environment<br>PROD_API_URL=https://api.com<br><br># This gets overridden by the Xcode scheme<br>APP_ENV=dev</pre><h4><strong>📦 Step 2: Install Config Library</strong></h4><pre>npm install react-native-config<br>cd ios &amp;&amp; pod install</pre><h4><strong>🧱 Step 3: Create Schemes in Xcode</strong></h4><ol><li>Xcode already has <strong>Debug</strong> and <strong>Release</strong> by default</li><li>Open scheme selector → <strong>Manage Schemes</strong></li><li>Duplicate scheme and rename to <strong>Dev, UAT, Prod</strong></li></ol><ul><li>App-Dev → uses <strong>Debug configuration</strong></li><li>App-UAT → uses <strong>Debug configuration (optional separate mapping)</strong></li><li>App-Prod → uses <strong>Release configuration</strong></li></ul><p>4. Map <strong>Debug → Dev/UAT</strong> and <strong>Release → Prod</strong></p><p>5. This allows you to reuse Xcode’s default setup while still controlling environments through schemes and .env logic.</p><h4>🔗 Step 4: Set Environment Variable per Scheme</h4><ol><li>Choose your scheme (Dev / UAT / Prod) and click <strong>Edit</strong></li><li>Go to <strong>Run → Arguments tab</strong><br>Under Environment Variables, add a new variable:<br>Key: ENVFILE<br>Value: .env</li><li>(Optional but recommended) Under Environment Variables, add a new variable:<br><strong>Key</strong>: APP_ENV<br><strong>Value</strong>: dev / uat / prod depending on scheme</li><li>Repeat the same setup for each scheme</li><li>Ensure each scheme has the correct APP_ENV value to identify the environment at runtime</li></ol><h4>🧠 Step 5: Handle Logic in React Native</h4><pre>import Config from &#39;react-native-config&#39;;<br><br>const getApiUrl = () =&gt; {<br>  switch (Config.APP_ENV) {<br>    case &#39;dev&#39;:<br>      return Config.DEV_API_URL;    // https://dev.api.com<br>    case &#39;uat&#39;:<br>      return Config.UAT_API_URL;    // https://uat.api.com<br>    case &#39;prod&#39;:<br>      return Config.PROD_API_URL;   // https://api.com<br>    default:<br>      return Config.DEV_API_URL;    // safe fallback<br>  }<br>};<br><br>export default {<br>  API_URL: getApiUrl(),<br>  ENV: Config.APP_ENV,<br>};</pre><h4>🧪 Step 6: Test Each Scheme</h4><pre>import Config from &#39;react-native-config&#39;;<br>import AppConfig from &#39;./config&#39;;<br><br>// Drop this in App.tsx on startup:<br>console.log(&#39;ENV:&#39;, Config.APP_ENV);<br>console.log(&#39;API:&#39;, AppConfig.API_URL);</pre><h4>💡 Real-World Best Practices</h4><ol><li><strong>Use Different App Names per Scheme</strong> — <br>In <em>Info.plist</em>, set distinct display names like <em>MyApp Dev</em>, <em>MyApp UAT</em>, and <em>MyApp</em>. This makes it immediately clear which build is installed on the device.</li><li><strong>Add Visual Indicators</strong> — <br>Use<em> Config.APP_ENV </em>to adjust UI elements such as theme color: red for Dev, yellow for UAT, and default styling for Prod. This helps prevent accidental testing on production builds.</li><li><strong>Keep It Extendable</strong> — <br>This single <em>.env</em> setup scales well. If your project grows, you can later split into <em>.env.dev</em> and <em>.env.prod</em> files and simply update the <em>ENVFILE </em>in each scheme—without changing your app structure.</li></ol><blockquote>Hope this helps you build cleaner, more structured React Native apps with less confusion and better control over Dev, UAT, and Prod environments.</blockquote><blockquote><strong><em>Happy coding 🚀</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e71914f574ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Git Submodules: How to Create, Manage, and Master Them]]></title>
            <link>https://medium.com/@iam.shivanic/git-submodules-how-to-create-manage-and-master-them-1403d5802647?source=rss-8c33016012b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/1403d5802647</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[submodules]]></category>
            <category><![CDATA[gitsubmodule]]></category>
            <category><![CDATA[advance-git]]></category>
            <category><![CDATA[git-workflow]]></category>
            <dc:creator><![CDATA[Shivani Chaudhari]]></dc:creator>
            <pubDate>Thu, 29 May 2025 06:50:14 GMT</pubDate>
            <atom:updated>2025-05-29T06:50:14.098Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*ApBO-CsklBJNo7_ucYRNqg.png" /></figure><p>If you’ve ever found yourself needing to include one Git repository inside another — say, a library, dependency, or a shared module — you’ll want to get familiar with <strong>Git Submodules</strong>. Submodules allow you to keep another Git repository as a subdirectory of your own project. This lets you clone and pull updates independently, which is perfect for shared codebases or decoupled components.</p><p>In this article, you’ll learn how to <strong>create, manage, and remove Git submodules</strong> — step by step.</p><h3>🔧 Step 1: Initialize Your Main Repository</h3><p>If you don’t already have a Git project, you’ll need to create one:</p><pre>mkdir my-main-project &amp;&amp; cd my-main-project<br>git init<br>echo &quot;# My Main Project&quot; &gt; README.md<br>git add README.md<br>git commit -m &quot;Initial commit&quot;</pre><h3>➕ <strong>Step 2: Add a Git Submodule</strong></h3><p>To add an external repository as a submodule, run:</p><pre># git submodule add &lt;repository_url&gt; &lt;path/to/submodule&gt;<br>git submodule add https://github.com/example/repo.git libs/repo<br><br># Now, Commit the changes<br>git add .gitmodules libs/repo<br>git commit -m &quot;Add submodule for external repo&quot;</pre><p>This does two things:</p><ol><li>Adds the repo under libs/repo</li><li>Creates a .gitmodules file with metadata about the submodule</li></ol><h3>🔄 Step 3: Initialize and Update the Submodule</h3><p>After adding or cloning a repo with submodules, you need to fetch the actual submodule contents:</p><pre>git submodule init<br>git submodule update</pre><h3>⛓ Step 4: Clone a Repository With Submodules</h3><p>If someone clones your repository, they should use the --recurse-submodules flag:</p><pre>git clone --recurse-submodules &lt;repository_url&gt;<br><br># If already cloned<br>git submodule update --init --recursive</pre><h3>✏️ Step 5: Work With the Submodule</h3><p>Submodules are just regular Git repositories inside your main project. You can work in them independently.</p><pre>cd libs/repo   # Enter submodule<br><br># Make changes<br>git add .<br>git commit -m &quot;Made changes inside submodule&quot; # Commit inside submodule<br>git push origin master  # Or the correct branch<br><br># Then, update the reference in your main project:<br>cd .. # Return to main repo<br>git add libs/repo<br>git commit -m &quot;Update submodule reference&quot; # Commit submodule update<br>git push</pre><h3>⬆️ Step 6: Update Submodule to the Latest Commit</h3><p>To pull the latest changes from the submodule’s remote:</p><pre>cd libs/repo<br>git fetch                          # Get latest<br>git checkout master                # Switch branch (if needed)<br>git pull origin master             # Pull latest changes<br><br># Then update the reference in the main repo<br>cd ..<br>git add libs/repo<br>git commit -m &quot;Update submodule&quot;  # Sync with latest<br>git push</pre><h3>❌ Step 7: Remove a Submodule</h3><p>Need to delete a submodule? Follow these steps:</p><pre>git submodule deinit -f libs/repo<br>git rm -f libs/repo<br>rm -rf .git/modules/libs/repo<br>git commit -m &quot;Remove submodule&quot;</pre><h3>✨ Benefits of Git Submodules</h3><ul><li><strong>Isolated Repositories: </strong>Keep external code (like libraries or plugins) separate and version-controlled.</li><li><strong>Independent Updates: </strong>Submodules point to specific commits — no surprises from upstream changes unless you update intentionally.</li><li><strong>Reuse Shared Code: </strong>Share modules (like SDKs, UI components, etc.) across multiple projects.</li><li><strong>Clean Project Structure: </strong>Submodules live in their own folders — no code copy-pasting needed.</li><li>📜 <strong>History Integrity: </strong>Submodule changes don’t clutter your main repo’s commit history.</li></ul><h3>✅ Conclusion</h3><p>Git submodules are a powerful way to manage external dependencies in your project. They keep things organized and version-controlled — perfect for shared libraries or decoupled components.</p><p>💡 Just keep in mind: submodules <strong>lock to specific commits</strong>, not branches. That means no surprise updates — but also, updates won’t happen unless <strong>you pull them in manually</strong> (or automate it with a script).</p><p>In short, Use them when you want control and avoid them if you want continuous updates without extra steps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1403d5802647" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From useEffect to useQuery: Modernising React Data Fetching.]]></title>
            <link>https://medium.com/@iam.shivanic/from-useeffect-to-usequery-modernising-react-data-fetching-9bde1fb0e422?source=rss-8c33016012b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bde1fb0e422</guid>
            <category><![CDATA[data-fetching]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[tanstack-query]]></category>
            <category><![CDATA[react-query]]></category>
            <dc:creator><![CDATA[Shivani Chaudhari]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 07:28:15 GMT</pubDate>
            <atom:updated>2025-04-03T07:32:46.488Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Simplify data fetching in React by switching from useEffect to useQuery with React Query.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ii_EkmeOje7M8f-ghMydtA.png" /></figure><p><strong>In </strong>modern React development, fetching data is a common task for most apps. Traditionally, developers have used the <strong>useEffect</strong> hook to handle side effects like API requests. While this method works, it can get tricky and hard to manage as your app grows. That&#39;s where React Query comes in – a library that makes data fetching simpler.</p><p>In this blog post, we’ll compare <strong>useEffect</strong> with <strong>useQuery</strong> from React Query, highlighting the advantages of adopting <strong>useQuery</strong> for a more efficient and scalable approach to data fetching.</p><h3><strong>Traditional Data Fetching with useEffect</strong></h3><p>Before React Query, the most common approach to fetching data was using the useEffect hook in combination with fetch or axios. Here’s how a typical data-fetching scenario would look with useEffect:</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>const DataFetcher = () =&gt; {<br>  const [data, setData] = useState(null);<br>  const [loading, setLoading] = useState(true);<br>  const [error, setError] = useState(null);<br><br>  useEffect(() =&gt; {<br>    // API call<br>    const fetchData = async () =&gt; {<br>      try {<br>        const response = await fetch(&#39;https://api.example.com/data&#39;);<br>        const result = await response.json();<br>        setData(result);<br>      } catch (err) {<br>        setError(err);<br>      } finally {<br>        setLoading(false);<br>      }<br>    };<br><br>    fetchData();<br>  }, []); <br><br>  if (loading) return &lt;div&gt;Loading...&lt;/div&gt;;<br>  if (error) return &lt;div&gt;Error: {error.message}&lt;/div&gt;;<br><br>  return &lt;div&gt;Data: {JSON.stringify(data)}&lt;/div&gt;;<br>};<br><br>export default DataFetcher;</pre><h4><strong>Challenges with the useEffect Approach:</strong></h4><p>While useEffect works for simple cases, it can get complicated as your app grows. Here are some common issues:</p><ul><li><strong>Repetitive Code:</strong> You end up repeating the same logic for loading, error handling, and updating data.</li><li><strong>Manual Caching:</strong> You have to manually manage caching, invalidation, and refetching, which can cause bugs and extra network requests.</li><li><strong>Global State Management:</strong> Sharing data between multiple components becomes difficult.</li><li><strong>Pagination and Infinite Scrolling:</strong> Handling paginated data or infinite scrolling can get complex.</li></ul><h4><strong>So, What’s the Alternative?</strong></h4><p>This is where React Query comes in. It simplifies data fetching by handling caching, pagination, refetching, and syncing data across components, all with an easy-to-use API.</p><p><strong>1. Getting</strong> <strong>Started</strong> <strong>with</strong> <strong>React</strong> <strong>Query by installing dependency</strong></p><pre>npm install @tanstack/react-query</pre><p><strong>2. Setup React Query Provider</strong></p><pre>import React from &quot;react&quot;;<br>import { QueryClient, QueryClientProvider } from &quot;@tanstack/react-query&quot;;<br>import { SafeAreaView } from &quot;react-native&quot;;<br>import RQDemoComponent from &quot;./RQDemoComponent&quot;;<br><br>const queryClient = new QueryClient();<br><br>const App = () =&gt; {<br>  return (<br>    &lt;QueryClientProvider client={queryClient}&gt;<br>      &lt;SafeAreaView style={{ flex: 1 }}&gt;<br>        &lt;RQDemoComponent /&gt;<br>      &lt;/SafeAreaView&gt;<br>    &lt;/QueryClientProvider&gt;<br>  );<br>};<br><br>export default App;</pre><p><strong>3. Implementing</strong> <strong>React</strong> <strong>Query</strong></p><pre>// RQDemoComponent.js<br>import React from &quot;react&quot;;<br>import { View, Text, FlatList, ActivityIndicator, Button} from &quot;react-native&quot;;<br>import { useInfiniteQuery } from &quot;@tanstack/react-query&quot;;<br>import axios from &quot;axios&quot;;<br><br>// Function to fetch paginated posts<br>const fetchPosts = async ({ pageParam = 1 }) =&gt; {<br>  try {<br>    const response = await axios.get(<br>      `https://jsonplaceholder.typicode.com/posts?_limit=5&amp;_page=${pageParam}`<br>    );<br><br>    return {<br>      data: response.data,<br>      nextPage: response.data.length ? pageParam + 1 : undefined, // If no more data, nextPage is undefined<br>    };<br>  } catch (error) {<br>    throw new Error(&quot;Network Error: Unable to fetch posts.&quot;);<br>  }<br>};<br><br>const RQDemoComponent = () =&gt; {<br>  // useInfiniteQuery fetches data in pages and manages infinite scrolling<br>  const {<br>    data, // Contains all fetched pages<br>    fetchNextPage, // Function to fetch the next page<br>    hasNextPage, // Boolean indicating if more pages are available<br>    isFetchingNextPage, // Boolean indicating if new data is being fetched<br>    isLoading, // Boolean for initial loading state<br>    isError, // Boolean for error state<br>    error, // Contains error message if request fails<br>    refetch, // Function to retry fetching data<br>  } = useInfiniteQuery({<br>    queryKey: [&quot;posts&quot;], // Caches data based on this key<br>    queryFn: fetchPosts, // Function that fetches data<br>    getNextPageParam: (lastPage) =&gt; lastPage.nextPage, // Determines next page<br>    staleTime: 5000, // Cache data for 5 seconds before refetching<br>    retry: 2, // Retry failed requests up to 2 times<br>  });<br><br>  // Render each item in the list<br>  const renderItem = ({ item }) =&gt; (<br>    &lt;View&gt;<br>      &lt;Text&gt;{item.title}&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br><br>  // Handles loading more data when user scrolls<br>  const loadMore = () =&gt; {<br>    if (hasNextPage &amp;&amp; !isFetchingNextPage) {<br>      fetchNextPage();<br>    }<br>  };<br><br>  return (<br>    &lt;View&gt;<br>      &lt;Text&gt;Infinite Scroll Posts&lt;/Text&gt;<br><br>      {/* Show loading state before data is fetched */}<br>      {isLoading ? (<br>        &lt;ActivityIndicator size=&quot;large&quot; color=&quot;blue&quot; /&gt;<br>      ) : isError ? (<br>        &lt;View&gt;<br>          &lt;Text&gt;{error.message}&lt;/Text&gt;<br>          &lt;Button title=&quot;Retry&quot; onPress={refetch} color=&quot;red&quot; /&gt;<br>        &lt;/View&gt;<br>      ) : (<br>        &lt;FlatList<br>          data={data.pages.flatMap((page) =&gt; page.data)} // Flatten paginated data<br>          renderItem={renderItem}<br>          keyExtractor={(item) =&gt; item.id.toString()}<br>          onEndReached={loadMore} // Load more when reaching the end<br>          onEndReachedThreshold={0.5} // Trigger load when halfway through last item<br>          ListFooterComponent={isFetchingNextPage ? &lt;ActivityIndicator size=&quot;small&quot; color=&quot;gray&quot; /&gt; : null}<br>        /&gt;<br>      )}<br><br>      {/* Show message when there are no more posts to load */}<br>      {!hasNextPage &amp;&amp; !isLoading &amp;&amp; &lt;Text&gt;No more posts to load.&lt;/Text&gt;}<br>    &lt;/View&gt;<br>  );<br>};<br><br>export default RQDemoComponent;</pre><p>The above example contains automatic pagination, caching, error handling with retries, and smooth UX with loading indicators. 🚀</p><h4><strong>How Does This Improve the Data Fetching Process?</strong></h4><ul><li><strong>Simplified Code: </strong>useQuery simplifies your code by handling loading, error states, and updates automatically.</li><li><strong>Auto Caching: </strong>React Query caches data and fetches fresh data in the background on repeated requests.</li><li><strong>Error &amp; Loading States: </strong>No need for useState, useQuery manages loading and error states for you.</li><li><strong>Background Refetching: </strong>React Query keeps data fresh by refetching when the component mounts or the window is refocused.</li></ul><h4>Comparison of Old Method vs New Method: React Data Fetching</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWoXoLWoi2gO-mmWYY_5_Q.png" /><figcaption>Comparison of Old Method vs New Method of data fetching</figcaption></figure><h3>Conclusion</h3><p>If you’re using useEffect for data fetching, switch to React Query and useQuery for simpler, faster, and more efficient code. ⚡️ React Query streamlines data management, improves performance, and offers a cleaner API for complex scenarios. Say goodbye to repetitive useEffect and embrace modern data fetching! 🔥</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bde1fb0e422" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>