<?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 Krishnadeva Sathursan on Medium]]></title>
        <description><![CDATA[Stories by Krishnadeva Sathursan on Medium]]></description>
        <link>https://medium.com/@sathursan?source=rss-e535c37b7b66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qY9aCJNAeXX5UEw96ewg2g.jpeg</url>
            <title>Stories by Krishnadeva Sathursan on Medium</title>
            <link>https://medium.com/@sathursan?source=rss-e535c37b7b66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:36:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sathursan/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[An Introduction to Serverless Computing with AWS Lambda and DynamoDB: Building a Todo List]]></title>
            <link>https://awstip.com/an-introduction-to-serverless-computing-with-aws-lambda-and-dynamodb-building-a-todo-list-959e06a8d308?source=rss-e535c37b7b66------2</link>
            <guid isPermaLink="false">https://medium.com/p/959e06a8d308</guid>
            <category><![CDATA[solution-architect]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[lambda-function]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Krishnadeva Sathursan]]></dc:creator>
            <pubDate>Tue, 03 Jan 2023 17:50:13 GMT</pubDate>
            <atom:updated>2023-01-12T15:26:30.995Z</atom:updated>
            <content:encoded><![CDATA[<p>In this tutorial, we will learn how to build a simple todo list using AWS Lambda and Amazon DynamoDB. AWS Lambda is a serverless computing platform that runs your code in response to events and automatically manages the underlying compute resources. DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance. By combining these two services, we can create a todo list that is scalable, reliable, and easy to maintain. We will create a Lambda function that can be triggered by HTTP requests, and use DynamoDB to store and retrieve the todo items.</p><h3>Prerequisites</h3><p>Before getting started, you will need the following:</p><ul><li>An AWS account. If you don’t have one already, you can sign up for a free trial at <a href="https://aws.amazon.com/">aws.amazon.com</a>.</li></ul><h3>Creating the DynamoDB Table</h3><p>The first step is to create a DynamoDB table that will store the todo items. We will use the AWS Management Console to create the table.</p><ol><li>Go to the <a href="https://console.aws.amazon.com/dynamodb">DynamoDB console</a>.</li><li>Click the “Create table” button.</li><li>In the “Create DynamoDB table” form, enter the following:</li></ol><ul><li>Table name: todos</li><li>Primary key: todo_id (string)</li></ul><p>4. Click the “Create” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RlckZTf64VGu87Efa2bjdg.png" /><figcaption>Table Creation</figcaption></figure><p>The table will be created in a few seconds. You can view the table in the DynamoDB console to see the details and the current contents of the table (which should be empty).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qyL3e2Y_esf635Ec6ONZOQ.png" /></figure><h3>Creating the Lambda Function</h3><p>Next, we will create the Lambda function that will handle the HTTP requests and interact with the DynamoDB table.</p><ol><li>Go to the <a href="https://console.aws.amazon.com/lambda">Lambda console</a>.</li><li>Click the “Create function” button.</li><li>In the “Create function” form, enter the following:</li></ol><ul><li>Name: todos</li><li>Runtime: Node.js 14.x</li><li>Permissions: Choose “Create a new role with basic Lambda permissions”</li></ul><p>4. Click the “Create function” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Vd9q219g4nciv7UBymmMQ.png" /></figure><p>This will create a new Lambda function with a basic configuration. You can view the function in the Lambda console to see the details and the code editor.</p><p>In the permission section, you need to give permission to access dynamodb so you have to create a role and assign it here.</p><p>To allow an AWS Lambda function to access Amazon DynamoDB, you will need to create an IAM execution role for the function and attach a policy that grants the necessary permissions. Here are the steps to do this:</p><ol><li>Go to the <a href="https://console.aws.amazon.com/iam">IAM console</a>.</li><li>Click the “Roles” menu in the left sidebar, and then click the “Create role” button.</li><li>In the “Create role” form, select “Lambda” as the service that will use this role, and click the “Next: Permissions” button.</li><li>In the “Attach permissions policies” step, search for and select the “AWSLambdaDynamoDBExecutionRole” policy. This policy grants the necessary permissions for a Lambda function to access DynamoDB.</li><li>Click the “Next: Tags” button.</li><li>(Optional) Add any tags that you want to associate with the role.</li><li>Click the “Next: Review” button.</li><li>In the “Review” step, enter a name and a description for the role, and then click the “Create role” button.</li></ol><p>This will create a new IAM execution role with the necessary permissions to access DynamoDB. To use this role with a Lambda function, you will need to specify the role when you create or update the function.</p><h3>Writing the Code</h3><p>Now, we can write the code for the Lambda function. The function will support four HTTP methods: POST, GET, PATCH, and DELETE.</p><ul><li>The POST method will be used to create a new todo item.</li><li>The GET method will be used to retrieve the entire list of todo items.</li><li>The PATCH method will be used to update the completed status of a todo item.</li><li>The DELETE method will be used to delete a todo item.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pl6H7pBzQi8jcp96Ms1w1A.png" /></figure><p>Here is the code for the Lambda function:</p><pre>const AWS = require(&#39;aws-sdk&#39;);<br>const dynamoDB = new AWS.DynamoDB.DocumentClient();<br><br>exports.handler = async (event) =&gt; {<br>    // Extract the HTTP method and the request body from the event<br>    const { httpMethod, body } = event;<br><br>    if (httpMethod == &#39;POST&#39;) {<br>        // Parse the request body as JSON<br>        const { todo_id, todo } = event.body;<br><br>        // Create a new item in the DynamoDB table<br>        const params = {<br>            TableName: &#39;todos&#39;,<br>            Item: {<br>                todo_id: todo_id,<br>                todo: todo,<br>                completed: false<br>            }<br>        };<br>  <br>        let confrim = await dynamoDB.put(params).promise();<br><br>        // Return the new item in the response<br>        return {<br>            statusCode: 201,<br>            body: JSON.stringify(params.Item, confrim)<br>        };<br>    } else if (httpMethod === &#39;GET&#39;) {<br>        // Retrieve all items from the DynamoDB table<br>        const params = {<br>            TableName: &#39;todos&#39;<br>        };<br>        const result = await dynamoDB.scan(params).promise();<br><br>        // Return the list of items in the response<br>        return {<br>            statusCode: 200,<br>            body: JSON.stringify(result.Items)<br>        };<br>    } else if (httpMethod === &#39;PATCH&#39;) {<br>        // Parse the request body as JSON<br>        const { id, completed } = JSON.parse(body);<br><br>        // Update the item in the DynamoDB table<br>        const params = {<br>            TableName: &#39;todos&#39;,<br>            Key: {<br>                id: id<br>            },<br>            UpdateExpression: &#39;SET completed = :completed&#39;,<br>            ExpressionAttributeValues: {<br>                &#39;:completed&#39;: completed<br>            }<br>        };<br>        await dynamoDB.update(params).promise();<br><br>        // Return the updated item in the response<br>        return {<br>            statusCode: 200,<br>            body: JSON.stringify({ id, completed })<br>        };<br>    } else if (httpMethod === &#39;DELETE&#39;) {<br>        // Parse the request body as JSON<br>        const { id } = JSON.parse(body);<br><br>        // Delete the item from the DynamoDB table<br>        const params = {<br>            TableName: &#39;todos&#39;,<br>            Key: {<br>                id: id<br>            }<br>        };<br>        await dynamoDB.delete(params).promise();<br><br>        // Return an empty response<br>        return {<br>            statusCode: 204,<br>            body: &#39;&#39;<br>        };<br>    }<br>};</pre><p>when we test this with this json,</p><pre>{<br>  &quot;httpMethod&quot;: &quot;POST&quot;,<br>  &quot;body&quot;: {<br>    &quot;todo_id&quot;: &quot;1&quot;,<br>    &quot;todo&quot;: &quot;learn lambda&quot;<br>  }<br>}</pre><p>we can get a successful message in the lambda log section with a 201 status code as a response, and you can verify the result in DynamoDB table also.</p><p>In conclusion, AWS Lambda and Amazon DynamoDB are powerful tools for building serverless applications. By using these services together, we can create a scalable, reliable, and easy-to-maintain todo list. In this tutorial, we learned how to create a DynamoDB table, create a Lambda function, and write code to handle HTTP requests and interact with the DynamoDB table. With these skills, you can build other serverless applications that leverage the power of AWS Lambda and DynamoDB.</p><p>To learn more about these services, you can check out the following resources:</p><ul><li>The <a href="https://docs.aws.amazon.com/lambda">AWS Lambda documentation</a> provides a comprehensive guide to using AWS Lambda.</li><li>The <a href="https://docs.aws.amazon.com/amazondynamodb">Amazon DynamoDB documentation</a> provides detailed information on working with DynamoDB tables and items.</li></ul><p>I hope you enjoyed this tutorial and that it was helpful in your journey to becoming an AWS developer!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=959e06a8d308" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/an-introduction-to-serverless-computing-with-aws-lambda-and-dynamodb-building-a-todo-list-959e06a8d308">An Introduction to Serverless Computing with AWS Lambda and DynamoDB: Building a Todo List</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[Transfer ERC20 Token with and without a wallet.]]></title>
            <link>https://medium.com/web3-magazine/transfer-erc20-token-with-and-without-a-wallet-2b8ddb470db1?source=rss-e535c37b7b66------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b8ddb470db1</guid>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[ethersjs]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[metamask]]></category>
            <dc:creator><![CDATA[Krishnadeva Sathursan]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 15:37:13 GMT</pubDate>
            <atom:updated>2022-07-04T05:34:13.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hO2rIgch6xyBZqpn" /><figcaption>Photo by <a href="https://unsplash.com/@quantitatives?utm_source=medium&amp;utm_medium=referral">Quantitatives</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Usually, we are using Ether or other core Blockchain coins (MATIC/ SOLANA) for the payment. Even though, some applications use their own ERC-20 Token for purchasing their NFTs / play games (Axie Infinity). So, In this article, we will look up how to use an ERC-20 Token for payment using Metamask.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWl3kT1A8JkDTKXlCXp1Nw.jpeg" /><figcaption>Sample ERC20 Tokens</figcaption></figure><h4>Using an ERC-20 Token in Ethereum Blockchain</h4><p>Things needed to connect to the blockchain.</p><ol><li>Token Address.</li><li>Token ABI.</li><li>Wallet</li><li>Ethers.js / Web3.js</li></ol><h4>Token Address</h4><p>In Blockchain, <strong>Address</strong> is like an email address for crypto assets. It is a unique sequence of numbers and letters. We need this address to interact with other crypto holders/ smart contracts. Now to interact with an ERC-20 Token, we need its smart contract address. While we deploy the token contract, we can get the token address. For this article, we are using NXC Token (<a href="https://ropsten.etherscan.io/address/0xf78375c346da3adae1c8b07ea1fdff93da08ddb9">https://ropsten.etherscan.io/address/0xf78375c346da3adae1c8b07ea1fdff93da08ddb9</a>). It is deployed on Ropsten Test Network (It&#39;s an Ethereum test net). Now we have the address of the token, but that is not only enough to connect with the blockchain. Now we need its Token ABI.</p><h4>ABI (Application Binary Interface)</h4><p>There could be several functions in a contract. An <strong>ABI</strong> is necessary so that we can point to the specific function call that we want to evoke and also get a guarantee that the function will return data in the format we are expecting. So to call the specific functions on our token contract, we need this token ABI. While we deploy the smart contract, the Remix IDE automatically generates the ABI code for us. Here is the standard ERC-20 Token ABI code. <a href="https://ethereumdev.io/abi-for-erc20-contract-on-ethereum/">https://ethereumdev.io/abi-for-erc20-contract-on-ethereum/</a>. Now, we have Token address and Token ABI. Now we need a wallet to send/ receive an ERC-20 Token.</p><h4>Wallet</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*-4mms6YCrjqgvpu-z-08Wg.jpeg" /></figure><p>Blockchain Wallet is digital software that runs on a blockchain and stores private and public keys as well as monitors and keeps all the transactions related to those keys on a blockchain. Metamask, Wallet connect, Exodus, Mycelium, and Electrum are some of the well know wallets. So, In our application, we will use Metamask. Because it is very easy to use and has developer-friendly documentation.</p><blockquote><strong>Now we need to add our NXC Token to Metamask wallet.</strong></blockquote><p>When we paste, the Token contract address, it will automatically fill up the Token Symbol and Token Decimal fields.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eh5XqCkP_54a1K3C08oVdA.png" /><figcaption>Metamask Import Token window</figcaption></figure><p><strong><em>Let’s get into code….</em></strong></p><p>Now we can use Ethers.js/ Web3.js library to connect the application with the Blockchain. These are the most famous library used by developers. Both have good documentation also.There are so many ways to connect our application with the blockchain.</p><h4>Connect the application with Metamask Wallet</h4><p>Common customers can send tokens to the application through wallets. First, we need to connect the Metamask wallet with our application.</p><pre>import {useEffect, useState} from &quot;react&quot;;<br>import {ethers} from &quot;ethers&quot;;</pre><pre>export const getWeb3 = () =&gt; {<br>  if (window.ethereum) {<br>    provider = new ethers.providers.Web3Provider(window.ethereum);<br>    return provider;<br>  } else {<br>    return false;<br>  }<br>}</pre><pre>const provider = getWeb3();<br></pre><pre>function MetaMaskContext() {</pre><pre>  const [isMetaMaskInstall,setIsMetaMaskInstall]=useState();<br>  const [isMetaMaskConnected,setIsMetaMaskConnected]=useState(true);<br>  const [accountId, setAccountId] = useState();<br>  const [networkVersion, setNetworkVersion] = useState();<br>  const [isDataLoading, setIsDataLoading] = useState(true);</pre><pre>  const setAccountDetails = async () =&gt; {<br>    const accounts = await provider.listAccounts();</pre><pre>    if (accounts.length === 0) {<br>      setIsMetaMaskConnected(false);<br>    } else {<br>      setIsMetaMaskConnected(true);<br>      setAccountId(accounts[0]);<br>    }<br>  }</pre><pre>  <em>// subscription for account change detection</em><br>  const accountChangeDetection = async () =&gt; {<br>    window.ethereum.on(&quot;accountsChanged&quot;, async function () {<br>      setIsDataLoading(true);<br>      await setAccountDetails().finally(() =&gt;  setIsDataLoading(false));<br>    });<br>  }</pre><pre>  <em>// subscription for networkVersion change detection</em><br>  const networkVersionChangeDetection = async () =&gt; {<br>    window.ethereum.on(&#39;chainChanged&#39;, function (networkId) {<br>      setNetworkVersion(Number(networkId));<br>    });<br>  }</pre><pre>  useEffect(() =&gt; {<br>    const init = async () =&gt; {<br>      try {<br>        await provider.send(&quot;eth_requestAccounts&quot;, []);<br>        setIsMetaMaskInstall(true);</pre><pre>        <em>// first time set current network version Id.</em><br>        const {chainId} = await provider.getNetwork()<br>        setNetworkVersion(chainId);</pre><pre>        <em>// first time call for load initial details</em><br>        await setAccountDetails();</pre><pre>        <em>// subscription for account change detection</em><br>        await accountChangeDetection();</pre><pre>      } catch (e) {<br>        setIsMetaMaskInstall(false);<br>        setIsDataLoading(false);<br>        setIsMetaMaskConnected(false);<br>        const eMessage = e.message.split(&#39;{&#39;)[0] || &#39;&#39;;<br>        console.log(eMessage);<br>      }<br>    }init().then(r =&gt; setIsDataLoading(false));<br>  }, []);</pre><pre>  useEffect(async() =&gt; {</pre><pre><em>    // subscription for network Version change detection</em><br>    await networkVersionChangeDetection();<br>  },[networkVersion])</pre><pre>  return {isMetaMaskInstall, accountId, networkVersion, isDataLoading, isMetaMaskConnected};</pre><pre>}</pre><pre>export default MetaMaskContext;</pre><p>We just connected Metamask with our application. Now our application can track the wallet Id, Metamask connection status, and Blockchain Id(Ropsten/ Matic/Klaytn).</p><h3>Initiate ERC20 transaction through metamask.</h3><pre>import web3 from &#39;web3&#39;;</pre><pre><em>//Calling the metamask plugin</em><br>const Web3 = new web3(window.ethereum);</pre><pre>const nxcETHTransaction = async () =&gt; {</pre><pre>  <em>//convert the integer into Ehter standard</em><br>  const ethValue = Web3.utils.toWei(<br>    sendAmount.toString(),&quot;ether&quot;);</pre><pre>  <em>//Intialize the contract</em><br>  var nxcTokenContract = <br>    new Web3.eth.Contract(NXC_Token_ABI, NXC_Address,<br>     {from: accountId});</pre><pre>  <em>//Call the contract method transfer to send token to recepient id</em><br>  nxcTokenContract.methods.transfer(<br>    receiptAccount,ethValue).send({from: accountId})<br>    .then((res) =&gt; {<br>      console.log(res);<br>    }<br>}</pre><p>We can initiate our transactions through metamask plugin. So, firstly we need to assign its variable. We cant send normal integer values for (int 256) smart contracts, We need to convert it into Ethereum’s standard. Next, we need to give the contract address and contract ABI to initialize the contract in our application. Next, we will call the ERC20 Token’s standard method ‘transfer’, here we need to pass the recipient account and the value we send.</p><p>In backend transactions, system needs to initiate the transaction in its own, without signing the transaction by user. So in that situation, we need to hardcoded wallet’s private address to the backend code to sign the transaction.</p><h3>Send ERC20 Token without a wallet</h3><pre>import { ethers } from &quot;ethers&quot;;</pre><pre>let network = &#39;ropsten&#39;;</pre><pre><em>//connects to a node on the ethereum network</em><br>export const ethProvider = ethers.getDefaultProvider(network);</pre><pre><em>//Initialize the contract</em><br>export const NXC = new ethers.Contract(                        <br>   process.env.NXC_ADDRESS ,  //address of nxc token contract<br>   nxc_token_abi,             //ABI of the contract<br>   ethProvider                <br>);</pre><pre><em>//provide wallet private address to initiate the transaction</em><br>export const signerEther = new ethers.Wallet(<br>   process.env.SENDER_PRIVATE_ADDRESS,   //sender address<br>   ethProvider<br>);</pre><pre>export const nxcTransferFunc = async (transferTo, price) =&gt; {</pre><pre>   <em>//transfer amount in ether conversion</em><br>   const tokenAmount = ethers.utils.parseUnits( <br>      price.toString(), 18);</pre><pre>   <em>//connect the wallet with contract</em><br>   const tokenSigner = NXC.connect(Signer);</pre><pre>   const transaction = await tokenSigner.transfer(      <br>        transferTo, tokenAmount, {gasLimit: 81000});</pre><pre>   const receipt = await transaction.wait();</pre><pre>};</pre><p>Here, First we connected to a node of ropsten network. Then we initialize the contract by giving its token address, token abi and node provider. Previously we connected through metamask, So we dont need to give wallet’s private address. But here in backend there were no wallets to initiate the transaction. So we used ether.js library’s wallet function to connect the wallet with our application. Then we converted integer into ether amount. After that, we need to connect the contract with wallet. Finally, we can initiate the transaction.</p><p>These are the common ways used in frontend and backend to transfer ERC20 Tokens. I hope this article will save your time when developing this feature in your application. Thank you. HODL FOR SURE…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b8ddb470db1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/web3-magazine/transfer-erc20-token-with-and-without-a-wallet-2b8ddb470db1">Transfer ERC20 Token with and without a wallet.</a> was originally published in <a href="https://medium.com/web3-magazine">Web3 Magazine</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implement Multi Select Box in ReactJS]]></title>
            <link>https://sathursan.medium.com/implement-multi-select-box-in-reactjs-6fa222ccd9f9?source=rss-e535c37b7b66------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fa222ccd9f9</guid>
            <category><![CDATA[multiselectbox]]></category>
            <category><![CDATA[select-box]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Krishnadeva Sathursan]]></dc:creator>
            <pubDate>Sat, 05 Jun 2021 18:51:05 GMT</pubDate>
            <atom:updated>2021-06-05T18:51:05.581Z</atom:updated>
            <content:encoded><![CDATA[<p>First, we need to install <a href="https://www.npmjs.com/package/multiselect-react-dropdown"><strong>multiselect-react-dropdown</strong></a><strong> </strong>package.</p><p>It has the multi select functionality with various features like selection limit, CSS customization, checkbox, search option, disable preselected values, flat array, keyboard navigation for accessibility and grouping features. Also it has feature to behave like normal dropdown(means single select dropdown).</p><pre>import React,{useState} from &#39;react&#39;;<br>import {Multiselect} from &#39;multiselect-react-dropdown&#39;<br>import &#39;./App.css&#39;;<br>function App() {</pre><pre>  const data = [<br>     {id:1,fruit:&quot;banana&quot;},<br>     {id:2,fruit:&quot;pineapple&quot;},<br>     {id:3,fruit:&quot;mango&quot;},<br>     {id:4,fruit:&quot;apple&quot;}<br>  ]</pre><pre>const [options] = useState(data);</pre><pre>return (</pre><pre>  &lt;div style={{width:&quot;80%&quot;,justifyContent:&quot;center&quot;,display:&quot;flex&quot;}}&gt;</pre><pre>     &lt;div className=&quot;App&quot;&gt;</pre><pre>        &lt;h3&gt;Multi Select Box&lt;/h3&gt;</pre><pre>        &lt;Multiselect options={options} displayValue=&quot;fruit&quot; /&gt;</pre><pre>     &lt;/div&gt;</pre><pre>  &lt;/div&gt;</pre><pre>);</pre><pre>}</pre><pre>export default App;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*52C75TrZjwARw-cUzbuBPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*xMHuh7-NVa6HrlwHQ1VP6A.png" /><figcaption>User Interface of Multi Select Box</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fa222ccd9f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservices Architecture]]></title>
            <link>https://sathursan.medium.com/microservices-architecture-f39dd9cf3b24?source=rss-e535c37b7b66------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39dd9cf3b24</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Krishnadeva Sathursan]]></dc:creator>
            <pubDate>Fri, 29 Jan 2021 17:31:57 GMT</pubDate>
            <atom:updated>2021-01-29T19:21:31.349Z</atom:updated>
            <content:encoded><![CDATA[<h3>Microservices Architecture from Scratch and Demo</h3><p><strong>What are Microservices? Why we use them? How do they work? What are the examples of Microservice? What is the difference between API and Microservices?</strong> These are the <strong>common questions</strong> that arise for programmers. So, let&#39;s look at everything in an easily understandable way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*JEy7YjPgP1GvojEPn94K6A.jpeg" /></figure><blockquote><strong>What are Microservices?</strong></blockquote><p>Microservices are both architecture and an approach to writing software. Microservices applications are broken into the smallest components and independent from each other (loosely coupled). So these tiny services communicate with each other through APIs. Each service has its server and is connected to the database separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*Gn_VwQcIjKWQDiH_bmQnfw.png" /><figcaption>Sample Microservices Architecture</figcaption></figure><p>In this picture, the Client application communicates with Products, Order and Shipping services through API calls. Each service has its database and each service runs on its server port. You can see that there is a dotted line between services. This means both these services are communicating between them with the help of API calls.</p><blockquote><strong>Why we use Microservices?</strong></blockquote><p>Before we dive into this topic, we should know the traditional approach used for building applications. It is called Monolithic Architecture. The <strong>Monolithic application</strong> describes a single-tiered <strong>software application</strong> in which different components are combined into a single program from a single platform. Here, multiple components share one database and run in one server. This architecture is easy to develop, deploy and scale. However, once the application becomes large and the team grows in size, this approach becomes more difficult. And it is extremely problematic to apply new technology in a monolithic application because then the entire application has to be rewritten. That’s why the Microservices concept comes into software development.</p><p>All the services can be deployed and updated independently, which gives more flexibility. A bug in one microservice has an impact only on a particular service and does not influence the entire application. Also, it is much easier to add new features to a microservice application than a monolithic one. Another advantage of the microservices approach is that each element can be scaled independently. So the entire process is more cost- and time-effective than with monoliths when the whole application has to be scaled even if there is no need for it. Also, every monolith has limits in terms of scalability, so the more users you acquire, the more problems you have with your monolith. Therefore, many companies, end up rebuilding their monolithic architectures. And it is easy to apply various technologies and frameworks for each microservice in one project. For example, we can use nodejs for customer service and springboot for order service. We can choose the technology according to our needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kFED24L5NXyrhZJOURH0vQ.jpeg" /></figure><p>But still, microservices have some drawbacks. Since a microservices architecture is a distributed system, you have to choose and set up the connections between all the modules and databases. Also, as long as such an application includes independent services, all of them have to be deployed independently. Microservices architecture is a complex system of multiple modules and databases so all the connections have to be handled carefully. A multitude of independently deployable components makes testing a microservices-based solution much harder.</p><p><strong>Let&#39;s build an application using Microservices Architecture in nodeJS, Express, and MongoDB</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fd582pvsfDFSLcOv72OXag.jpeg" /><figcaption>Technologies used in Demo</figcaption></figure><p>In this Demo part, we gonna use NodeJs, ExpressJs and MongoDB. So it is better you have basic knowledge about these technologies. Create Microservices Directory and create 3 subfolders(Customers, Books, Orders) in it. Then in each subfolder install the below dependencies.</p><pre>npm install express body-parser nodemon mongoose</pre><p><strong>Express</strong>, is a back end web application framework for <strong>Node</strong>. <strong>js. </strong>The<strong> body-parser</strong> is a <strong>NodeJs </strong>body parsing<strong> </strong>middleware that is used to extract the entire body portion of an incoming request stream and exposes it on req.body. <strong>nodemon</strong> is a command-line interface (CLI) utility that wraps your <strong>Node</strong> app, watches the file system, and automatically restarts the process. Then connect mongoose with each server and run it.</p><p><strong>In /book.js</strong></p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const bodyParser = require(&#39;body-parser&#39;);</pre><pre>app.use(bodyParser.json());</pre><pre>const mongoose = require(&quot;mongoose&quot;);<br>mongoose.connect(&#39;mongodb://localhost:27017/library-book&#39;, {useNewUrlParser: true}, () =&gt; {<br>    console.log(&quot;mongoose connected&quot;)<br>})</pre><pre>app.listen(3000, () =&gt;{<br>    console.log(&quot;Book Server start&quot;);<br>})</pre><p>Book server is running on port 3000.</p><p><strong>In /customer.js</strong></p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const bodyParser = require(&#39;body-parser&#39;);</pre><pre>app.use(bodyParser.json());</pre><pre>const mongoose = require(&quot;mongoose&quot;);<br>mongoose.connect(&#39;mongodb://localhost:27017/library-customer&#39;, {useNewUrlParser: true}, () =&gt; {<br>    console.log(&quot;mongoose connected&quot;)<br>})</pre><pre>app.listen(4000, () =&gt;{<br>    console.log(&quot;Customer Server start&quot;);<br>})</pre><p>Customer server is running on port 4000.</p><p><strong>In /order.js</strong></p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const bodyParser = require(&#39;body-parser&#39;);</pre><pre>app.use(bodyParser.json());</pre><pre>const mongoose = require(&quot;mongoose&quot;);<br>mongoose.connect(&#39;mongodb://localhost:27017/library-order&#39;, {useNewUrlParser: true}, () =&gt; {<br>    console.log(&quot;mongoose connected&quot;)<br>})</pre><pre>app.listen(4000, () =&gt;{<br>    console.log(&quot;Order Server start&quot;);<br>})</pre><p>Order server is running on port 5000.</p><p>Now, we have to create a database model for each folder.</p><p>./BookModel.js</p><pre>const mongoose = require(&quot;mongoose&quot;);<br>mongoose.model(&#39;Book&#39;,{<br>title:{<br>   type:String,<br>   require:true<br>},<br>author:{<br>   type:String,<br>   require:true<br>},<br>numberofPages:{<br>   type:Number,<br>   require:true<br>},<br>publisher:{<br>   type:String,<br>   require:true<br>}<br>})</pre><p>./CustomerModel.js</p><pre>const mongoose = require(&quot;mongoose&quot;);<br>mongoose.model(&#39;Cutomer&#39;,{<br>name:{<br>   type:String,<br>   require:true<br>},<br>age:{<br>   type:String,<br>   require:true<br>},<br>address:{<br>   type:String,<br>   require:true<br>}<br>})</pre><p>./OrderModel.js</p><pre>const mongoose = require(&quot;mongoose&quot;);<br>mongoose.model(&#39;Order&#39;,{<br>customerID:{<br>   type:mongoose.SchemaTypes.ObjectId,<br>   require:true<br>},<br>BookID:{<br>   type:mongoose.SchemaTypes.ObjectId,<br>   require:true<br>},<br>initialDate:{<br>   type:Date,<br>   require:true<br>},<br>deliveryDate:{<br>   type:Date,<br>   require:true<br>}<br>})</pre><p>Then in /book.js connect MongoDB model with the server and add HTTP requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8SW1CGRowPS2Fi1jveyaLg.png" /></figure><p>in /customer.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EVeTF1NyQMXAleD_RqURcA.png" /></figure><p>in /order.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqwKT_xiKzXUeq_eAAN8kQ.png" /></figure><p>Here is the fun part begins. Every service runs separately. So we have to connect services to communicate within them. When customer orders books, order document is generated in the database and it contains customerID and bookID. So we have to connect bookModel and CustomerModel with OrderModel. Here we use JS library called<strong> Axios</strong> which is used to make HTTP requests from node. js or XMLHttpRequests from the browser and it supports the Promise API that is native to JS ES6.</p><p>So in the order.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQLJNPtvxtIs6IXxufb2CQ.png" /></figure><p>Here we connect customer service to retrieve customer name and book service to retrieve the book name with the help of Axios library. So in our JSON response, it will give the customer name and book title of a particular order.</p><p>This is the small basic structure of Microservices in nodeJS. Generally, we don&#39;t use Microservices architecture for small applications. I hope this article gives you a basic introduction to MicroServices.</p><p>Here you can view the entire code.</p><ul><li><a href="https://github.com/sathudeva7/Microservices">sathudeva7/Microservices</a></li><li><a href="https://microservices.io/">What are microservices?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39dd9cf3b24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real Time AI Face Detection With Python for Beginners]]></title>
            <link>https://medium.com/swlh/real-time-ai-face-detection-with-python-for-beginners-a2a097636205?source=rss-e535c37b7b66------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2a097636205</guid>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[facedetection]]></category>
            <dc:creator><![CDATA[Krishnadeva Sathursan]]></dc:creator>
            <pubDate>Sat, 15 Aug 2020 10:58:52 GMT</pubDate>
            <atom:updated>2020-09-06T20:16:56.308Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll look at an easy method to get started with Face Detection using Python and OpenCV. OpenCV is the most popular library for computer vision. Originally written in C/C++, it provides bindings for Python. Machine Learning Algorithm is used in OpenCV for searching faces within pictures. Because faces are all seen as complex, they cannot be determined by a simple test. The algorithms break the task of identifying the face into thousands of smaller, bite-sized tasks, each of which is easy to solve. These tasks are also called C<a href="http://en.wikipedia.org/wiki/Statistical_classification"><strong>lassifiers</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*rj4DmlbX2G4Aq_TfuvnmJg.png" /></figure><p>First we need to install openCV in our computer. So, we need to write that below code in command line</p><pre><strong>pip install python-opencv</strong></pre><p>Then we need to import that(openCV) library in our code. That library is called that cv2. it means <em>openCV version 2</em>.</p><pre><strong>import cv2</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*vW5NEGog0xgmwxXu-7LTrg.jpeg" /><figcaption>Trained face datasets</figcaption></figure><p>Then we need to download pre-trained data. openCV provides bunch of data and they actually trained bunch of face images. These data is actually trained on bunch of faces.</p><p><a href="https://github.com/opencv/opencv/tree/master/data/haarcascades">opencv/data/haarcascades at master · opencv/opencv</a></p><p>we need to download below marked(haarcascade_frontalface_default.xml) file. Put the downloaded file in the same working directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TL-kuBxCWTL2-kaWi5fvug.jpeg" /><figcaption>Front face data set</figcaption></figure><p>Then we can go and import it in our code. I assign the downloaded file to a variable called <em>face_cascade.</em> Here we call the opencv library(cv2) and call the function called CascadeClassifier() to classify the faces with the help of Cascade algorithm<em>.</em></p><pre><strong>face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + ‘haarcascade_frontalface_default.xml’)</strong></pre><p>Then we need to pass the input image. Here we using the image read function called imread() from openCV. Image is just an array like a big matrix of a bunch of numbers, here pixels are just numbers. So, here we reading the image into big two dimensional array.</p><pre><strong>img = cv2.imread(‘img.jpg’)</strong></pre><p>Then we need to turn the picture into black and white. The only way that algorithm knows, how to look at a face is in black and white. Because, It is easier to work with one number in each pixels, on a range from black and white. If it is a coloured picture(RGB) then it has 3 numbers in each pixels. so it may take some some time and may be less accurate to process.</p><pre><strong>grayscaled_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*Sam9l2ImX0J_FaWsXq25bg.jpeg" /></figure><p>Next, we want to detect faces in the input image. Before, we created a classifier called <strong>face_cascade.</strong> From<strong> there, we’re gonna call a function called detectMultiScale(), </strong>this means, no matter the scale of the face whether it is small or big it’s just looking for the overall composition like the relations of eyes to the nose to the mouth whether it’s smaller up close or if there’s multiple of them then it just wants to detect all of them. Detected faces are returned as a list of rectangles. So it just returned the coordinates of those green rectangles</p><pre><strong>face_coordinates= face_cascade.detectMultiScale(grayscaled_img)</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*MH0_Tum8PVi-8ozZ52kswQ.jpeg" /><figcaption>Detected face with coordinates</figcaption></figure><p>Once we have those coordinates, we are able to draw those rectangles on our image. If a lot of faces are found in our image, the coordinates of each face will be calculated using the for loop. The rectangle() function has 5 parameters. First one is the input of the image and the second parameter is the top left coordinate of the rectangle and the next parameter describes about the bottom right coordinate of the rectangle. The 4th parameter gives the colour of the rectangle and the final parameter describes the thickness of the circle.</p><pre><strong>for (x,y,w,h) in face_coordinates:<br>     cv2.rectangle(img, (x,y),(x+w,y+h),(0,255,0),2)</strong></pre><p>Finally we need to open the detected photo.</p><pre><strong>cv2.imshow(‘Face detecter’,img)<br>cv2.waitKey()</strong></pre><pre><strong>#ENTIRE CODE</strong><br>import cv2</pre><pre><em>#Load some pre-trained data on face frontals from opencv (haar cascade algorithm)</em></pre><pre>face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + &#39;haarcascade_frontalface_default.xml&#39;)</pre><pre><em>#choose an image to detect faces in</em></pre><pre>img = cv2.imread(&#39;av.jpg&#39;)</pre><pre><em>#Must convert to grayscale</em></pre><pre>grayscaled_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)</pre><pre><em>#Detect faces</em></pre><pre>face_coordinates= face_cascade.detectMultiScale(grayscaled_img)</pre><pre><em>#Draw rectangles around the face</em></pre><pre>for (x,y,w,h) in face_coordinates:</pre><pre>     cv2.rectangle(img, (x,y),(x+w,y+h),(0,255,0),2)</pre><pre>cv2.imshow(&#39;Face detecter&#39;,img)</pre><pre>cv2.waitKey()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*xR3Z9z0eVfDG19NXob4clw.jpeg" /><figcaption>Multiple face detection using openCV</figcaption></figure><p>Just 10 lines of code…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2a097636205" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/real-time-ai-face-detection-with-python-for-beginners-a2a097636205">Real Time AI Face Detection With Python for Beginners</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NodeJS Introduction for begineers]]></title>
            <link>https://sathursan.medium.com/nodejs-introduction-for-begineers-fcc5b7f0049d?source=rss-e535c37b7b66------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcc5b7f0049d</guid>
            <category><![CDATA[india]]></category>
            <category><![CDATA[node-for-begginners]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Krishnadeva Sathursan]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 06:08:55 GMT</pubDate>
            <atom:updated>2020-07-25T06:11:07.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jw9V__6jYhm2amP74D_0lw.png" /><figcaption>Node.js</figcaption></figure><p>Nodejs is an open source cross platform(implemented on multiple computer platforms) runtime environment for executing JavaScript code out side of a Browser. In earlier times, we use JavaScript for client side only. But now we can use JavaScript for server side too with the help of Nodejs. Whatever we can done by php, c# to build back end services are now easily done by Nodejs too.</p><blockquote><strong>What So Special about Nodejs than other back end building tools and frameworks like RAILS,DJANGO…..</strong></blockquote><p>#Nodejs is very easy to get start.</p><p>#Great for prototyping and Agile Development.</p><p># Also used for building superfast and highly scalable services.</p><p>#It’s used in production by large companies such as PayPal, Netflix, Uber, Walmart and so on…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*AdBz8eVWigTsELpaAkkOwA.jpeg" /><figcaption>Advantages About Node App</figcaption></figure><p><strong>Nodejs Architecture</strong></p><p>Every Web Browser has a JavaScript Engine, that takes our JavaScript code and converts it to a code that a computer can understand.For example <strong>Microsoft Edge </strong>uses<strong> Chakra, Firefox </strong>uses<strong> Spidermonkey </strong>and<strong> Chrome </strong>uses <strong>v8 engine.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*_XqlNfYss9vwzyiQwS3auw.png" /></figure><p>In 2009, <strong>Ryan Dahl</strong>, the creator of Nodejs came up with an idea , he thought it will be great to execute JavaScript outside of a browser. So, he took google’s <strong>v8</strong> engine which is the fastest JavaScript engine and embedded it inside a c++ program and called that program<strong> “Nodejs”</strong>. So similar to a browser, Nodejs is a run time environment for JavaScript code. It contains a JavaScript engine that can execute our JavaScript code but these objects are different from the environment objects we have in the browsers.For example, we don’t have document object(<strong>document.getElementbyId(‘ ’)</strong>) instead we have objects can work with file systems(<strong>fs.readFile()</strong>) , listen for requests (<strong>http.createServer()</strong>) and so on. We can’t do these stuffs inside of a browser.</p><p><em>Nodejs is a program that includes V8 javascript engine plus some additional modules that gives us capabilities, not available inside browsers we can work with the file system or the network and so on. Both Chrome and Nodejs share the same JS engine but they provide different runtime environments for JS.</em></p><p><a href="https://nodejs.org/en/download/">Node.js - Download Node.js®</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*9WFP2CD3COyu1Z7VDdI5Ug.png" /></figure><p>A single thread is allocated to handle multiple requests in Nodejs. This is called Non-blocking Asynchronous Architecture.So, requests do not want to wait for so long.</p><p>When a request arrives that single thread is used to handle that request if we need to query a database or thread doesn’t have to wait for the database to return the data. While the database is executing our query that thread will be used to serve another client. When the database prepares the result it puts a message in what we call an event queue. Node is continuously monitoring this queue in the background. When it finds an event in this queue it will take it out an event and process it. This kind of architecture makes node ideal for building applications that include a lot of disk or network access. We can serve more clients without the need to throw in more hardware.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcc5b7f0049d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>