<?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 Abhay Ahire on Medium]]></title>
        <description><![CDATA[Stories by Abhay Ahire on Medium]]></description>
        <link>https://medium.com/@abhayahire?source=rss-d10431ecf4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pbpQBE3spmTSgXpO-kk8mg.png</url>
            <title>Stories by Abhay Ahire on Medium</title>
            <link>https://medium.com/@abhayahire?source=rss-d10431ecf4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 10:46:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhayahire/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[PageIndex vs RAG for Healthcare: Why We Switched Our Denial Rebuttal Pipeline]]></title>
            <link>https://abhayahire.medium.com/pageindex-vs-rag-for-healthcare-why-we-switched-our-denial-rebuttal-pipeline-28ee6f19569b?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/28ee6f19569b</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[anthropics]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sat, 28 Feb 2026 14:31:00 GMT</pubDate>
            <atom:updated>2026-02-28T14:31:00.679Z</atom:updated>
            <content:encoded><![CDATA[<p><em>We love RAG. But it kept pulling the wrong policy clause at the worst possible time.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KfXK-Riffk82IvXDnxCgBg.png" /></figure><p>Last couple of months , our team was demoing our denial rebuttal tool to a client. The system pulled what looked like a solid policy excerpt to support medical necessity. Confident, relevant-sounding language. The client’s appeals specialist glanced at it and said, “That’s the exclusion criteria. You just made the payer’s argument for them.”</p><p>That moment stuck with us.</p><p>Not because the system was broken, it was doing exactly what vector search does. It found the most semantically similar chunk to the query. The problem was that similarity and relevance aren’t the same thing. Especially not in healthcare.</p><h3>The Problem With Vector Search for Payer Policies</h3><p>RAG works great for a lot of healthcare tasks. We still use it daily. But payer policy documents broke our pipeline consistently.</p><p>These documents are long, hierarchical, and deeply contextual. A coverage criterion in section 4.2.3 might only apply if conditions in section 4.1 are met. A clinical threshold on page 47 might be modified by an exception on page 52. Meaning lives in the structure, not in isolated paragraphs.</p><p>When you chunk these documents and retrieve by vector similarity, predictable things go wrong. Critical criteria get split across chunks. The system retrieves text that’s topically close but from the wrong section. And your clinical reviewers end up spending more time fact-checking the AI than doing the work manually.</p><p>We tried the usual fixes , adjusted chunk sizes, added overlap, bolted on rerankers. Each helped a little. None solved the core issue: <strong>the system was pattern-matching, not reading.</strong></p><h3>How PageIndex Works Differently</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zdj7LjhswETw10xh36n76A.png" /></figure><p>PageIndex is an open-source framework that skips vectors entirely. It builds a hierarchical tree index of a document like an AI-generated table of contents and uses LLM reasoning to navigate that tree to find the right sections.</p><p>This is exactly how a good appeals specialist works. They don’t do keyword search a policy document. They scan the table of contents, find the coverage section, drill into the specific criteria, and pull the exact language they need. Reasoning, not similarity.</p><p>No vector database. No chunking strategy. No embedding model.</p><h3>What We Actually Use Where</h3><p>We stopped trying to find one architecture for everything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_RJnlQuScHwPK2NamBLdg.png" /></figure><p>The decision comes down to two questions. Does the task require reasoning to find the right information? And are the source documents long and hierarchical? If yes to both, PageIndex. If not, RAG is simpler and cheaper.</p><h3>Try It Yourself</h3><p>PageIndex is open source on <a href="https://github.com/VectifyAI/PageIndex">GitHub</a>. Take one payer policy document your current RAG pipeline struggles with. Generate the tree index. Run the same queries against both systems.</p><p>That single test told us more than weeks of benchmarking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28ee6f19569b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Rise of ^ DeepSeek AI: How It Impacts the U.S. AI Market]]></title>
            <link>https://abhayahire.medium.com/the-rise-of-deepseek-ai-how-it-impacts-the-u-s-ai-market-673d1c31fb71?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/673d1c31fb71</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 03:31:36 GMT</pubDate>
            <atom:updated>2025-02-10T03:31:36.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NF1EuGC0x5pBdzzOVsQrg.png" /></figure><p>The AI landscape is evolving rapidly nowadays. New players entering the space to challenge established industry leaders. One of them is <strong>DeepSeek AI.</strong> A Chinese AI company developing powerful language models like <strong>DeepSeek LLM</strong> and <strong>DeepSeek Coder</strong>. <br>While its impact is more immediate in China and Asia, the ripple effects are being felt in the <strong>U.S. AI market</strong> as well.</p><h3>Increased Competition in AI Models</h3><p>For years, OpenAI, Google (Gemini), and Anthropic (Claude) have led the U.S. AI industry. <br>However, DeepSeek AI’s rapid advancements introduce a new layer of competition. Particularly in <strong>bilingual AI applications</strong> (English and Chinese). As DeepSeek continues to improve, <strong>U.S. companies may need to accelerate innovation. Also they have to reduce pricing</strong> to stay competitive.</p><h3>Stock Market Implications</h3><p>AI-related stocks have seen significant growth over the past year. OpenAI’s partner Microsoft (MSFT) has surged over <strong>50%</strong> in the past 12 months. Due to AI advancements, while NVIDIA (NVDA) continues to dominate the AI chip market. They had a <strong>200%+ stock rise</strong> in 2023. Now Chinese AI firms, including DeepSeek AI’s backers, are seeing increased investor interest. Although regulatory concerns create volatility in Chinese tech stocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*72SAV1NosgTYjs-vHuQ79Q.png" /></figure><h3>The Shift in AI Infrastructure &amp; Cloud Services</h3><p>With China aiming for <strong>AI independence</strong>, cloud providers like Alibaba Cloud and Tencent Cloud could gain traction against <strong>AWS, GCP, and Azure</strong>. If DeepSeek AI’s models become widely adopted, they might create an alternative AI ecosystem. It can shift the balance of power in global AI infrastructure.</p><h3>The Impact on AI Talent &amp; Research</h3><p>The U.S. has long been the epicenter of AI research. Because of companies like OpenAI, Google DeepMind, and Meta. However, <strong>China’s growing investment in AI talent</strong> could create competition for researchers and engineers. While the U.S. still dominates in AI research, <strong>DeepSeek’s growth highlights the increasing global diversification of AI expertise</strong>.</p><h3>Security Concerns with AI Models</h3><p>Security remains a major concern with both <strong>DeepSeek AI and U.S.-based AI models</strong>. OpenAI has faced scrutiny over <strong>data privacy, hallucinations, and misinformation risks</strong>, while DeepSeek AI raises concerns over <strong>government surveillance, censorship, and potential misuse by authoritarian regimes</strong>. The <strong>Biden administration has already imposed AI chip export restrictions</strong> to curb China’s advancements, citing <strong>national security risks</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*1AnvIqExRzUSc_C9P_eY7w.png" /></figure><h3>The Rise of Open-Source AI and Enterprise Adoption</h3><p>DeepSeek AI, like Meta’s LLaMA, is <strong>open-source</strong>, which poses a challenge to proprietary AI models like GPT-4 and Gemini. If open-source models continue to improve, <strong>enterprises may shift towards free, customizable AI solutions</strong>, potentially impacting OpenAI’s revenue model.</p><h3>Regulatory &amp; Geopolitical Considerations</h3><p>As China advances in AI, the <strong>U.S. government may tighten AI export controls. </strong>Specially on advanced chips (like NVIDIA’s GPUs) used for training LLMs. This could slow DeepSeek’s progress but may also drive China to develop independent AI hardware solutions. It can <strong>reduce reliance on U.S. technology</strong>.</p><h3>Final Thoughts</h3><p>While DeepSeek AI introduces fresh competition, the <strong>U.S. AI market seems dominant</strong> due to its compute power, AI research. However, in the long run, <strong>China’s AI independence could reshape global AI leadership. </strong>It can force U.S. companies to innovate even faster.</p><p>As the AI race intensifies, one thing is clear: the future of AI will be shaped by global competition, and DeepSeek AI is a key player to watch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2xjo8FaM7LxYwZkn-enFw.png" /></figure><p><strong>What do you think? Will DeepSeek AI disrupt the U.S. market, or will American companies maintain their edge? When India will surprise world with it’s own AI model? Let’s discuss in the comments!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=673d1c31fb71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Python Basics to Machine Learning: A Beginner’s Roadmap]]></title>
            <link>https://abhayahire.medium.com/from-python-basics-to-machine-learning-a-beginners-roadmap-82da9125d9f5?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/82da9125d9f5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[healthcare]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sun, 15 Dec 2024 17:09:42 GMT</pubDate>
            <atom:updated>2024-12-15T17:09:42.438Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GhQMifiZIAK5jddldAEfYw.jpeg" /><figcaption>Python Learning</figcaption></figure><p>This blog is the first step in our journey toward understanding Machine Learning (ML). We’ll start with the fundamentals of Python, progress to ML concepts. Also work through a practical example. By the end, you’ll have a clear idea of where to begin and what lies ahead!</p><h4>Starting with Python</h4><p>If you’re new to Python, it’s essential to get comfortable with the basics. Here’s a quick recap of key concepts:</p><h4>1. Variables and Data Types</h4><p>Python uses dynamic typing, which means you don’t need to specify the type of variable:</p><pre>name = &quot;Abhay&quot;;<br>age=30;<br>height=5.2<br>is_engineer=True<br><br>print(name)<br>print(age)<br>print(height)<br>print(is_engineer)</pre><h4>2. Control Flow</h4><p>Loops and conditional statements allow for repetitive tasks and decision-making:</p><pre>fruits = [&quot;apple&quot;, &quot;banana&quot;, &quot;grapes&quot;]<br><br>for fruit in fruits:<br>    print(fruit)<br><br>if x &gt; 5:<br> print(&quot;x is greater than 5&quot;)</pre><h4>3. Functions</h4><p>Functions group reusable code into a single block. I have provided few possible variations:</p><pre><br># Declare Function<br>def greet(name):<br>    print(f&quot;hello {name}&quot;)<br>    <br>greet(&quot;Abhay&quot;)<br><br># Declare Function with args<br>def sum(a,b):<br>    return a+b;<br><br>total = sum(5,5)<br>print(total)<br><br># Declare Function with default args<br>def greetByDefault(name = &quot;there&quot;) :<br>        print(f&quot;Hello {name}&quot;)<br>        <br>greetByDefault()<br>greetByDefault(&quot;Abhay&quot;)<br><br><br># Declare Function with arbitary args<br>def printList(*items):<br>    for item in items:<br>        print(item)<br><br>printList(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;)<br><br># Lambda Functions<br># lambda arguments: expression<br>square = lambda x : x*x<br>print(square(4))<br>sum = lambda  a,b : a+b<br>print(sum(1,2))</pre><h4>4. Libraries</h4><p>Libraries like <strong>NumPy</strong> and <strong>Pandas</strong> simplify tasks. Practice them with examples:</p><pre>pip install numpy pandas</pre><pre>import numpy as np<br>array = np.array([1, 2, 3])<br>print(array)</pre><p>By mastering these, you’ll be well-equipped for working with data and ML libraries.</p><h3><strong>I</strong>ntroduction to Machine Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbf7eHzBQfrOl_1RhlDXoA.jpeg" /><figcaption>Robots in Surgery</figcaption></figure><p>Machine Learning (ML) enables computers to identify patterns and make predictions based on data. Here’s how it works:</p><h4><strong>Real-Life Examples of ML:</strong></h4><p>- <strong>Predicting house prices</strong> based on location, size, etc.<br>- Monitoring <strong>health data</strong>,<strong> predicting diseases</strong>, creating <strong>clinical notes</strong>.<br>- Recommending products on e-commerce platforms.</p><h4>Key ML Concepts:</h4><p><strong>Features</strong> : Input variables (e.g., age, income, clinical data).<br><strong>Target</strong> : The output we want to predict (e.g. house price, diabetic conditions).<br><strong>Model</strong> : A mathematical representation that maps features to the target.</p><h4>Transitioning from Python to ML with Scikit-learn</h4><p>We’ll use Scikit-learn, a Python library, to build and evaluate ML models. Follow these steps to predict flower species using the Iris dataset:</p><h4>Step 1: Install Scikit-learn</h4><pre>pip install scikit-learn</pre><h4>Step 2: Import Libraries</h4><pre>from sklearn.datasets import load_iris<br>from sklearn.model_selection import train_test_split<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.metrics import accuracy_score</pre><h4>Step 3: Load and Understand the Dataset</h4><pre>iris = load_iris()<br>X = iris.data # Features (measurements of flowers)<br>y = iris.target # Target (flower species)<br>print(iris.feature_names) # [&#39;sepal length&#39;, &#39;sepal width&#39;, …]<br>print(iris.target_names) # [&#39;setosa&#39;, &#39;versicolor&#39;, &#39;virginica&#39;]</pre><h4><strong>Step 4: Split the Data</strong></h4><p><strong>Why do we split the data?</strong><br>Think of the dataset as a school exam:</p><ul><li><strong>Training data</strong> is like the study material. The model learns patterns from this.</li><li><strong>Testing data</strong> is like the actual exam. We test how well the model learned by giving it unseen data.<br><strong>How to do it?</strong><br>The train_test_split function separates the dataset into two parts:</li></ul><pre>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)</pre><ul><li>test_size=0.2 means 20% of the data is for testing, and 80% is for training.</li><li>random_state=42 ensures the split is the same every time for reproducibility.</li></ul><h4>Step 5: Train the Model</h4><p><strong>What does this mean?</strong><br>Training a model is like teaching a child to recognize animals using pictures. You show the child labeled pictures (e.g., “This is a cat,” “This is a dog”) repeatedly.</p><p><strong>In our code:</strong><br>We use a Decision Tree Classifier to “learn” patterns from the training data.</p><pre>model = DecisionTreeClassifier()<br>model.fit(X_train, y_train)</pre><p>model.fit(X_train, y_train) teaches the model the relationship between input (X_train) and output (y_train).</p><h4>Step 6: Make Predictions</h4><p><strong>What are predictions?</strong><br>Predictions are guesses based on what the model has learned. Continuing our analogy, after studying, the child sees a new animal and guesses, “This is a cat!”</p><p><strong>In our code:</strong><br>The model uses its knowledge to guess the flower species for the unseen test data. Nothing less than virtual brain … :</p><pre>predictions = model.predict(X_test)</pre><h4>Step 7: Evaluate the Model</h4><p><strong>Why evaluate?</strong><br>Evaluation is like grading the exam to see how well the child did. Did they correctly identify the animals?</p><p><strong>In our code:</strong><br>We compare the model’s predictions to the actual answers in the test data:</p><pre>accuracy = accuracy_score(y_test, predictions)<br>print(f”Accuracy: {accuracy}”)</pre><ul><li>accuracy_score calculates how many guesses were correct as a percentage. For example, if 90% were correct, the model has 90% accuracy.</li></ul><h4>Understanding the Process</h4><p><strong>What is `train_test_split`?</strong><br>It splits data into:<br>- <strong>Training</strong> <strong>set</strong> : Used to teach the model.<br>- <strong>Testing</strong> <strong>set</strong>: Used to evaluate the model’s performance.</p><p><strong>What is a Model?</strong><br>A model is like a formula that learns patterns from the data and predicts outcomes.</p><p><strong>What is Accuracy?</strong><br>Accuracy = (Correct Predictions) / (Total Predictions).</p><h3>Roadmap for Beginners</h3><p>1. <strong>Learn Python</strong> : Focus on syntax, libraries (<strong>NumPy</strong>, <strong>Pandas</strong>), and data handling.<br>2. <strong>Understand ML Basics</strong> : Study datasets, features, targets, and common algorithms.<br>3. <strong>Practice with Scikit-learn</strong> : Build simple models like Decision Trees.<br>4. <strong>Explore Advanced Topics </strong>: Dive into deep learning, natural language processing, etc.</p><h3>What’s Next?</h3><p><strong>In the next post, we’ll cover:<br>- Preprocessing data for ML.<br>- Using advanced models.<br>- Applying ML to healthcare problems.</strong></p><p>Stay tuned as we continue this exciting journey into Machine Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82da9125d9f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speech to Text Magic with React & AWS Transcribe]]></title>
            <link>https://awstip.com/speech-to-text-magic-with-react-aws-transcribe-088e54b83694?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/088e54b83694</guid>
            <category><![CDATA[voice-to-text-app]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[aws-transcribe]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sat, 20 Apr 2024 13:15:03 GMT</pubDate>
            <atom:updated>2024-04-24T14:43:00.614Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3TWFcb7y5-ar9vFaVr0Vw.png" /></figure><blockquote>In today’s world, AI is at our doorsteps. Everything is automated. Nowadays converting <strong>spoken words to text</strong> is becoming increasingly valuable. Imagine a scenario where you can get real-time transcripts within your application when user speaks something. This is precisely what <strong>Amazon Transcribe</strong> allows you to achieve.</blockquote><p>This blog will guide you through building a React app that leverages AWS Transcribe to deliver speech-to-text functionality.<br>Let’s understand the Architecture first :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uSU8w3Khypyip5O1WD7DIg.png" /></figure><ol><li><strong>Pick up audio files from S3:</strong> We’ll utilise the AWS SDK for JavaScript within the React app to access audio files stored in your S3 bucket.</li><li><strong>Interact with AWS Transcribe:</strong> The code will interact with the Transcribe service using the SDK to initiate the transcription process on the uploaded audio.</li><li><strong>Display Transcribed Text:</strong> Once the transcription is complete, the app will retrieve the output text from S3 and display it within the React interface.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jk7Rla02-NiXDErViIoDdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6_uX4BcyVAGxo-dX" /><figcaption>Let’s Do it</figcaption></figure><p>Let’s see how this is done, I have already built a working demo react app for same. You can find source code here <a href="https://github.com/abhay-321/voice-to-text">https://github.com/abhay-321/voice-to-text</a></p><p>The code implements a React application that utilises AWS Transcribe to convert audio files to text. Here’s a breakdown:</p><ol><li>Project Set up :<br>Please go through the ReadME file</li><li>There is connectAndTranscribe function that handles the audio processing:</li></ol><ul><li>Creates a unique job name and sets up parameters for the transcription job.</li><li>Starts the transcription job using startTranscriptionJob.</li><li>Waits for job completion using a loop (waitForTranscriptionJobCompletion).</li><li>Retrieves the transcribed text from S3 (getTranscriptionResult).</li><li>Updates the application state (textValue) with the transcribed text.</li></ul><p>You just need to update the actual keys in the app and that’s it, you will be able to demo this to anyone!<br>This application can be improved to have Microphone button in the app itself and on clicking on that button, user can have real time experience of converting speech to text.<br>Let me know in the comments if you want it, I will create Part 2<br>Thanks for reading the blog …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qppIHPfGvKIrOaWD" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=088e54b83694" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/speech-to-text-magic-with-react-aws-transcribe-088e54b83694">Speech to Text Magic with React &amp; AWS Transcribe</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying IP Addresses: A Guide to Networking]]></title>
            <link>https://abhayahire.medium.com/demystifying-ip-addresses-a-guide-to-networking-b65ca7f0952e?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b65ca7f0952e</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sun, 29 Oct 2023 07:32:52 GMT</pubDate>
            <atom:updated>2023-10-29T07:32:52.222Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*n9deHoKN736ozjNf4Hof7A.png" /></figure><p>Are you interested in networking?<br>Let’s first understand how internet works. Not about internet basics though.</p><h4>How Domain Resolution Works?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*3AWBG1X4fbZljxnoaQbYnA.png" /></figure><p>When you type a web address (like “<a href="http://www.example.com/">www.example.com</a>&quot;) into your browser, here’s what happens:</p><ol><li>Your browser asks a DNS (Domain Name System) resolver like Amazon Route 53 to find the IP address for the given domain.</li><li>The resolver checks its cache. If it doesn’t have the IP, it asks the root server where to find the domain’s DNS server.</li><li>The DNS server for the domain provides the IP address.</li><li>Your browser uses this IP to connect to the web server, which hosts the website you want to visit.<br>So what is ip address?</li></ol><h4>IP addresses</h4><p>IP addresses are the fundamental building blocks that enable communication across the internet. Whether you’re a seasoned developer or just starting out, understanding the details of IP addresses is crucial. <br>In this blog series, we’ll dive into the world of IP addresses. <br>We will understand IPv4 Addresses, classes and CIDR notation<br>IPv4 Addresses: The Cornerstone of Internet Communication<br>IP (Internet Protocol) addresses are the heart of the internet, acting as unique identifiers for devices on networks. <br>In this blog, we’ll focus on IPv4 addresses, the most commonly used version. <br>Let’s start with the basics.</p><h4>Structure of IPv4 Address</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*icpnQaAMFp-O9KzvzK3UDg.png" /><figcaption>Structure of Ip Address</figcaption></figure><p>An IPv4 address consists of four decimal numbers separated by periods, following the dotted decimal notation. <br>For example: 192.168.0.1.<br>Each of these numbers represents an octet (8 bits) of the address in binary form.<br>Let’s break down the address 192.168.0.1. <br>This address comprises four octets, where “<strong>192</strong>” signifies the <strong>network</strong>. <br>“<strong>168</strong>” represents the <strong>subnet</strong> within that network.<br>“<strong>0.1</strong>” (This depend upon subnet mask) identifies a <strong>specific device</strong> on that subnet. <br>This breakdown is essential because it helps in routing data to the correct destination.</p><h4>Network and Host</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*zwJJe7rnvgCyEAEFanS0tg.png" /></figure><p>Every IPv4 address is composed of two parts: the <strong>network ID</strong> and the <strong>host ID</strong>. <br>To differentiate between them, we use a <strong>subnet</strong> <strong>mask</strong>. <br>Take, for instance, the address 192.168.0.1/24, where the subnet mask is 255.255.255.0. The first 24 bits are the network ID, and the remaining 8 bits represent the host ID.<br>Imagine you live in an apartment complex. <br>The building’s address represents the network, your apartment number is your host ID. <br>The layout of the complex is similar to the subnet mask. It can help direct visitors to visit the correct building and apartment.<br>E.g. Network : Epsilon Society Host Id : Flat no. 1<br>Network : Epsilon Society Host Id : Flat no. 2</p><h4>Classes of IPv4 Addresses</h4><p>IPv4 addresses are categorised into three main classes: A, B, and C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*pq5PLCR-VHXq3VB8Be_MJg.png" /><figcaption>Ipv4 Classes</figcaption></figure><blockquote>Class A: Class A addresses range from 1.0.0.0 to 126.0.0.0. <br>They use an 8-bit subnet mask, allowing for a massive number of total usable addresses. The first octet is used for the network ID, while the remaining three are for host IDs.<br>Class A addresses are like mega cities within the world, with countless addresses.</blockquote><blockquote>Class B: Class B addresses span from 128.0.0.0 to 191.0.0.0. <br>They employ a 16-bit subnet mask. It has more moderate number of usable addresses. The first two octets are dedicated to the network ID.<br>Think of Class B addresses as neighbourhoods in the internet city. <br>Each neighbourhood is a network, and every house within it is a host. <br>These addresses are ideal for medium-sized organisations and networks.</blockquote><blockquote>Class C: Class C addresses extend from 192.0.0.0 to 223.0.0.0. <br>They use a 24-bit subnet mask, providing a smaller range of usable addresses.<br>In this case, the first three octets form the network ID.<br>Class C addresses resemble small communities in the internet landscape. <br>Each community is a network, and each house represents a host. <br>Class C addresses are commonly used for smaller networks, such as home or office setups.</blockquote><h4>Private IP Address Ranges</h4><p>Within the world of IPv4 addresses, certain ranges are reserved for private use. These addresses are not routable on the public internet but are invaluable for creating private networks.<br>Suppose you’re setting up a home network. <br>You might choose an IP address like 192.168.0.1 for your router. This falls within the private Class C range, and it won’t conflict with public internet addresses.</p><h4>Classless Interdomain Routing (CIDR)</h4><p>As the internet continues to grow, a more flexible method for allocating IP addresses came out — Classless Interdomain Routing (CIDR). CIDR allows for variable-length subnet masks, which make IP address allocation much more efficient.<br>Simplified Example<br>Suppose you’re managing a large organization with multiple branches. Traditionally, you might allocate fixed, often oversized address ranges for each branch. This can lead to a waste of IP addresses.</p><p>With CIDR:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*jcs5ld_COiqfUmh10eMAaw.png" /></figure><p>Your main office can use the IP range 192.168.0.0/16.<br>Each branch can use something like 192.168.1.0/24.<br>Here’s what it means:<br>“192.168.0.0” is the <strong>network’s base address</strong>.<br>“/16” and “/24” are <strong>subnet masks</strong>, specifying how many bits are used for the network portion.<br>Efficiency at Its Best<br>CIDR ensures efficient use of IP addresses. You allocate precisely the number of addresses needed for each location. <br>CIDR simplifies IP address management, making allocation and utilisation precise and efficient, which is crucial in our ever-growing digital world.</p><h4>Conclusion</h4><p>Understanding IPv4 addresses is paramount in networking, and this blog has taken you through the essentials. We’ve covered the structure of IPv4 addresses, the concept of network and host. Also the classes of IPv4 addresses, private IP address ranges, and the flexibility provided by CIDR. In our next blog, we’ll dive deeper into the AWS VPC and it’s details. Stay tuned for more networking insights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b65ca7f0952e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing with Mocha and Chai in JavaScript Part 1]]></title>
            <link>https://abhayahire.medium.com/testing-with-mocha-and-chai-in-javascript-part-1-4e54f808a295?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e54f808a295</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sat, 07 Oct 2023 12:17:52 GMT</pubDate>
            <atom:updated>2023-10-07T14:09:47.237Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Introduction</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*Il9V0LI5YNVSqvET397Ybw.png" /></figure><p>Unit Testing is an essential aspect of software development. It ensures your code works as expected. Also prevents bugs from reaching production. Testing provides confidence when making changes to your code base.</p><p>Mocha and Chai are two powerful tools that make writing and running tests a breeze.<br>In this blog post, we’ll dive into the fundamentals of Mocha and Chai testing. We will cover everything from the initial setup to writing complex test suites in TypeScript.<br>Mocha is a testing framework that provides a structure for organising tests. On the other hand, Chai is an assertion library that helps you make assertions.</p><h4>Section 1: Setting up the Environment</h4><p>Before we can start writing tests with Mocha and Chai, let’s set up our development environment.<br>Here are the prerequisites:<br>Node.js: Ensure that you have Node.js installed on your system.<br>You can download it from the official website. https://nodejs.org/ennpm (Node Package Manager): npm comes bundled with Node.js.<br>Verify installation by using node -v and npm -v</p><p>Now, let’s install Mocha and Chai:<br>Open your terminal and create a project directory. <br>mkdir mocha-test <br>Run the following commands to install Mocha and Chai inside directory:<br>npm init -y <br>npm install --save-dev mocha chai<br>This command will add Mocha and Chai to your project’s package.json.</p><p>Congratulations! You’ve successfully set up the environment for Mocha and Chai testing. In the next section, we’ll write our first test.</p><h4>Section 2: Writing Your First Test</h4><p>Let’s start by creating a simple test suite and test case in JavaScript. In your project directory, create a new file, <strong>logger.js</strong>, and add the following code:</p><pre>module.exports = {<br>    greet: function () {<br>        return &quot;hello&quot;;<br>    }<br>}</pre><p>Now Add directory called test and inside that directory create a file loggerTest.js<br>Let’s modify package.json script to run test<br>Modify test command as below<br>“test”: “mocha”<br>Now let’s write our first unit test in loggerTest.js</p><pre>const assert = require(&#39;chai&#39;).assert;<br>const greet = require(&#39;../logger&#39;).greet;<br><br>describe(&#39;logger&#39;, function () {<br>    it(&#39;it should return hello&#39;, function () {<br>        assert.equal(greet(), &#39;hello&#39;);<br>    })<br>})</pre><p>Let’s understand what we are doing here<br>Here’s a breakdown of the code<br>const assert = require(‘chai’).assert;<br>This line imports the assert function from the Chai library.<br>Assertions allow us to check whether the actual result matches the expected result.<br>const greet = require(‘../index’).greet;<br>This line imports the greet function from the logger.js file.<br>The greet function is what we want to test.<br>describe(‘Logger’, function(){…})<br>This is a Mocha test suite.<br>The describe function is used to group related test cases together.<br>In this case, we’re creating a test suite named ‘Logger’ to group our tests related to the logger functions.<br>it(‘it should return hello’, function () {…})<br>This is a Mocha test case.<br>The it function is used to define a single test case. Here we are describing what the test is supposed to check.<br>assert.equal(greet(),’hello’);<br>This line of code is the actual test. It uses the assert.equal function from Chai. It checks whether the result of calling the greet function is equal to the string ‘hello’.<br>If they are equal, the test case passes; otherwise, it fails.<br>Now, open your terminal and run Mocha to execute the test:<br>npm run test</p><pre>aaa-host@ubuntu:~/mocha-tests$ npm run test<br>&gt; mocha-tests@1.0.0 test<br>&gt; mocha<br>  Logger<br>    ✔ it should return hello<br><br>  1 passing (3ms)</pre><p>You should see an output indicating that the test passed. You’ve just written and executed your first Mocha and Chai test!<br>In the next section, we’ll explore Chai’s assertion methods in more detail and learn how to make various types of assertions.</p><h4>Section 3: Using Chai Assertions</h4><p>Chai provides several assertion styles to make your tests more expressive and readable. Here are three common assertion styles: expect, should, and assert for String<br>Create stringUtils.js file in your directory and add following snippets to it</p><pre>module.exports = {<br>  concatStrings: function (str1, str2) {<br>    return str1 + str2;<br>  },<br><br>  capitalize: function (str) {<br>    return str.charAt(0).toUpperCase() + str.slice(1);<br>  },<br><br>  countCharacters: function (str) {<br>    return str.length;<br>  },<br><br>  containsSubstring: function (str, substring) {<br>    return str.includes(substring);<br>  },<br><br>  replaceSubstring: function (str, oldSubstr, newSubstr) {<br>    return str.split(oldSubstr).join(newSubstr);<br>  },<br><br>  splitIntoWords: function (str) {<br>    return str.split(/\s+/);<br>  },<br>};</pre><p>Now to test this functions, create a stringUtilsTest.js inside test directory.</p><pre>const assert = require(&#39;chai&#39;).assert;<br>const expect = require(&#39;chai&#39;).expect;<br><br>const stringUtils = require(&#39;../stringUtils&#39;);<br><br>describe(&#39;String Utilities&#39;, function () {<br>    it(&#39;should concatenate two strings correctly&#39;, function () {<br>        const result = stringUtils.concatStrings(&#39;Hello&#39;, &#39; World&#39;);<br>        assert.strictEqual(result, &#39;Hello World&#39;, &#39;Concatenation failed&#39;);<br>    });<br><br>    it(&#39;should capitalize the first letter of a string&#39;, function () {<br>        const result = stringUtils.capitalize(&#39;javascript&#39;);<br>        assert.equal(result, &#39;Javascript&#39;, &#39;Capitalization failed&#39;);<br>    });<br><br>    it(&#39;should count the number of characters in a string&#39;, function () {<br>        const result = stringUtils.countCharacters(&#39;Hello, World!&#39;);<br>        expect(result).to.be.a(&#39;number&#39;, &#39;Character count is not a number&#39;);<br>        expect(result).to.equal(13, &#39;Character count is incorrect&#39;);<br>    });<br><br>    it(&#39;should check if a string contains a substring&#39;, function () {<br>        const str = &#39;Hello, World!&#39;;<br>        const substring = &#39;World&#39;;<br>        expect(stringUtils.containsSubstring(str, substring)).to.be.a(&#39;boolean&#39;, &#39;Result is not a boolean&#39;);<br>        expect(stringUtils.containsSubstring(str, substring)).to.be.true;<br>    });<br><br>    it(&#39;should replace all occurrences of a substring in a string&#39;, function () {<br>        const str = &#39;Hello, Hello, Hello&#39;;<br>        const oldSubstr = &#39;Hello&#39;;<br>        const newSubstr = &#39;Hi&#39;;<br>        const result = stringUtils.replaceSubstring(str, oldSubstr, newSubstr);<br>        expect(result).to.be.a(&#39;string&#39;, &#39;Replacement result is not a string&#39;);<br>        expect(result).to.equal(&#39;Hi, Hi, Hi&#39;, &#39;Replacement failed&#39;);<br>    });<br><br>    it(&#39;should split a string into an array of words&#39;, function () {<br>        const str = &#39;This is a test&#39;;<br>        const result = stringUtils.splitIntoWords(str);<br>        expect(result).to.be.an(&#39;array&#39;, &#39;Split result is not an array&#39;);<br>        expect(result).to.deep.equal([&#39;This&#39;, &#39;is&#39;, &#39;a&#39;, &#39;test&#39;], &#39;Splitting failed&#39;);<br>    });<br><br>});</pre><p>In these assertions:</p><ul><li>assert.strictEqual: Checks if two values are strictly equal (no type coercion).</li><li>assert.equal: Checks if two values are equal (with type coercion).</li><li>assert.isNumber: Verifies that the result is a number.</li><li>assert.isBoolean: Checks if the result is a boolean.</li><li>assert.isTrue: Asserts that the result is true.</li><li>assert.isString: Verifies that the result is a string.</li><li>assert.isArray: Checks if the result is an array.</li><li>assert.deepEqual: Compares two arrays or objects for deep equality.</li><li>expect(result).to.equal(&#39;value&#39;): Checks if the result is equal to a specific value.</li><li>expect(result).to.be.a(&#39;type&#39;): Verifies the type of the result.</li><li>expect(result).to.be.true: Ensures that the result is true.</li></ul><p>These assertions cover various aspects of testing, such as type checking, equality, and deep comparisons, ensuring thorough testing of stringUtils functions. You can either use assert or expect depending on use case.<br>We will see test cases for more data types like Numbers, Arrays, Object in next part. Also Typescript Set up for Mocha and chai in next article.<br>Facing difficulties to understand the code, please find all source code over here. <a href="https://github.com/abhay-321/mocha-chai-unit-testing/commits/feature/unit-testing-javascript">Github Unit Testing</a></p><p>Thanks for reading, we’ll continue this series and learn more about Testing with mocha and chai 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e54f808a295" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React App CI/CD with Github Actions And AWS S3]]></title>
            <link>https://abhayahire.medium.com/react-app-ci-cd-with-github-actions-and-aws-s3-b23bc43445ff?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b23bc43445ff</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[s3-bucket]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sun, 02 Oct 2022 09:10:16 GMT</pubDate>
            <atom:updated>2022-10-02T09:14:01.769Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Folks,<br>I was working on setting up CI/CD pipeline for deploying React js web applications.<br>Along with that I used Vite for setting up react js typescript application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*ghm6RBV4buTNpg9VmOxf6A.png" /></figure><p>In this short blog we are going to see how we can do that</p><p>1. Set up React js Web application with typescript template using Vite<br>2. Use Github action to build and push build contents to S3<br>3. Host a static website using AWS S3 Service</p><h3>1. Set up React js Web application using Vite</h3><p>Let’s first understand advantages of vite over create-react-app.<br><em>Vite improves the dev server start time by first dividing the modules in an application into two categories: dependencies and source code.</em><br>Check more details at https://vitejs.dev/guide/<br>Now Let’s set up react js application from scratch<br>Use `yarn create vite react-ci-cd — template react-ts` command to create new react project.<br>It will create a react js template inside directory currently you’re in.<br>Use `yarn` to install dependencies and `yarn dev` to run your local server.<br>Head over to http://localhost:5173/ to see the app running.<br>Bravo we have set up react app with vite, it’s pretty fast for live reload.</p><h3>2. Use Github action to build and push build contents to S3</h3><p>For this step, let’s create a empty git repository and add source code into that directory.<br>I have created <a href="https://github.com/abhay-321/react-ci-cd">https://github.com/abhay-321/react-ci-cd</a> and cloned it into my local. I have added all source code into that directory.<br>Let’s add git hub action to build our source code.<br>Create <strong>.github</strong> folder at root level and add <strong>workflows</strong> folder in that.<br>Inside you can create different workflows.<br>Let’s add workflow to build source code, so create <strong>dev-workflow.yml</strong> and add following code in it</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a3c6d91d8a90d5584ad7ea77ba33caa/href">https://medium.com/media/1a3c6d91d8a90d5584ad7ea77ba33caa/href</a></iframe><p>Let’s understand what we are doing over here.<br><strong>name : W</strong>e have given name to our workflow as React CI<br><strong>push :</strong> Our workflow will get triggered whenever we push something to master<br><strong>jobs : </strong>We can create multiple jobs inside jobs<br><strong>build :</strong> We have created build job for configuration of source code in it<br><strong>steps : </strong>Using available step to fetch code and run commands<br>We’re done. Let’s commit and push this code to master and you’ll be able to see build triggered on git hub page.<br>You can check build triggered on github repository page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*qdEs2i5_JLjEcTxf-g4R-w.png" /></figure><p>You can click on that yellow dot to see the build details or go to actions tab in repository page. Let’s add one more step to push build to S3 bucket. But before that let’s create s3 bucket</p><h3>3. Host a static website using AWS S3 Service</h3><p>Head over aws s3 console and create s3 bucket, add name to bucket and disable block public access and click on Create bucket button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*AShYaGEWpa6NVSOnSLNAZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*1-DYll2dnJvLy_qlW97bHQ.png" /></figure><p>Now to go to properties section and Enable Static Web hosting, also add <strong>index.html</strong> as index document</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*aXPNBBW8icnmjyTDE-U2yg.png" /></figure><p>Also in Permissions section Add following <strong>bucket policy</strong> with your bucket arn</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*Z8OUuq3B54j44OM6IQUkpQ.png" /></figure><p>We are done with set up for S3.<br>Let’s go to github dashboard and click on settings for repository<br>Click on Secrets and then Actions and add secrets as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*sqbHRKIBO71j_vW-FYrLQQ.png" /></figure><p>You can get access and secret key from IAM service and bucket name from s3. <br>Now let’s update our github workflow to push build to s3.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0b6764c5365a398a3bd1398ef516aa6/href">https://medium.com/media/a0b6764c5365a398a3bd1398ef516aa6/href</a></iframe><p>Add above step just below the build step. Here we are using already built step which helps us to push build into s3. We need to specify access key, secret key and bucket name. We have already stored them inside secrets.<br>Let’s commit this code and push to git. You can see the action triggered in git. Once build is finished, you can go to S3’s Properties section and copy url from Static web hosting section. Open that url in web browser<br>Hooray, We are able to automate web hosting for our react ci cd app.<br>Now every time you push something to master branch that will be automatically reflected in your web site.<br>Facing issues in work flows, no worries, checkout ready code base at<br><a href="https://github.com/abhay-321/react-ci-cd">GitHub Repo for CI/CD</a></p><p>In next article we’ll take this more further with Cloudfront and Route53 services</p><p>Stay tuned, Thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b23bc43445ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular View Blob (Base64) Image and Print PDF]]></title>
            <link>https://abhayahire.medium.com/angular-view-blob-base64-image-and-print-pdf-33b8e7dfaecd?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/33b8e7dfaecd</guid>
            <category><![CDATA[blob]]></category>
            <category><![CDATA[base64]]></category>
            <category><![CDATA[print-pdf]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sun, 14 Aug 2022 13:06:43 GMT</pubDate>
            <atom:updated>2022-08-14T13:20:34.289Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Folks,<br>I was working on quick fix to add<strong> print pdf feature in angular.</strong> <br>But didn’t found relevant resource around it. So writing this blog for you guys.<br>In this short blog we are going to see how we can do that<br><strong>1. Render base64 image into browser.</strong><br><strong>2. To print that image using angular</strong> with the help of JavaScript.</p><p>Let’s generate angular application from scratch<br>Use ng new print-pdfcommand to create new angular project.<br>Now as first thing we need to show image into browser. <br>We have added static base64 encoded string into assets folder within data.json file. You can check <a href="https://github.com/abhay-321/angular-print-pdf">github link</a> to see the contents.<br>We’ll use that string to render image into browser.<br>But what’s base64? <strong>Base64 is to encode files into string format that can be transferred over the network and can again be decoded to get the same file.</strong><br>Let’s see how to do that<br>Let’s create a http service to load that static base64 string for us.<br>Create Http Service named data-service as follows<br>You can use ng g s datacommand to generate it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dacd6f77bd80ad8600f24e0d76e8d41b/href">https://medium.com/media/dacd6f77bd80ad8600f24e0d76e8d41b/href</a></iframe><p>Now In main app component , inject data-service as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2079dfbd3b4981d059b7016868a45ec/href">https://medium.com/media/c2079dfbd3b4981d059b7016868a45ec/href</a></iframe><p>Along with dataService we have injected DomSanitizer to allow us to render image from base64 string into browser. In ngOnInit, we are calling dataService to load base64 string and store it into base64String.<br>Before storing it, we are sanitizing it using DomSanitizer’s bypassSecurityTrustUrl function.<br>Let’s add image tag in app component to render the image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e89c5060e2cb782ef5e6cd5512f2dca/href">https://medium.com/media/3e89c5060e2cb782ef5e6cd5512f2dca/href</a></iframe><p>Now run your application using ng serve<br>Bravo!!! Our first job is completed…<br>Now we’ll see how to add Print PDF feature.<br>Add a simple button in our page to open print view.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9979d889c89f31c09ca0d20c46de75f3/href">https://medium.com/media/9979d889c89f31c09ca0d20c46de75f3/href</a></iframe><p>In app.component.ts add following printPDF() function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f3f3af5fbec00440ab0fd9d23ae8800/href">https://medium.com/media/3f3f3af5fbec00440ab0fd9d23ae8800/href</a></iframe><p>Here we are referecing target element to be printed by id `printContainer`<br>We are using javascript to open new window using window.open()<br>You can adjust new window’s location using css specified as a third argument.</p><p>Now let’s run our application again.<br>It’s opening print window as expected after clicking on print button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqtxxcwQZFp0ty8pE-Rmxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*MwwkpsKhspi5zFCnX6F3Tg.png" /></figure><p>Now you can use more controls as Saving PDF, changing layout mode.<br>Cool!!!<br>You can checkout ready codebase at <a href="https://github.com/abhay-321/angular-print-pdf">https://github.com/abhay-321/angular-print-pdf</a>.<br>Thanks for reading.. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33b8e7dfaecd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring boot Micro services Architecture with Spring Cloud 1.0]]></title>
            <link>https://abhayahire.medium.com/spring-boot-micro-services-architecture-with-spring-cloud-1-0-fd510cec8534?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd510cec8534</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring-cloud-config]]></category>
            <category><![CDATA[spring-cloud]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Mon, 25 Apr 2022 04:08:56 GMT</pubDate>
            <atom:updated>2022-04-25T04:08:56.719Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we are going to see all fine details to create micro services in spring boot. This will be in series and in first article we are going to see all theoretical stuff and config server set up that you guys need to understand before jumping into implementing micro services with spring boot and spring cloud. Let’s first understand what is micro service architecture and what are the advantages of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*C-RPYhhxCZwwbFdVbr3CFA.png" /></figure><h3>What are microservices?</h3><p>Micro services is a architecture(<strong>service-oriented architecture) </strong>(SOA). In this architecture, applications are broken down into various services. Motivation behind this is separation and modularity.</p><p>Unlike monolithic architecture, microservices are more beneficial.<br>We don’t need to specify all business logic into a single software module which leads to complexity and time consuming while debugging.</p><p>Few Advantages of microservices are</p><ul><li>Increases scalability</li><li>More flexibility</li><li>Modular architecture</li><li>Ease of introducing new features</li><li>More reliable and robust structure</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*nchr2Q9wC9uC-6Dv" /></figure><p>Monolithic Architecture</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/0*BHqyq4UI2RZbjNo4.png" /></figure><h3>Why Spring boot+ Spring cloud for microservices?</h3><p>With Spring Boot, your microservices can start small and iterate fast. That’s why it has become the de facto standard for Java microservices. Quickstart your project with Spring Initializr and then package as a JAR. With Spring Boot’s embedded server model, you’re ready to go in minutes.<br>Now we have understood , what is micro service architecture and how spring boot helps us implement same. Let’s understand the all components involve in this architecture.</p><h3>Spring boot and Spring cloud Components</h3><ul><li>Spring Cloud Config Server</li><li>Manage multiple Environments using config server</li><li>Need of Spring Cloud Bus</li><li>Microservices inter communication using RestTemplate</li><li>Microservices inter communication using Feign Client and OpenFeign</li><li>Load Balancer (Ribbon)</li><li>Need of Naming Server (Eureka)</li><li>Service Registry and Service Discovery</li><li>Intro to API Gateway (Zuul) and Spring Cloud Gateway</li><li>Intro to Distributed Tracing (Zipkin)</li><li>Fault Tolerance(Hystrix)</li><li>Spring Cloud Bus</li></ul><p>Let’s see all of them one by one. For this article, we’ll consider creating a Appointment MicroService and Spring Cloud Config Server.<br>Again, we are not going to write down any business logic or implementation for any of the service, we’re just considering this services to understand flow theoretically.</p><h4>Spring Cloud Config Server -&gt; Why ?</h4><p>Let’s understand need of config server. In microservice architecture we need to maintain configuration for each service. This configuration may include database credentials for that service or any environment variables you may declare. Spring comes with application.properties file for storing configurations for your application. But it’s a hectic job for Devops person to update those configurations looking into individual service in case of any updates. So spring cloud comes up with a way to manage all configurations for each service at <strong>central place</strong>. We can do it with help of Spring cloud <strong>Config Server</strong></p><h4>Spring Cloud Config Server -&gt; How ?</h4><p>To create config server, you need to create spring app with Config Client dependency with following dependencies. <strong>Dev Tools</strong> is used for live reloading and <strong>config server</strong> for Spring Cloud Config Server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*feYn7Y-7lB6nm_obolwuRw.png" /></figure><p>Inside your main class, Add @<strong>EnableConfigServer</strong> annotation. Almost done,<br>But wait, where we’ll store configurations.</p><h4>Spring Cloud Config Server -&gt; Git Repo Role ?</h4><p>You need to create a git repo and link it to your spring config application. You can create a local git repo or add it to origin. Inside your git repo, you can add multiple configuration files for your services like provider-service.properties, appointment-service.properties etc. If you want to manage multiple environments for a service then you can do that as well like appointment-service-dev, appointment-service-qa.properties. You’ll be able to read those configurations in config client. You need to make sure name of properties inside git repo must match with name of application inside your microservice application properties file. Also make sure to commit changes otherwise they’ll not be reflected</p><h4><strong>Spring Cloud Config Server -&gt; Connect Git repo to microservice</strong></h4><p>For that you need to add <br><strong>spring.cloud.config.server.git.uri</strong>: file://${user.home}/config-repo<br>inside your config server application.properties file.<br>Now navigate to browser and hit `<a href="http://localhost:9000/webtech4u-appointment-service/default">http://localhost:9000/webtech4u-appointment-service/default</a>` and you’ll be able to list of configurations we added inside webtech4u-appointment-service.properties file.</p><h4>Spring Cloud Config Server -&gt; Create Micro service and Read configurations from Application.properties</h4><p>Let’s create Appointment Service app with following dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*lYZ9fOOItskmGPxElhDA4Q.png" /></figure><p>You can create config class to read configurations from application.properties.<br>Let’s create AppointmentConfig class and annotate it with @Component and <a href="http://twitter.com/ConfigurationPropert">@ConfigurationPropert</a>ies(“Application name here”) and you can declare properties inside your application file inside this class with same name and getters, setters and spring will do the magic of mapping and you’ll be able to read those values inside config class.<br>You can now autowire your config class into your controller to test flow</p><h4>Spring Cloud Config Server -&gt; Connect Micro service and Spring Cloud Config Server</h4><p>To connect your microservice with config server, you need to add <strong>spring.cloud.config.uri: </strong><a href="http://myconfigserver.co/"><strong>http://configServerUrl.co</strong></a><strong>m </strong>in your service and you’ll be able to access every configuration inside your git repo by the file name e.g. In Appointment Service, you’ll be able to read configuration from appointment-service.properties inside git repo. The properties declare inside git repo properties file will override the local properties in your service.</p><h4>Spring Cloud Config Server -&gt; Implementation</h4><p>Facing difficulties in understanding above flow, no worries! We have everything ready and implemented for you. Just visit <a href="https://github.com/abhay-321/webtech4u-spring-microservices">https://github.com/abhay-321/webtech4u-spring-microservices</a>, clone the repos and run Appointment Service and Config Server with the help of commands mvn clean install &amp;&amp; mvn spring-boot:run and visit `<a href="http://localhost:9000/webtech4u-appointment-service/default">http://localhost:9000/webtech4u-appointment-service/default</a> to see config server output and `<a href="http://localhost:8100/configs">http://localhost:8100/configs</a> to read configs in appointment service.</p><p>We’ll continue this series and understand rest of components involved in microservice architecture, see you guys in next part of this series!!!.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd510cec8534" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD using GitHub Actions, Build/Push Docker Image to Docker Hub]]></title>
            <link>https://abhayahire.medium.com/ci-cd-using-github-actions-build-push-docker-image-to-docker-hub-f2b6e5a6f6e9?source=rss-d10431ecf4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2b6e5a6f6e9</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Abhay Ahire]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 05:06:48 GMT</pubDate>
            <atom:updated>2022-02-26T05:06:48.863Z</atom:updated>
            <content:encoded><![CDATA[<p>Nowadays automation is the key to the success. Manually handling deployments and servers is completely outdated. But why are we talking about automation here. I came across many people who want to know CI/CD in detail and see it action with GitHub which completely automates process of code build and deployment process. So in this article we are going to</p><ol><li>Learn About CI/CD</li><li>Create NodeJs Express App</li><li>Add GitHub Action for CI</li><li>Dockerize NodeJs App</li><li>Finally, Build and Push Docker Image to Private Docker Repo</li></ol><p>So, first of all, let’s understand what’s CI/CD and what is need for it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJ2nmXjd-8hVOVlUsvPTqw.png" /></figure><h4>Continuous Integration</h4><p>Continuous integration (CI) is a software practice that requires frequently committing code to a shared repository. Committing code more often detects errors sooner and reduces the amount of code a developer needs to debug when finding the source of an error. This is great for developers, who can spend more time writing code and less time debugging errors or resolving merge conflicts.<br>When you commit code to your repository, you can continuously build and test the code to make sure that the commit doesn’t introduce errors.</p><h4>Continuous Deployment</h4><p>You can configure your CD workflow to run when a GitHub event occurs (e.g. when new code is pushed to the default branch of your repository), on a set schedule, manually, or when an external event occurs using the repository dispatch webhook.<br>So whenever developer commits code to specified branch, he don’t need to worry about building the code , executing tests and deploying the application to specified environment.<br>Now we know what is CI/CD, then let’s see how we can achieve same using GitHub Actions but more of practically.<br>Let’s create a simple NodeJs simple application <br>Create a directory in your system and fire npm initand initialise node app. Install express package, using npm install express.<br>Create Express server by adding following piece of code in index.js file in same directory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fc51d92da76f0e64ad8bee597f2d0eb/href">https://medium.com/media/7fc51d92da76f0e64ad8bee597f2d0eb/href</a></iframe><p>Hit npm start and head over to browser and type url “<a href="http://localhost:3000/">http://localhost:3000/</a>” and you’ll be able to see greeting from server.<br>For any issues, check code base from here, <a href="https://github.com/abhay-321/node-docker-ci-cd.">https://github.com/abhay-321/node-docker-ci-cd.</a> In many of cases, we need to run tests before merging our code into public branches. To achieve same, we’ll add dummy test case in our app and Jest library as a test framework.<br>Add script in package.json file as “test: jest”, when you run command npm test jest will look for all files in codebase having test.js or spec.js.<br>We’ll add dummy test as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d891a54e480cfe82a3d29ac8e2376f8b/href">https://medium.com/media/d891a54e480cfe82a3d29ac8e2376f8b/href</a></iframe><p>Now run tests with npm test and you’ll be able to see one successful test case passed. Now it’s time to use github action to build and test our code. To use github actions, we need to create actions to tell git what needs to be done within scope of that action.<br>Github actions are located under .github/workflows. Let’s add a action for CI<br>Create a directory .github/workflows and create a file node.js.yml as</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90a8c67308b6338a9dad014d0770fcb0/href">https://medium.com/media/90a8c67308b6338a9dad014d0770fcb0/href</a></iframe><p>Let’s understand yaml file to define github action.<br>name: Node.js CI The name of the workflow (Optional)<br>on: [push] Trigger for this workflow. Determines on which type of event this workflow will be triggered<br>branches: [development] Work flow will be triggered if push events happens on development branch.<br>jobs: Contains all the jobs that run in the Node.js CI workflow.<br>runs-on: ubuntu-latest Decides where job will run. Here it will run on fresh virtual machine hosted by GitHub.<br>strategy: Used to create build matrix<br>matrix: can be used to run tests across multiple combinations of operating systems, platforms, and languages.<br>steps: Contains together all the steps that run in the build job.<br>- uses: actions/checkout@v2 The <strong>uses</strong> keyword specifies that this step will run <strong>v2</strong> of the <strong>actions/checkout</strong> action. This predefined action checks out your code to runner to build and run test etc.<br>- name: Step name that will appear on GitHub UI<br>- uses: actions/setup-node@v2 Action to install the specified version of the Node.js given in node-version<br>- run: npm ci The <strong>run</strong> keyword tells the job to execute a command on the runner. Same for next two commands to build and test code.<br>So Above workflow simply tells git that <strong>whenever code is committed to development branch, checkout that code build it and run tests.<br></strong>This ensures code stability before merging code into stable branches.<br>You’ll be able to see workflow status under Repository -&gt; Actions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uef8zJIPOl67xiUaAN1uTw.png" /></figure><p>But what about continuous development. Let’s do that as well</p><h4>Continuous Deployment</h4><p>Whenever code is tested and build, we can create a docker image and push that image to docker repository (Either ECR repository or Docker Repo) can be used to create a writable container layer over the specified image.<br>To do that let’s add one more step in our workflow.<br>Before that let’s dockerize our nodejs app. For same add Dockerfile in your code base at root level as in following github repo. <a href="https://github.com/abhay-321/node-docker-ci-cd/blob/development/Dockerfile">https://github.com/abhay-321/node-docker-ci-cd/blob/development/Dockerfile</a></p><p>Adding this you can test your docker image locally as<br>docker build -t ci-cd-app:latest. Once your image is built, you can run docker run -p 3000:3000 ci-cd-app:latest. You can add -d flag to run container in detached mode. To know more about dockerizing node app, please visit this article.</p><p><a href="https://medium.com/@abhayahire3/dockerize-nodejs-expressapplication-d765411b741b">Dockerize NodeJs ExpressApplication</a></p><p>Now we have added Dockerfile, let’s add one more step in work flow to build and push our docker image to docker hub.<br>Add following code snippet at end of your workflow yaml file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ec72492c5a019b1ebc3c57f0d0e16a40/href">https://medium.com/media/ec72492c5a019b1ebc3c57f0d0e16a40/href</a></iframe><p>Here we’re adding predefined action which is used to build and push docker image. <br>image: Name of private repository in docker hub.<br>registry: Type of docker registry used to store docker image. <br>username: Docker username stored under Settings -&gt; Secrets in Github Repo<br>password: Docker password stored under Settings -&gt; Secrets in Github Repo<br>dockerfile: Dockerfile used to build docker image with specified commands</p><p>You can either push your image to Docker Hub or AWS ECR, in our example we’re pushing image into docker hub repository. Once you commit changes to development, work flow will be triggered and once it’s succeeded, you’ll be able to image in docker hub as follows. You can share it with anyone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNibNOvPfkJBFXehdBCjgw.png" /></figure><p>That image can be used to run a container over ECS or GKE to deploy your application.<br>That’s it, we have built a complete CI/CD workflow using github actions here.<br>Though, it’s very simple and basic flow, Github actions can be used based on environments, deployments, security, Automation like automating issue assigning process or greeting user.<br>You can checkout complete code base here <a href="https://github.com/abhay-321/node-docker-ci-cd">https://github.com/abhay-321/node-docker-ci-cd</a>.<br>Thanks for reading, In case of any doubts feel free to ask them in comment section, I’ll be happy to help 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2b6e5a6f6e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>