<?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 Ritesh Nagpure on Medium]]></title>
        <description><![CDATA[Stories by Ritesh Nagpure on Medium]]></description>
        <link>https://medium.com/@ritesh.rnagpure?source=rss-c600749906c7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BNUFIo6PL6DT9scN.jpg</url>
            <title>Stories by Ritesh Nagpure on Medium</title>
            <link>https://medium.com/@ritesh.rnagpure?source=rss-c600749906c7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:45:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ritesh.rnagpure/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[How We Built an AI Cost Optimizer to Slash LLM Bills During Our Hackathon]]></title>
            <link>https://medium.com/@ritesh.rnagpure/how-we-built-an-ai-cost-optimizer-to-slash-llm-bills-during-our-hackathon-45da328662f5?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/45da328662f5</guid>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Sat, 31 May 2025 18:30:58 GMT</pubDate>
            <atom:updated>2025-05-31T18:30:58.364Z</atom:updated>
            <content:encoded><![CDATA[<p>In the era of Generative AI, large language models (LLMs) like GPT-4 have revolutionized how we interact with software. But with great power comes great cost. Every API call, every token — input or output — translates into dollars spent. This realisation struck our team during an internal company hackathon, where we saw an opportunity to build something impactful: an <strong>AI Cost Optimizer.</strong></p><p>We took on the challenge of helping products reduce their AI costs by identifying which requests truly need a cloud LLM or require local LLM to process request more efficiently. Here’s how we built a smart, scalable, and insightful SaaS product in just a 2 days.</p><p><strong>Problem Statement</strong></p><p>Many products today integrate GPT-4 or similar models for varied tasks like summarisation, form generation, or structured output. However, not every prompt justifies a input/ output tokens price tag. Often, prompts are repetitive or simple enough to be handled by:</p><ul><li>A static response (cached output or template)</li><li>A lightweight local model (like Mistral)</li></ul><p>Yet, companies lack visibility into their AI usage breakdown. Without prompt-level analytics, they cannot optimize costs effectively. That’s the gap we aimed to close.</p><p><strong>The Idea</strong></p><p>We created a plug-and-play SaaS tool that product teams could easily integrate. Our solution works as follows:</p><ul><li>A <strong>webhook</strong> captures all incoming/outgoing LLM traffic from the product</li><li>These prompts and responses are stored in MongoDB</li><li>A background service uses GPT-4 to classify each prompt</li><li>Each prompt is tagged as suitable for:</li><li><strong>Static Stub</strong> (e.g., reusable JSON, HTML templates)</li><li><strong>Local LLM</strong> (like Mistral)</li><li><strong>Cloud LLM</strong> (GPT-4, Claude, etc.)</li><li>A dashboard/API exposes cost breakdown, optimization potential, and quality issues</li></ul><p><strong>Architecture Overview</strong></p><ul><li>Our architecture is microservice-based and cloud-ready:</li><li><strong>Webhook API:</strong> Receives and logs prompts/responses</li><li><strong>MongoDB:</strong> Stores raw and analyzed data</li><li><strong>Analyzer Service:</strong> Batch queries GPT-4 to classify prompts</li><li><strong>API Layer:</strong> Exposes results to frontend/dashboard</li><li><strong>Dashboard (React):</strong> Shows metrics, guideline violations, and savings</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D_9SF47e3-u6Cms0Rmrr_A.png" /></figure><p><strong>Key Features</strong></p><ul><li><strong>Prompt Classification using GPT-4:</strong> Each prompt is dynamically analyzed for complexity, frequency, and purpose.</li><li><strong>Dashboard Analytics:</strong> Product-specific reports with token usage, cost projections, and model distribution.</li><li><strong>Guideline Checker:</strong> Evaluates prompt quality against industry best practices.</li><li><strong>Static Prompt Download:</strong> Developers can download static responses and integrate them directly.</li><li><strong>API-first:</strong> Everything is accessible via REST APIs, making integration seamless.</li></ul><p><strong>Dashboard looks like -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNKhmGd9K9_nOIaozFVXaQ.png" /></figure><p><strong>Product specific detail</strong>s -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LfhViQ5QxF51GzfxZ6jQxA.png" /></figure><p><strong>Guidelines checker and download static response</strong> -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfYa180Cp7V8403fDJCaWw.png" /></figure><p><strong>Future Scope</strong></p><p>We’re excited about taking this further:</p><ul><li><strong>Internal Model Training:</strong> Replace GPT-4 classification with our own fine-tuned model</li><li><strong>PII/Sensitive Info Detection:</strong> Flag risky prompts and suggest sanitization</li><li><strong>Prompt Rewriting Suggestions:</strong> Make prompts more efficient</li><li><strong>Integrate Claude, Gemini:</strong> Offer smart routing based on cost-performance ratio</li><li><strong>Alerts &amp; Thresholds:</strong> Notify teams when cloud LLM usage spikes</li><li><strong>Dashboard Enhancement:</strong> Add graphs, timeline views, and export features</li></ul><p>Our team consist of <a href="https://medium.com/u/319d012594d9">Vivek Bariya</a>, Poonam Hole, Suraj Hase, Sandesh Dhawan and me.</p><p>We would also like to extend our heartfelt thanks to our manager <a href="https://medium.com/u/bf0427dafc0f">Dharmendra Kumar</a> for his support and encouragement throughout the hackathon.</p><p>Together, we brainstormed, coded, tested, and deployed this in a span of 2 days.</p><p><strong>Conclusion</strong></p><p>AI Cost Optimizer started as a hackathon idea but has the potential to become a game-changing DevOps tool for AI-powered products. It not only brings visibility but provides actionable optimization strategies, saving both cost and compute.</p><p>If you’re excited about reducing your AI bills and improving prompt efficiency, reach out or leave a comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45da328662f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Latency vs  Throughput — What’s the Difference?]]></title>
            <link>https://medium.com/@ritesh.rnagpure/latency-vs-throughput-whats-the-difference-1571130119be?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1571130119be</guid>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Tue, 29 Apr 2025 18:32:47 GMT</pubDate>
            <atom:updated>2025-04-29T18:32:47.904Z</atom:updated>
            <content:encoded><![CDATA[<h3>🕒 Latency vs 🚚 Throughput — What’s the Difference?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C0U5FttikprjHmPa.jpg" /></figure><p>Ever clicked a button and waited for something to load? Or watched a video stream glitch? Then you’ve already experienced latency and throughput in real life.</p><p>Though often used together, <strong>latency</strong> and <strong>throughput</strong> mean very different things. Understanding the difference can help you diagnose performance issues in systems — from websites to networks, apps to games.</p><p>This article breaks them down with clear definitions, simple real-life analogies, and concrete examples.</p><h3>What is Latency?</h3><p><strong>Latency</strong> is the <strong>time delay</strong> between an action and its response.</p><p>Think of it as the time it takes for a single request to go from Client to Server and get a reply/ response.</p><p>It’s how long it takes for <em>one task</em> to complete from start to finish.</p><p>In the digital world, it’s usually measured in <strong>milliseconds (ms)</strong>.</p><pre>+--------+                              +--------+<br>| Client | ------ Request Sent -------&gt; | Server |<br>|        | &lt;----- Response Received ----|        |<br>+--------+                              +--------+<br><br>         &lt;--------- Latency ----------&gt;<br>     (Time delay between request &amp; response)</pre><p><em>Example: If you send a message to a friend and it takes 100 milliseconds to reach them and get a reply, your latency is 100ms.</em></p><p>In simple terms:</p><ul><li><strong>Low latency</strong> = fast response time.</li><li><strong>High latency</strong> = slow or laggy response.</li></ul><h3>What is Throughput?</h3><p><strong>Throughput</strong> is the <strong>amount of work done</strong> in a given period.</p><p>It measures how many tasks, requests, or units of data can be processed <strong>per second</strong>, <strong>per minute</strong>, or <strong>per hour</strong>.</p><p>It’s like asking: how many messages can you send in one second? Or how many requests can a server handle per minute?</p><p>Throughput is often measured in:</p><ul><li><strong>Requests per second (RPS)</strong></li><li><strong>Megabits per second (Mbps)</strong> for network traffic</li></ul><pre>+--------+         +--------+<br>| Client |=======&gt; | Server |<br>|        |=======&gt; |        |<br>|        |=======&gt; |        |<br>+--------+         +--------+<br><br>   ↑               ↑<br>Multiple requests/responses in a time period<br>Throughput = Requests handled per second</pre><p><em>Example: If your system handles 1000 requests every second, that’s its throughput.</em></p><p>In short:</p><ul><li><strong>High throughput</strong> = more work done.</li><li><strong>Low throughput</strong> = less work done.</li></ul><h3>Real-World Examples -</h3><h3>📱 1. Messaging App (e.g. WhatsApp)</h3><p>You type a message and hit send. You’re expecting it to be delivered instantly.</p><ul><li><strong>Latency</strong>: The time it takes for your message to be delivered and show two blue ticks. If latency is high, there’s a noticeable delay.</li><li><strong>Throughput</strong>: How many messages WhatsApp servers can handle per second across millions of users. If throughput is low, messages might get delayed during peak hours.</li><li><strong>Why it matters</strong>: In real-time conversations, high latency ruins flow. Low throughput affects reliability at scale.</li></ul><h3>🚄 2. IRCTC Tatkal Ticket Booking</h3><p>It’s 10:00 AM and you’re ready with fingers on the mouse and keyboard.</p><ul><li><strong>Latency</strong>: The delay between clicking “Book Now” and getting a booking confirmation. High latency = page not loading, or failed transaction.</li><li><strong>Throughput</strong>: How many tickets IRCTC can successfully book per second during the Tatkal window when lakhs of users log in.</li><li><strong>Why it matters</strong>: Low latency helps you book faster, and high throughput ensures more users can book successfully before tickets run out.</li></ul><p>If IRCTC improves both — you book faster <em>and</em> more people succeed.</p><h3>🎥 3. Streaming YouTube or Netflix</h3><p>You’re watching a 4K movie on Netflix.</p><ul><li><strong>Latency</strong>: The time between pressing “Play” and the video starting. High latency = long buffering at the start.</li><li><strong>Throughput</strong>: How much video data is streamed per second (measured in Mbps). If throughput is low, the video buffers or drops to lower quality.</li><li><strong>Why it matters</strong>: Latency affects the initial load, but throughput determines how smooth and high-quality your viewing experience is.</li></ul><h3>🛒 4. Online Shopping During a Sale</h3><p>It’s Black Friday or Big Billion Day. You rush to buy that discounted iPhone.</p><ul><li><strong>Latency</strong>: The time it takes to load a product page or complete a checkout. High latency = spinning loaders and failed payments.</li><li><strong>Throughput</strong>: Number of users or purchase transactions that website can handle simultaneously.</li><li><strong>Why it matters</strong>: High traffic and slow servers can make people abandon carts — both latency and throughput are critical for sales success.</li></ul><h3>🖨️ 5. Office Printer</h3><p>You’re printing a 50-page report just before a meeting.</p><ul><li><strong>Latency</strong>: Time from pressing “Print” to when the first page starts printing. Long delays = high latency.</li><li><strong>Throughput</strong>: How many pages it can print per minute (e.g. 30 PPM).</li><li><strong>Why it matters</strong>: Even if the first page prints quickly (low latency), low throughput means the full document takes too long to print.</li></ul><h3>Conclusion</h3><p>Latency and throughput sound technical, but they’re just about <strong>speed per task</strong> and <strong>volume over time</strong>.</p><p>To recap:</p><ul><li><strong>Latency</strong> is how <em>fast</em> a single thing happens.</li><li><strong>Throughput</strong> is how <em>much</em> can happen over time.</li></ul><p>Next time your app feels slow, a ticket doesn’t book, or your stream buffers, ask yourself: <strong><em>“Is it a latency problem… or a throughput issue?”</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1571130119be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating from Slack Bots to Slack Apps: A Java Developer’s Guide]]></title>
            <link>https://medium.com/@ritesh.rnagpure/migrating-from-slack-bots-to-slack-apps-a-java-developers-guide-a5dc6b19d81a?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5dc6b19d81a</guid>
            <category><![CDATA[slack-apps]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[develper-guide]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Mon, 31 Mar 2025 10:24:40 GMT</pubDate>
            <atom:updated>2025-03-31T10:24:40.016Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJHYBQ34KSuDhPdFkfsPaQ.png" /></figure><p>Slack is deprecating legacy bot starting <strong>March 31, 2025</strong>, urging developers to migrate to Slack Apps. If you’re using a Slack Bot, now is the time to switch to Slack Apps for better security, flexibility, and features. I recently built a Slack App using <strong>Slack Bolt for Java</strong> and found it interesting and easy to implement. In this article, I’ll show you how to migrate from a Slack Bot to a Slack App using simple steps.</p><h3>Why is Slack Deprecating Bots?</h3><p>Slack is stopping support for legacy bots because:</p><ul><li><strong>Better security</strong>: Slack Apps use fine-grained OAuth permissions instead of broad access tokens.</li><li><strong>More features</strong>: Apps support interactivity, slash commands, and event subscriptions.</li><li><strong>Scalability</strong>: Apps work better in modern cloud environments.</li></ul><p>If your bot still uses legacy custom bots, it will <strong>stop working</strong> after March 31, 2025.</p><h3>Why Choose Slack Bolt for Java?</h3><p>Slack provides multiple SDKs, but we chose <strong>Slack Bolt for Java</strong> because:</p><ul><li><strong>Simple and structured</strong>: It offers an intuitive framework for handling events and interactions.</li><li><strong>Built-in web server support</strong>: It integrates easily with Spring Boot.</li><li><strong>Asynchronous processing</strong>: It allows handling long-running tasks efficiently.</li><li><strong>Easy OAuth handling</strong>: Manages authentication and permissions seamlessly.</li><li><strong>Multi-language support</strong>: Slack Bolt is available in multiple languages, including <strong>Java, JavaScript (Node.js), TypeScript and Python</strong>, so you can choose the best fit for your project.</li></ul><h3>Key Differences Between Slack Bots and Slack Apps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*V4_GkuicXo9rq2UWJ5wsBg.png" /></figure><h3>Steps to Migrate from Slack Bot to Slack App</h3><h3>1. Create a Slack App</h3><ul><li>Go to the <a href="https://api.slack.com/apps">Slack API Console</a> and create a new app.</li><li>Choose the workspace where you want to install it.</li></ul><h3>2. Set Up OAuth and Permissions</h3><ul><li>Under “OAuth &amp; Permissions,” add required scopes like chat:write, commands, channels:history etc. Add as per your requirements.</li><li>Install the app to your workspace and get OAuth tokens.</li></ul><h3>3. Enable Event Subscriptions</h3><ul><li>Under “Event Subscriptions,” turn on event handling.</li><li>Set a <strong>Request URL</strong> where Slack will send events.</li><li>Subscribe to events like message.channels and message.im</li><li><strong>Important</strong>: Slack will first send a URL verification request to your server. You must respond within <strong>3 seconds</strong> with the challenge value provided in the request. Only after successful verification will Slack start sending events.</li></ul><h3>Developing a Slack App Using Slack Bolt for Java</h3><h3>1. Add Bolt Dependency to Your Java Project</h3><p>Use the following dependency in your pom.xml file:</p><pre>  &lt;dependency&gt;<br>   &lt;groupId&gt;com.slack.api&lt;/groupId&gt;<br>   &lt;artifactId&gt;bolt&lt;/artifactId&gt;<br>   &lt;version&gt;1.45.3&lt;/version&gt;<br>  &lt;/dependency&gt;</pre><h3>2. Initialize a Basic Slack App</h3><pre>@Configuration<br>public class SlackConfig {<br>    @Value(&quot;${slack.bot-token}&quot;)<br>    private String botToken;<br><br>    @Value(&quot;${slack.signing-secret}&quot;)<br>    private String signingSecret;<br><br>    @Bean<br>    public App slackApp() {<br>        AppConfig config = new AppConfig();<br>        config.setSingleTeamBotToken(botToken);<br>        config.setSigningSecret(signingSecret);<br><br>        App app = new App(config);<br><br>        // Handle incoming messages<br>        app.event(com.slack.api.model.event.MessageEvent.class, (req, ctx) -&gt; {<br>            String user = req.getEvent().getUser();<br>            String message = req.getEvent().getText();<br>            String channel = req.getEvent().getChannel();<br><br>            // Log received message<br>            System.out.println(&quot;Received message from &quot; + user + &quot;: &quot; + &quot;Channel: &quot; +  channel + &quot;: &quot;+  message);<br><br>            // Send response to Slack channel<br>            ctx.say(&quot;Hello &lt;@&quot; + user + &quot;&gt;, I got your message: &quot; + message);<br><br>            return ctx.ack();<br>        });<br><br>        return app;<br>    }<br>}</pre><h3>3. Handle Events</h3><pre>@RestController<br>@RequestMapping(&quot;/slack/events&quot;)<br>public class SlackEventThroughSpringBoot {<br>    private static final ObjectMapper objectMapper = new ObjectMapper();<br><br>    @Value(&quot;${slack.bot-token}&quot;) // Inject Slack bot token from application properties<br>    private String botToken;<br><br>    @PostMapping<br>    public ResponseEntity&lt;String&gt; handleSlackEvent(@RequestBody String requestBody) throws IOException {<br>        JsonNode requestJson = objectMapper.readTree(requestBody);<br>        System.out.println(&quot;Received Slack Event: &quot; + requestJson);<br><br>        // Handle Slack Challenge Verification<br>        if (requestJson.has(&quot;challenge&quot;)) {<br>            return ResponseEntity.ok(&quot;{\&quot;challenge\&quot;:\&quot;&quot; + requestJson.get(&quot;challenge&quot;).asText() + &quot;\&quot;}&quot;);<br>        }<br><br>        // Handle Slack Event Messages<br>        if (requestJson.has(&quot;event&quot;)) {<br>            JsonNode event = requestJson.get(&quot;event&quot;);<br>            String eventType = event.get(&quot;type&quot;).asText();<br><br>            if (&quot;message&quot;.equals(eventType) &amp;&amp; event.has(&quot;text&quot;)) {<br>                String channelId = event.get(&quot;channel&quot;).asText();<br>                String userMessage = event.get(&quot;text&quot;).asText();<br><br>                // Avoid responding to bot messages<br>                if (!event.has(&quot;bot_id&quot;)) {<br>                    sendSlackMessage(channelId, &quot;You said: &quot; + userMessage);<br>                }<br>            }<br>        }<br><br>        return ResponseEntity.ok(&quot;{\&quot;status\&quot;:\&quot;ok\&quot;}&quot;);<br>    }<br><br>    private void sendSlackMessage(String channel, String message) {<br>        Slack slack = Slack.getInstance();<br>        try {<br>            ChatPostMessageResponse response = slack.methods(botToken).chatPostMessage(<br>                    ChatPostMessageRequest.builder()<br>                            .channel(channel)<br>                            .text(message)<br>                            .build()<br>            );<br><br>            if (!response.isOk()) {<br>                System.err.println(&quot;Error sending message: &quot; + response.getError());<br>            }<br>        } catch (IOException | SlackApiException e) {<br>            e.printStackTrace();<br>        }<br>    }<br>}</pre><h3>4. Use ngrok to Expose Your Local Server</h3><p>While developing, Slack needs a public URL to send events. <strong>ngrok</strong> helps expose your local app:</p><ol><li>Install ngrok from <a href="https://ngrok.com/download">ngrok.com</a>.</li><li>Run: ngrok http 3000</li><li>Copy the https URL from ngrok and use it as the <strong>Request URL</strong> in Slack App settings.</li></ol><h3>5. Deploying Your Slack App</h3><ul><li>Deploy with <strong>Docker</strong>, <strong>AWS Lambda</strong>, or a cloud platform.</li><li>Replace ngrok with a permanent domain for production.</li></ul><h3>Screenshot of Slack App in Action</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*KgRXKp-6KntzXvuawUxRHQ.png" /></figure><h3>Challenges and Lessons Learned</h3><ul><li><strong>OAuth authentication</strong>: Managing tokens properly is important.</li><li><strong>Event verification</strong>: Slack requires a challenge response when setting up events.</li><li><strong>Latency</strong>: Slack expects responses within <strong>3 seconds</strong> — long processes should run asynchronously.</li></ul><h3>Conclusion</h3><p>Migrating to Slack Apps before <strong>March 31, 2025</strong> is essential. The migration improves security, adds interactive features, and ensures long-term compatibility with Slack’s platform.</p><p>Have you migrated your Slack Bot yet? Share your experience in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5dc6b19d81a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Aspect-Oriented Programming (AOP) in Java]]></title>
            <link>https://medium.com/@ritesh.rnagpure/aspect-oriented-programming-aop-in-java-aae5451faaaf?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/aae5451faaaf</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[aop]]></category>
            <category><![CDATA[self-learning]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 13:18:40 GMT</pubDate>
            <atom:updated>2025-02-28T13:18:40.758Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VZ04bINQNUmqR-MO.png" /><figcaption>AOP</figcaption></figure><p>Have you ever wished you had a magical assistant who could take care of things for you without you even asking? Imagine if every time you put on your shoes, they automatically tied themselves, or every time you finished eating, the dishes magically washed themselves. Sounds amazing, right?</p><p>This is exactly how <strong>Aspect-Oriented Programming (AOP) </strong>works in Java! It allows us to add extra functionality — like logging, security checks, or performance monitoring to our code without modifying the core logic.</p><p><strong>Why Do We Need AOP?</strong></p><p>In traditional programming, we often find ourselves writing the same logic in multiple places. For e.g., if we need to log method executions, we might add System.out.println(“Method started”) at the beginning and System.out.println(“Method ended”) at the end of many methods. This makes the code messy and hard to maintain.</p><p>AOP helps solve this problem by allowing us to separate cross-cutting concerns things that are needed across multiple parts of your code but don’t belong to one specific place. Some examples include:</p><ul><li>Logging</li><li>Security checks</li><li>Transaction management</li></ul><p>Instead of writing the same logic again and again, AOP allows you to define it separately and apply it where needed.</p><p><strong>What is AOP?</strong></p><p>AOP is a programming technique that enables the separation of concerns by allowing additional behavior like logging or security checks to be added to existing code without modifying it directly. It works by defining aspects that can be automatically applied to different parts of your codebase.</p><p><strong>Real-Life Analogy: The Magic Helper</strong></p><p>Imagine you are getting ready for school every morning. Normally, you:</p><ol><li>Wake up</li><li>Brush your teeth</li><li>Wear your uniform</li><li>Eat breakfast</li><li>Take your school bag</li><li>Go to school</li></ol><p>But what if you always forget to pack your lunch? Your mom decides to help by packing your lunch every morning <strong>automatically</strong>, no matter what. You don’t have to remind her, and you don’t have to change your routine. The lunch is packed without you even thinking about it.</p><p>In AOP terms:</p><ul><li><strong>Your routine</strong> is your main code (Business logic)</li><li><strong>Packing lunch</strong> is a cross-cutting concern (Common logic)</li><li><strong>Your mom handling it automatically</strong> is <strong>AOP</strong> in action!</li></ul><p><strong>Understanding Joinpoints, and some advices in AOP</strong></p><p>In AOP, we define specific points in our code where additional behaviour (like logging) should be executed. These points are known as <strong>Joinpoints.</strong></p><p><strong>Joinpoint -</strong></p><p>A joinpoint is a specific point in the execution of your program where an aspect (extra functionality) can be applied. For example, calling a method or handling an exception can be a joinpoint.</p><p>Using our school analogy, each step in your morning routine (like brushing your teeth or eating breakfast) is a joinpoint where some extra behaviour (like getting reminder) can be added.</p><p><strong>Pointcut -</strong></p><p>A pointcut is a rule that defines where an aspect should be applied. It helps AOP decide which methods or classes should be intercepted</p><p>Example:</p><pre>@Pointcut(&quot;execution(* com.example.service.*.*(..))&quot;)<br>public void serviceMethods() {}</pre><ul><li>execution(* com.example.service.*.*(..)) -&gt; Applies to all methods inside class in the com.example.service package.</li><li>serviceMethods() is a reusable definiation.</li></ul><p><strong>Before Advice -</strong></p><p>A before advice is something that runs <strong>before</strong> a specific joinpoint (like a method execution). Think of it like your mom reminding you <strong>before</strong> leaving the house to check if you have your lunch.</p><p>Example:</p><pre>@Aspect<br>@Component<br>public class LoggingAspect {<br>    @Before(&quot;execution(* com.example.service.*.*(..))&quot;)<br>    public void logBeforeMethod(JoinPoint joinPoint) {<br>        System.out.println(&quot;Logging before method: &quot; + joinPoint.getSignature().getName());<br>    }<br>}</pre><p>This means that before any method in com.example.service package runs, the logging logic will be executed.</p><p><strong>After Advice -</strong></p><p>An after advice runs <strong>after</strong> a joinpoint complets. This is like your mom checking if you reached school safely.</p><p>Example:</p><pre>@After(&quot;execution(* com.example.service.*.*(..))&quot;)<br>public void logAfterMethod(JoinPoint joinPoint) {<br>    System.out.println(&quot;Logging after method: &quot; + joinPoint.getSignature().getName());<br>}</pre><p>This means that after any method in com.example.service package completes, the logging logic will be executed.</p><p>We can use this Pointcut in multiple advices:</p><pre>@Before(&quot;serviceMethods()&quot;)<br>public void logBeforeMethod(JoinPoint joinPoint) {<br>    System.out.println(&quot;Logging before method: &quot; + joinPoint.getSignature().getName());<br>}<br><br>@After(&quot;serviceMethods()&quot;)<br>public void logAfterMethod(JoinPoint joinPoint) {<br>    System.out.println(&quot;Logging after method: &quot; + joinPoint.getSignature().getName());<br>}</pre><p><strong>Around Advice -</strong></p><p>An around advice runs <strong>before </strong>and<strong> after </strong>a method execution. It is like your mom <strong>checking</strong> on you <strong>before </strong>and <strong>after</strong> you leave the house.</p><p>Example:</p><pre>@Around(&quot;execution(* com.example.service.*.*(..))&quot;)<br>public Object logAroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {<br>    System.out.println(&quot;Before executing: &quot; + joinPoint.getSignature().getName());<br>    Object result = joinPoint.proceed(); // Proceed with the actual method execution<br>    System.out.println(&quot;After executing: &quot; + joinPoint.getSignature().getName());<br>    return result;<br>}</pre><p><strong>After Returning Advice -</strong></p><p>An after returning advice runs <strong>only if a method completes successfully.</strong> Think of it like your mom giving you a high-five only if you finish your homework correctly.</p><p>Example:</p><pre>@AfterReturning(value = &quot;execution(* com.example.service.*.*(..))&quot;, returning = &quot;result&quot;)<br>public void logAfterReturning(JoinPoint joinPoint, Object result) {<br>    System.out.println(&quot;Method &quot; + joinPoint.getSignature().getName() + &quot; returned: &quot; + result);<br>}</pre><p><strong>After Throwing Advice -</strong></p><p>An After throwing advice runs <strong>only if method throws an exception.</strong> It is like your mom scolding you if you spill your lunch.</p><p>Example:</p><pre>@AfterThrowing(value = &quot;execution(* com.example.service.*.*(..))&quot;, throwing = &quot;exception&quot;)<br>public void logAfterThrowing(JoinPoint joinPoint, Throwable exception) {<br>    System.out.println(&quot;Method &quot; + joinPoint.getSignature().getName() + &quot; threw an exception: &quot; + exception.getMessage());<br>}</pre><p><strong>Complete Example: Logging Before and After with Timestamp</strong></p><p>Step 1: Create the Aspect</p><pre>@Aspect<br>@Component<br>public class LoggingAspect {<br>    @Before(&quot;execution(* com.example.service.*.*(..))&quot;)<br>    public void logBeforeMethod(JoinPoint joinPoint) {<br>        System.out.println(&quot;[&quot; + System.currentTimeMillis() + &quot;] Before method: &quot; + joinPoint.getSignature().getName());<br>    }<br>    <br>    @After(&quot;execution(* com.example.service.*.*(..))&quot;)<br>    public void logAfterMethod(JoinPoint joinPoint) {<br>        System.out.println(&quot;[&quot; + System.currentTimeMillis() + &quot;] After method: &quot; + joinPoint.getSignature().getName());<br>    }<br>}</pre><p>Step 2: Enable AOP in Spring Boot</p><p>Add the @EnableAspectJAutoProxy annotation in your configuration class:</p><pre>@Configuration<br>@EnableAspectJAutoProxy<br>public class AppConfig {<br>}</pre><p>Step 3: Use the Service</p><pre>@Service<br>public class StudentService {<br>    public void study() {<br>        System.out.println(&quot;Studying...!&quot;);<br>    }<br>}</pre><p>Step 4: Run and see the Magic</p><p>When calling study(), you will see:</p><pre>[1740727185000] Before method: study<br>Studying...!<br>[1740727245000] After method: study</pre><p><strong>What is Weaving in AOP?</strong></p><p>Weaving is the process of <strong>linking aspects with the target objects</strong> to create an <strong>advised object.</strong> In simple terms, it is like stitching the additional behavior (advice) into the main code.</p><p>Imagine you have a superhero suit, but it needs extra power. The tailor sews hidden gadgets (like jet boosters or invisibility cloaks) inside your suit. You don’t see these gadgets, but they activate when needed.</p><p>Similarly, <strong>weaving</strong> in AOP integrates aspects (like logging, security, or transaction management) into your code at different points without modifying the actual business logic.</p><p><strong>Types of Weaving in AOP:</strong></p><ol><li><strong>Compile-Time Weaving</strong> — Aspects are woven into the compiled bytecode before execution.</li><li><strong>Load-Time Weaving</strong> — Aspects are woven at runtime when the class is loaded into memory.</li><li><strong>Runtime Weaving (Proxy-Based Weaving)</strong> — Used in Spring AOP, weaving happens at runtime using dynamic proxies.</li></ol><p><strong>Conclusion:</strong></p><p>Aspect-Oriented Programming is like having a magic helper that does extra work for you without changing your routine. In Java, Spring AOP makes it easy to implement logging, security, and other cross-cutting concerns efficiently. Just like your mom packing lunch automatically and checking if you reached school, AOP ensures your additional functionalities are handled seamlessly.</p><p>So next time you hear about AOP, just remember: It’s like having an invisible assistant in your code! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aae5451faaaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serving the Internet Like a Restaurant: The Role of Load Balancers]]></title>
            <link>https://medium.com/@ritesh.rnagpure/serving-the-internet-like-a-restaurant-the-role-of-load-balancers-a6aadc66315a?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6aadc66315a</guid>
            <category><![CDATA[learning-design]]></category>
            <category><![CDATA[load-balancer]]></category>
            <category><![CDATA[high-level-design]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Thu, 30 Jan 2025 19:22:27 GMT</pubDate>
            <atom:updated>2025-01-30T19:22:27.036Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*s1-qr5hduK-YV09Zu-UU_g.png" /><figcaption>Load Balancer</figcaption></figure><p>Imagine a small but popular restaurant in your area. The restaurant has a single waiter who takes orders, serves food, and clears tables. Let’s walk through what happens as the restaurant grows more popular.</p><p><strong>Phase 1: A Small Crowd</strong> (No Load Balancer)</p><p>Initially, the restaurant starts with a few customers, and the <strong>single waiter </strong>manages everything comfortably.</p><ul><li>Takes orders quickly</li><li>Delivers food on time</li><li>Provides good customer service</li></ul><p>The system works because the load (number of customers) is manageable.</p><p><strong>Phase 2: Growing Popularity</strong> (Increased Load)</p><p>The restaurant becomes famous through word of mouth and it’s service. Now, more customers arrive to restaurant and single waiter can not handle all at once.</p><ul><li>Some customers wait too long to place orders</li><li>Others don’t get their food on time</li><li>A few get frustrated and leave the restaurant</li></ul><p>The restaurant’s performance suffers, and both the customers and the waiter feel the strain. Without help, the restaurant’s reputation will take a hit.</p><p><strong>Phase 3: Adding More Waiters</strong> (Load Balancer Introduced)</p><p>The restaurant owner decides to hire more waiters. However, if each customer randomly approaches a waiter, it will be chaos situation — some waiters are overwhelmed, while others are idle. To solve this, the owner assigns a <strong>manager (Load balancer)</strong> to handle the flow of customers.</p><p>The manager will do following things -</p><ul><li><strong>Distributes Work Evenly:</strong> Assigns customers to the least busy waiter, ensuring no one is overburdened.</li><li><strong>Handles Special Requests:</strong> Knows which waiter can handle specific needs, like serving large groups or managing any other preferences.</li><li><strong>Improve Efficiency:</strong> If one waiter takes a break, the manager redirects customers to the available staff without disrupting service.</li></ul><p>With the manager in place, the restaurant operates smoothly</p><ul><li>Waiters aren’t overwhelmed</li><li>Customers are served promptly and leave satisfied.</li></ul><p><strong>How a Load Balancer Works in Real World:</strong></p><p>Just like the restaurant manager, a load balancer ensures smooth operation by distributing user requests (customers) across multiple servers (waiters). Let’s break it down:</p><ul><li><strong>Without a Load Balancer:</strong> All requests go to one server, leading to slow responses or crashes with the load is too high</li><li><strong>With a Load Balancer:</strong> Requests are distributed across multiple servers based on their availability and capacity</li></ul><p><strong>Types of Load Balancers</strong></p><p>Let’s now explore the types of load balancers and their advantages and disadvantages. Just like a restaurant manager can have different styles of managing the waiters, load balancers in technology also work differently depending on their type</p><ol><li><strong>Round-Robin Load Balancer: </strong>The manager assigns customers to waiters one by one in a fixed order, like a queue. The first customer goes to waiter 1, the second to waiter 2, and so on. Once all waiters are assigned, the manager starts again with waiter 1.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*cDY0rq3_edj6OVOItVx8Hg.png" /><figcaption>Round Robin</figcaption></figure><p><strong>Example in the Restaurant</strong>:<br>If 12 customers arrive:</p><ul><li>Customers 1, 4, 7, 10 go to Waiter 1.</li><li>Customers 2, 5, 8, 11 go to Waiter 2.</li><li>Customers 3, 6, 9, 12 go to Waiter 3.</li></ul><p><strong>Advantages</strong>:</p><ul><li>Simple and easy to implement.</li><li>Ensures equal distribution of customers.</li></ul><p><strong>Disadvantages</strong>:</p><ul><li>Doesn’t account for the waiter’s workload. If Waiter 1 has a table of 10 people and Waiter 2 has just 2, Waiter 1 will still get the next customer.</li></ul><p><strong>2. Least Connections Load Balancer: </strong>The manager checks how busy each waiter is and assigns customers to the waiter with the fewest active tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*BrZ6vsTy0hOq5ZazyptuMg.png" /><figcaption>Least Connections</figcaption></figure><p><strong>Example in the Restaurant</strong>:</p><ul><li>Waiter 1 has 3 active tables.</li><li>Waiter 2 has 1 active table.</li><li>The next customer goes to Waiter 2.</li></ul><p><strong>Advantages</strong>:</p><ul><li>Balances the workload more effectively.</li><li>Ideal when customers (requests) require different amounts of time to serve.</li></ul><p><strong>Disadvantages</strong>:</p><ul><li>Requires more effort to monitor the number of active tables (connections).</li><li>Can cause delays if monitoring is inaccurate or slow.</li></ul><p><strong>3. Weighted Load Balancer: </strong>The manager considers the capability of each waiter before assigning customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*EdU4Fgm8KY_so9rIfB8lPQ.png" /></figure><ul><li>Experienced waiters (strong servers) get more customers</li><li>New waiters (weaker servers) handle fewer customers</li></ul><p><strong>Example in the Restaurant</strong>:</p><ul><li>Waiter 1 is experienced and can handle 60% of the customers.</li><li>Waiter 2 is a trainee and handles 40%.</li></ul><p><strong>Advantages</strong>:</p><ul><li>Distributes workload based on the capacity of the waiters (servers).</li><li>Efficient for systems with a mix of high-performance and low-performance servers.</li></ul><p><strong>Disadvantages</strong>:</p><ul><li>Requires careful configuration to set the right weights.</li><li>Imbalance can occur if weights don’t match actual capacity.</li></ul><p><strong>4. Dynamic Load Balancer: </strong>The manager uses real-time data ( e.g. how fast orders are served or how long tables have waited) to make decisions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*9Dkw6Y8hs_tJaDM1if6raQ.png" /><figcaption>Dynamic Load Balancer</figcaption></figure><p><strong>Example in the Restaurant</strong>:</p><ul><li>The manager notices Waiter 1 is slowing down because he is handling a large group, so manager redirect new customers to Waiter 2 or Waiter 3.</li></ul><p><strong>Advantages</strong>:</p><ul><li>Most efficient in handling unpredictable workloads.</li><li>Adjusts dynamically to real-time conditions.</li></ul><p><strong>Disadvantages</strong>:</p><ul><li>More complex to implement.</li><li>Requires constant monitoring and decision-making.</li></ul><p><strong>Advantages of a Load Balancer</strong></p><p>Here’s why introducing a load balancer (<strong>Restaurant Manager)</strong> makes a huge difference -</p><ul><li><strong>Improved Performance:</strong> Servers (waiters) handle smaller workloads, so users (customers) experience faster service</li><li><strong>Reliability:</strong> If one server (waiter) is down, the load balancer redirects traffic to others, keeping the service running</li><li><strong>Scalability:</strong> As traffic (customers) grows, new servers (waiters) can be added seamlessly</li><li><strong>Consistency:</strong> Ensures all users get a similar experience, avoiding frustration</li></ul><p><strong>Disadvantages of Load Balancer</strong></p><ul><li><strong>Cost:</strong> A good manager (load balancer) requires an investment, whether it’s hardware or software</li><li><strong>Single Point of Failure: </strong>If the load balancer itself fails, the entire system can collapse unless backup systems are in place</li></ul><p>Just like a restaurant needs a manager to ensure great service during peak hours, websites and apps need a load balancer to handle growing traffic. Understanding the types of load balancers — round-robin, least connections, weighted and dynamic helps businesses choose the right solution for their needs.</p><p>So next time you enjoy a seamless experience on your favorite app, remember: there’s a load balancer working behind the scenes, much like a silent hero who ensures everything runs like clockwork.</p><p><strong>References </strong>-</p><ol><li><a href="https://www.geeksforgeeks.org/what-is-load-balancer-system-design">https://www.geeksforgeeks.org/what-is-load-balancer-system-design</a></li><li><a href="https://www.digitalocean.com/community/tutorials/what-is-load-balancing">https://www.digitalocean.com/community/tutorials/what-is-load-balancing</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6aadc66315a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to CSFLE: Understanding the Basics]]></title>
            <link>https://medium.com/@ritesh.rnagpure/introduction-to-csfle-understanding-the-basics-8f4f16fa89e?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f4f16fa89e</guid>
            <category><![CDATA[csfle]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[encryption]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 14:32:26 GMT</pubDate>
            <atom:updated>2023-08-30T14:32:26.930Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*HCh1pAZ-BGfYIVMuC8AbOQ.jpeg" /><figcaption><strong>Client side Field level Encryption</strong></figcaption></figure><p>In our last article (<a href="https://medium.com/@ritesh.rnagpure/mongo-csfle-its-harder-than-it-looks-c37325ae5ea9">Mongo CSFLE — It’s Harder Than It Looks</a>), we tackled many obstacles with Mongo CSFLE. From setup issues to problems with the MongoDB version and many more, it wasn’t easy. But, we found solutions for every challenge. Now, let’s dive into the basic ideas behind CSFLE and see why it’s key for protecting our data.</p><h3>Why Encryption Matters</h3><p>In today’s digital age, data is as valuable as gold. Much like we secure gold in safes, our data needs robust protection. With risks such as hackers and data breaches ever-present, encryption is our defense mechanism. It ensures that even if someone accesses the data, they can’t decipher its content without the correct decryption key. Just as gold is safeguarded, our data demands similar protective measures to ensure its security and confidentiality.</p><h3>A Closer Look at CSFLE</h3><p>When diving into the world of encryption, it becomes evident that not all encryption is created equal. Broadly speaking, there are two common approaches: <strong>whole-database encryption</strong> and <strong>field-level encryption</strong>. CSFLE is a prime example of the latter.</p><ol><li><strong>Whole-Database Encryption</strong>:</li></ol><ul><li><strong>Overview</strong>: This method encrypts the entire database. Every piece of data, from user credentials to simple metadata, is protected.</li><li><strong>Example</strong>: An example of whole-database encryption is <strong>Transparent Data Encryption</strong> (TDE). Databases like Microsoft SQL Server and Oracle Database offer TDE as a standard feature. When TDE is enabled, it encrypts the physical files of the database, the associated backup files, and even the log files.</li><li><strong>Benefits</strong>:</li><li>Uniform Security: The entire database is encrypted, so unauthorized users can’t see any of the data in a readable format if they somehow access the physical files.</li><li>Safeguard against Physical Threats: It’s especially effective against threats like stolen hard drives or backups since the raw data on them would be encrypted.</li><li><strong>Drawbacks</strong>:</li><li>Performance Impact: Encrypting and decrypting the entire dataset can sometimes impact database performance.</li><li>Lack of Flexibility: Since everything is encrypted uniformly, you can’t prioritize more sensitive data over less-sensitive data.</li><li>Decryption in Memory: With methods like TDE, while the data at rest is encrypted, once it’s loaded into the system’s memory, it’s decrypted. This could be a vulnerability if there’s a memory breach.</li></ul><p>2. <strong>Field Level Encryption</strong> (<strong>FLE</strong>):</p><ul><li><strong>Overview</strong>: Unlike methods that secure the entire database, Field Level Encryption (FLE) encrypts specific pieces of data or fields within a database entry. This selective approach allows for targeted encryption of sensitive data.</li><li><strong>Example</strong>: Imagine a user profile in a database that has fields like ‘Name’, ‘Email’, ‘Address’, and ‘Credit Card Number’. With FLE, you could choose to only encrypt the ‘Credit Card Number’ field, ensuring that this highly sensitive information is scrambled and unreadable without the decryption key, while the other less-sensitive fields remain in their regular state.</li><li><strong>Benefits</strong>:</li><li>Targeted Security: Instead of encrypting everything, you only secure the most sensitive data. This ensures protection where it’s most needed without unnecessary performance overheads for less sensitive data.</li><li>Flexibility: With FLE, you can decide which specific data points to encrypt, allowing you to adjust your encryption strategy based on the evolving needs of your application.</li><li>Efficiency: By encrypting only select fields, database operations can be faster and more efficient compared to encrypting the entire database.</li><li><strong>Drawbacks</strong>:</li><li>Complexity: Implementing FLE may require a more intricate setup than whole-database encryption, especially when deciding which fields to encrypt and managing the encryption keys for those fields.</li><li>Key Management: With multiple fields encrypted using potentially different keys, managing and securing these keys becomes paramount.</li></ul><h3>The Special Thing About CSFLE in MongoDB</h3><p>Many databases offer encryption, but MongoDB’s CSFLE stands out. It lets app developers decide which specific pieces of data to encrypt. This means even if someone gets into the database, they can’t understand or use the encrypted parts without the right key.</p><h3>Why Choose CSFLE?</h3><ol><li>Selective Encryption: You choose what to protect. Maybe it’s just the sensitive stuff like passwords or personal details.</li><li>Strong Security: With CSFLE, the data stays scrambled unless someone has the right key.</li><li>Meets Rules and Regulations: Some industries or countries have rules about protecting data. CSFLE can help businesses follow these rules.</li></ol><h3>Implementation of CSFLE in MongoDB</h3><p>Understanding the “why” behind CSFLE is foundational. However, to truly harness its benefits, it’s essential to grasp the “how”. Here’s a step-by-step breakdown:</p><ol><li><strong>Defining the Encryption Schema</strong>:</li></ol><ul><li>In MongoDB, each collection’s schema can be detailed with encryption specifications. For instance, in a patientRecord’s collection, fields like bloodGroup or policyNumber can be tagged for encryption.</li><li>Developers have the option of choosing between deterministic encryption (where the same input gives the same encrypted output) and random encryption (different encrypted output for the same input). Each has its use cases: deterministic for fields you might need to query, and random for enhanced security.</li></ul><p>2. <strong>Managing Encryption Keys</strong>:</p><ul><li>Master Key: This key is the guardian of other keys and must be stored securely, typically in an external Key Management Service (KMS).</li><li>Data Keys: Generated by the master key, these are used for the actual encryption and decryption of fields or documents. Storing them separately from the master key ensures an added layer of security.</li><li>MongoDB has built-in support for various KMS providers, offering flexibility and ensuring the keys are as secure as the encrypted data itself.</li></ul><p>3. <strong>Transparent Application Operations</strong>:</p><ul><li>Behind the scenes, MongoDB drivers handle all encryption intricacies. For an application interacting with the database, the processes of encryption and decryption are invisible, allowing developers to focus on core functionalities rather than encryption logistics.</li></ul><h3>Real-world Applications of CSFLE</h3><p>CSFLE isn’t just a theoretical concept — it’s reshaping data security in real industries:</p><ol><li>Healthcare: Medical records are goldmines of personal information. CSFLE ensures data like medical histories or prescription details are safeguarded from unauthorized access, aligning with regulations like HIPAA.</li><li>E-Commerce: Online shopping platforms house sensitive financial details. CSFLE offers these platforms a way to secure payment information, bolstering consumer trust.</li><li>Finance: For banking apps or financial software, protecting transaction histories or account details is paramount. CSFLE provides this security layer, ensuring user trust and regulatory compliance.</li><li>Social Media Platforms: With the surge in data breaches, users are increasingly wary of where their data goes. Platforms using CSFLE can assure users that personal information or chat histories remain confidential.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*EZ1EUzIqrJav2YSgcMp6RQ.png" /><figcaption><strong>Real world Applications of CSFLE</strong></figcaption></figure><h3>Key Takeaways for Developers</h3><p>As powerful as CSFLE is, it’s not a set-it-and-forget-it tool. Here are some critical considerations:</p><ul><li><strong>Key Rotation</strong>: Periodically changing encryption keys is a best practice, ensuring long-term data security.</li><li><strong>Performance Impact</strong>: While CSFLE is efficient, encrypting and decrypting data has a performance cost. It’s essential to monitor and optimize database performance continually.</li><li><strong>Stay Updated</strong>: Encryption standards and best practices evolve. Regularly updating the MongoDB version and ensuring you’re using the latest CSFLE features is crucial.</li></ul><h3>Conclusion</h3><p>In today’s digital environment, data security isn’t just a luxury; it’s a necessity. MongoDB’s CSFLE stands as a testament to this, offering an innovative solution to protect sensitive data with precision. This tool not only offers unmatched security but also ensures ease of use for developers.</p><p>As we’ve explored the depth of CSFLE, it’s clear that its introduction is a game-changer. Whether you’re a developer, business leader, or everyday user, MongoDB’s commitment to robust data protection is reassuring. With CSFLE in our toolkit, we’re better equipped to face the challenges of today’s digital landscape, ensuring that our valuable data remains shielded and secure.</p><p>#MongoDB #AWS #Encryption #Cybersecurity #DataPrivacy #Coding #Database #Technology #Java #CSFLE #KMS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f4f16fa89e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mongo CSFLE — It’s Harder Than It Looks]]></title>
            <link>https://medium.com/@ritesh.rnagpure/mongo-csfle-its-harder-than-it-looks-c37325ae5ea9?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c37325ae5ea9</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[aws-kms]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[csfle]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 07:37:33 GMT</pubDate>
            <atom:updated>2023-08-02T07:37:33.785Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mongo CSFLE — It’s Harder Than It Looks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wCwweii9af4VcWxN.png" /></figure><p>Recently, I was presented with an exciting challenge. One of our clients had a significant requirement — they needed to ensure that their sensitive data stored in MongoDB was encrypted at the field level. Traditional methods like whole-database or disk-level encryption wouldn’t suffice in this case. This is where <strong>MongoDB’s Client-Side Field Level Encryption (CSFLE)</strong> came into the picture. But I had no prior experience working with CSFLE, let alone combining it with AWS.</p><p>The first step of my journey was understanding what CSFLE really was! I immersed myself in the documentation, learning how it works, why it’s essential, and how it could solve our client’s problem. I realized that CSFLE could not only ensure the security of our client’s sensitive data but also prevent potential data breaches by encrypting data at the field level on the client-side before it even reaches the database server.</p><p>Once I had a basic understanding, I started working on a Proof of Concept (POC). The aim was to test CSFLE’s feasibility and understand how to integrate it into our existing system. I was right in the middle of my POC when I stumbled upon a discovery. Our existing services were running on an older MongoDB client version that did not support CSFLE. This was like hitting a brick wall. It was clear that an upgrade was needed. But upgrading a database client in dev/staging/production environments isn’t a small task. It’s not just about changing a version number. It involves thorough testing to ensure that the upgrade does not break functionality or cause performance regressions. I am glad that we write automation test cases and unit test cases during development. Through this habit, we easily identified and fixed the breaking functionality during the development phase! I would highly encourage developers to write unit test cases, automation test cases. It will save a lot of your precious time!!</p><p>This experience taught me a valuable lesson — <strong>Always write automation test cases and unit test cases.</strong></p><p>After the MongoDB client was updated to support CSFLE, I was ready to dive into the world of field-level encryption. After setting up the AWS Key Management Service (KMS) and creating a master key, another challenge was waiting for me! As I started to dive deeper into the implementation of CSFLE, I quickly realized that it was more complex than it first appeared. It required careful handling of a variety of technical aspects, from the mongo crypt shared path to intricate JSON schemas defining the encryption rules.</p><p>The mongo crypt library is a crucial component in the CSFLE process. It provides the binding to <strong>libmongocrypt </strong>that handles the automatic encryption and decryption of data. The shared library path needed to be specified correctly for the application to work. Figuring this out was quite a task and involved a lot of reading and re-reading of documentation.</p><p>Equally challenging was the <strong>JSON schema</strong>. Defining the encryption rules correctly was critical. A single mistake could mean that the data wouldn’t encrypt or decrypt properly. It felt like trying to solve a Rubik’s cube. (I actually bought a Rubik’s cube for myself during this phase!)</p><p>Just as I thought I had conquered the major hurdles in implementing CSFLE, I encountered another aspect of MongoDB that proved challenging. Our client’s data included arrays where we needed to encrypt individual elements. However, I discovered that <strong>MongoDB’s CSFLE does not support encrypting individual elements within an array — it encrypts the whole array.</strong></p><p>This posed a significant challenge. We needed the flexibility to encrypt specific elements without affecting the rest of the array. However, MongoDB’s limitation meant we had to re-evaluate our approach.</p><p>This experience served as a powerful reminder that <strong>even the most robust technologies have their limitations.</strong></p><p>To add to the complexity, <strong>CSFLE is platform-dependent</strong>. This meant that I had to carefully consider the differences between various environments and ensure that the implementation would work across all our target platforms. This was a significant factor, especially when setting up the mongo crypt shared path and integrating it with AWS.</p><p>During this process, I found myself often turning to MongoDB’s support. I raised several tickets, detailing the issues and roadblocks I was facing. Their help was invaluable. Each ticket was an opportunity to learn something new, to understand a different aspect of CSFLE, or to find a solution to a problem I had been wrestling with.</p><p>Just when I thought I had completed the implementation of CSFLE, a new challenge arose. Our application runs on Docker, and the Docker image we were using had an outdated version of <strong>glibc</strong>. Glibc is the GNU C Library, which defines the system calls and other basic facilities that applications can use. It turned out that the version we had was not compatible with the mongo crypt shared path — a crucial component needed for the implementation of CSFLE.</p><p>This was a tricky problem. Upgrading glibc isn’t as straightforward as updating a typical software package. I needed expert advice, so I turned to MongoDB’s support once again. I raised a ticket explaining the issue in detail: the Docker image, the glibc version, the mongo crypt shared path, and how these elements were proving to be incompatible.</p><p>This issue taught me an important lesson: when you’re working with layered systems like Docker containers and complex features like CSFLE, version conflicts can and will arise. <strong>It’s crucial to be patient, thorough, and not afraid to seek help</strong>. We had 2 approaches here. One to upgrade the docker image and second is to have compatible mongo cyrpt shared path. Fortunately, the MongoDB support team provided us with a mongo crypt shared path that supported our Docker image and glibc version, and finally, it worked.</p><p>Despite these complexities and challenges, I remained undeterred. With every issue I overcame, I was not only one step closer to successfully implementing CSFLE for our client but also gaining a wealth of knowledge. The challenges were difficult, but with each problem solved, I could see the bigger picture more clearly.</p><p>It was a complicated journey, filled with roadblocks and aha moments. But with persistence, the right support from teammates, and a lot of coffee, I was able to navigate through these complexities.</p><p>As I reflect back on my journey with CSFLE, I want to express my profound gratitude towards my teammates <a href="https://medium.com/u/76eb22c6c777">Yuri Granovsky</a>, <a href="https://medium.com/u/bf0427dafc0f">Dharmendra Kumar</a> and <a href="https://medium.com/u/11ed1e271aeb">Surajhase</a>. They were an integral part of this process, always there to lend a hand, brainstorm solutions, or simply provide a word of encouragement when I encountered roadblocks.</p><p>Implementing CSFLE in MongoDB on AWS was a challenging, yet rewarding experience. And while I’ve shared my journey and the high-level process in this article, I realize there’s so much more to dive into.</p><p>That’s why I’m excited to announce that I’ll be writing a series of follow-up articles, providing a deep dive into the specifics of implementing CSFLE. These articles will be packed with code snippets, detailed explanations, and lessons learned from my own experience.</p><p>My goal with this series is to share the knowledge I’ve gained and provide practical, hands-on guidance to those who are embarking on a similar journey.</p><p>So stay tuned for my upcoming articles, where we will dive deeper into the world of CSFLE in MongoDB on AWS. :)</p><p>#MongoDB #AWS #Encryption #Cybersecurity #DataPrivacy #Coding #Database #Technology #Java #CSFLE #KMS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c37325ae5ea9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Closure and Decorators in Python]]></title>
            <link>https://medium.com/@ritesh.rnagpure/closure-and-decorators-in-python-b72b2aa527c5?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b72b2aa527c5</guid>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[decorators]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Fri, 12 Jun 2020 20:22:31 GMT</pubDate>
            <atom:updated>2020-06-13T03:24:17.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*whqbVULCus5pE4PIPPDvBA.jpeg" /></figure><p>In this article, I tried to explain how to use Closures and Decorators with few examples. Hope you’ll like it :)</p><p><strong>Closure:</strong></p><p>[Note: Before starting of closure, I’m assuming the reader is familiar with the concept of an inner function and return the function by reference]</p><p>Closure in very simple terms can be defined as creating as inner function and returning a reference of inner function to caller.</p><pre># outer function<br>def outer():<br>    print(f&quot;Inside outer&quot;)<br>    # inner function<br>    def inner():<br>        print(f&quot;Inside inner&quot;)<br><br>    # returning reference of inner function<br>    return inner<br><br># calling outer function<br>result = outer()<br>print(f&quot; result {result} \n type of result {type(result)}&quot;)</pre><p>Here we have defined simple outer function which has an inner function and we are returning inner function reference to caller. This is a Closure .</p><p>output:</p><pre>Inside outer<br> result &lt;function outer.&lt;locals&gt;.inner at 0x7ff2b845b170&gt; <br> type of result &lt;class &#39;function&#39;&gt;</pre><p>we can see, result is of type function because we have returned reference of the inner function.</p><p>But we do not see the print line Inside inner . This is because we have not called the inner function yet.</p><p>To call the inner function, we will have to call result() and then we will get output Inside inner.</p><pre># outer function<br>def outer():<br>    print(f&quot;Inside outer&quot;)<br>    # inner function<br>    def inner():<br>        print(f&quot;Inside inner&quot;)<br><br>    # returning reference of inner function<br>    return inner<br><br># calling outer function<br>result = outer()<br># calling inner function which is collected in result variable<br>result()<br>print(f&quot; result {result} \n type of result {type(result)}&quot;)</pre><p>output:</p><pre>Inside outer<br>Inside inner<br> result &lt;function outer.&lt;locals&gt;.inner at 0x7f2b521eb170&gt; <br> type of result &lt;class &#39;function&#39;&gt;</pre><p>So to define a closure, we have to follow two rules:</p><ol><li>There should be an inner function defined inside the outer function</li><li>The outer function must return a reference of an inner function</li></ol><p>We will see the simple example of how to use Closure for printing tables.</p><p>Before closure, we will see how we can print the tables in python using different ways.</p><ol><li>This is the simplest way just by writing in the print statement, we can print anything we want on the console 😝</li></ol><pre>def firstWay():<br>    print(&quot;4, 8, 16, 20, .....&quot;)</pre><pre>firstWay()<br>#output:<br>4, 8, 16, 20, .....</pre><p>2. By using for loop we can print the table</p><pre>def secondWay(number):<br>    for index in range(1, 11):<br>        print(index * number)<br><br>secondWay(5)<br>#output:<br>5, 10, 15, 20, 25, 30, 35, 40, 45, 50<br>[range function will loop from 1 till 10]</pre><p>3. By using lambda function</p><pre>thirdWay = list(map(lambda number: number * 5, range(1, 11)))<br>print(thirdWay)<br>#output:<br>[5, 10, 15, 20, 25, 30, 35, 40, 45, 50]</pre><p>4. By using list comprehension</p><pre># fourthway<br>print([number * 5 for number in range(1, 11)])<br>#output:<br>[5, 10, 15, 20, 25, 30, 35, 40, 45, 50]</pre><p>Just writing one line inside print statement, we are getting a table of 5. This is a beauty of list comprehension. :)</p><p>Now same can be achieved with the help of closure</p><pre># outer function<br>def table(number):<br>    # inner function<br>    def inner():<br>        # using list comprehension<br>        print([number * index for index in range(1, 11)])<br>    # returning reference of inner function<br>    return inner</pre><pre># taking reference of inner function by passing argument 5<br>table_5 = table(5);<br>table_5()</pre><pre># taking reference of inner function by passing argument 4<br>table_4 = table(4);<br>table_4()</pre><pre>#output:<br>[5, 10, 15, 20, 25, 30, 35, 40, 45, 50]<br>[4, 8, 12, 16, 20, 24, 28, 32, 36, 40]</pre><p>Now we will try to see what is a Decorator and later we will try to combine closure and decorator with example.</p><p><strong>Decorator:</strong></p><p>Decorators are used to enhance existing functions without changing their definition. A decorator is itself a callable and takes in another callable to return another callable.</p><p>Simply put — A decorator is a function that takes in another function and returns another function, although it is a bit more than just that.</p><p>Let&#39;s see an easy example to understand Decorator.</p><p>We have two simple functions, addition, and multiplication.</p><pre># addition function which takes two parameters<br>def addition(number1, number2):<br>    print(f&quot;Addition of {number1} + {number2} = {number1 + number2}&quot;)<br><br># multiplication function which takes two parameters<br>def multiplication(number1, number2):<br>    print(f&quot;Multiplication of {number1} * {number2} = {number1 * number2}&quot;)</pre><pre># calling both the method<br>addition(10, 20)<br>multiplication(5, 10)<br><br>#output<br>Addition of 10 + 20 = 30<br>Multiplication of 5 * 10 = 50</pre><p>Now our requirement is to add some dash (-) after the result for better output of the result but we do not want to modify the existing definition of these functions.</p><p>Using closure we can do this.</p><pre># decorator which takes function as a parameter <br>def decorate_result(myFunction):<br>    # inner function<br>    def inner(number1, number2):<br>        # calling function which was passed as parameter<br>        myFunction(number1, number2)<br>        # printing dash -<br>        print(&quot;-&quot; *20)<br>    # returning reference of inner function<br>    return inner<br><br>decorate_add = decorate_result(addition)<br>decorate_add(10, 20)<br><br>decorate_multiplication = decorate_result(multiplication)<br>decorate_multiplication(5, 10)<br><br># output:<br>Addition of 10 + 20 = 30<br>--------------------<br>Multiplication of 5 * 10 = 50<br>--------------------</pre><p>Here we have called decorate_result() method by passing addition function and which internally calling addition function and returing reference of function .</p><p>So to define a decorator we must follow these rules:</p><ol><li>A decorator is a function that takes in another function</li><li>It must return another function</li></ol><p>But here, we have to remember the sequence of execution. ie. write decorator, pass function, and then finally call decorator.</p><p>Hence Python has made our life simple. We have to use @ annotation to call a decorator.</p><p>So before function declaration, we need to call decorator.</p><pre># decorator which takes function as a parameter<br>def decorate_result(function):<br>    # inner function<br>    def inner(number1, number2):<br>        # calling function which was passed as parameter<br>        function(number1, number2)<br>        # printing dash -<br>        print(&quot;-&quot; *20)<br>    # returning reference of inner function<br>    return inner<br><br>@decorate_result -----&gt; call our decorator here<br>def addition(number1, number2):<br>    print(f&quot;Addition of {number1} + {number2} = {number1 + number2}&quot;)<br><br>@decorate_result -----&gt; call our decorator here<br># multiplication function which takes two parameters<br>def multiplication(number1, number2):<br>    print(f&quot;Multiplication of {number1} * {number2} = {number1 * number2}&quot;)<br><br>addition(10, 20) ------&gt; calling our normal function<br>multiplication(5, 10) -----&gt; calling our normal function<br><br>#output:<br><br>Addition of 10 + 20 = 30<br>--------------------<br>Multiplication of 5 * 10 = 50<br>--------------------</pre><p>So here before addition() function, python will call first decorate_result , store the result (function reference) and calling addition() method on that.</p><p>Now we will see an example where we can use the concept of closure and decorator in real-life applications.</p><p>We will be writing a log function, which will print information like function name, it’s parameters, and returning value, etc.</p><pre># decorator method which takes function as a parameter<br>def log(myFunction):<br>    # inner function which takes variable number of arguments<br>    def inner(*args, **kwargs):<br>        # printing all information<br>        print(f&quot;function name: {myFunction.__name__}&quot;)<br>        print(f&quot;args: {args}&quot;)<br>        print(f&quot;kwargs: {kwargs}&quot;)<br>        # collection return value of function<br>        result = myFunction(*args, **kwargs)<br>        print(f&quot;return value: {result}&quot;)<br>        print(&quot;-*-&quot; *20)<br>    # returning inner function<br>    return inner<br><br># calling decorator<br>@log<br>def addition(number1, number2):<br>    return number1 + number2<br><br># calling decorator<br>@log<br>def multiplication(number1, number2):<br>    return number1 * number2<br><br>addition(10, 20)<br>multiplication(5, 10)<br><br><br># output:<br>function name: addition<br>args: (10, 20)<br>kwargs: {}<br>return value: 30<br>-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-<br>function name: multiplication<br>args: (5, 10)<br>kwargs: {}<br>return value: 50<br>-*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-</pre><p>I hope you understood the concept of closure and decorator and these concepts can be applied in a real-world applications.</p><p>Thank you for reading.</p><p>Please share your feedback on this :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b72b2aa527c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git basics]]></title>
            <link>https://medium.com/@ritesh.rnagpure/git-basics-93298c1e3fe3?source=rss-c600749906c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/93298c1e3fe3</guid>
            <category><![CDATA[git-basics]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Ritesh Nagpure]]></dc:creator>
            <pubDate>Mon, 08 Jun 2020 12:41:27 GMT</pubDate>
            <atom:updated>2020-06-08T12:41:27.239Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I will try to explain various git states that your files can reside in.</p><p><strong>Basic concepts</strong>:</p><p>Git has three main states</p><ol><li>Committed: It simply means the data is safely stored in your local database. Here local database we can say it as .git directory</li><li>Modified: It simply means that you have changed the file but have not committed it to your local database.</li><li>Staged: It simply means that you have marked a modified file in its current version to go into your next commit snapshot.</li></ol><p>There is one more area called Stash Areawhere you can temporarily save changes you have made to your working file so you can work on something else and then come back and re-apply those changes later on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lFLVDaX7lUv_aH-xIS_5g.jpeg" /></figure><p>When we do git init , then .git repository is created in a system that contains Head, config, description, objects, references, etc.</p><p>When we create a file eg. demo.txt , then that file resides in Working area . Simply we can say that this file is in unstaged area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*k-2VwwwShb8OFkNvOIRXIA.png" /></figure><p>If we want to move demo.txt file inside Staged Area , then we have to use the command: git add demo.txt</p><p>If we want to see how many files are present inside Staged Area , then use the command: git ls-files --stage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*sksxTdBeGjMluC6cthqmDw.png" /></figure><p>If we want to remove any file from Staging Area , then use the command: git reset -- demo.txt This will move demo.txt file from staging area to working area</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*7nLzerOpcc5q0iHwD8JtUQ.png" /></figure><p>Now once again, I am adding these changes in staging area , now we will commit those changes in .git repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*b27wVFmAKenCpFmmtQz2eg.png" /></figure><p>To commit the changes, we have to use the command: git commit -m &quot;your commit message&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*DvjlUbeJTKV5BTZPiVts8A.png" /></figure><p>If you want to check which files are present inside .git repository , then use the command: git ls-files --cached</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*1B2bzd0G3cAv56ZxKMEsIw.png" /></figure><p>Here we can see that demo.txt is present inside .git repository .</p><p>Now, we will try to modify the demo.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*3EKwXZHGz4ZpY_vxplmM7w.png" /></figure><p>We can check the modified status using the command: git status -s . Here M indicates modified.</p><p>If we want to discard these new changes from Working area , then we have to use the command: git checkout --demo.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*TuDhNyps_zrahBq8eLIKYA.png" /></figure><p>In starting I had mentioned one more area called as Stash Area .</p><p>Now we will try to see some examples of that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*2HO8kqAePA6RU5JzBnLtqQ.png" /></figure><p>We do not want to discard these new changes but try to add new lines instead of these, then we can move those changes inside Stash area using the command: git stash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*_FscZju5BilFKPWokRLR7Q.png" /></figure><p>If we want to see how many changes are present inside Stash area , then use the command: git stash list</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*faSyuHsxeUGyjy5wmOfBWg.png" /></figure><p>and if we want to move the changes from Stash area to working area , then we can use the command: git stash pop</p><p>NOTE: git stash pop will always take the last changes and move it to working area</p><p>If there are multiple stash indexes present inside stash area then we can take specific changes and move those changes into working area using the command: git stash apply 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*mvkbFof45_KTQpJjvk6yrA.png" /></figure><p>If we want to clear the Stash area , then we have to use the command: git stash clear This will clear the stash area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*QmesqGeMI9WO0oL_ELoxsQ.png" /></figure><p>Now finally, we want to push those changes on Remote repository . We can use the command: git push origin master</p><p>If we want to create a copy of remote repository into our local system, then we can use the command: git clone</p><p>If we want to take out new changes from the remote repository to the local repository, then we can use the command: git pull origin master .</p><p>Thank you all for reading this.</p><p>Try this and share your comments here :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93298c1e3fe3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>