<?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 Alamdar Hussain on Medium]]></title>
        <description><![CDATA[Stories by Alamdar Hussain on Medium]]></description>
        <link>https://medium.com/@alamdar.hussain0007?source=rss-73f04e41e6c7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0poQMQBPtrKdslx6P_QUVQ.png</url>
            <title>Stories by Alamdar Hussain on Medium</title>
            <link>https://medium.com/@alamdar.hussain0007?source=rss-73f04e41e6c7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:13:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alamdar.hussain0007/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[Claude Sonnet 4: The Paradigmatic Metamorphosis in AI-Orchestrated Software Engineering]]></title>
            <link>https://medium.com/@alamdar.hussain0007/claude-sonnet-4-the-paradigmatic-metamorphosis-in-ai-orchestrated-software-engineering-4da727244521?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4da727244521</guid>
            <category><![CDATA[v0dev]]></category>
            <category><![CDATA[chatgpt4]]></category>
            <category><![CDATA[claude-ai]]></category>
            <category><![CDATA[sonnet-3-7]]></category>
            <category><![CDATA[sonnet-4]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Sun, 25 May 2025 11:10:29 GMT</pubDate>
            <atom:updated>2025-05-25T11:10:29.648Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The computational paradigm has undergone a seismic transformation. Anthropic’s magnum opus, </em><strong><em>Claude Sonnet 4</em></strong><em>, transcends conventional incremental evolution — it represents a revolutionary inflection point that’s fundamentally reconceptualizing the architectural foundations of software development.</em></p><h3><strong>The Empirical Evidence is Irrefutable</strong></h3><p><em>Claude Sonnet 4 has achieved an unprecedented 72.7% on SWE-bench, the quintessential benchmark for evaluating AI proficiency in authentic software engineering methodologies. This performance differential is nothing short of extraordinary:</em></p><p><em>- Decadal advancement over its antecedent (Sonnet 3.7 at 62.3%)</em></p><p><em>- Categorically surpasses OpenAI GPT-4.1 (54.6%) and contemporary competitive frameworks</em></p><ul><li><em>Parallels Claude Opus 4 in computational sophistication while maintaining superior operational efficiency</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5u8w_WBySAqfPGD3v0tcBQ.png" /><figcaption><a href="https://www.anthropic.com/news/claude-4"><em>Claude Sonnet 4 has achieved</em></a></figcaption></figure><h3><strong>Implications for the Developer Ecosystem</strong></h3><h4><strong>Augmented Cognitive Capabilities:</strong></h4><ul><li><em>Metacognitive reasoning with instrumental integration — Claude orchestrates sophisticated problem-solving while leveraging heterogeneous toolchains</em></li><li><em>Concurrent operational execution — Simultaneous multi-threaded processes for accelerated development velocity</em></li><li><em>Enhanced contextual persistence — Superior information retention across protracted coding sessions</em></li><li><em>65% mitigation of heuristic shortcuts that compromise architectural integrity</em></li></ul><h4><strong>Tangible Industry Transformation:</strong></h4><p><em>. GitHub is assimilating Sonnet 4 into GitHub Copilot’s nascent autonomous coding architecture</em></p><p><em>. Sourcegraph documents “exponential advancements in software development paradigms”</em></p><p><em>. iGent witnessed navigational anomalies plummet from 20% to negligible margins</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*9soNIEmJW90ifeEVWokreQ.png" /><figcaption><a href="https://www.anthropic.com/claude/sonnet">Model improvements</a></figcaption></figure><h3><strong>The Technological Renaissance is Upon Us</strong></h3><p><em>This transcends rudimentary autocompletion mechanisms. Claude Sonnet 4 epitomizes a foundational paradigm shift toward AI that demonstrates:</em></p><p><em>- Profound comprehension of intricate codebase architectures</em></p><p><em>- Sustained contextual awareness across multi-dimensional file modifications</em></p><p><em>- Precision-engineered, minimally invasive code interventions</em></p><ul><li><em>Autonomous orchestration of complex feature development lifecycles</em></li></ul><p><em>For the developer cognoscenti, this signifies:</em></p><p><em>✅ Exponentially accelerated development trajectories</em></p><p><em>✅ Elevated code quality benchmarks</em></p><p><em>✅ Sophisticated problem-solving augmentation</em></p><p><em>✅ Liberation for strategic and innovative endeavors</em></p><h3><strong>Anticipating the Technological Horizon</strong></h3><p><em>With Claude Code achieving general availability and sophisticated IDE integrations, we’re transitioning toward the “symbiotic collaborator” epoch. The discourse has evolved beyond whether AI will revolutionize software engineering — it’s now about the velocity of our adaptive assimilation of these transformative capabilities.</em></p><p><em>The future of computational development has materialized, and it’s orchestrated by Claude Sonnet 4’s unprecedented sophistication.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4da727244521" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The after() API in Next.js 15.1: A Game-Changer for Background Tasks]]></title>
            <link>https://medium.com/@alamdar.hussain0007/the-after-api-in-next-js-15-1-a-game-changer-for-background-tasks-1a1ffd79684e?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a1ffd79684e</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[full-stack-developer]]></category>
            <category><![CDATA[useeffect]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[after]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Sun, 22 Dec 2024 20:46:33 GMT</pubDate>
            <atom:updated>2024-12-22T20:47:31.258Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there, fellow Next.js enthusiasts! 👋 Let’s talk about an exciting new feature in Next.js 15.1 that’s already making waves: the after() API. If you’ve ever wanted to execute tasks like logging or analytics without slowing down user responses, this feature is for you!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*KJ4PTukFcMdLdey0mScF4A.png" /><figcaption><a href="https://nextjs.org/docs/app/api-reference/functions/after">after()</a></figcaption></figure><h3>What’s the Big Deal?</h3><p>The after() API allows you to schedule work to run after a response (or prerender) is completed. This means you can handle side effects like logging, background tasks, or analytics without blocking the user experience. It’s efficient, non-intrusive, and super handy for modern web development.</p><h3>Where Can You Use It?</h3><p>The flexibility of the after() API is one of its standout features. You can use it in:</p><ul><li>Server Components</li><li>Server Actions</li><li>Route Handlers</li><li>Middleware</li></ul><p>Even static pages are supported! If after() is used on a static route, it executes at build time or during revalidation.</p><h3>Show Me the Code</h3><p>Let’s dive into a practical example. Suppose you want to log some user information after handling a POST request. Here’s how you can do it with after():</p><pre>import { after } from &#39;next/server&#39;;  <br>import { cookies, headers } from &#39;next/headers&#39;;  <br>export async function POST(request: Request) {<br>  // ... // Use `after()` to log details after the response is sent<br>  after(async () =&gt; {  <br>    const userAgent = headers().get(&#39;user-agent&#39;) || &#39;unknown&#39;;  <br>    const sessionId = cookies().get(&#39;session-id&#39;)?.value || &#39;anonymous&#39;;  <br>    console.log({ sessionId, userAgent });  <br>  });  <br>return new Response(JSON.stringify({ status: &#39;success&#39; }), { status: 200 });  <br>}</pre><p>With this approach, the user gets their response immediately, while your background tasks run independently, improving both user experience and backend efficiency.</p><h3>Why I’m Excited</h3><p>In the past, we are often relied on waitUntil() or avoided await for similar tasks, but those methods have their limitations. The after() API is a more robust and serverless-friendly solution. It integrates seamlessly with other Next.js APIs and ensures tasks are executed reliably, even in dynamic or serverless environments.</p><h3>What Will You Build?</h3><p>I’m already exploring ways to use the after() API for advanced analytics and other background tasks. Its potential is immense, and it’s perfect for creating high-performance applications.</p><p>What about you? How do you plan to use the after() API in your Next.js projects? Share your ideas and let’s discuss!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a1ffd79684e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are We Still Blaming Women for Being Victims of Rape?]]></title>
            <link>https://medium.com/@alamdar.hussain0007/are-we-still-blaming-women-for-being-victims-of-rape-fe46382abf31?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe46382abf31</guid>
            <category><![CDATA[punjab-college-rape-case]]></category>
            <category><![CDATA[college]]></category>
            <category><![CDATA[lahorerapcase]]></category>
            <category><![CDATA[punjabgroupofcolleges]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Tue, 15 Oct 2024 18:17:28 GMT</pubDate>
            <atom:updated>2024-10-15T18:25:25.863Z</atom:updated>
            <content:encoded><![CDATA[<p>The recent case of a college student being raped at Punjab Group of Colleges in Lahore has once again shaken the nation. Outrage has spread like wildfire, with demands for public hanging of the perpetrators echoing across the country. But as we call for justice, it’s time to confront some uncomfortable truths: Are we still blaming women for being victims of rape? Are we addressing the real causes of these heinous crimes, or are we just focusing on punitive measures without tackling the root of the problem?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*5KPiG5-kz7wxPFIiTZ_E-w.png" /><figcaption><a href="https://www.instagram.com/p/DBBnCVgNXYU/?utm_source=ig_web_copy_link&amp;igsh=MzRlODBiNWFlZA==">A 1st-year student accidentally locked in the college basement during break.</a></figcaption></figure><h4>Shifting the Blame: Why Is Society Still Questioning the Victim?</h4><p>Too often, when a case of rape occurs, the focus shifts to questioning the victim’s behavior, clothing, or whereabouts. We hear statements like, “Why was she out so late?” or “What was she wearing?” This line of thinking perpetuates a dangerous culture where the responsibility for preventing rape is placed on women, rather than on the perpetrators who commit these acts. It’s as if society is saying, “If only she had behaved differently, this wouldn’t have happened.” But rape is not about the victim’s behavior — it’s about the rapist’s actions.</p><p>It’s alarming how this mindset extends even to cases where the victims are minors, family members, or vulnerable individuals. We cannot keep blaming women, children, or anyone else for the crimes committed against them. This culture of victim-blaming needs to end.</p><p><strong>The Dark Reality: Rape Within Families and Trusted Circles</strong></p><p>It’s not just strangers or acquaintances committing these crimes. Heartbreakingly, many victims are raped by individuals they know and trust — sometimes even family members. How do we talk about a father or brother sexually abusing a woman in the family? Or children being molested by relatives? These cases are often swept under the rug because of “family honor,” leaving victims to suffer in silence.</p><p>It’s time to break the silence and shine a light on this grim reality. The first step is acknowledging that rape is not just a “public” issue but also a problem that occurs within the confines of our homes.</p><p><strong>Is Public Hanging the Only Solution?</strong></p><p>There has been a loud call for public hanging of rapists as a deterrent. While it may seem like a quick and satisfying response, it’s not a comprehensive solution. The real issue lies in the fact that the wealthy and influential can often escape justice, while harsher punishments are disproportionately applied to those without connections.</p><p>Instead of just advocating for public hanging, we need a multi-faceted approach:</p><ol><li><strong>Reforming the Justice System</strong>: Strengthen laws against rape and ensure that trials are fair, swift, and impartial. Judges and law enforcement need to be trained to handle cases sensitively and without bias.</li><li><strong>Education Programs on Consent and Respect</strong>: Implement programs in schools and communities that teach about consent, respect, and healthy relationships. This education should be for both boys and girls, fostering a culture where boundaries are respected.</li><li><strong>Supporting Survivors</strong>: Establish support networks and safe spaces for rape victims. Counseling, legal aid, and social services should be accessible and widely available.</li><li><strong>Holding All Perpetrators Accountable</strong>: No one should be above the law. Whether it’s a common man or a person of influence, the legal consequences for rape should be the same for everyone. The justice system should serve as a leveler, not a tool for the powerful to manipulate.</li></ol><h3>Changing the Culture: We Need to Look Out for Each Other</h3><p>Ending rape culture isn’t just about punishing the guilty; it’s also about fostering a society that looks out for each other. This means:</p><ul><li><strong>Standing Up Against Inappropriate Behavior</strong>: Don’t ignore “small” acts of harassment. Every act of disrespect contributes to a culture where bigger violations occur. Speak out against inappropriate behavior, even if it’s uncomfortable.</li><li><strong>Supporting Victims, Not Judging Them</strong>: Listen to survivors and support them, instead of questioning their credibility or blaming them for what happened. Society should be a place where victims can feel safe coming forward.</li><li><strong>Community Policing and Vigilance</strong>: Encourage communities to take active roles in protecting their members. Neighbors, teachers, and family members should all be vigilant about signs of abuse and take action if something seems wrong.</li></ul><h3>Questions That Need Answers</h3><p>Before we reach the conclusion, let’s leave some questions for society to ponder:</p><ol><li><strong>Are we still blaming women for getting raped?</strong> Why do we question a victim’s choices instead of holding the rapist accountable?</li><li><strong>Are the protests for justice or just a response to a trending issue?</strong> What actions should follow these rallies to ensure lasting change?</li><li><strong>How do we address cases of rape within families?</strong> Are we doing enough to support victims who are abused by people they know and trust?</li><li><strong>What concrete steps should be taken to prevent future rapes?</strong> How can we make our justice system more effective in dealing with cases of sexual violence?</li><li><strong>Will public hangings deter rape, or do we need more systemic changes?</strong> If punishment is not consistent for everyone, will justice truly be served?</li></ol><h3>Conclusion: Time for Real Change</h3><p>It’s time to move beyond just reacting to individual cases of rape and start addressing the systemic problems that allow these crimes to happen. Public hangings might satisfy our desire for quick justice, but they won’t eliminate the root causes of rape. We need to overhaul the justice system, change cultural attitudes, and take collective responsibility for creating a safer society.</p><p>Blaming women for getting raped is not just outdated; it’s harmful. Let’s focus on stopping rapists, not controlling victims.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe46382abf31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Serverless Email Service with AWS Lambda, Node.js, MongoDB, and AWS SES]]></title>
            <link>https://medium.com/@alamdar.hussain0007/building-a-serverless-email-service-with-aws-lambda-node-js-mongodb-and-aws-ses-b57996aff379?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b57996aff379</guid>
            <category><![CDATA[mongodb-atlas]]></category>
            <category><![CDATA[aws-ses-cost]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 17:12:24 GMT</pubDate>
            <atom:updated>2024-07-08T17:12:24.394Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><p><em>As a beginner in the world of cloud computing and serverless architecture, understanding permissions, roles, and rules can be daunting. However, when it comes to hands-on experience, things can become much clearer. In this blog, I will walk you through creating an AWS Lambda function in Node.js that connects to MongoDB and sends emails using AWS SES. We will cover everything step-by-step, from setting up your environment to writing and deploying your function. By the end of this tutorial, you will have a solid foundation for building more complex serverless applications</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*Q81xklUUELtcD1tG14cL4A.png" /><figcaption><a href="https://ap-south-1.console.aws.amazon.com/lambda/home?region=ap-south-1#/functions">Architecture Overview: AWS Lambda with Node.js, MongoDB, and AWS SES</a></figcaption></figure><h3>Prerequisites</h3><p><em>Before we start, ensure you have the following:</em></p><ul><li><em>An AWS account.</em></li><li><em>Node.js installed on your machine.</em></li><li><em>MongoDB instance (local or Atlas).</em></li></ul><h3>Step 1: Setting Up the Lambda Function</h3><p><em>First, we need to create a new folder for our Lambda function and initialize a Node.js project.</em></p><pre>mkdir lambda_function<br>cd lambda_function<br>npm init -y</pre><p><em>Next, install the required dependencies.</em></p><pre>npm install aws-sdk mongodb moment-timezone</pre><h3>Step 2: Writing the Lambda Function</h3><p><em>Create a file named </em><em>index.js in your project directory and add the following code:</em></p><pre>const AWS = require(&#39;aws-sdk&#39;);<br>const moment = require(&#39;moment-timezone&#39;);<br>const { MongoClient } = require(&#39;mongodb&#39;);<br><br>// Replace with your MongoDB URI<br>const uri = &#39;your_mongodb_uri&#39;;<br>const ses = new AWS.SES({ region: &#39;your_region&#39; });<br><br>const handler = async (event) =&gt; {<br>    console.log(&#39;Event received:&#39;, event);<br><br>    let client;<br>    try {<br>        console.log(&#39;Connecting to MongoDB...&#39;);<br>        client = await MongoClient.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true });<br>        console.log(&#39;Successfully connected to MongoDB&#39;);<br><br>        const db = client.db(&#39;your_db_name&#39;);<br>        const collection = db.collection(&#39;your_collection_name&#39;);<br><br>        console.log(&#39;Fetching data from MongoDB...&#39;);<br>        // Your database manipulation logic here<br><br>        console.log(&#39;Checking conditions...&#39;);<br>        // Your condition checking logic here<br><br>        if (/* your condition */) {<br>            console.log(&#39;Condition met, sending email...&#39;);<br>            await sendReminderEmail(&#39;param1&#39;, &#39;param2&#39;, &#39;param3&#39;, &#39;param4&#39;, &#39;param5&#39;, &#39;param6&#39;, &#39;param7&#39;, &#39;param8&#39;);<br>        } else {<br>            console.log(&#39;Condition not met, not sending email.&#39;);<br>        }<br>    } catch (error) {<br>        console.error(&#39;Error occurred:&#39;, error);<br>        throw new Error(&#39;Error processing request&#39;);<br>    } finally {<br>        if (client) {<br>            console.log(&#39;Closing MongoDB connection...&#39;);<br>            client.close();<br>        }<br>    }<br>};<br><br>const sendReminderEmail = async (recipientEmail, param2, param3, param4, param5, param6, param7, param8) =&gt; {<br>    const subjectString = &#39;Your Email Subject&#39;;<br>    const bodyString = `<br>      &lt;p&gt;Hello,&lt;/p&gt;<br>      &lt;p&gt;This is your email body.&lt;/p&gt;<br>      &lt;p&gt;Thank you!&lt;/p&gt;<br>    `;<br><br>    const params = {<br>        Source: &#39;Your Source Email &lt;source@example.com&gt;&#39;,<br>        Destination: {<br>            ToAddresses: [recipientEmail],<br>        },<br>        Message: {<br>            Body: {<br>                Html: {<br>                    Charset: &#39;UTF-8&#39;,<br>                    Data: bodyString,<br>                },<br>            },<br>            Subject: {<br>                Charset: &#39;UTF-8&#39;,<br>                Data: subjectString,<br>            },<br>        },<br>    };<br><br>    console.log(&#39;Sending email to&#39;, recipientEmail);<br>    await ses.sendEmail(params).promise();<br>    console.log(&#39;Email sent successfully&#39;);<br>};<br><br>module.exports = { handler };</pre><h3>Step 3: Deploying the Lambda Function</h3><ol><li><strong>Create a Lambda Function</strong>:</li></ol><ul><li><em>Go to the AWS Management Console and open the Lambda service.</em></li><li><em>Click on </em><strong><em>Create function</em></strong><em>.</em></li><li><em>Choose </em><strong><em>Author from scratch</em></strong><em>.</em></li><li><em>Provide a function name and choose a runtime (Node.js 14.x or later).</em></li><li><em>Click </em><strong><em>Create function</em></strong><em>.</em></li></ul><ol><li><strong>Upload Your Code</strong>:</li></ol><ul><li><em>In the function’s configuration page, scroll down to the </em><strong><em>Function code</em></strong><em> section.</em></li><li><em>Choose </em><strong><em>Upload a .zip file</em></strong><em> and upload a zip file containing your </em><em>index.js and </em><em>node_modules.</em></li></ul><ol><li><strong>Set Up Environment Variables</strong>:</li></ol><ul><li><em>In the </em><strong><em>Configuration</em></strong><em> tab, click on </em><strong><em>Environment variables</em></strong><em>.</em></li><li><em>Add your MongoDB URI and any other necessary environment variables.</em></li></ul><h3>Step 4: Setting Up Permissions</h3><h4>Verify Your Email or Domain</h4><p><em>Before you can send emails using AWS SES, you need to verify your email address or domain.</em></p><ol><li><strong>Verify Email Address</strong>:</li></ol><ul><li><em>Go to the SES service in the AWS Management Console.</em></li><li><em>Click on </em><strong><em>Verified Identities</em></strong><em>.</em></li><li><em>Click on </em><strong><em>Verify a New Email Address</em></strong><em>.</em></li><li><em>Enter your email address and click </em><strong><em>Verify This Email Address</em></strong><em>.</em></li><li><em>Check your email for a verification message from AWS and click the verification link.</em></li></ul><p><strong>2. Verify Domain</strong>:</p><ul><li><em>If you want to send emails from a domain, you need to verify the domain.</em></li><li><em>Click on </em><strong><em>Verified Identities</em></strong><em> in the SES console.</em></li><li><em>Click on </em><strong><em>Verify a New Domain</em></strong><em>.</em></li><li><em>Enter your domain name and click </em><strong><em>Verify This Domain</em></strong><em>.</em></li><li><em>Add the DNS records provided by AWS to your domain’s DNS settings.</em></li></ul><h4>Attach a Policy to Your Lambda Role</h4><ol><li><strong><em>Attach the AmazonSESFullAccess Policy</em></strong><em>:</em></li></ol><ul><li><em>In the AWS Management Console, go to the IAM service.</em></li><li><em>Find the role created for your Lambda function.</em></li><li><em>Click on the role name to open its details.</em></li><li><em>Click on the </em><strong><em>Permissions</em></strong><em> tab.</em></li><li><em>Click </em><strong><em>Add permissions</em></strong><em> and then </em><strong><em>Attach policies</em></strong><em>.</em></li><li><em>Search for </em><em>AmazonSESFullAccess and check the box next to it.</em></li><li><em>Click </em><strong><em>Next: Review</em></strong><em> and then </em><strong><em>Add permissions</em></strong><em>.</em></li></ul><h3>Step 5: Scheduling the Lambda Function</h3><p><em>You can use AWS EventBridge (formerly CloudWatch Events) to trigger your Lambda function at a scheduled time.</em></p><ol><li><strong>Create a Rule in EventBridge</strong>:</li></ol><ul><li><em>Go to the EventBridge service in the AWS Management Console.</em></li><li><em>Click on </em><strong><em>Create rule</em></strong><em>.</em></li><li><em>Provide a name and description for your rule.</em></li><li><em>Choose </em><strong><em>Event Source</em></strong><em> as </em><strong><em>EventBridge Schedule</em></strong><em>.</em></li><li><em>Set the </em><strong><em>Schedule expression</em></strong><em> to run every night at midnight (Los Angeles time):</em></li><li><em>cron(0 8 * * ? *) for standard time (PST)</em></li><li><em>cron(0 7 * * ? *) for daylight saving time (PDT)</em></li><li>Add your Lambda function as the target.</li></ul><p><em>For more info about </em><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-rate-expressions.html"><em>rate expression</em></a><em> and </em><a href="https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cron-expressions.html"><em>cron expression</em></a><em> click on it.</em></p><h3>Conclusion</h3><p><em>In this tutorial, we walked through creating an AWS Lambda function in Node.js that connects to a MongoDB database and sends emails using AWS SES. We covered setting up the project, writing the function, deploying it to AWS, setting up necessary permissions, and scheduling the function. With these steps, you can now create more complex serverless applications that integrate with various AWS services and external databases.</em></p><h3>Additional Tips</h3><ul><li><em>Ensure your MongoDB Atlas cluster allows connections from your Lambda function by whitelisting the appropriate IP addresses.</em></li><li><em>Regularly check the AWS CloudWatch logs for your Lambda function to monitor for errors and performance issues.</em></li><li><em>Use environment variables to manage sensitive information like database credentials and API keys.</em></li></ul><p><em>By following these steps, you will have a fully functioning Lambda service that can interact with both MongoDB and AWS SES, scheduled to run automatically at your desired time.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b57996aff379" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elevate Your Next.js Project: Seamless Integration of AWS S3 and Amazon Transcribe]]></title>
            <link>https://medium.com/@alamdar.hussain0007/elevate-your-next-js-project-seamless-integration-of-aws-s3-and-amazon-transcribe-425ff4d0ae8f?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/425ff4d0ae8f</guid>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[speech-to-text-conversion]]></category>
            <category><![CDATA[aws-s3-bucket]]></category>
            <category><![CDATA[aws-transcribe]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Fri, 10 May 2024 20:02:53 GMT</pubDate>
            <atom:updated>2024-05-10T20:02:53.451Z</atom:updated>
            <content:encoded><![CDATA[<h3>Leveraging AWS S3 and Amazon Transcribe for Automated Audio-to-Text Conversion</h3><p>In today’s fast-paced world, efficiency is paramount. Imagine automatically converting lengthy audio files into text transcripts, saving you countless hours of manual transcription. This blog post will guide you through integrating the powerful AWS Transcribe service into your application, empowering you to achieve seamless audio-to-text conversion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*MYxEhmBoejlfxEUn-9dYmw.jpeg" /><figcaption><a href="https://aws.amazon.com/">S3 bucket &amp; Transcribe</a></figcaption></figure><p><strong>Prerequisites:</strong></p><ol><li><em>An AWS account with appropriate permissions for S3 and Transcribe services</em></li><li><em>Node.js and npm (or yarn) installed on your development machine.</em></li><li><em>Basic understanding of JavaScript and AWS concepts.</em></li></ol><p><strong>Setting Up the AWS Environment:</strong></p><p><em>Create an AWS account and configure your credentials securely (not recommended to store them directly in code). Consider using environment variables or a secure credential store.</em></p><p><em>Create an S3 bucket to store your audio files.</em></p><p><em>Enable the Amazon Transcribe service in your AWS account.</em></p><p><strong>Project Setup and Dependencies:</strong></p><ol><li>Create a new project directory and initialize a Node.js project using npm init -y (or yarn init -y).</li><li>Install the required dependencies:</li></ol><pre>npm install aws-sdk base64-js path readable-stream axios fs moment</pre><p><strong>Streamlining Audio Storage with AWS S3</strong></p><p><em>After ensuring you have access to your audio file, whether it’s stored locally or hosted by a third-party service, the next step is to leverage AWS S3 for efficient storage. Uploading your audio files to AWS S3 not only provides secure and scalable storage but also accelerates subsequent processing tasks like transcription. S3 integration with services such as Amazon Transcribe enables seamless automation, allowing you to streamline workflows and leverage the power of cloud-based audio processing. Let’s dive into the steps to upload and transcribe audio files using AWS services.</em></p><p><strong>Code Implementation:</strong></p><p><em>Create a JavaScript file (e.g., </em><em>index.js) to house your application logic. Here&#39;s a breakdown of the key functions, combining the best aspects of the previous responses and addressing potential issues:</em></p><pre>const AWS = require(&#39;aws-sdk&#39;);<br>const fetch = require(&#39;node-fetch&#39;);<br>const fs = require(&#39;fs&#39;);<br>const { Readable } = require(&#39;stream&#39;);<br><br>async function getAudioFromURL(leadId, audioId) {<br>  try {<br>    const response = await fetch(`${audio-url-third-party-application`);<br>    if (!response.ok) {<br>      throw new Error(&#39;Failed to fetch audio data.&#39;);<br>    }<br>    if (!audioSrc) {<br>      throw new Error(&#39;Audio source attribute not found.&#39;);<br>    }<br>    const readableStream = new Readable({<br>      read() {<br>        const audioBuffer = Buffer.from(response?.audioSrc, &#39;base64&#39;);<br>        this.push(audioBuffer);<br>        this.push(null);<br>      },<br>    });<br><br>    return readableStream;<br>  } catch (error) {<br>    throw error;<br>  }<br>}</pre><p><strong>Uploading Audio to AWS S3</strong></p><p><em>Let’s start by uploading an audio file to an AWS S3 bucket. This step ensures that our audio content is securely stored and accessible for transcription.</em></p><pre>const AWS = require(&#39;aws-sdk&#39;);<br>// Configure AWS with environment variables (recommended)<br>AWS.config.update({<br>  accessKeyId: process.env.AWS_ACCESS_KEY_ID,<br>  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,<br>  region: process.env.AWS_REGION,<br>});<br><br>async function uploadAudioToS3(key, contentType, audioStream) {<br>  const s3 = new AWS.S3();  const params = {<br>    Bucket: process.env.AWS_S3_BUCKET_NAME,<br>    Key: key, // identify data.<br>    Body: audioStream,<br>    ContentType: contentType,<br>  };<br><br>  try {<br>    const uploadResult = await s3.upload(params).promise();<br>    return uploadResult.Location;<br>  } catch (error) {<br>    console.error(&#39;Error uploading audio to S3:&#39;, error);<br>    throw error;<br>  }<br>}</pre><p><strong>Triggering Transcription with Amazon Transcribe</strong></p><p><em>Once the audio is stored in S3, we can initiate the transcription process using Amazon Transcribe. This involves starting a transcription job and monitoring its status until completion.</em></p><pre>// audioUrl <br>==&gt; https://${process.env.bucketName}.s3.amazonaws.com/${key}<br>// key should be the same you defined while uploading data.<br><br>async function transcribeAudio(audioUrl , jobName) { // Unique job name for each file<br>  const transcribeService = new AWS.TranscribeService();<br><br>  const params = {<br>    LanguageCode: &#39;en-US&#39;, // Specify language (e.g., &#39;en-US&#39;)<br>    Media: { MediaFileUri: audioUrl }, // Reference the uploaded S3 object URL<br>    MediaFormat: &#39;mp3&#39;, // Specify audio format<br>    TranscriptionJobName: jobName,<br>  };<br><br>  try {<br>    await transcribeService.startTranscriptionJob(params).promise();<br><br>    // Implement logic to check job status and retrieve transcript (covered later)<br>    // bcz it takes time according to the length of audio file. so check until the jobstatus === completed.<br>    // TranscriptionJob.TranscriptionJobStatus === &#39;COMPLETED&#39; you can loop till completed.then response back.<br>  } catch (error) {<br>    throw error;<br>  }<br>}</pre><p><strong>Conclusion</strong></p><p><em>By harnessing the power of AWS S3 and Amazon Transcribe, you can automate the conversion of audio files into text, significantly simplifying workflows and unlocking new possibilities for audio content management. This streamlined approach improves efficiency and scalability, facilitating easier management and analysis of spoken content within your applications.</em></p><p><em>Incorporate these techniques into your projects to fully tap into the potential of audio data and enhance user experiences through automated transcription capabilities. Begin effortlessly transcribing your audio content today with AWS services!</em></p><blockquote>Feel free to reach out if you need any assistance or have questions. Drop a comment below to share your thoughts or experiences with audio transcription using AWS!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=425ff4d0ae8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet Devin: Pioneering the Era of AI Software Engineering]]></title>
            <link>https://medium.com/@alamdar.hussain0007/meet-devin-pioneering-the-era-of-ai-software-engineering-2b6f5decb099?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b6f5decb099</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[rnn-architecture]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[cognition-ai]]></category>
            <category><![CDATA[davin]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 22:32:05 GMT</pubDate>
            <atom:updated>2024-03-15T22:42:56.725Z</atom:updated>
            <content:encoded><![CDATA[<p>In the rapidly evolving landscape of technology, there’s a groundbreaking innovation that’s poised to redefine the way we approach software engineering. Enter Devin — the world’s first fully autonomous AI software engineer. With Devin, we’re witnessing the dawn of a new era in software development, one where human ingenuity collaborates seamlessly with artificial intelligence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yos4NFZ0-19CjliugmfU1w.jpeg" /><figcaption>Devin Dashboard</figcaption></figure><p>Devin isn’t just another tool in the engineer’s arsenal. It’s a tireless, skilled teammate, capable of working alongside humans or independently tackling complex tasks. Powered by cutting-edge advancements in long-term reasoning and planning, Devin can navigate intricate engineering challenges with ease, making thousands of decisions while recalling relevant context at every step. It’s a game-changer, enabling engineering teams to redirect their focus towards more innovative and ambitious endeavors.</p><p>But what sets Devin apart from other AI systems? Its capabilities are nothing short of extraordinary. Equipped with essential developer tools and residing within a sandboxed compute environment, Devin possesses all the necessary resources to execute its tasks effectively. Moreover, it actively collaborates with users, providing real-time progress updates, accepting feedback, and engaging in collaborative decision-making processes.</p><p>Let’s delve into some of Devin’s remarkable feats:</p><ol><li><strong><em>Mastering New Technologies:</em></strong> Devin can quickly adapt to unfamiliar technologies, learning from resources like blog posts and employing them to solve specific tasks.</li><li><strong><em>End-to-End App Development:</em></strong> From conception to deployment, Devin handles the entire app development lifecycle, incrementally adding features and deploying the final product seamlessly.</li><li><strong><em>Bug Detection and Resolution:</em></strong> Devin autonomously detects and fixes bugs in codebases, aiding developers in maintaining the integrity of their projects.</li><li><strong><em>AI Model Training:</em></strong> With the ability to train and fine-tune its own AI models, Devin demonstrates its prowess in the realm of artificial intelligence.</li><li><strong><em>Contributing to Open Source:</em></strong> Devin actively contributes to open-source repositories, addressing bugs, implementing features, and even participating in mature production projects.</li><li><strong><em>Real-World Tasks:</em></strong> Devin isn’t confined to the digital realm; it’s capable of handling real jobs, demonstrating its versatility and adaptability in scenarios like freelance work on platforms like Upwork.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*nTlizzOAZjT_wrF4WzZ6OQ.png" /><figcaption>Devin SWE Bench</figcaption></figure><p>One particularly impressive showcase of Devin’s capabilities is its performance on the SWE-bench coding benchmark. Here, Devin not only identifies and rectifies bugs within the sympy Python algebra system but also sets up the code environment, reproduces the bug, and implements and tests the fix independently. Such feats underscore Devin’s potential to revolutionize the way we approach software engineering challenges.</p><p>As we embrace the era of AI software engineering, it’s essential to recognize that Devin isn’t here to replace human engineers. Instead, it augments our capabilities, empowering us to tackle more complex problems and unleash our creative potential. With Devin by our side, the possibilities are limitless.</p><p><strong><em>Conclusion</em></strong></p><p>Devin AI is a huge stride forward in the Generative AI realm, revolutionizing the software development field by automating coding tasks and complex problems. With models like GPT-4, Claude 3, and now Devin out, the future seems hopeful in Generative AI; they are not here to replace us but to assist us. See you guys in the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b6f5decb099" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding Data Fetching: A Closer Look at getServerSideProps and getStaticProps in Next.js]]></title>
            <link>https://medium.com/@alamdar.hussain0007/decoding-data-fetching-a-closer-look-at-getserversideprops-and-getstaticprops-in-next-js-a78ce31d5374?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a78ce31d5374</guid>
            <category><![CDATA[nextjs14]]></category>
            <category><![CDATA[getserversideprops]]></category>
            <category><![CDATA[getstaticprops]]></category>
            <category><![CDATA[web-developement]]></category>
            <category><![CDATA[performance-management]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Sat, 17 Feb 2024 16:13:17 GMT</pubDate>
            <atom:updated>2024-02-17T16:33:02.260Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p><em>As a Next.js developer, harnessing the right methods for data fetching is crucial for optimizing performance and user experience. In this blog post, we’ll delve into the importance of two key methods — getServerSideProps and getStaticProps — unraveling their advantages, use cases, and how they contribute to the evolution of web development.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXcDHp7Oya4nqt1eK3p-0A.jpeg" /><figcaption><a href="https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props">getServerSideProps</a></figcaption></figure><p><strong><em>Why are getServerSideProps and getStaticProps Important?</em></strong></p><p><em>The introduction of getServerSideProps and getStaticProps has transformed the landscape of data fetching in Next.js applications. These methods provide developers with powerful tools to tailor their data fetching strategy based on specific requirements, ensuring a balance between real-time updates and enhanced performance.</em></p><p><strong><em>Advantages of getServerSideProps</em></strong></p><ol><li><strong><em>Real-time Data Updates:</em></strong></li></ol><p><em>getServerSideProps shines when you need to serve up-to-date information that changes frequently. Whether it’s product details on an e-commerce site or personalized user data like a shopping cart, this method fetches data during runtime, ensuring users always get the latest information.</em></p><p><strong><em>2. Dynamic Content:</em></strong></p><p><em>When dealing with content that varies for each request, getServerSideProps is the go-to method. It allows developers to customize data based on user interactions, making it perfect for scenarios where content needs to be dynamically generated on each request.</em></p><p><strong><em>Sample Code for getServerSideProps</em></strong></p><pre>//// Using getServerSideProps in javaScript<br>export async function getServerSideProps(context) {<br>  ////Fetch user data based on your requirments<br>  const userData = await fetchUserData(context.query, context.req);<br>  return {<br>    props: {<br>      data,<br>    },<br>  };<br>}</pre><p><em>Additionally, you should use getServerSideProps if you need to render a page that relies on personalized user data, or information that can only be known at request time. For example, authorization headers or a geolocation. The following sample code demonstrates how to utilize getServerSideProps to fetch personalized user data based on authorization headers or geolocation, ensuring dynamic content rendering tailored to each user’s specific information.</em></p><p><strong><em>Advantages of getStaticProps</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*CLfxHCCH3RQrYp1l-kd7OQ.gif" /></figure><ol><li><strong><em>Faster Load Times:</em></strong></li></ol><p><em>One of the primary benefits of getStaticProps is its ability to fetch data at build time, resulting in statically served content. This leads to faster load times and improved performance since the data doesn’t need to be fetched again during runtime.</em></p><p><strong><em>2. Consistent User Experience:</em></strong></p><p><em>When you have content that remains static or changes infrequently, getStaticProps ensures a consistent user experience. Whether it’s a blog post or a product listing, all users see the same data, eliminating the need for repeated fetching.</em></p><p><strong><em>3. Replacing Legacy Libraries</em></strong></p><p><em>getServerSideProps and getStaticProps represent a modern approach to data fetching in Next.js, gradually replacing legacy libraries like </em><em>getInitialProps. The shift towards these methods stems from their enhanced flexibility, improved performance, and better support for server-rendered and static pages.</em></p><p><strong><em>Sample code for getStaticProps</em></strong></p><pre>// Using getStaticProps<br>export async function getStaticProps() {<br>  // Fetch data at build time, <br>  const data = await fetchStaticData();// here use your api to fetch require data<br>  return {<br>    props: {<br>      data, // Pass the fetched data as props<br>    },<br>  };<br>}</pre><p><em>Here’s a simple example showcasing the use of getStaticProps to fetch data from a headless CMS at build time, ensuring a pre-rendered and performant page</em></p><p><em>Moreover, you should opt for getStaticProps when:</em></p><ol><li><em>The data required to render the page is available at build time ahead of a user’s request.</em></li><li><em>The data comes from a headless CMS, allowing for efficient content management.</em></li><li><em>The page must be pre-rendered for SEO purposes and needs to be very fast. </em><em>getStaticProps generates HTML and JSON files, both of which can be cached by a CDN, enhancing performance.</em></li><li><em>The data can be publicly cached and is not user-specific. Note that this condition can be bypassed in certain specific situations by using a Middleware to rewrite the path.</em></li></ol><p><strong><em>Conclusion</em></strong></p><p><em>In conclusion, the decision to use getServerSideProps or getStaticProps depends on the specific needs of your Next.js application. Leveraging these methods empowers developers to strike a balance between real-time data updates and optimized performance, ensuring a seamless user experience. As you embark on your Next.js journey, understanding the significance of these methods will undoubtedly elevate the quality of your web applications.</em></p><blockquote>For a more in-depth exploration and detailed guidance, consider visiting the official Next.js documentation on data fetching<strong>: </strong><a href="https://nextjs.org/docs/pages/building-your-application/data-fetching"><strong>Next.js Data Fetching Documentation</strong></a><strong>.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a78ce31d5374" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing React Data Grid Component with MUI X in Your Next.js 14 Project]]></title>
            <link>https://medium.com/@alamdar.hussain0007/implementing-react-data-grid-component-with-mui-x-in-your-next-js-14-project-c47806553d25?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c47806553d25</guid>
            <category><![CDATA[web-develop-and-design]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[datagrid]]></category>
            <category><![CDATA[material-ui]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Wed, 31 Jan 2024 19:07:42 GMT</pubDate>
            <atom:updated>2024-01-31T19:07:42.458Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p><em>As a developer working with React.js and Next.js, I recently implemented a powerful and customizable </em><a href="https://mui.com/x/react-data-grid/"><em>Data Grid</em></a><em> component in my project. The </em><a href="https://mui.com/x/react-data-grid/"><em>DataGrid</em></a><em> presents information in a structured format of rows and columns. The data is displayed in a user-friendly, quick-to-scan and interactive way, enabling users to efficiently identify patterns, edit data, and gather insights.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*msa1vIuu1zea50D1aTUqlA.png" /><figcaption>Material UI</figcaption></figure><p><em>In this blog post, I’ll guide you through the implementation of the React Data Grid component in a Next.js project, sharing the code snippets that made it easy for me to manage and display data efficiently.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6kW2FKbemO9d7bMJOl5Z7A.png" /><figcaption>Data Grid MUI Graphical representation <strong>(mock data)</strong></figcaption></figure><h3>Installation</h3><p><em>Before diving into the code, make sure to install the required package:</em></p><pre>npm install @mui/x-data-grid</pre><h3>Fetching and Displaying Data</h3><p><em>I used the Data Grid component to display a list of users fetched from an API. Let’s take a closer look at the key parts of my implementation.</em></p><pre>// Importing necessary dependencies<br>import { DataGrid } from &#39;@mui/x-data-grid&#39;;<br>import React, { useEffect, useState } from &#39;react&#39;;<br><br>const YourComponent = () =&gt; {<br>  // State variables for managing data and pagination<br>  const [users, setUsers] = useState([]);<br>  const [totalItems, setTotalItems] = useState([]);<br>  const [currentPage, setCurrentPage] = useState(1);<br>  const [pageSize, setPageSize] = useState(100);<br>  // ... other state variables ...<br><br>  useEffect(() =&gt; {<br>    setLoading(true);<br>    // Fetching data from the API using a custom function (getAllMissingLeadsUsers)<br>    getAllMissingLeadsUsers(pageNumber, selectedAccountType, searchTerm, selectedDateRange, pageSize).then((data) =&gt; {<br>      if (data?.leads?.leads) {<br>        setUsers(data?.leads?.leads);<br>        setTotalItems(data.leads.total_leads);<br>        <br>        // ... other state updates ...<br>      } else {<br>        setUsers([]);<br>      }<br>      setLoading(false);<br>    });<br>  }, [selectedAccountType, onSubmit, selectedDateRange, currentPage, pageSize]);<br>  // ... other functions ...<br><br>  return (<br>    &lt;div style={{ height: &#39;600px&#39;, width: &#39;100%&#39;, display: &#39;flex&#39;, justifyContent: &#39;center&#39;, alignItems: &#39;center&#39;, marginTop: &#39;20px&#39; }}&gt;<br>      {loading ? (<br>        // Show a loading spinner or component when data is being fetched<br>        &lt;Loading /&gt;<br>      ) : (<br>        // Display the Data Grid component when data is available<br>        &lt;DataGrid<br>          rows={users}<br>          columns={columns}<br>          pageSize={pageSize}<br>          rowsPerPageOptions={[10, 25, 50, 100]}<br>          disableSelectionOnClick<br>          pagination<br>          paginationMode=&quot;server&quot;<br>          rowCount={totalItems}<br>          onPageChange={(e) =&gt; {<br>            handlePageChange(e);<br>          }}<br>          page={currentPage}<br>          getRowId={(row) =&gt; row.lead_id}<br>          onPageSizeChange={handlePageSizeChange}<br>        /&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default YourComponent;</pre><ul><li><em>The </em><em>DataGrid component receives various props, including </em><em>rows (the data to be displayed), </em><em>columns (defining the structure of the grid), </em><em>pageSize, and others.</em></li><li><em>Configurations like </em><em>pagination, </em><em>paginationMode, and callback functions (</em><em>onPageChange, </em><em>onPageSizeChange) enable server-side pagination, ensuring optimal performance with large datasets.</em></li></ul><h3>Pagination and Server-Side Data Handling</h3><p><em>The Data Grid component supports server-side pagination, which is crucial for handling a large dataset efficiently. I managed the current page, page size, and total item count using state variables and provided appropriate callbacks for handling page changes (</em><em>onPageChange) and page size changes (</em><em>onPageSizeChange).</em></p><pre>const handlePageChange = (params) =&gt; {<br>  if (params === pageNumber + 1) {<br>    setCurrentPage(params + 1);<br>    setPageNumber(pageNumber + 1);<br>  } else if (params === pageNumber - 1) {<br>    setCurrentPage(params - 1);<br>    setPageNumber(pageNumber - 1);<br>  }<br>};<br>const handlePageSizeChange = (newPageSize) =&gt; {<br>  setCurrentPage(1);<br>  setPageNumber(1);<br>  setPageSize(newPageSize); // Reset to the first page when pageSize changes<br>};</pre><ul><li><em>The </em><em>handlePageChange function manages page changes, updating both the current page and the page number. This function is essential for keeping track of the displayed data when users navigate through pages.</em></li><li><em>handlePageSizeChange resets the current page and page number when the page size changes. This ensures a smooth transition and correct display of data based on the new page size.</em></li></ul><h3>Conclusion</h3><p><em>Implementing the React Data Grid component from MUI X has transformed the data presentation and interaction within my Next.js project. The key advantages of this implementation include:</em></p><ol><li><strong><em>Efficient Data Handling:</em></strong><em> The server-side pagination ensures smooth performance, even with extensive datasets.</em></li><li><strong><em>User-Friendly Features:</em></strong><em> The built-in sorting and pagination features provided by MUI X enhance the user experience, making data exploration intuitive.</em></li><li><strong><em>Customization Opportunities:</em></strong><em> The Data Grid component’s flexibility allows for easy customization, adapting to various project requirements.</em></li></ol><p><em>While the current implementation has proven effective, there are always opportunities for improvement:</em></p><ul><li><strong><em>Enhanced Styling:</em></strong><em> Consider further customization of the Data Grid’s appearance to align with your project’s design principles.</em></li><li><strong><em>Error Handling:</em></strong><em> Implement robust error handling mechanisms to gracefully manage API request failures or unexpected responses.</em></li></ul><p><em>Incorporating the React Data Grid component into your project opens up a world of possibilities for displaying and interacting with data. Explore the </em><a href="https://mui.com/x/react-data-grid/getting-started/"><em>MUI X Data Grid documentation</em></a><em> for additional customization options and advanced features.</em></p><p><em>Happy Happy Coding!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c47806553d25" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing a Secure Password Recovery System with AWS SES and @aws-sdk/client-ses (v3) in Next.js]]></title>
            <link>https://medium.com/@alamdar.hussain0007/implementing-a-secure-forgot-password-feature-with-aws-ses-and-aws-sdk-client-ses-v3-c456f4b36e7b?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c456f4b36e7b</guid>
            <category><![CDATA[ses-aws-price]]></category>
            <category><![CDATA[nextjs14]]></category>
            <category><![CDATA[forgot-password]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Sat, 20 Jan 2024 17:13:30 GMT</pubDate>
            <atom:updated>2024-01-22T07:03:05.129Z</atom:updated>
            <content:encoded><![CDATA[<h3>Implementing a Secure Password Recovery System with AWS SES and @aws-sdk/client-ses (v3) in Next.js 14</h3><h3>Blog Content:</h3><p>If you’re building a Next.js 14 project and want to implement a secure and reliable Forgot Password feature, using AWS SES (Simple Email Service) with the @aws-sdk/client-ses library is a great choice. In this tutorial, we&#39;ll walk through the steps of setting up the feature, including the necessary code snippets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y_pzifMpmtMr7x4lnbiYug.jpeg" /><figcaption><a href="https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/ses-examples-sending-email.html">Reset your Password</a></figcaption></figure><p><em>the seamless flow of our password recovery process: A click on the login screen’s button guides users to an intuitive screen, where they input their email. Our backend, driven by AWS SESClient Service V3, confirms the email’s existence and sends a secure key. A carefully crafted email arrives, containing a reset link. With a click, users effortlessly establish a new password, swiftly regaining control. This fusion of Next.js innovation and AWS excellence guarantees a secure, user-centric journey through password recovery.</em></p><h3>Install AWS SDK Client for SES</h3><p><em>Start by installing the AWS SDK Client for SES. Open your terminal and run:</em></p><pre>npm install @aws-sdk/client-ses</pre><p><em>This library provides an easy-to-use interface for interacting with the AWS SES service.</em></p><h3>Create an Email Module</h3><p><em>Now, let’s create a module for sending emails. Below is a simplified version of the </em><em>emailModule.js file:</em></p><pre>// emailModule.js<br><br>//aws-pakage<br>import { SESClient } from &quot;@aws-sdk/client-ses&quot;;<br>import { SendEmailCommand } from &quot;@aws-sdk/client-ses&quot;;<br><br>//access-keys &amp; region <br>const SES_CONFIG = {<br>  credentials: {<br>    accessKeyId: process.env.accessKeyId,<br>    secretAccessKey: process.env.secretAccessKey,<br>  },<br>  region: &#39;us-east-1&#39;,<br>};<br>const sesClient = new SESClient(SES_CONFIG);<br><br>export default async function ForgotPassword(recipientEmail, name, key) {<br>//Email body<br>  const params = {<br>    Source: &#39;Productdata &lt;alerts@productdata.co&gt;&#39;,<br>    Destination: {<br>      ToAddresses: [recipientEmail],<br>    },<br>    Message: {<br>      Body: {<br>        Html: {<br>          Data: `&lt;p&gt;Need to reset your password at www.productdata.co?&lt;/p&gt;<br>                 &lt;p&gt;To reset the password &lt;a href=&quot;${process.env.URI}/verify?key=${key}&quot;&gt;click here!&lt;/a&gt;.&lt;/p&gt;<br>                 &lt;br /&gt;<br>                 &lt;p&gt;If you did not make this request then please ignore this email.&lt;/p&gt;`,<br>        },<br>      },<br>      Subject: {<br>        Data: `Hello, ${name}!`,<br>      },<br>    },<br>  };<br>  try {<br>    return await sesClient.send(new SendEmailCommand(params));<br>  }<br>  catch (error) {<br>    console.log(&quot;erro : &quot;, error);<br>    return error;<br>  }<br>};<br><br></pre><p><em>This module uses the </em><em>@aws-sdk/client-ses library to send a password reset email with a unique key.</em></p><p><strong>To obtain the necessary AWS credentials for SES</strong></p><p><em>follow these steps:</em></p><ol><li><strong><em>Create an AWS Account: </em></strong><em>Sign up for an AWS account on the </em><a href="https://aws.amazon.com/"><em>AWS website</em></a><em>.</em></li><li><strong><em>Navigate to IAM:</em></strong><em> Access the Identity and Access Management (IAM) service in the AWS Management Console.</em></li><li><strong><em>Create or Use IAM User:</em></strong><em> Create a new IAM user or use an existing one, granting programmatic access.</em></li><li><strong><em>Generate Access and Secret Keys:</em></strong><em> For the IAM user, generate an access key and secret key. Set them as environment variables in your development environment or server.</em></li></ol><p><em>For a detailed guide, </em>refer to the <a href="https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html">AWS IAM User Guide.</a></p><h3>Backend Route to Verify Email and Update Password</h3><p><em>Next, create the backend routes to handle the email verification and password update. Below is a simplified version of the route handler:</em></p><pre>// Import necessary modules and functions<br>import { NextResponse } from &#39;next/server&#39;;<br>import sendForgotPasswordEmail from &#39;@/path-to-your-email-module/emailModule&#39;;<br>import dbConnect from &#39;@/lib/dbConnect&#39;;<br>import User from &#39;@/models/User&#39;;<br>import bcrypt from &#39;bcrypt&#39;;<br><br>// Handle the POST request to initiate password reset<br>export async function POST(request) {<br>  try {<br>    // Connect to the database<br>    await dbConnect();<br>    <br>    // Retrieve email from the request body<br>    const body = await request.json();<br>    <br>    // Find the user with the provided email<br>    const user = await User.findOne({ email: body?.email });<br><br>    // If user not found, return an error response<br>    if (!user) {<br>      return NextResponse.json(<br>        message: &#39;Email is not correct, please check your email again!&#39;);<br>    }<br><br>    // Generate a unique key for password reset<br>    const key = makeKey(20);<br>    <br>    // Save the key to the user&#39;s record in the database<br>    user.verification_token = key;<br>    await user.save();<br><br>    // Send the password reset email with the unique key<br>    await sendForgotPasswordEmail(user.email, user.first_name, key);<br><br>    // Return a success response<br>    return NextResponse.json(<br>      message: &#39;Password reset email sent successfully&#39;);<br>  } catch (error) {<br>    // Handle errors and return an error response<br>    console.error(&#39;Error:&#39;, error);<br>    return NextResponse.json(<br>      message: &#39;An error occurred while verifying email.&#39;);<br>  }<br>}<br><br>// Handle the PUT request to update the user&#39;s password<br>export async function PUT(request) {<br>  try {<br>    // Connect to the database<br>    await dbConnect();<br>    <br>    // Retrieve password update details from the request body<br>    const body = await request.json();<br>    <br>    // Hash the new password<br>    const hash = await bcrypt.hash(body.password, 10);<br>    <br>    // Update the user&#39;s password in the database using the verification token<br>    const user = await User.updateOne({ verification_token: body.keyvalue }, { $set: { password: hash } });<br><br>    // Additional logic if needed...<br><br>    // Return a success response<br>    return NextResponse.json(<br>      message: &#39;Password updated successfully.&#39;);<br>  } catch (error) {<br>    // Handle errors and return an error response<br>    console.error(&#39;Error:&#39;, error);<br>    return NextResponse.json(<br>      message: &#39;An error occurred while updating the password.&#39;);<br>  }<br>}</pre><p><em>This route file handles the email verification and password update logic.</em></p><h3>Frontend Screen for Forgot Password:</h3><p><em>Now, let’s take a look at the frontend screen designed for the Forgot Password feature. The </em><em>UserForgotPassword component offers a clean and efficient form for users to initiate the password reset process:</em></p><pre>// Import necessary modules and functions<br>import { Input } from &quot;@/components/ui/input&quot;;<br>import { Label } from &quot;@/components/ui/label&quot;;<br>import { useForm } from &quot;react-hook-form&quot;;<br>import { ForgotPassword } from &quot;@/data/client/user&quot;;<br>import { toast } from &quot;@/components/ui/use-toast&quot;;<br><br>// Component for Forgot Password<br>export default function UserForgotPassword({ className, ...props }) {<br>    // State and form setup<br>    const [email, setEmail] = useState(&#39;&#39;);<br>    const { register, handleSubmit, formState: { errors } } = useForm({<br>        resolver: zodResolver(userAuthSchema),<br>    });<br>    const [isLoading, setIsLoading] = useState(false);<br><br>    // Handle form submission<br>    const handleOnsubmit = async (e) =&gt; {<br>        setIsLoading(true);<br><br>        // Call ForgotPassword function<br>        const user = await ForgotPassword(email);<br><br>        // Display result using Toast notifications<br>        if (!user.isSuccess) {<br>            toast(&quot;failed&quot;);<br>            setIsLoading(false);<br>            return;<br>        }<br><br>        toast(&quot;success&quot;);<br>        setIsLoading(false);<br>    }<br><br>    // Render the form<br>    return (<br>        &lt;form&gt;<br>            {/* Form components */}<br>            &lt;div className=&quot;grid gap-2&quot;&gt;<br>                &lt;div className=&quot;grid gap-1&quot;&gt;<br>                    &lt;Label className=&quot;sr-only&quot; htmlFor=&quot;email&quot;&gt;<br>                        email<br>                    &lt;/Label&gt;<br>                    &lt;Input<br>                        id=&quot;email&quot;<br>                        placeholder=&quot;email&quot;<br>                        type=&quot;text&quot;<br>                        className=&quot;bg-transparent&quot;<br>                        onChange={(e) =&gt; setEmail(e.target.value)}<br>                        disabled={isLoading}<br>                        value={email}<br>                    /&gt;<br>                    {errors?.email &amp;&amp; (<br>                        &lt;p className=&quot;px-1 text-xs text-red-600&quot;&gt;<br>                            {errors.email.message}<br>                        &lt;/p&gt;<br>                    )}<br>                &lt;/div&gt;<br><br>                {/* Submit button */}<br>                &lt;button disabled={isLoading} onClick={handleOnsubmit}&gt;<br>                    Verify your email<br>                &lt;/button&gt;<br>            &lt;/div&gt;<br>        &lt;/form&gt;<br>    );<br>}</pre><p><em>This streamlined form combines functionality with an intuitive design, making the password reset journey effortless for users.</em></p><h3>Conclusion</h3><p><em>With these code snippets, you’ve implemented a secure and reliable Forgot Password feature in your Next.js 14 project using AWS SES. Make sure to replace placeholders like </em><em>your-sender-email@example.com and </em><em>path-to-your-email-module with your actual values.</em></p><p><em>Feel free to customize the code according to your project’s needs and enhance the security features as required.</em></p><p><em>Happy coding! 🚀</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c456f4b36e7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Gmail Login in Next.js 14: A Quick Guide]]></title>
            <link>https://medium.com/@alamdar.hussain0007/implementing-gmail-login-in-next-js-14-a-quick-guide-93ac426d6305?source=rss-73f04e41e6c7------2</link>
            <guid isPermaLink="false">https://medium.com/p/93ac426d6305</guid>
            <category><![CDATA[login-with-google]]></category>
            <category><![CDATA[nextauth]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Alamdar Hussain]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 09:19:38 GMT</pubDate>
            <atom:updated>2024-01-18T09:19:38.487Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Introduction:</strong></blockquote><p><em>In the ever-evolving landscape of web development, staying updated with the latest technologies is essential. Recently, I had the opportunity to work on a Next.js 14 project, where the task at hand was to implement Gmail login functionality alongside traditional email/password authentication. In this blog post, I’ll walk you through the process and share insights on how to seamlessly integrate Gmail login into your Next.js 14 application.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mr6WJlUkYxDIey6YLp1O6g.jpeg" /><figcaption>Next.js 14</figcaption></figure><blockquote><strong>Section 1: Setting up the Frontend</strong></blockquote><p>To start, let’s look at the frontend code responsible for user registration and Gmail login. The following React component, UserRegisterForm, showcases a user registration form with the option to sign up using either email/password or Gmail credentials. Note that this component leverages the NextAuth library for authentication.</p><pre>// Frontend code: UserRegisterForm component<br><br>import { signIn } from &quot;next-auth/react&quot;;<br>import { Icons } from &quot;@/components/Shared/icons&quot;;<br>import { buttonVariants } from &quot;@/components/ui/button&quot;;<br>import { /* ... Other imports ... */ }<br><br>export default function UserRegisterForm({ /* ... Props ... */ }) {<br>  // ... [Other component code] ...<br><br>  const handleLoginWithGoogle = async () =&gt; {<br>    setIsLoadingG(true);<br>    await signIn(&quot;google&quot;);<br>    setIsLoadingG(false);<br>    return;<br>  }<br><br>  return (<br>    &lt;div className={cn(&quot;grid gap-6&quot;, className)} {...props}&gt;<br>      {/* ... [Other form fields] ... */}<br><br>      &lt;button className={buttonVariants()} disabled={isLoadingG} onClick={handleLoginWithGoogle}&gt;<br>        {isLoadingG &amp;&amp; (<br>          &lt;Icons.spinner className=&quot;mr-2 h-4 w-4 animate-spin&quot; /&gt;<br>        )}<br>        Sign Up with Gmail<br>      &lt;/button&gt;<br><br>      {/* ... [Other elements] ... */}<br>    &lt;/div&gt;<br>  );<br>}</pre><p><em>In this component:</em></p><ul><li><em>Users can choose their user type from a dropdown.</em></li><li><em>Traditional registration with email and password is supported.</em></li><li><em>A “Sign Up with Gmail” button allows users to register using their Gmail accounts.</em></li></ul><blockquote><strong>Section 2: Backend Configuration</strong></blockquote><p><em>Now, let’s delve into the backend configuration necessary for NextAuth. The </em><em>authOptions object showcases the setup for both traditional email/password authentication and Gmail login.</em></p><pre>// Backend code: authOptions configuration<br><br>import dbConnect from &quot;@/lib/dbConnect&quot;;<br>import User from &quot;@/models/User&quot;;<br>import CredentialsProvider from &quot;next-auth/providers/credentials&quot;;<br>import GoogleProvider from &#39;next-auth/providers/google&#39;;<br>const bcrypt = require(&quot;bcrypt&quot;);<br><br>// ... Other imports ...<br><br>export const authOptions = {<br>  // ... Other options ...<br><br>  providers: [<br>    CredentialsProvider({<br>      name: &quot;Credentials&quot;,<br>      async authorize(credentials, req) {<br>        await dbConnect();<br>        const user = await User.findOne({ email: credentials.email });<br>        if (user) {<br>          // Handling traditional email/password authentication<br>          // ... [Code for email/password authentication] ...<br>        } else {<br>          return null;<br>        }<br>      },<br>    }),<br>    GoogleProvider({<br>      clientId: process.env.GOOGLE_CLIENT_ID,<br>      clientSecret: process.env.GOOGLE_CLIENT_SECRET,<br>    }),<br>  ],<br><br>  callbacks: {<br>    // ... Other callbacks ...<br><br>    async signIn({ user, account, profile }) {<br>      if (account?.provider === &quot;google&quot;) {<br>        // Handling Gmail authentication<br>        // ... [Code for creating user account after successful Gmail authentication] ...<br>      } else {<br>        return true;<br>      }<br>    },<br>  },<br><br>  // ... Other options ...<br>};</pre><p><em>In this configuration:</em></p><ul><li><em>NextAuth is configured with both </em><em>CredentialsProvider (for email/password) and </em><em>GoogleProvider (for Gmail).</em></li><li><em>The </em><em>authorize function in </em><em>CredentialsProvider handles traditional email/password authentication.</em></li><li><em>The </em><em>signIn callback handles the creation of a user account upon successful Gmail authentication.</em></li></ul><blockquote><strong>Section3: Setting Up Google API Credentials</strong></blockquote><p><strong><em>Visit Google Cloud Console:</em></strong></p><p><a href="https://console.cloud.google.com/"><em>Go to the Google Cloud Console.</em></a></p><p><strong><em>Create a New Project:</em></strong></p><ul><li><em>Click on the project drop-down menu at the top of the page.</em></li><li><em>Click on the “+ Create Project” button.</em></li><li><em>Enter a project name and click on the “Create” button.</em></li></ul><p><strong><em>Enable the Google+ API:</em></strong></p><ul><li><em>In the left-hand navigation menu, click on “APIs &amp; Services” &gt; “Dashboard.”</em></li><li><em>Click on “+ ENABLE APIS AND SERVICES” at the top.</em></li><li><em>Search for “Google+ API” and select it.</em></li><li><em>Click on the “Enable” button.</em></li></ul><p><strong><em>Create Credentials:</em></strong></p><ul><li><em>In the left-hand navigation menu, click on “APIs &amp; Services” &gt; “Credentials.”</em></li><li><em>Click on “Create Credentials” and choose “OAuth client ID.”</em></li><li><em>Select “Web application” as the application type.</em></li><li><em>Enter a name for your OAuth client.</em></li><li><em>Add the authorized redirect URI(s) for your application (e.g., </em><em>http://localhost:3000/api/auth/callback/google for development).</em></li><li><em>Click on the “Create” button.</em></li></ul><p><strong><em>Obtain Client ID and Secret:</em></strong></p><ul><li><em>Once created, you’ll see your OAuth client in the “Credentials” tab.</em></li><li><em>Find your client ID and client secret on this page.</em></li></ul><blockquote><strong>Section 4: The Implementation Process</strong></blockquote><p><strong><em>Frontend Integration:</em></strong></p><ul><li><em>Copy the </em><em>UserRegisterForm component into your Next.js 14 project.</em></li><li><em>Ensure that the required dependencies, such as </em><em>next-auth, are installed.</em></li></ul><p><strong><em>Backend Setup:</em></strong></p><ul><li><em>Copy the </em><em>authOptions configuration into your Next.js 14 project.</em></li><li><em>Set up environment variables for your Google API credentials (</em><em>GOOGLE_CLIENT_ID and </em><em>GOOGLE_CLIENT_SECRET).</em></li></ul><p><strong><em>Testing:</em></strong></p><ul><li><em>Test the user registration form to ensure traditional email/password signup is functioning.</em></li><li><em>Test the “Sign Up with Gmail” button to verify Gmail login functionality.</em></li></ul><p><strong><em>Deploy:</em></strong></p><ul><li><em>Once everything is working as expected, deploy your Next.js 14 application.</em></li></ul><blockquote><strong>Conclusion:</strong></blockquote><p><em>Implementing Gmail login in Next.js 14 is a powerful way to enhance user experience and broaden your authentication options. By following this guide, you can seamlessly integrate Gmail authentication into your projects, offering users a convenient and secure way to sign up. Feel free to share your thoughts or ask questions in the comments, and happy coding with Next.js 14!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93ac426d6305" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>