<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sanket Kalekar</title>
    <description>The latest articles on Forem by Sanket Kalekar (@ooye_sanket).</description>
    <link>https://forem.com/ooye_sanket</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1134135%2Fb1b137a3-01dd-420c-82cb-6271e699d309.jpg</url>
      <title>Forem: Sanket Kalekar</title>
      <link>https://forem.com/ooye_sanket</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ooye_sanket"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Mon, 21 Apr 2025 17:29:33 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/-4d1n</link>
      <guid>https://forem.com/ooye_sanket/-4d1n</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" class="crayons-story__hidden-navigation-link"&gt;No Hassle: Serverless Social Login Powered by AWS Cognito&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/ooye_sanket" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1134135%2Fb1b137a3-01dd-420c-82cb-6271e699d309.jpg" alt="ooye_sanket profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/ooye_sanket" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Sanket Kalekar
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Sanket Kalekar
                
              
              &lt;div id="story-author-preview-content-2340205" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/ooye_sanket" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1134135%2Fb1b137a3-01dd-420c-82cb-6271e699d309.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Sanket Kalekar&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Mar 18 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" id="article-link-2340205"&gt;
          No Hassle: Serverless Social Login Powered by AWS Cognito
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/aws"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;aws&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/awscognito"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;awscognito&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/automation"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;automation&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/awschallenge"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;awschallenge&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/fire-f60e7a582391810302117f987b22a8ef04a2fe0df7e3258a5f49332df1cec71e.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/exploding-head-daceb38d627e6ae9b730f36a1e390fca556a4289d5a41abb2c35068ad3e2c4b5.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;20&lt;span class="hidden s:inline"&gt; reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              2&lt;span class="hidden s:inline"&gt; comments&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            8 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>aws</category>
      <category>awscognito</category>
      <category>automation</category>
      <category>awschallenge</category>
    </item>
    <item>
      <title>AI-Built Flight Sim Becomes a Business</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Wed, 26 Mar 2025 07:40:49 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/ai-built-flight-sim-becomes-a-business-4h9i</link>
      <guid>https://forem.com/ooye_sanket/ai-built-flight-sim-becomes-a-business-4h9i</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://future.forem.com/challenges/writing-2025-02-26"&gt;Future Writing Challenge&lt;/a&gt;: How Technology Is Changing Things.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Hey friend,&lt;/p&gt;

&lt;p&gt;Look what i just  came across something that blew my mind, and I had to share it with you. An indie hacker named Peter, with &lt;em&gt;no prior experience&lt;/em&gt; in flight simulators, managed to build a fully functional multiplayer flying game in just a few hours. How? By using &lt;code&gt;AI&lt;/code&gt; tools like Cursor and large language models (LLMs) such as Grog to write most of the code for him.&lt;/p&gt;

&lt;h1&gt;
  
  
  AI-Powered Game Development
&lt;/h1&gt;

&lt;p&gt;Instead of relying on a complex game engine, Peter built everything using HTML, vanilla JavaScript, and Three.js for 3D graphics. On the back-end, Python WebSockets handle real-time multiplayer synchronization, broadcasting player positions 10 times per second. The red planes in the game? They’re real players flying in real time. No Unity. No Unreal Engine. Just AI-assisted coding and lightweight web technologies.&lt;br&gt;
From Experiment to Business&lt;/p&gt;

&lt;p&gt;At first, this was just a fun experiment. But Peter took it a step further by adding a buy button—offering an F-16 jet for $29.99. To his surprise, within days, he had sold nine of them and even landed a $1,000 ad deal. What started as an AI-powered project turned into a real business overnight.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Future of AI in Game Development
&lt;/h1&gt;

&lt;p&gt;This caught even Elon Musk’s attention. AI-assisted game development is shaking up the industry, making it easier for people with ideas—but limited coding experience—to create games in record time. Some critics call these AI-generated games “sloppy,” but they’re missing the bigger picture. As AI improves, we’ll see more sophisticated rendering, physics, and interactivity, transforming simple prototypes into immersive, high-quality experiences.&lt;/p&gt;

&lt;h1&gt;
  
  
  What This Means for Creators
&lt;/h1&gt;

&lt;p&gt;The barriers to entry are crumbling. Imagine being able to build a game, an app, or any digital experience in hours instead of years. This isn’t just about gaming—it’s about how AI is democratizing creativity in real time. We’re witnessing a shift where anyone with a vision can turn an idea into reality with AI as their co-creator.&lt;/p&gt;

&lt;p&gt;Would love to hear your thoughts on this. Do you think AI is changing game development for the better?&lt;/p&gt;

&lt;p&gt;Talk soon, Sanket&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Prize Categories
&lt;/h3&gt;

&lt;p&gt;This submission qualifies for Ripple Effects / Explain Like I'm Five.&lt;/p&gt;

</description>
      <category>futurechallenge</category>
    </item>
    <item>
      <title>have a look to this</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Tue, 18 Mar 2025 14:59:26 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/have-a-look-to-this-ok6</link>
      <guid>https://forem.com/ooye_sanket/have-a-look-to-this-ok6</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/ooye_sanket" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1134135%2Fb1b137a3-01dd-420c-82cb-6271e699d309.jpg" alt="ooye_sanket"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;No Hassle: Serverless Social Login Powered by AWS Cognito&lt;/h2&gt;
      &lt;h3&gt;Sanket Kalekar ・ Mar 18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#aws&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#awscognito&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#automation&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#awschallenge&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>aws</category>
      <category>awscognito</category>
      <category>automation</category>
      <category>awschallenge</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Tue, 18 Mar 2025 14:58:53 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/-2jo8</link>
      <guid>https://forem.com/ooye_sanket/-2jo8</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/ooye_sanket" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1134135%2Fb1b137a3-01dd-420c-82cb-6271e699d309.jpg" alt="ooye_sanket"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;No Hassle: Serverless Social Login Powered by AWS Cognito&lt;/h2&gt;
      &lt;h3&gt;Sanket Kalekar ・ Mar 18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#aws&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#awscognito&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#automation&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#awschallenge&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>aws</category>
      <category>awscognito</category>
      <category>automation</category>
      <category>awschallenge</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Tue, 18 Mar 2025 10:05:05 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/-59k0</link>
      <guid>https://forem.com/ooye_sanket/-59k0</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/ooye_sanket" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1134135%2Fb1b137a3-01dd-420c-82cb-6271e699d309.jpg" alt="ooye_sanket"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;No Hassle: Serverless Social Login Powered by AWS Cognito&lt;/h2&gt;
      &lt;h3&gt;Sanket Kalekar ・ Mar 18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#aws&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#awscognito&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#automation&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#awschallenge&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>aws</category>
      <category>awscognito</category>
      <category>automation</category>
      <category>awschallenge</category>
    </item>
    <item>
      <title>No Hassle: Serverless Social Login Powered by AWS Cognito</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Tue, 18 Mar 2025 09:55:18 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i</link>
      <guid>https://forem.com/ooye_sanket/no-hassle-serverless-social-login-powered-by-aws-cognito-f3i</guid>
      <description>&lt;p&gt;&lt;strong&gt;An architectural perspective on choosing between possible solutions&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Context
&lt;/h1&gt;

&lt;p&gt;Let's assume that I have an application for which user &lt;strong&gt;No Need to Login&lt;/strong&gt; just need to register with their social identity.&lt;/p&gt;

&lt;p&gt;If you're wondering why to think like this and how it can be done.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Registration/signup can be a barrier for users as it involves multiple steps and data sharing.&lt;/li&gt;
&lt;li&gt;Most internet users have at least one social identity, while all mobile users have either a Google (Android) or Apple (iOS) identity.&lt;/li&gt;
&lt;li&gt;Users can access your app more easily if login is mostly password-free.&lt;/li&gt;
&lt;li&gt;You can collect user data from social providers, provided users grant permission.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the most popular social like Facebook, Google, Apple, Amazon, LinkedIn, Github and many others.&lt;/p&gt;

&lt;p&gt;Since every IdP is expected to implement the OpenID Connect standard (built on top of OAuth2) and requires some configuration, let's explore the available options. &lt;/p&gt;

&lt;h1&gt;
  
  
  Option 1: Native integration
&lt;/h1&gt;

&lt;p&gt;Every one has its own SDK and apis to integrate natively, so you can code in your app the integration for IdPs you want to use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2fivfx31x6qgfid088w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2fivfx31x6qgfid088w.png" alt="Image description" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Pros
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Granular Control&lt;/em&gt;: Manage each IdP integration individually with native support, allowing you to customize the user experience through configuration. You can also handle IdP-specific requests beyond the OAuth standard (more on that later...).&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Direct Integration&lt;/em&gt;: No intermediaries, ensuring a straightforward architecture. Leverage robust SDKs from providers like Google, Facebook, and Amazon, benefiting from their high availability and resilience.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Cost-Effective&lt;/em&gt;: Most IdPs offer a free tier for their APIs, eliminating additional costs from that side.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Cons
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;challenge to scale&lt;/em&gt;: Each IdP come with its own SDK and unique requirement, making standardization difficult. Managing these variation requires extensive code, and even if you centralize authentication in library, every client must update it to apply changes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Complex Testing &amp;amp; Debugging&lt;/em&gt;: More code means more testing. Additionally, each IdP has specific nuances, requiring in-depth knowledge to troubleshoot and maintain integrations effectively.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Option 2: use an OAuth Provider
&lt;/h1&gt;

&lt;p&gt;Since Social IdPs follow a standard, their implementations can be abstracted using interfaces. This allows seamless integration with an OAuth 2 service provider, reducing dependency on specific SDKs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffly1jgiajyt6b3uwmfxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffly1jgiajyt6b3uwmfxs.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Pros
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Simplified Integration&lt;/em&gt;: A single connection between your client and the OAuth identity platform means less code, fewer tests, fewer releases, and faster development.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Scalability&lt;/em&gt;: Easily add or remove IdPs without affecting clients (as mentioned earlier).&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Centralized Authentication Management&lt;/em&gt;: Configure and govern authentication flows in one place, ensuring consistency across all IdPs while enabling monitoring, metrics, and analytics.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Standards-Based Authentication&lt;/em&gt;: Build your authentication flow on industry standards for reliability and interoperability.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Identity Platforms as a Service&lt;/em&gt;: Solutions like AWS Cognito, Auth0, Google Firebase, and others provide managed authentication services.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Cons
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Limited IdP Support&lt;/em&gt;: You can only integrate with IdPs that your OAuth provider supports, restricting flexibility.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Increased System Complexity&lt;/em&gt;: Adding an OAuth provider introduces extra components, making the architecture more complex.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Potential Single Point of Failure&lt;/em&gt;: If the OAuth provider goes down, authentication becomes unavailable for users. Ensuring high availability and scalability of your OAuth provider is crucial.&lt;/p&gt;

&lt;h1&gt;
  
  
  My choice: Option 2 with AWS Cognito
&lt;/h1&gt;

&lt;p&gt;I understand there are many constraints, and I can't list them all here. Given my context, I chose option 2 and implemented AWS Cognito as my OAuth provider. I also explored Auth0 and a few other services during my evaluation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I chose to accept Cognito's constraints and costs in exchange for a low-code implementation and easy setup—essentially prioritizing faster delivery—since I wasn't certain if a more complex solution would be worthwhile.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here is my implementation&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6akalae6jd8cysqt64kk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6akalae6jd8cysqt64kk.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All you need is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;configure your integration on social Provider side.Here a reference for each provider i got form internet &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ryandam9.medium.com/using-google-as-an-identity-provider-in-aws-cognito-acddfb58fad" rel="noopener noreferrer"&gt;Google&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://victorhzhao.medium.com/add-social-login-to-aws-cognito-user-pool-facebook-94a2cee5136e" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jainsameer.medium.com/react-native-social-sign-in-with-apple-and-amplify-6c803b2971d6" rel="noopener noreferrer"&gt;Apple&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Config Cognito integration. &lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/external-identity-providers.html" rel="noopener noreferrer"&gt;HERE AWS Doc for each Supported Providers&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/cognito/dev-resources/?nc1=h_ls&amp;amp;cognito-whats-new.sort-by=item.additionalFields.postDateTime&amp;amp;cognito-whats-new.sort-order=desc" rel="noopener noreferrer"&gt;Integrate your application with Amazon Cognito&lt;/a&gt;. Cognito provides an &lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-managed-login.html" rel="noopener noreferrer"&gt;hosted ui&lt;/a&gt; for the login page, but you can create your own.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  Pitfalls: things to be careful about
&lt;/h1&gt;

&lt;p&gt;Here are some challenges I encountered during this integration. While this isn’t a complete list of potential issues with Amazon Cognito and the social login flow, it reflects my personal experience—things I discovered while working on it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out for Cognito limits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Serverless doesn’t mean unlimited, and Cognito is a prime example of this.&lt;/p&gt;

&lt;p&gt;In simple terms, Cognito's scaling policy isn't built for sudden traffic spikes. Its capacity scales based on user pool size, meaning more users allow for higher TPS. However, the first threshold is set at 1 million users—whether you have 1 or 999,999 users, your TPS remains the same.&lt;/p&gt;

&lt;p&gt;If logins are steady, this isn't an issue. But if your app experiences traffic surges, such as during specific time periods, you may face throttling errors from Cognito.&lt;/p&gt;

&lt;p&gt;These diagram show successful federation logins and throttling errors:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm5gwthpbc10p28g2ge4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbm5gwthpbc10p28g2ge4.png" alt="Image description" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fii6z4rivwvl2yakj0pek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fii6z4rivwvl2yakj0pek.png" alt="Image description" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;i split into two distinct diagrams for better visualisation, but i want to point out that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;around 20:50 i had ~7K throttling errors and ~1.5K of success (total requests: ~8.5K)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;around 21:20 i had ~6K throttling errors and ~1.4K success (total requests: ~7.5K)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;around 22:30 i had ~1.3K success with ZERO throttling errors&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find Cognito's TPS calculation rules in a specific section of its documentation, and it's important to review them carefully.&lt;/p&gt;

&lt;p&gt;As shown in the successful login metric diagram, handling throttling exceptions in your app can reduce user impact. While users may experience a slight delay, they will still be able to log in successfully.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I decided that it could be acceptable, and i traded it for easy setup and integration with Social Providers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since this decision affects the customer experience, I tried to mitigate it as much as possible. For example, I sent push notifications before traffic spikes to encourage users to log in earlier and distribute login requests more evenly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standards are not prescriptive&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I love standards, everybody should love them in engineering.&lt;/p&gt;

&lt;p&gt;Unfortunately, sometimes for good reasons and sometimes not, giants have bias to force standards a little bit.&lt;br&gt;
Apple, i'm pointing my finger at you!&lt;/p&gt;

&lt;p&gt;For instance, Apple’s guidelines mandate that if your app includes social login and is distributed on the App Store, it must also support Sign in with Apple. While this may feel restrictive, it’s a reasonable requirement.&lt;/p&gt;

&lt;p&gt;Additionally, Apple enforces that the "User Cancellation" option must be easily accessible and clear, which is fair.&lt;/p&gt;

&lt;p&gt;And here Apple does not adhere to the OAuth standard: if an Apple user allows Apple to share their data with your app, some kind of association between your app and the user also takes place in the Apple system, and if a user wants to cancel from your app (also known as your user pool), this association should also be removed.&lt;/p&gt;

&lt;p&gt;To do that, you have to invoke Apple apis to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;generate a valid access or refresh token.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;invalidate the freshly generated token.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://developer.apple.com/documentation/sign_in_with_apple/revoke_tokens" rel="noopener noreferrer"&gt;Sounds weird, but this is exactly what this doc page prescribes.&lt;/a&gt;&lt;br&gt;
And, guess what? Cognito doesn't handle it.&lt;/p&gt;

&lt;p&gt;Even if Cognito could handle it because it has all the information it needs, especially the private key you created on the Apple side and provided to Cognito to request the tokens, that's reasonable from a product perspective: Cognito adheres to standards and can't track every specific implementation.&lt;/p&gt;

&lt;p&gt;But it does mean that Apple won't include your app in the store if you don't take care of it.&lt;/p&gt;

&lt;p&gt;Let's look at &lt;strong&gt;&lt;em&gt;how to i implement this&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You can't handle it directly in the app since I used Cognito to separate the app from authentication providers, I wanted to maintain that separation. Plus, storing a private key on the device is not a good idea.&lt;/p&gt;

&lt;p&gt;Instead, this needs to be implemented on the backend. My initial approach was to use Cognito events—when a user is deleted in Cognito, an event triggers a Lambda function that calls Apple's API to remove the user from Apple's system.&lt;/p&gt;

&lt;p&gt;As far as I know, Cognito today has&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-working-with-lambda-triggers.html#cognito-user-pools-lambda-trigger-event-parameter-shared" rel="noopener noreferrer"&gt;Lambda triggers&lt;/a&gt;: user deletion not supported&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-info-in-cloudtrail.html" rel="noopener noreferrer"&gt;Cloudtrail tracks all management api calls&lt;/a&gt;, and user cancellation is a management api. But Cloudtrail event doesn't have any reference to actual user (and it saved my day in an audit session, but this is another story)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-events.html" rel="noopener noreferrer"&gt;Cognito Sync&lt;/a&gt;: it seems to handle user deletion. Quoting:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To remove a record, either set the &lt;code&gt;op&lt;/code&gt; to &lt;code&gt;remove&lt;/code&gt;, or set the value to null.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is how it looks like:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbv2n7teu21jz5ohq6hj1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbv2n7teu21jz5ohq6hj1.png" alt="Image description" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;still there are 2 problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;first, i have to put your Apple's private key in Cognito and in Secret Manager. Cognito can't retrieve it from Secret Manager. I raised this issue to Cognito team, keep you posted on this.&lt;/li&gt;
&lt;li&gt;second, Cognito user cancellation and Apple user cancellation are asynchronous: what if it success on Cognito side and than fails on Apple side? User wont be in our Cognito user pool anymore, so we can't rollback the operation. So I need to handle failures, and to handle it you need to store it. Let's add a DLQ for our deletion lambda&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;After update this is how it look:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9p1i3buopcuuns3dfu1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9p1i3buopcuuns3dfu1.png" alt="Image description" width="800" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After saving, you must analyse why the deletion failed and try again. How long can this take? It depends on the cause and your process, but until you've done that, users will still see their user associated with your app, and I'm not sure Apple would like it and approve your app submission.&lt;/p&gt;

&lt;p&gt;You need to reverse the order of deletion, first on the Apple side and then on the Cognito side. If the Apple deletion fails, you can send an error message to the user and inform he/she that the deletion cannot be performed and they should try again later.&lt;/p&gt;

&lt;p&gt;In the case of a Cognito error, you will have to do this later, but at least the user will not see that their user is linked to your app and Apple should be satisfied and approve your request.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's see how it looks like&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6am59d4w43eu08rjvzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6am59d4w43eu08rjvzc.png" alt="Image description" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;I decided to implement a custom api for Apple user deletion because it can be implemented just in half our code base (not for Android version of the app), the integration is quite simple and Apple would be happy with this solution, but probably not with the alternative solution. Still an error handling mechanism still need to be implemented to catch Cognito deletion errors and to recover them.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Wrap up
&lt;/h1&gt;

&lt;p&gt;I have shown you my solution to real-world problems and how you can make informed decisions by carefully weighing trade-offs between different solutions that best fit your context and constraints.&lt;/p&gt;

&lt;p&gt;In other words, the daily work of an architect, simplified.&lt;/p&gt;

&lt;p&gt;Architectures need to evolve as the context and constraints change over time. So always design your solutions so that they can easily evolve with them.&lt;/p&gt;

&lt;p&gt;I hope it was useful for you!&lt;/p&gt;

&lt;p&gt;Bye 👋!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awscognito</category>
      <category>automation</category>
      <category>awschallenge</category>
    </item>
    <item>
      <title>The Hexagonal Code: How Uber Finds You Fast!</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Fri, 13 Sep 2024 10:18:11 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/the-hexagonal-code-how-uber-finds-you-fast-1p4b</link>
      <guid>https://forem.com/ooye_sanket/the-hexagonal-code-how-uber-finds-you-fast-1p4b</guid>
      <description>&lt;h1&gt;
  
  
  Have you ever wondered how Uber magically finds a driver near you within seconds of booking a ride?🤔
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;where my night 2AM brain cells are decoding this after some of research i got this:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So suppose this is you🧍and these are the drivers around you&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yr3urquq9fszbadhg93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4yr3urquq9fszbadhg93.png" alt="Image description" width="800" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Uber uses a thing called hexagonal index So what it does is it divides the entire map into hexagons So you are in a hexagon So it will search in all the hexagons that are near you to see if it finds a driver or not&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvdgj45qcfngp4ctnlmy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvdgj45qcfngp4ctnlmy.png" alt="Image description" width="607" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it is possible that you are covering a lot of area and we have to find more drivers nearby So what it does is it breaks these hexagons into smaller hexagons so that it will be able to find very close drivers,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkm42c0tclmjhuxqzlmnd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkm42c0tclmjhuxqzlmnd.png" alt="Image description" width="608" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So simply you can imagine how it will be suppose we first looked at the big hexagons to see how many are there around you &lt;strong&gt;this is how it works.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;but still in confuse why &lt;strong&gt;hexagons&lt;/strong&gt; why not did we use &lt;strong&gt;triangles&lt;/strong&gt; and &lt;strong&gt;squares?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ueq92x126g6390p0b3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2ueq92x126g6390p0b3.png" alt="Image description" width="585" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if you look at one hexagon, the adjacent hexagon the distance will be equidistant if you look at it from the center but this doesn't happen in a square or triangle now how are these hexagons stored?&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>algorithms</category>
      <category>startup</category>
      <category>design</category>
    </item>
    <item>
      <title>Beyond the Cloud: How On-Device AI Could Rescue Our Privacy!?</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Wed, 28 Aug 2024 18:15:44 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/beyond-the-cloud-how-on-device-ai-could-rescue-our-privacy-4abk</link>
      <guid>https://forem.com/ooye_sanket/beyond-the-cloud-how-on-device-ai-could-rescue-our-privacy-4abk</guid>
      <description>&lt;p&gt;&lt;em&gt;In an era where our digital footprints are expanding exponentially, the question of privacy has never been more critical. As artificial intelligence (AI) continues to evolve and personalize our experiences, we find ourselves at a crossroads: How do we balance the benefits of AI-driven personalization with the fundamental need for privacy?&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The Illusion of Privacy in the Cloud
&lt;/h1&gt;

&lt;p&gt;For years, we've been told that our data is safe in the cloud. Yet, time and time again, we've witnessed major data breaches and leaks that have shaken our trust in cloud-based systems. The truth is, anything that goes into the cloud has a non-zero chance of being compromised. This realization has led to a growing concern among users and a demand for more secure alternatives.&lt;/p&gt;

&lt;h1&gt;
  
  
  Enter On-Device AI: The Game Changer
&lt;/h1&gt;

&lt;p&gt;The emergence of powerful on-device AI processing, made possible by advanced Neural Processing Units (NPUs), is revolutionizing the way we think about privacy and personalization. This technology brings three key benefits to the table:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Immediacy&lt;/strong&gt;&lt;/em&gt;: On-device processing provides instant results, eliminating the lag associated with cloud-based computations.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Privacy&lt;/em&gt;&lt;/strong&gt;: By keeping data on the device, users can enjoy AI-driven features without exposing their information to external servers.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Personalization&lt;/em&gt;&lt;/strong&gt;: Local processing allows AI to learn and adapt to user behavior more intimately, leading to better personalized experiences.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Power of Local Processing
&lt;/h1&gt;

&lt;p&gt;Modern mobile chipsets, equipped with NPUs capable of handling billions of parameters, are now powerful enough to run complex AI models directly on the device. This means that sensitive data - from your search history to your writing style - never needs to leave your phone.&lt;/p&gt;

&lt;h1&gt;
  
  
  Breaking the Cloud Dependence
&lt;/h1&gt;

&lt;p&gt;The shift towards on-device AI processing creates what some experts are calling an "air gap" - a physical separation between your personal data and potential external threats. This approach significantly reduces the risk of data breaches and unauthorized access.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Future of Privacy-First AI
&lt;/h1&gt;

&lt;p&gt;As on-device AI capabilities continue to improve, we can expect to see a paradigm shift in how tech companies approach privacy. The ability to offer advanced AI features without compromising user data could become a key selling point for mobile devices and personal computing platforms.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;While the cloud has been the dominant paradigm for AI processing and data storage, on-device AI represents a promising path towards a more privacy-conscious future. As users become increasingly aware of the value and vulnerability of their personal data, solutions that offer both advanced AI capabilities and robust privacy protections will likely lead the way.&lt;br&gt;
The evolution of privacy in the age of AI personalization is not just about technological advancements; it's about putting control back into the hands of users. On-device AI might just be the key to unlocking a future where we can enjoy the benefits of AI without sacrificing our privacy.&lt;/p&gt;

</description>
      <category>security</category>
      <category>devops</category>
      <category>cloud</category>
      <category>ai</category>
    </item>
    <item>
      <title>What's Really Going on Behind the Scenes of Loading Bars? 🤔💡</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Sun, 14 Apr 2024 17:45:49 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/whats-really-going-on-behind-the-scenes-of-loading-bars-52kc</link>
      <guid>https://forem.com/ooye_sanket/whats-really-going-on-behind-the-scenes-of-loading-bars-52kc</guid>
      <description>&lt;p&gt;&lt;em&gt;We’ve all been there staring at a loading bar that seems to be stuck in place. But did you know that loading bars are secretly multitasking behind the scenes? Here's what's actually happening when they appear to be stuck.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Hidden Sub-processes 😲
&lt;/h3&gt;

&lt;p&gt;When the bar is halted, your system is busy managing a vertical subprocess—a side quest your main program has embarked on. It could be fetching data, compressing files, or performing complex calculations, all while you wait. So, when a game or application seems to freeze up, it might be juggling tasks rather than taking a break.&lt;/p&gt;

&lt;p&gt;A Twitter user(@ahieiei) delved into this mystery using a 3D analysis tool and discovered that when a loading bar stops moving, it's often handling an intense background task that requires a lot of computational power. This is why the pace can slow down dramatically during the second half of a video game or large application launch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5r4daf3jvgr9g0gqy2k4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5r4daf3jvgr9g0gqy2k4.png" alt="explaining the working of loading bars" width="563" height="413"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, what if we could make this experience a little more engaging? Imagine multi-dimensional loading bars that not only tell you how much progress has been made but also reveal what kind of work is being done behind the scenes. You might see tasks such as data retrieval, file management, and more, all visually represented on screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fochnpe1qygm6wvlzs87a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fochnpe1qygm6wvlzs87a.jpg" alt="explaining the working of loading bars" width="800" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As technology evolves, this kind of feature could become a standard, offering a peek into the secret life of loading bars. So next time you’re waiting, take comfort in knowing your system is busy at work, doing the heavy lifting so your experience can be smooth and enjoyable. Let’s look forward to a future where waiting on a loading bar is not just a pause, but an interactive insight into the process!What are your thoughts on the potential for more informative loading bars? Share your insights in the comments!!!!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>discuss</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Deja-Vu your AI✦ Bookmarking Tool</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Sun, 10 Mar 2024 16:49:05 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/deja-vu-your-ai-bookmarking-tool-41k9</link>
      <guid>https://forem.com/ooye_sanket/deja-vu-your-ai-bookmarking-tool-41k9</guid>
      <description>&lt;p&gt;&lt;strong&gt;An AI powered Chrome Extension which offers a seamless way to find bookmarks. by &lt;em&gt;@sanket-kalekar&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;1) Clone the installation repo locally by&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/ooye-sanket/Deja-Vu-Installation-Files.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnj113hvc298ctf97v1qf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnj113hvc298ctf97v1qf.png" alt="Image description" width="698" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OR&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Download the ZIP files&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;a href="https://github.com//ooye-sanket/Deja-Vu-Installation-Files" rel="noopener noreferrer"&gt; Deja-Vu-Installation-Files&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on "Code" &amp;gt; "Download ZIP"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unzip the file using any tool like &lt;a href="https://www.win-rar.com/start.html?&amp;amp;L=0" rel="noopener noreferrer"&gt;WinRAR&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rdcdgbqfncpxbjo5qro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rdcdgbqfncpxbjo5qro.png" alt="Image description" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Go to Chrome(or any Chromium-based browsers like Brave, Opera etc.) and click on the Kebab Menu on the top-right and go to &lt;code&gt;"Extensions"&lt;/code&gt; &amp;gt; &lt;code&gt;"Manage Extensions"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2v3fn5cydd3ahcf96thk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2v3fn5cydd3ahcf96thk.png" alt="Image description" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3) Switch &lt;strong&gt;ON&lt;/strong&gt; the Developer Mode at the top-right corner.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcgszmvajmikd2vei13iy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcgszmvajmikd2vei13iy.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4)  Click on &lt;code&gt;Load Unpack&lt;/code&gt; at the top-left corner&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fim86rcxl0dv2awx8uxqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fim86rcxl0dv2awx8uxqo.png" alt="Image description" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5) Choose the directory in which you cloned the repo-and click Open&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomtlabkjtmd7691gl2oi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomtlabkjtmd7691gl2oi.png" alt="Image description" width="628" height="33"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🎉 The extension has been installed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg2ppcrvnlswptmjizmm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvg2ppcrvnlswptmjizmm.png" alt="Image description" width="531" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Running the Project Locally
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo and enter the project directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   git clone https://github.com/ooye-sanket/deja-vu
   &lt;span class="nb"&gt;cd &lt;/span&gt;Deja-Vu
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install the necessary dependencies:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Build the project:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Add the extension to your browser. To do this, go to &lt;code&gt;chrome://extensions/&lt;/code&gt;, enable developer mode (top right), and click "Load unpacked". Select the &lt;code&gt;build&lt;/code&gt; directory from the dialog which appears and click "Select Folder".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;That's it! You should now be able to open the extenion's popup and use the model in your browser!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Development
&lt;/h3&gt;

&lt;p&gt;We recommend running &lt;code&gt;npm run dev&lt;/code&gt; while editing the project as it will rebuild the project when changes are made.&lt;/p&gt;

&lt;p&gt;All source code can be found in the &lt;code&gt;./src/&lt;/code&gt; directory but the &lt;code&gt;options&lt;/code&gt; (The page where you see all your bookmarks) will be found in &lt;code&gt;.public/options.*&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;background.js&lt;/code&gt; (&lt;a href="https://developer.chrome.com/docs/extensions/mv3/service_workers/" rel="noopener noreferrer"&gt;service worker&lt;/a&gt;) - handles all the requests from the UI, does processing in the background, then returns the result. You will need to reload the extension (by visiting &lt;code&gt;chrome://extensions/&lt;/code&gt; and clicking the refresh button) after editing this file for changes to be visible in the extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;popup.html&lt;/code&gt;, &lt;code&gt;popup.css&lt;/code&gt;, &lt;code&gt;popup.js&lt;/code&gt; (&lt;a href="https://developer.chrome.com/docs/extensions/reference/action/" rel="noopener noreferrer"&gt;toolbar action&lt;/a&gt;) - contains the code for the popup which is visible to the user when they click the extension's icon from the extensions bar. For development, we recommend opening the &lt;code&gt;popup.html&lt;/code&gt; file in its own tab by visiting &lt;code&gt;chrome-extension://&amp;lt;ext_id&amp;gt;/popup.html&lt;/code&gt; (remember to replace &lt;code&gt;&amp;lt;ext_id&amp;gt;&lt;/code&gt; with the extension's ID). You will need to refresh the page while you develop to see the changes you make.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Made possible by &lt;a href="https://github.com/xenova/transformers.js" rel="noopener noreferrer"&gt;Xenova&lt;/a&gt; and &lt;a href="https://huggingface.co/Supabase/gte-small" rel="noopener noreferrer"&gt;Supabase / gte-small&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This REAME.md file is very similary to &lt;a href="https://github.com/xenova/transformers.js/blob/main/examples/extension/README.md" rel="noopener noreferrer"&gt;Xenova Chrome Extension Template&lt;/a&gt; README.md file, since it was there Chrome extension template on which this project was built.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>extensions</category>
      <category>javascript</category>
      <category>chrome</category>
      <category>ai</category>
    </item>
    <item>
      <title>Mastering Node.js: From Fundamentals to Production-Ready Apps</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Fri, 05 Jan 2024 18:17:15 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/mastering-nodejs-from-fundamentals-to-production-ready-apps-1230</link>
      <guid>https://forem.com/ooye_sanket/mastering-nodejs-from-fundamentals-to-production-ready-apps-1230</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;A Comprehensive Guide to Building, Deploying, and Securing Node.js Applications&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.js has emerged as a powerful and versatile runtime environment for building server-side applications. Whether you're a beginner looking to learn the basics or an experienced developer aiming to deepen your Node.js expertise, this comprehensive guide is tailored to help you master Node.js. We'll cover everything from the fundamentals to advanced topics, complete with practical code examples.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. What is Node.js?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript on the server-side, opening up the possibility of building high-performance, scalable, and non-blocking applications. To get started, download and install Node.js from the official website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Setting Up Your Development Environment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before diving into code, set up your development environment. Use a code editor of your choice, such as Visual Studio Code, and initialize a new Node.js project using &lt;code&gt;npm init&lt;/code&gt;. This will create a &lt;code&gt;package.json&lt;/code&gt; file to manage your project's dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Basic Node.js Concepts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Understand the core concepts of Node.js, including the Event Loop, Non-blocking I/O, and the CommonJS module system. Explore the global objects like &lt;code&gt;process&lt;/code&gt; and &lt;code&gt;console&lt;/code&gt; and learn how to use them effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Asynchronous JavaScript and Callbacks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.js shines when dealing with asynchronous operations. Master the art of using callbacks to handle asynchronous tasks efficiently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');

fs.readFile('file.txt', 'utf8', (err, data) =&amp;gt; {
  if (err) {
    console.error(err);
    return;
  }
  console.log(data);
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Promises and Async/Await&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Upgrade your asynchronous code with Promises and the modern Async/Await syntax for better readability and maintainability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function readFileAsync(filename) {
  return new Promise((resolve, reject) =&amp;gt; {
    fs.readFile(filename, 'utf8', (err, data) =&amp;gt; {
      if (err) reject(err);
      else resolve(data);
    });
  });
}

async function main() {
  try {
    const data = await readFileAsync('file.txt');
    console.log(data);
  } catch (err) {
    console.error(err);
  }
}

main();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Modules and Dependency Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.js uses the CommonJS module system, which allows you to create reusable code modules and manage dependencies. Let's explore how to create and use modules:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Creating a Module (math.js)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// math.js
module.exports = {
  add: (a, b) =&amp;gt; a + b,
  subtract: (a, b) =&amp;gt; a - b,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using a Module (app.js)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const math = require('./math.js');

console.log(math.add(5, 3));      // Output: 8
console.log(math.subtract(10, 2)); // Output: 8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additionally, Node.js provides the npm (Node Package Manager) to manage external packages and libraries. You can initialize a project with npm init and install packages like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install package-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7. File System Operations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.js makes it easy to perform file system operations like reading, writing, and managing files and directories. Here's an example of reading and writing files:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Reading a File&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');

fs.readFile('file.txt', 'utf8', (err, data) =&amp;gt; {
  if (err) {
    console.error(err);
    return;
  }
  console.log(data);
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Writing to a File&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');

const content = 'Hello, Node.js!';
fs.writeFile('output.txt', content, (err) =&amp;gt; {
  if (err) {
    console.error(err);
    return;
  }
  console.log('File written successfully.');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next part, we'll dive into building a RESTful API with Express.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Building a RESTful API with Express.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Express.js is a popular Node.js web application framework that simplifies the process of building APIs and web applications. Here's a basic example of creating an API endpoint that returns JSON data:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Install Express&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create an Express App (app.js)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const app = express();
const port = 3000;

app.get('/api/hello', (req, res) =&amp;gt; {
  res.json({ message: 'Hello, Express!' });
});

app.listen(port, () =&amp;gt; {
  console.log(`Server is running on port ${port}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Start your Express app with:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visit&lt;code&gt;http://localhost:3000/api/hello&lt;/code&gt; in your browser to see the JSON response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Working with Databases (MongoDB)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Databases are a critical component of most applications, and Node.js makes it easy to interact with them. In this section, we'll focus on working with MongoDB, a popular NoSQL database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Installing MongoDB&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, make sure you have MongoDB installed on your machine. You can download it from the official website or use a cloud-hosted MongoDB service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Connecting to MongoDB&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To connect your Node.js application to MongoDB, you'll need to use a MongoDB driver. The most commonly used driver is &lt;code&gt;mongoose&lt;/code&gt;. Install it using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install mongoose

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's an example of how to connect to a MongoDB database using &lt;strong&gt;&lt;em&gt;mongoose&lt;/em&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/mydb', { useNewUrlParser: true, useUnifiedTopology: true });

const db = mongoose.connection;

db.on('error', (error) =&amp;gt; {
  console.error('Connection error:', error);
});

db.once('open', () =&amp;gt; {
  console.log('Connected to MongoDB');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Creating a Schema and Model&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In MongoDB, data is stored in collections. To interact with a collection, you'll need to define a schema and create a model. For example, let's create a model for a "User" collection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({
  name: String,
  email: String,
});

const User = mongoose.model('User', userSchema);

// Example of creating a new user
const newUser = new User({
  name: 'John Doe',
  email: 'john@example.com',
});

newUser.save((err) =&amp;gt; {
  if (err) {
    console.error(err);
  } else {
    console.log('User saved successfully');
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Querying and Updating Data&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can perform various operations on your MongoDB data, such as querying for specific documents or updating existing ones:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Querying for users with a specific name
User.find({ name: 'John Doe' }, (err, users) =&amp;gt; {
  if (err) {
    console.error(err);
  } else {
    console.log('Users with the name "John Doe":', users);
  }
});

// Updating a user's email
User.updateOne({ name: 'John Doe' }, { email: 'new.email@example.com' }, (err) =&amp;gt; {
  if (err) {
    console.error(err);
  } else {
    console.log('User email updated successfully');
  }
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This concludes our exploration of working with MongoDB in Node.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Authentication and Authorization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Securing your Node.js applications is crucial, especially when dealing with user data and sensitive information. In this section, we'll explore authentication and authorization techniques using popular libraries like passport and jsonwebtoken.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Installing Passport and JSON Web Tokens&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, install the necessary packages for authentication and authorization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install passport passport-local passport-jwt jsonwebtoken

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Setting Up Passport&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Passport is a popular authentication middleware for Node.js. Let's set up Passport with a local strategy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;

passport.use(new LocalStrategy(
  (username, password, done) =&amp;gt; {
    // Verify username and password here (e.g., check a database)
    if (username === 'user' &amp;amp;&amp;amp; password === 'password') {
      return done(null, { username });
    } else {
      return done(null, false);
    }
  }
));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Using Passport for Authentication&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, you can use Passport to protect your routes by requiring authentication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.post('/login', passport.authenticate('local', { session: false }), (req, res) =&amp;gt; {
  // If authentication succeeds, this function will be called
  const token = generateToken(req.user);
  res.json({ token });
});

// Example of a protected route
app.get('/profile', passport.authenticate('local', { session: false }), (req, res) =&amp;gt; {
  res.json({ message: 'This is a protected route', user: req.user });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;JSON Web Tokens (JWT) for Authorization&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JSON Web Tokens are a common method for handling user authorization. You can generate and verify JWTs using the &lt;code&gt;jsonwebtoken&lt;/code&gt; library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const jwt = require('jsonwebtoken');
const secretKey = 'your-secret-key';

function generateToken(user) {
  const payload = { sub: user.username };
  const options = { expiresIn: '1h' };
  return jwt.sign(payload, secretKey, options);
}

// Verifying and decoding a JWT
function verifyToken(token) {
  try {
    const decoded = jwt.verify(token, secretKey);
    return decoded;
  } catch (error) {
    return null; // Token is invalid
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using JWT for Authorization&lt;/strong&gt;&lt;br&gt;
You can use JWTs to protect routes and verify user identity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get('/api/private', (req, res) =&amp;gt; {
  const token = req.headers.authorization;

  if (!token) {
    return res.status(401).json({ message: 'Unauthorized' });
  }

  const decoded = verifyToken(token);

  if (!decoded) {
    return res.status(401).json({ message: 'Invalid token' });
  }

  // Token is valid, proceed with the request
  res.json({ message: 'This is a protected route', user: decoded.sub });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this part, we've covered the basics of authentication and authorization using Passport and JWTs. In the next section, we'll explore error handling and logging techniques in Node.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. Error Handling and Logging&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Error handling and logging are crucial aspects of Node.js development. Proper error handling ensures that your application gracefully handles unexpected issues, and effective logging helps in debugging and monitoring. In this section, we'll cover these essential topics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Error Handling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Node.js provides several mechanisms for error handling:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Try...Catch&lt;/em&gt;&lt;/strong&gt;: Use try...catch blocks to catch synchronous errors within a function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
  // Code that may throw an error
} catch (error) {
  // Handle the error
  console.error(error);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Error Events:&lt;/strong&gt; For handling asynchronous errors, Node.js emits 'error' events on various objects (e.g., EventEmitter, HTTP server).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');

const stream = fs.createReadStream('nonexistent.txt');

stream.on('error', (err) =&amp;gt; {
  console.error('Error reading file:', err);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Custom Error Handling Middleware:&lt;/strong&gt; In Express.js, you can create custom error-handling middleware to handle errors that occur during request processing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.use((err, req, res, next) =&amp;gt; {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Logging&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logging is essential for monitoring and debugging your Node.js applications. Popular logging libraries include Winston and Morgan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Install Winston and Morgan&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install winston morgan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Setting Up Winston for Logging&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const winston = require('winston');

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.simple(),
  transports: [
    new winston.transports.Console(),
    new winston.transports.File({ filename: 'error.log', level: 'error' }),
    new winston.transports.File({ filename: 'combined.log' }),
  ],
});

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using Morgan for HTTP Request Logging&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Morgan is a middleware for logging HTTP requests in Express.js applications:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const morgan = require('morgan');
const app = express();

app.use(morgan('combined')); // Logs all requests

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Logging with Winston&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use Winston for custom application logging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logger.log('info', 'This is an informational message.');
logger.error('This is an error message.');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Centralized Error Handling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For better error management, consider centralizing error handling and logging in your application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function handleError(err, req, res, next) {
  // Log the error
  logger.error(err.stack);

  // Respond to the client
  res.status(500).json({ error: 'Internal Server Error' });
}

// Attach the error handler to your Express app
app.use(handleError);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this section, we've explored error handling and logging techniques, which are essential for building robust and maintainable Node.js applications. In the next part, we'll dive into real-time applications using &lt;code&gt;Socket.IO&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. Real-Time Applications with Socket.IO&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Building real-time applications, such as chat applications or live updates, is a common use case for Node.js. In this section, we'll explore how to create real-time functionality using Socket.IO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Installing Socket.IO&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, install the Socket.IO library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install socket.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;2. Setting Up Socket.IO&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a Socket.IO server and attach it to your Express.js application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require('express');
const http = require('http');
const socketIo = require('socket.io');

const app = express();
const server = http.createServer(app);
const io = socketIo(server);

// Handle socket connections
io.on('connection', (socket) =&amp;gt; {
  console.log('A user connected');

  // Handle events from clients
  socket.on('chat message', (message) =&amp;gt; {
    console.log('Message received:', message);

    // Broadcast the message to all connected clients
    io.emit('chat message', message);
  });

  // Handle disconnections
  socket.on('disconnect', () =&amp;gt; {
    console.log('A user disconnected');
  });
});

// Serve your Express app as usual
app.get('/', (req, res) =&amp;gt; {
  res.sendFile(__dirname + '/index.html');
});

server.listen(3000, () =&amp;gt; {
  console.log('Server is running on port 3000');
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;3. Creating a Simple Chat Interface (index.html)&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Socket.IO Chat&amp;lt;/title&amp;gt;
  &amp;lt;script src="/socket.io/socket.io.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;script src="https://code.jquery.com/jquery-3.6.0.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;ul id="messages"&amp;gt;&amp;lt;/ul&amp;gt;
  &amp;lt;input id="messageInput" autocomplete="off" /&amp;gt;&amp;lt;button id="sendButton"&amp;gt;Send&amp;lt;/button&amp;gt;
  &amp;lt;script&amp;gt;
    const socket = io();

    $('#sendButton').click(() =&amp;gt; {
      const message = $('#messageInput').val();
      socket.emit('chat message', message);
      $('#messageInput').val('');
    });

    socket.on('chat message', (message) =&amp;gt; {
      $('#messages').append($('&amp;lt;li&amp;gt;').text(message));
    });
  &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code sets up a basic chat application using Socket.IO. Users can enter messages, which are then broadcasted to all connected clients in real-time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. Testing Node.js Applications&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testing is an integral part of software development, ensuring that your Node.js applications work as expected and remain reliable over time. In this section, we'll cover testing techniques and libraries commonly used in the Node.js ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Setting Up Testing Frameworks&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To get started with testing Node.js applications, you'll need testing libraries and tools. Popular choices include Mocha for test framework, Chai for assertions, and Supertest for HTTP testing. Install them using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install mocha chai supertest --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Writing Tests&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a test directory in your project and start writing test files. For example, if you're testing an Express.js API, you might create a file named api.test.js. Here's a simple test for an Express route:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const request = require('supertest');
const app = require('../app'); // Your Express app

describe('GET /api/hello', () =&amp;gt; {
  it('responds with JSON', (done) =&amp;gt; {
    request(app)
      .get('/api/hello')
      .set('Accept', 'application/json')
      .expect('Content-Type', /json/)
      .expect(200)
      .end((err, res) =&amp;gt; {
        if (err) return done(err);
        done();
      });
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;3. Running Tests&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use a test runner like Mocha to execute your tests. In your package.json file, configure a test script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "test": "mocha"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can run your tests with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm test

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Deployment and Scaling Node.js Applications
Deployment and scaling are crucial steps in making your Node.js application accessible to users and ensuring it can handle increased load as your user base grows. In this section, we'll cover deployment options and scaling strategies for Node.js applications.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. Deployment Options&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are various ways to deploy Node.js applications, depending on your project's requirements. Here are some common options:&lt;/p&gt;

&lt;p&gt;a. Self-Managed Servers: You can deploy your Node.js application on self-managed virtual private servers (VPS) or dedicated servers. Popular choices include providers like DigitalOcean, AWS EC2, and Linode. This option offers maximum control but requires server management skills.&lt;/p&gt;

&lt;p&gt;b. Platform as a Service (PaaS): PaaS providers like Heroku, Google App Engine, and Microsoft Azure App Service abstract server management, allowing you to focus on your application's code. Heroku, in particular, is known for its ease of use with Node.js applications.&lt;/p&gt;

&lt;p&gt;c. Containerization: Use containerization platforms like Docker and container orchestration tools like Kubernetes to package your Node.js application into containers. This approach provides portability and scalability.&lt;/p&gt;

&lt;p&gt;d. Serverless: Consider serverless platforms like AWS Lambda, Azure Functions, or Google Cloud Functions. Serverless enables you to run code in response to events without managing servers. It's suitable for functions or microservices that require scalability on-demand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Preparing for Deployment&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before deploying your Node.js application, make sure you:&lt;/p&gt;

&lt;p&gt;Configure environment variables for sensitive data like API keys and database credentials.&lt;/p&gt;

&lt;p&gt;Optimize your application for production by setting appropriate Node.js environment variables (e.g., NODE_ENV=production).&lt;/p&gt;

&lt;p&gt;Set up a process manager like PM2 to keep your application running and handle restarts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Database Considerations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your application uses a database, consider these database scaling strategies:&lt;/p&gt;

&lt;p&gt;Vertical Scaling: Increase the resources (CPU, RAM) of your database server to handle increased load.&lt;/p&gt;

&lt;p&gt;Horizontal Scaling: Distribute your database across multiple servers using sharding or replication.&lt;/p&gt;

&lt;p&gt;Use managed database services like AWS RDS, Google Cloud SQL, or MongoDB Atlas for automatic scaling and maintenance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Load Balancing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For high availability and scalability, use load balancers like Nginx or HAProxy to distribute incoming traffic among multiple instances of your Node.js application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Monitoring and Scaling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implement monitoring and alerting using tools like New Relic, Datadog, or Prometheus. Monitor key metrics like CPU usage, memory consumption, and request latency. Set up autoscaling policies to automatically adjust the number of application instances based on traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Caching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implement caching mechanisms to reduce the load on your application servers. Tools like Redis or Memcached can cache frequently accessed data and improve response times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Content Delivery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Leverage Content Delivery Networks (CDNs) like Cloudflare or Amazon CloudFront to cache and deliver static assets, reducing the load on your server and improving user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pay special attention to security when deploying in production. Use HTTPS, implement security headers, and regularly update dependencies to patch vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Continuous Integration and Deployment (CI/CD)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Set up a CI/CD pipeline to automate the deployment process. Tools like Jenkins, CircleCI, or GitHub Actions can help automate testing, building, and deploying your Node.js application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Disaster Recovery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Plan for disaster recovery by creating regular backups of your data and having a plan in place to restore services in case of unexpected outages.&lt;/p&gt;

&lt;p&gt;In this section, we've covered deployment and scaling strategies for Node.js applications. Successfully deploying and scaling your application ensures it can handle traffic and provides a reliable experience for your users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. Best Practices and Security Considerations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you continue to develop and maintain your Node.js applications, it's essential to follow best practices and pay close attention to security. In this final section, we'll explore key best practices and security considerations for Node.js development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;1. Keep Dependencies Up to Date&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Regularly update your project's dependencies to benefit from bug fixes, performance improvements, and security patches. Use tools like npm audit to check for known vulnerabilities in your project's dependencies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm audit
npm update

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;2. Implement Input Validation&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Always validate user inputs to prevent security vulnerabilities like SQL injection, XSS attacks, and more. Use libraries like express-validator to sanitize and validate incoming data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { body, validationResult } = require('express-validator');

app.post(
  '/login',
  [
    body('username').isEmail(),
    body('password').isLength({ min: 8 }),
  ],
  (req, res) =&amp;gt; {
    const errors = validationResult(req);
    if (!errors.isEmpty()) {
      return res.status(422).json({ errors: errors.array() });
    }
    // Proceed with authentication
  }
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;3. Enable CORS Safely&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If your application serves content to different domains, configure Cross-Origin Resource Sharing (CORS) to control which domains are allowed to access your resources. Be cautious not to allow overly permissive CORS settings.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;4. Set Secure HTTP Headers&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Use HTTP security headers like Content Security Policy (CSP), Strict-Transport-Security (HSTS), and X-Content-Type-Options to enhance your application's security posture.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;5. Authentication and Authorization&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Implement secure authentication mechanisms and proper authorization controls. Store user passwords securely using bcrypt or argon2 and use JSON Web Tokens (JWT) or OAuth for token-based authentication.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;6. Protect Against Common Attacks&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Be aware of and protect against common web application attacks such as Cross-Site Scripting (XSS), Cross-Site Request Forgery (CSRF), and security misconfigurations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;7. Rate Limiting and DDoS Protection&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Implement rate limiting to prevent abuse of your APIs and consider DDoS protection services to mitigate distributed denial-of-service attacks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;8. Logging and Monitoring&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Continuously monitor your application for unusual activities and security incidents. Implement robust logging and log analysis to identify and respond to potential threats.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;9. Container Security&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you use containerization, ensure your Docker images are built securely, and follow container best practices. Regularly scan container images for vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;10. Security Headers and Middleware&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Use security-focused middleware like helmet to automatically set security headers in your Express.js application. Install it using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install helmet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const helmet = require('helmet');
app.use(helmet());

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;11. Keep Secrets Secure&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Never store sensitive information like API keys, database credentials, or private keys in your codebase. Use environment variables or secret management tools to securely store and manage secrets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;12. Security Audits&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consider conducting security audits and penetration testing of your application to identify vulnerabilities and weaknesses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;13. Regularly Back Up Data&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create automated backups of your data and ensure that you can restore your application and data in case of data loss or security incidents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;14. Compliance with Regulations&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your application deals with user data, ensure compliance with data protection regulations like GDPR, HIPAA, or CCPA.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;15. Education and Training&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Keep your development team updated on security best practices and provide security training to help them understand and mitigate risks.&lt;/p&gt;

&lt;p&gt;By following these best practices and security considerations, you can significantly improve the security and reliability of your Node.js applications, protecting both your users and your reputation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this comprehensive guide to Node.js development, we've embarked on a journey from the fundamentals to advanced topics, exploring every aspect of building, deploying, and securing Node.js applications. Whether you're a beginner taking your first steps in Node.js or an experienced developer looking to refine your skills, we've covered a breadth of knowledge to help you succeed.&lt;/p&gt;

&lt;p&gt;We began by understanding what Node.js is and how to set up your development environment. We then delved into essential Node.js concepts, asynchronous programming, and modules. Along the way, we explored file system operations, building RESTful APIs with Express.js, working with databases using MongoDB, and implementing authentication and authorization for your applications.&lt;/p&gt;

&lt;p&gt;We continued by discussing error handling, logging, and real-time application development using Socket.IO. Testing Node.js applications became second nature, as we explored various testing techniques and tools, including Mocha, Chai, and Supertest. We also touched upon deployment options, scaling strategies, and best practices to ensure your applications are performant, secure, and highly available.&lt;/p&gt;

&lt;p&gt;Lastly, we emphasized the significance of security in your Node.js applications, covering input validation, CORS, secure HTTP headers, authentication and authorization, protection against common attacks, and more. We discussed container security, rate limiting, and logging for monitoring and security incident response.&lt;/p&gt;

&lt;p&gt;As you embark on your Node.js development journey, remember that continuous learning and staying up-to-date with the rapidly evolving landscape of web development are key. Node.js offers a versatile platform to build a wide range of applications, from simple scripts to complex, real-time systems.&lt;/p&gt;

&lt;p&gt;We hope this guide has been a valuable resource in your Node.js endeavors. Whether you're crafting a personal project, a startup application, or contributing to the development of large-scale applications, Node.js offers the tools and flexibility to bring your ideas to life.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>backend</category>
    </item>
    <item>
      <title>Setting up Amazon Q in VSCode using IAM Identity Centre</title>
      <dc:creator>Sanket Kalekar</dc:creator>
      <pubDate>Tue, 12 Dec 2023 12:02:28 +0000</pubDate>
      <link>https://forem.com/ooye_sanket/setting-up-amazon-q-in-vscode-using-iam-identity-centre-4p71</link>
      <guid>https://forem.com/ooye_sanket/setting-up-amazon-q-in-vscode-using-iam-identity-centre-4p71</guid>
      <description>&lt;p&gt;&lt;strong&gt;Setting up Amazon Q in VSCode using IAM Identity Centre&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At re:Invent, AWS announced a suite of amazing generative AI–powered assistants, including one that compliments Amazon CodeWhisperer and provides a conversational assistant to help you develop, test, document, and many more developer related activities. All good. I am having curiosity to use these kinds of developer productivity tools, so was eager to try this out on my VSCode setup. One of the youtuber &lt;a href="https://youtu.be/HBsWGltsRaU?feature=shared" rel="noopener noreferrer"&gt;Denis&lt;/a&gt; put together a quick start video on how you can "get started with Amazon Q in VSCode in three easy steps", using the Builder ID which allows you to try this without the need for having or setting up an AWS Account. A really great and risk free way of checking out how Amazon Q can help you.&lt;/p&gt;

&lt;p&gt;Now whilst using your Builder ID is a great way to get started, you will not have access to some of the more advanced capabilities of Amazon Q, specifically Amazon Q feature development (which is invoked using /dev) and the Code Transformation feature (accessed from within Q via /transform). For that you will need to switch to the Amazon CodeWhisperer Professional Tier, and that is what this post is about. It will walk you through how to set this up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note!&lt;/strong&gt; Throughout this post I will talk about enabling and removing access to Amazon Q. This is only in the context of the Amazon CodeWhisperer Professional Tier. Developers can still enjoy free access to the basic features of Amazon Q by using their Builder ID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-reqs&lt;/strong&gt;&lt;br&gt;
Before proceeding, I make the following assumptions to what you have and what you will need.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An AWS Account with Administrator priviledges&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An AWS Account that is integrated with IAM Identity Centre - in my specific setup, I am using Keycloak as my Identity Provider (Idp)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A version of the AWS Toolkit for VSCode that supports the new Amazon Q features (I am using version v2.0.0)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VSCode (I am runing version 1.84.2 on my windows)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Important!!&lt;/strong&gt; You should be aware that following the steps in this blog post, for every user that you enable via IAM Identity Centre, you will incur charges to your AWS bill. If you are just testing this out, make sure you remove those users via the Amazon CodeWhisperer console at the end to reduce the cost.&lt;/p&gt;

&lt;p&gt;Assuming this is all good, lets get started.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;br&gt;
Before diving into how to set this up, it is worth understanding at a high level what you need to do. The documentation provides a good overview in these steps, covering how to manage access of Amazon Q within your AWS accounts. The first thing to take note of is that you configure Amazon Q using the Amazon CodeWhisperer console, so you will see the two names used interchangerbly in this post.&lt;/p&gt;

&lt;p&gt;Amazon CodeWhisperer has the concept of an administrator, who are able to determine who can and cannot access Amazon CodeWhisperer. This can be setup in single or more complex AWS account setups, including where you are using AWS Organisations. In this post I am going to be using a single AWS account that has been setup to use single sign on with IAM Identity Centre, and define a single user that I want to give access to Amazon Q.&lt;/p&gt;

&lt;p&gt;The approach is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a new Permissions set in IAM Identity Centre for my Amazon Q / Amazon CodeWhisperer "admins"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create two new groups - one for Amazon Q users, and another for Amazon Q admins (the folk who can add/remove access to Amazon Q)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a user into the Amazon Q users group (from the list of users managed by IAM Identity Centre), and add a user into the Amazon Q Admins group&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure an AWS account (in this case, my single account) to use these Groups, assigning Permission sets to both (For Amazon Q Users I will add ReadOnly access, for Amazon Q Admins, I will add the new Permissions set created for Amazon Q / CodeWhisperer&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From the Amazon CodeWhisperer console, now assign who I want to give access to (in this case, the Amazon Q Users group)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try and login to Amazon Q from VSCode&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1 - Create a new Permissions Set and Group within IAM Identity Centre&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first stage is to set up our Admins and Users groups to simplify how we administer access to Amazon Q. To help us we have the very helpful documentation guide, and the page we are specifically interested in is Setting up CodeWhisperer Professional with IAM Identity Center.&lt;/p&gt;

&lt;p&gt;We need to create a new Permissions set that we can delegate Amazon Q administrators, and who will have access to add/remove users from the Amazon CodeWhisperer console. We follow the instructions on that page to create the new Permissions set, which in this guide is called "CodeWhisperer_administrator".&lt;/p&gt;

&lt;p&gt;Once you have done that, we will create two groups, Amazon-Q-Admins, and Amazon-Q-Users. Click on Groups on the left hand side and then Create Groups, creating your group and assigning any users at the same time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxo14rh1s1nsjhnz1jtr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxo14rh1s1nsjhnz1jtr.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our Groups setup, we can assign these groups together with Permissions sets to our AWS Account. For the Amazon-Q-Users, we will assign the ReadOnlyAccess permissions set (you can use what ever permissions set you typically set up), and for the Amazon-Q-Admins, we assign the CodeWhisperer_administrator group.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fugm9e6lop1sd83et7xxd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fugm9e6lop1sd83et7xxd.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is it for this step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 - Enable Amazon Q within the Console&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From our AWS Account, we now need to enable (or remove) access to Amazon Q for our developers (in this case, those in the Amazon-Q-Users group). We head over to the Amazon CodeWhisperer console, and click on the Settings menu option on the left.&lt;/p&gt;

&lt;p&gt;To add users it is as simple as clicking on the Add Groups button, and then selecting the group we setup in the previous step (Amazon-Q-Users).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwn7nbajqugs96cfvspxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwn7nbajqugs96cfvspxy.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is it, we now have our user (we only defined a single one in this example) enabled for the use of Amazon Q.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 - Authenticate and use Amazon Q&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We are now ready to try this out and log in from our VSCode.&lt;/p&gt;

&lt;p&gt;From the AWS Toolkit icon in VSCode, you will see anumber of twisties/sections. One of these will be called "AMAZON Q (PREVIEW)" so click on that to reveal the "SIGN IN TO GET STARTED" link. This will reveal the "Sign in to Get Started" page, and the first panel will be "Amazon Q + CodeWhisperer" like the following screen.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwg1fz7p7854szgvoyaan.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwg1fz7p7854szgvoyaan.png" alt="Image description" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From here, you want to use the "Sign in with Identity Centre (SSO)" link, and then in the dialog that pops up, enter your SSO Url and the AWS region where you have your AWS SSO configured. In my case, I have configured AWS Identity Centre SSO in eu-west-1, so this is what I configure, and then add my SSO link. You will then need to follow a number of steps as outlined in the following screenshot. Between steps 2 and 3 you will probably be asked to log in to your identity provider (I was, but if you are already logged in then you might not have to do this).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1s13du0d3ahqfk4t40kc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1s13du0d3ahqfk4t40kc.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If everything from Steps 1 and 2 was setup correctly, then you should now be logged in, and you can now click on the Amazon Q chat icon in VSCode, hit "/" and see /dev and /transform options available to you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overview of the steps&lt;/strong&gt;&lt;br&gt;
If everything from Steps 1 and 2 was setup correctly, then you should now be logged in, and you can now click on the Amazon Q chat icon in VSCode, hit "/" and see /dev and /transform options available to you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this short post I showed you how you can set up users to use the advanced features of Amazon Q, by setting them up on the Amazon CodeWhisperer Professional Tier. If you followed along just to try this out, remember to remove any users to avoid additional charges on your AWS bill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Troubleshooting&lt;/strong&gt;&lt;br&gt;
As with all blog posts, what you see is the nice shiny, working stuff. But behind all of that, is typically head scratching errors and problems that come along. So here I want to share some of the things I found that took me a while to figure out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuring Amazon Q access&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you see the following error in the AWS Toolkit logs, then the most likely reason is that you have either not configured the right users/groups within the Amazon CodeWhisperer console settings, or you have not set up the permissions within IAM Identity Centre appropriately.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2023-11-30 12:37:39 [ERROR]: API response (oidc.eu-west-1.amazonaws.com /token): {
  name: 'AccessDeniedException',
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'f60ba750-xxxx-4axx-xx30-xxxxb0ecf504',
    extendedRequestId: undefined,
    cfId: undefined
  },
  error: 'access_denied',
  error_description: 'Access denied',
  message: 'UnknownError'
}
2023-11-30 12:37:39 [ERROR]: webviewId="authWebview": Error: Webview error
     -&amp;gt; Error: Webview backend command failed: "startCWIdentityCenterSetup()"
     -&amp;gt; Error: Failed to connect to IAM Identity Center [FailedToConnect]
     -&amp;gt; AccessDeniedException: UnknownError

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;InvalidGrantException&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
The main error I came across when putting this post together was that every time I went to authenticate, I would get an error within VSCode that looked like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbhel2jc0zvutx03kqz9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbhel2jc0zvutx03kqz9y.png" alt="Image description" width="800" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not particularly helpful, but looking at CloudWatch Trail and setting the AWS Toolkit for VSCode logging to DEBUG, provided me with some clues as to where the problems lied.&lt;/p&gt;

&lt;p&gt;The error within VSCode showed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2023-11-30 09:24:10 [ERROR]: API response (oidc.eu-west-1.amazonaws.com /token): {
  name: 'InvalidGrantException',
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'xxxxxxxxx',
    extendedRequestId: undefined,
    cfId: undefined
  },
  error: 'invalid_grant',
  error_description: 'Invalid grant provided',
  message: 'UnknownError'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And within CloudTrail I could see events failing with the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;..

    "eventVersion": "1.09",
    "userIdentity": {
        "type": "Unknown",
        "principalId": "xxxxx",
        "accountId": "xxxxxx",
        "userName": "Ricardo Sueiras AWS"
    },
    "eventTime": "2023-11-29T18:43:47Z",
    "eventSource": "sso.amazonaws.com",
    "eventName": "CreateToken",
    "awsRegion": "eu-west-1",
    "sourceIPAddress": "xx.67.127.xx",
    "userAgent": "aws-sdk-js/3.345.0 ua/2.0 os/darwin#22.6.0 lang/js md/nodejs#18.15.0 api/sso-oidc#3.345.0",
    "errorCode": "InvalidGrantException",
    "requestParameters": {
        "clientId": "xxxx",
        "clientSecret": "HIDDEN_DUE_TO_SECURITY_REASONS",
        "grantType": "urn:ietf:params:oauth:grant-type:device_code",
        "deviceCode": "xxxxx",
        "platformSessionExpiryRequired": false
   ..
   ..
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It turned out that something had got messed up in my local ~/.aws/sso directory, and the fix was pretty simple. I just deleted this directory, and then I was able to resolve the issues. Why did I do this? When exploring the logs output by the toolkit, I saw occasionaly the following lines&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2023-11-30 10:19:54 [DEBUG]: SSO token cache: read failed (file not found) key: https://xxxxx-uk.awsapps.com/start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and other related messages. Sometimes you have to play a hunch, and given that these are just cached files that I could regenerated, it seemed like a simple thing to try.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
