<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aditya Sharma on Medium]]></title>
        <description><![CDATA[Stories by Aditya Sharma on Medium]]></description>
        <link>https://medium.com/@sharmaadityahq?source=rss-ee110c5b3676------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Yg5zvTcCUnQaeLpxRqj3Uw.jpeg</url>
            <title>Stories by Aditya Sharma on Medium</title>
            <link>https://medium.com/@sharmaadityahq?source=rss-ee110c5b3676------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:20:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sharmaadityahq/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Demystifying web browser extensions]]></title>
            <link>https://sharmaadityahq.medium.com/demystifying-web-browser-extensions-531d7091fbbc?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/531d7091fbbc</guid>
            <category><![CDATA[browser-extension]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 00:17:54 GMT</pubDate>
            <atom:updated>2024-09-26T06:47:23.687Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ClGJEdbb8OdWXFhseb238w.png" /></figure><p>understanding working of browser extensions, anatomy, capabilities, UI options, common development challenges, and effective solutions</p><h3>introduction</h3><p>the world of browser extensions is quite different from normal web applications. an extension can take advantage of the same web APIs as JS on a web page but also has access to its own set of JS APIs. this means you can do a lot more in an extension than you can with code in a web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*FyOrj4QtCpri06GhkAMlvg.png" /></figure><p>in this blog, i’ll share my learnings from developing my first extension at work (a tool that helps customer support agents resolve customer issues quickly and efficiently) and help you get up to speed on building your extension.</p><p>let’s begin by addressing the question below.</p><h3>how do extensions fit into the browser architecture?</h3><p>let&#39;s take a step back and understand the workings of a modern web browser.</p><p>when you start an application, a process is created. the OS gives the process a private memory space to work with. when you close the application the process also goes away and the OS frees up the memory. a process can ask the OS to start another process to run different tasks. different parts of the memory are allocated to the new process and the two processes can communicate using Inter Process Communication (IPC).</p><p>a web browser could have one process with many different threads or many different processes with a few threads communicating over IPC. there is no standard specification on how one might build a web browser. in this blog, we’ll refer to chrome’s multi-process architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*4TTsSY9un7TjEGZ_9EFghw.png" /><figcaption>source: chrome documentation</figcaption></figure><p>each process controls different things. the multi-process architecture helps ensure stability and security. the OS provides a way to restrict the privileges of a process so the browser can sandbox certain processes from certain features.</p><p>you can see how many processes are running in your browser by clicking on the top right menu icon → more tools → task manager.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*vTn2LXr3ooGBCd12uQ_CNg.png" /></figure><p>extensions interact with many of the browsers sub-systems via the web extension APIs. eg. tabs, history, bookmarks, downloads. however, these data structures exist in another process so it is impossible to keep a perfectly consistent view of the world in the extension process.</p><p>this is addressed by:-</p><ol><li>modelling extension APIs as stateless asynchronous service calls. eg. browser.tabs.query to get all tabs with the specified properties.</li></ol><p><strong>why?</strong></p><ul><li>the browser doesn’t have to send copies of browser state to any extension process until it is requested.</li><li>browser doesn’t need to have complex machinery to keep multiple copies of browser state synchronized across processes.</li></ul><p>2. event based mechanism to register and get notified when something happens. eg. browser.tabs.onActivated event fires when the active tab in a window changes.</p><h3>what is the structure of an extension?</h3><p>an extension consists of a collection of files, packaged for installation and distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*Y14UtylFdsKdcUSFAwkr6g.png" /></figure><p>you can clone my <a href="https://github.com/sharmaadityaHQ/web-extension-starter">web-extension-starter</a> repo from github to follow along.</p><ul><li><strong>manifest.json</strong> — this file <strong>must be present</strong> in every extension. it contains name, version, extension permissions, pointers to different types of files.</li><li><strong>background script</strong> — a script that responds to browser events. eg. closing a tab, removing a bookmark. you can use any web extension APIs here as long as your extension has the necessary permissions.</li><li><strong>content script</strong> — JS included with the extension that is injected into web pages. these scripts can read and modify the content of their pages using the standard web APIs. you can only access a <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#webextension_apis">subset of the web extension APIs</a> in content scripts. however, you can communicate with background scripts using a messaging system and indirectly access all web extension APIs.</li><li><strong>sidebar, popup or option page</strong> — your extension can also have HTML documents that provide content for different types of UI components.</li></ul><p>you can communicate b/w your content script and background script by sending a single message with an optional response or you can setup a longer lived connection between the two sides to exchange messages. you can refer API usage <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#communicating_with_background_scripts">here</a>.</p><h3>what are the UI options for an extension?</h3><p>extensions have several UI options to present their functionality to a user. you can decide basis your use case and the type of experience you want to deliver to your users.</p><p>i have made a <a href="https://github.com/sharmaadityaHQ/web-extension-starter">web-extension-starter</a> to demonstrate different UI options and help you get up to speed on building your extension.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FC06jI5P9MVU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DC06jI5P9MVU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FC06jI5P9MVU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/92cde73ffa62f5774538c26c87dad8c4/href">https://medium.com/media/92cde73ffa62f5774538c26c87dad8c4/href</a></iframe><p>as you can see in the above video, you can make popups, sidebars, custom apps, developer tools via browser extensions. apart from this, there are a couple more UI options like options, extension pages. you can read more about them <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/user_interface/Extension_pages">here</a>.</p><h3>what challenges i faced while building my extension?</h3><p>i faced multiple challenges while building my first cross-browser extension:-</p><ul><li>there are 2 API namespaces in use among the main browsers — browser.* and chrome.* . this can be solved by using the <a href="https://github.com/mozilla/webextension-polyfill">webextension-polyfill</a>. also, the polyfill will allow you to use promises for handling asynchronous events and avoid callbacks.</li><li>handling API differences across browsers can be tricky. you can use runtime checks on the availability of a function’s features or provide fallback functionality to handle this.</li><li>there can be differences in the manifest.json keys supported by different browsers. eg. i faced issues with the background script as chrome replaced background scripts with extension service workers in manifest v3. the best way to address this is by referring to extension docs of multiple browsers and find a solution that works for all.</li><li>i faced issues while doing API calls from my extension to fetch data. this was because i was initially using manifest v2 and later updated to manifest v3 as i read that manifest v2 is about to be deprecated. in manifest v3, content scripts lose the ability to fetch cross-origin data from origins in their extension’s permissions. i had to move all my API calls to the background script. you can send messages from content scripts to your extension’s background pages, which can relay data via extension messaging APIs. you can read more about this restriction <a href="https://www.chromium.org/Home/chromium-security/extension-content-script-fetches">here</a>.</li><li>i was using the frequently used axios library for API calls which did not work in chrome. you can refer the adapter related issue <a href="https://github.com/axios/axios/issues/4458">here</a>. this was solved by using the fetch API and <a href="https://www.npmjs.com/package/fetch-intercept">fetch-intercept</a> library to add response interceptors and handle 401 scenario.</li><li>i faced an issue with API calls giving 401 unauthorized because of the extension origin not being supported by my server. i solved this by using the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/declarative_net_request">declarative_net_request</a> capability to modify the value of the origin header before the request is sent to the server.</li><li>i was using firebase for a real-time communication use case in my extension but firebase did not work in firefox. you can refer issue details <a href="https://github.com/firebase/firebase-js-sdk/issues/4002">here</a>. as this is still an open issue in the firebase library there is no solution for this yet. luckily, this was not a deal breaker for me as most of my users are on chrome.</li><li>i was usingstyled-components in my extension and encountered an issue in firefox. you can refer issue details <a href="https://github.com/styled-components/styled-components/issues/3695">here</a>. the only solution was to downgrade styled-components to v5.3.0 and use it with react v17. i skipped this as anyways my main use case of real-time communication was not working in firefox.</li></ul><p>i hope these challenges raise your awareness and help you build your first extension faster.</p><h3>wrap up</h3><p>in this blog, we covered how extensions fit into the browser architecture, the structure of a web extension, roles of different parts like content script, background script etc. we saw multiple UI options available to build extensions basis use case and different types of challenges you might face while building your first extension.</p><p>you can refer the <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions">MDN docs for extensions</a> for further study of specific concepts or API usage. knowledge knows no bounds.</p><p>thank you for taking the time to read my blog to this point. if you have any questions or suggestions, i’d love to hear from you <a href="https://x.com/sharmaadityaHQ">@sharmaadityaHQ</a> on twitter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=531d7091fbbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ramping up on the AWS Amplify CLI code base]]></title>
            <link>https://sharmaadityahq.medium.com/ramping-up-on-the-aws-amplify-cli-code-base-e361db1e0b5b?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/e361db1e0b5b</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[amplify]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Fri, 23 Apr 2021 15:05:12 GMT</pubDate>
            <atom:updated>2021-04-24T08:20:28.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*9c62eLh2UvHHDgI0.jpg" /></figure><h3>Introduction</h3><p>Decoding magic can be hard but not impossible. Take a deep breath before I start with a nice overview of the Amplify CLI and its source code. Be patient as I unfold the mysteries behind this large code base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ypc85Evj8e8ZgrbivSeNEw.gif" /></figure><p>Amplify framework provides multiple products to build full stack iOS, Android, Flutter, Web, and React Native apps. Amplify CLI helps you to configure all the services needed to power your backend through a simple command line interface. Amplify CLI depends on various Amazon Web Services like AppSync for data modelling and GraphQL API’s, CloudFormation templates for Infrastructure as Code and creating replicable stacks and a lot more to provide functionalities like authentication, storage, hosting, functions and REST API’s.</p><h3>Amplify CLI Architecture</h3><p>Now you know why everyone was talking about <a href="https://twitter.com/AWSAmplify">Amplify on Twitter</a>. Lets jump to the real part and try to understand how this beast framework works under the hood.</p><p>The source code can be overwhelming at first. It is a monorepo, a multi package repository written in TypeScript and JavaScript and managed by <a href="https://github.com/lerna/lerna">Lerna</a>. A monorepo makes it easier to share and refactor code. I assume that you are ready to dive deep with an instance of amplify-dev running on your system after following the <a href="https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#local-environment-setup">local environment setup instructions</a>. The official <a href="https://docs.amplify.aws/cli">AWS Amplify docs</a> are your best friend and I will list down some specific sections in the docs which can give a better understanding of the working instead of opening and exploring random files in the codebase.</p><p>Amplify CLI has a pluggable architecture where the core provides the pluggable platform and most of the CLI category functions are implemented as plugins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*3Q7OZ8iHysQpY1BG.jpg" /></figure><p>There are 4 main types of plugins:-</p><ol><li><strong>Category</strong>: Holds logic to create and manage one category of backend resources in the cloud.</li><li><strong>Provider</strong>: Abstracts the actual cloud resource provider and exposes methods for the category plugins to CRUD cloud resources. Currently, the only official provider plugin,amplify-provider-awscloudformation, uses AWS CloudFormation to create backend resources in AWS.</li><li><strong>Frontend</strong>: Handles specific types of frontend projects, such as JavaScript, Android or iOS projects.</li><li><strong>Util</strong>: Provides certain CLI commands and functionalities for the CLI core, and other plugins.</li></ol><p>Apart from the 4 main plugin types the Amplify CLI project holds the code for its core in the packages/amplify-cli and packages/amplify-cli-core directories. The packages/amplify-cli is a plugin of type core and holds code for some of the most used commands like init (used to start a Amplify project), push, pull, publish, status etc. You can checkout the full list of commands available in packages/amplify-cli/amplify-plugin.json . Plugins communicate with the CLI core and with each other through the project metadata. The CLI core provides the read and write access to the project metadata for the plugins. The project metadata is stored in the file amplify/backend/amplify-meta.json in the user project.</p><p>You can explore the plugin package directory structure in detail <a href="https://docs.amplify.aws/cli/plugins/authoring#plugin-package-structure">here</a>.</p><p>Amplify CLI uses AWS CloudFormation and nested stacks to create reusable templates and replicable stacks to simplify infrastructure management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*vs_AmuRS03T8Y7d6.png" /></figure><p>Amplify CLI uses CircleCI for continuous integration. 3 main workflows are used to run integration tests, do resource cleanups and build, test and deploy a new GitHub release.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6h3FEVqgPc56GqlVKUtnLg.png" /></figure><p>Amplify CLI has a base TypeScript configuration in the root tsconfig.base.json file. Many plugins in the packages directory extend this base TypeScript configuration and hold the source files in the src folder and all the emitted/compiled files in the lib folder.</p><p>Integration tests for Amplify CLI are present in the amplify-e2e-core and amplify-e2e-tests packages. These tests use <a href="https://github.com/nodejitsu/nexpect">nexpect</a> to run the CLI. It allows chaining so that we can compose complex terminal interactions. The amplify-e2e-core contains code shared between amplify-e2e-tests package and holds helper methods that can help you create resources and setup and delete projects.</p><p>Some packages like the graphql-key-transformer also use snapshot testing with Jest. A typical snapshot test case renders a UI component, takes a snapshot, then compares it to a reference snapshot file stored alongside the test. The test will fail if the two snapshots do not match: either the change is unexpected, or the reference snapshot needs to be updated to the new version of the UI component. However, snapshots can capture any serializable value and should be used anytime the goal is testing whether the output is correct. You can refer to the Jest repo to <a href="https://github.com/facebook/jest/blob/master/e2e/__tests__/console.test.ts">see an example of snapshotting CLI output</a>. You can read more about snapshot testing in <a href="https://jestjs.io/docs/snapshot-testing">this section</a> of Jest docs.</p><p>The graphql-transformer in Amplify is pure magic and helps you build, deploy and maintain GraphQL API’s really fast. It takes as input a GraphQL SDL document and a list of GraphQL transformers and returns a CloudFormation document that fully implements the data model defined by the input schema. Read <a href="https://docs.amplify.aws/cli/plugins/authoring#the-transform-lifecycle">this</a> section to understand the transform lifecycle in detail.</p><h3>My Experience</h3><p>I was new to AWS when I started contributing to this huge project so I can understand the pain and confusion. Whenever you come across a new service name in the docs say AWS CloudFormation for example you can do a quick search for the same and read about it from the official AWS docs for that service. You do not have to read the complete docs for a service. Just skim through the sections which describe what the service does and how it works and you will feel ready and confident to move on. You can always learn more about specific parts if you choose to work on an issue related to that service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*mMqJ3vV-E8PNiBZ-.png" /></figure><p>The first phase of contributing to any open source project is to become a good user of that project. In this case you can explore the functionalities of the Amplify framework by making a small sample project with React by following <a href="https://docs.amplify.aws/start/q/integration/react">this guide</a>.</p><p>The CLI places a folder structure in the root directory of the sample project during amplify init . You can read <a href="https://docs.amplify.aws/cli/reference/files">this section</a> to know more about the contents stored in these files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*qowb_YeQ_GXwA2DSBzUTlw.png" /></figure><p>Now that you have made a sample project its time to understand different parts of the Amplify codebase so that you can solve issues. I along with my awesome teammates <a href="https://twitter.com/_rajrajhans">Raj</a>, <a href="https://twitter.com/gitaalekhyapaul">Gita</a> and <a href="https://twitter.com/Pawan_Kolhe">Pawan</a> came up with a detailed set of guides called <a href="https://mlh-fellowship.github.io/amplify-cli-monorepo-tour">Amplify CLI Monorepo tour</a> which will help you understand different parts of the project. You are welcome to contribute to this project <a href="https://github.com/MLH-Fellowship/amplify-cli-monorepo-tour">here</a> and make it even better for other new contributors and Amazon engineers working on AWS Amplify CLI. <a href="https://www.canva.com/design/DAEYw29s4kY/-1_LshQ0GWvlGPwD3hPL3Q/view?utm_content=DAEYw29s4kY&amp;utm_campaign=designshare&amp;utm_medium=link&amp;utm_source=sharebutton">Here is a deck of slides</a> which explains more on the motivation behind this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYHguN3Ulrq30w5Dbt4LCw.png" /></figure><p>Now try to pick up issues labelled as <a href="https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22">good first issues</a> from the <a href="https://github.com/aws-amplify/amplify-cli">Amplify CLI GitHub repository</a>. Try to reproduce it using the sample project you made with the Amplify CLI. Do not forget to join the awesome community of developers and contributors on <a href="https://discord.com/invite/amplify">AWS Amplify Discord</a>. There are channels for first time contributors and CLI discussions where you can get help from the Amazon Amplify staff to make your first contributions.</p><p>Now I assume that you managed to reproduce an issue and the bug is right in front of your eyes. It is time to debug and identify which part of this large codebase it lies in and submit a patch.</p><h3>Debugging in AWS Amplify CLI with VS Code</h3><p>VS Code has built-in debugging support for the <a href="https://nodejs.org/">Node.js</a> runtime and can debug JavaScript, TypeScript, or any other language that gets transpiled to JavaScript.</p><p>To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file.</p><p>However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details. VS Code keeps debugging configuration information in a launch.json file located in the.vscode folder.</p><p>To create a launch.json file, click the create a launch.json file link in the Run start view in the Amplify CLI codebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/0*FyNPAICKvcfhUI5o.png" /></figure><p>VS Code will try to automatically detect your debug environment, but if this fails, you will have to choose it manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mdVKfBtGYbccKrME.png" /></figure><p>Here is the launch configuration generated for Node.js debugging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*dfqo-s7YhTGeybk3dbfZmw.png" /></figure><p>Note that the attributes available in launch configurations vary from debugger to debugger. Update the contents of the launch.json as given below to connect it with your Amplify CLI sample project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*8mKA4XT2PwAAiC0DdFQbHQ.png" /></figure><p>Let us understand how you can modify this launch.json to debug any part of the project. In the above example the cwd key holds the absolute path to the working directory of the program being debugged. You can update this value with the path to your sample project you created using Amplify CLI. You can change the name of the configuration with the name key depending on the part of project you are trying to debug. Here I was trying to debug the gql-compile command in the api category. This name will appear in the launch configuration dropdown menu. The args key holds the command line arguments passed to your program. I wanted to debug the flow of the command amplify api gql-compile so I passed 2 arguments api and gql-compile . For context the api gql-compile command is used to compile the backend/api/~apiname~/schema.graphql . The compiled schema output is generated in backend/api/~apiname~/build/schema.graphql .</p><p>In VS Code, there are two core debugging modes, Launch and Attach, which handle two different workflows and segments of developers. We are using a launch configuration here. You can think of a launch configuration as a recipe for how to start your app in debug mode before VS Code attaches to it, while an attach configuration is a recipe for how to connect VS Code’s debugger to an app or process that’s already running. The request key in the launch.json file specifies the type of configuration.</p><p>Now that you are ready with the debugger configuration you can add breakpoints in relevant files by clicking on the editor margin. Breakpoints in the editor margin are normally shown as red filled circles. You can also add logpoints which is a variant of a breakpoint that does not “break” into the debugger but instead logs a message to the console. Logpoints are especially useful for injecting logging while debugging production servers that cannot be paused or stopped. Log messages are plain text but can include expressions to be evaluated within curly braces (‘{}’).</p><p>You can read more about the different types of breakpoints you can add in VS Code <a href="https://code.visualstudio.com/docs/editor/debugging#_advanced-breakpoint-topics">here</a>. Happy debugging!</p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FC2DpI8wSonedzQb.jpg" /></figure><p>I worked with the Amazon team on the AWS Amplify project as a part of the <a href="https://fellowship.mlh.io/">MLH Open Source program</a>. This project has a huge scope of learning and I still feel that a lot is left to be done. I had a really nice experience working with highly experienced software developers, developer advocates and the Amplify product manager in the Amazon team. We as a team of 4 students used to meet weekly with the Amazon team along with our technical mentor who really helped us in debugging and understanding different parts of Amplify. We could also schedule career advice and pair programming sessions with different experienced technical mentors via the <a href="https://raise.dev/">Raise.dev</a> platform. No doubt MLH is one of the best learning experience for students.</p><p>I hope I was able to motivate you and help you get started with the Amplify CLI codebase. Take your time to get familiar with different parts. You can start by exploring the init workflow which is used to setup and initiliaze an Amplify project. Fret not, you’ll ramp up in a while. After all it takes time to decode magic. Keep it going. I’ll meet you soon with another tech blog and a new set of learnings. Cheers.</p><p><a href="https://www.linkedin.com/in/sharmaaditya570191">The Linux Boy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e361db1e0b5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From console.log to GSoC 2020 ]]></title>
            <link>https://sharmaadityahq.medium.com/from-console-log-to-gsoc-2020-1a6e9dc2334e?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a6e9dc2334e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 24 Aug 2020 23:22:21 GMT</pubDate>
            <atom:updated>2020-08-24T23:24:23.041Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*19KzVwbV6EapFOPu" /></figure><p>I am Aditya Sharma, a third year Computer Science student at Shri Mata Vaishno Devi University, Jammu. Yes! I belong to that so called “<strong>TIER-3</strong>” group but I firmly believe that hard work and a bit of proper guidance can never let anything come between you and your goals.</p><p>It is time to share my wonderful journey to GSoC, tips and tricks to get selected and what all you can do before GSoC to take a step closer to your dream career.</p><p><strong>My Journey</strong></p><p>I got to know about Google Summer of Code program from some of my college seniors who had been selected in the past. Since then our code club group of a handful of self-motivated students set out on a never ending journey full of learning, failures and success.</p><p><strong>Semester 1</strong></p><p>In my first semester I started with C and C++ and we used to solve language proficiency and algorithm questions and compete on HackerRank for the best score. This went on for the whole semester till I achieved 5 stars in problem solving. However, I soon realized that competitive coding was not really allowing me to build something and solve real world problems.</p><p><strong>Semester 2</strong></p><p>In my second semester I spent quite some time on <a href="https://www.codecademy.com/">Codecademy</a>(free PRO pack by using different email) , <a href="https://developer.mozilla.org/en-US/">MDN</a>, and <a href="https://frontendmasters.com/">Frontend Masters</a> (free for 6 months via <a href="https://education.github.com/pack">Github Students Developer pack</a>) to learn HTML, CSS and JavaScript. I know it sounds too basic but it is really fun if you explore the internals and dive deep to study about things like How JavaScript engines work, Javascript as a single-threaded language, Web Workers and their advantages and disadvantages. As GSoC focuses entirely on open source projects and contributions I also learnt basics of Git (a version control system) and GitHub. I always used to explore the official technical documentation of every technology after learning basics from the resources above or some YouTube videos.</p><p>To retain the high amount of learning for a long time I used to make and implement small projects. This finally kept me at peace as I had actually started building something. You can follow me on GitHub to get an idea of the type of projects you can build.</p><p><a href="https://github.com/sharmaaditya570191/">sharmaaditya570191 - Overview</a></p><p>By now it was time to apply for GSOC 2019. By the end of the application period my 7 code contributions got merged and I managed to make a project proposal after a lot of struggle.</p><p>Result: I failed and could not survive the high competition.</p><p>Reason: Lack of skills and preparation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*ENF6n9Mg4t9z0xoPLu1cPA.png" /><figcaption>GSoC 2019 Rejection</figcaption></figure><p>I was really sad but did not waste any time. I decided that I will not let this happen next year for sure.</p><p><strong>Semester 3</strong></p><p>In my 3rd semester I studied about How API’s work, How I can create my own API, What is REST, and much more of JavaScript including concepts like asynchronous programming. I learnt about REST and Node.js from <a href="https://frontendmasters.com/">Frontend Masters</a> (Yes it has awesome server side courses as well). I did not stop at this. I covered React when I was comfortable with JavaScript. It took time but I was able to understand the concepts with continuous efforts. <strong>Do not forget to make small projects using the things you learn. Push them to GitHub so that you can refer them in a click when needed.</strong></p><p>React really helped me to do some awesome code contributions to an existing project in my current organization. I also learnt a lot of best practices and debugging techniques along the way.</p><p><strong>Semester 4</strong></p><p>Ok. Loads of learning is complete. What next?</p><ol><li>Read the GSoC student guide <a href="https://google.github.io/gsocguides/student/">here</a>.</li><li>Make a list of 5–7 GSoC organizations working with your favorite technologies (Just search “gsoc organizations” on Google)</li></ol><blockquote><em>Try to select organizations which have been a part of GSoC for at least 2 years or more. Play safe!</em></blockquote><p>3. It is preferred to start contributing to a project from December (I know it is a bit early but it will help, trust me)</p><blockquote>I started contributing from around December 15 in <a href="https://github.com/creativecommons/">Creative Commons</a>. In January I switched to my current organization <a href="https://gitlab.com/SUSE-UIUX/eos/-/wikis/GSoC-2020-Sub-org-at-Python.org:-EOS">EOS Design System</a> in Python Software Foundation as the previous project was not going to be a part of GSoC. Hence, it is recommended to start early.</blockquote><p>4. After finalizing a project by mid January make as much code contributions as possible.</p><blockquote>This time I got more than 20 contributions merged within the application period. It is a bit tough but not impossible. You can do it too.</blockquote><p>5. Do not forget to interact with your potential mentors. Communication really plays an important part. Try to discuss and propose new feature implementations. Tell them about your experience and interests in the project. Be honest. 😀</p><blockquote>I was really active in weekly organization meetings and also participated in live group coding activities with my mentors during the application period. This may be specific to your organization but try to maximize interaction with your mentors.</blockquote><p>6. Start making your project proposal early. Prepare a draft in Google Docs and include timeline and solutions of solving the problem at hand. Add some new features from your side after discussion with mentors. <strong>Get your proposal reviewed from your mentors. Feedback works wonders.</strong> <strong>Improve and update it as they suggest.</strong></p><blockquote>You can refer my selected GSoC 2020 proposal <a href="https://docs.google.com/document/d/1U9AXtf27sxSUkLCn2ExSpAIk6j-xgCNE7K-kTOFcn8E/edit?usp=sharing">here</a>.</blockquote><p>7. Do final edits and submit your application.</p><blockquote>Keep contributing to the project even after application period. Be patient for the results. If you deserve it you will get it for sure. Trust me.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*3oWQVCB4XjcatuYThFlUAQ.png" /><figcaption>GSoC 2020 Selection</figcaption></figure><p>Celebrate with your friends and family after you receive this in your mail inbox on the results day. You have really worked hard and you completely deserve it. Thank your mentors for this awesome opportunity. 🎉</p><p><strong>Do not get demotivated if you fail.</strong></p><p>Keep learning because life never stops teaching. Try, try till you succeed!</p><p>In case you also want to work on web based projects in GSoC then <a href="https://medium.com/@theSDEshow/becoming-a-full-stack-developer-from-scratch-in-2020-9718dd4a2616">here</a> is a complete detailed roadmap for you.</p><p>You can reach out to me on <a href="https://www.linkedin.com/in/aditya-sharma-88541116a/">LinkedIn</a> for any other queries. I have also written weekly technical blogs on Medium sharing my GSoC work and experience. You can check them out <a href="https://medium.com/@sharmaaditya570191">here</a>.</p><p>Happy coding!</p><p>PS: I still use console.log every day for debugging easily. Basics always help.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a6e9dc2334e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inches closer to the GSOC’20 finish line]]></title>
            <link>https://sharmaadityahq.medium.com/inches-closer-to-the-gsoc20-finish-line-e3566e1d9b5?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3566e1d9b5</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 17 Aug 2020 18:06:48 GMT</pubDate>
            <atom:updated>2020-08-17T18:07:28.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*mKUYX3KZusqtDGri.jpg" /></figure><p>Our sweet GSOC family literally coded the summer away with some of the best developers from around the world always ready to hold our hand in case we loose balance. Now the hardest week has come. Its time to say goodbye and I am not able to get over it. The end is getting closer as you read this but my heart is not designed to close the best doors so easily. My brain is full of brand new ideas to implement after the GSOC timeline. For now lets check out my latest patches which got merged this week.</p><h4>What did I do this week?</h4><p>We made a decision that we should polish and test the existing features before adding new ones so that we can find and fix bugs if any.</p><p>Result? We ended up making a list of 13 bugs. 😂</p><p>User authentication was the first thing I completed but I could still access the protected routes in the UI although some of them were not working because of the absence of the JWT token in the cookies. Still we had to maintain the user session on the client side as well.</p><p>I created a global state using createContext in React so that we can update the state when the user logs in to our system. I allowed users to access the protected routes by checking against this state. Users would be redirected to the login page in case they are not authenticated. Solved?</p><p>Not yet. Another corner case got us thinking. If we reload the page then the state is lost and user is logged out. It would be a terrible user experience to force the user to login every time they may refresh the page because of connection issues on their side.</p><p>This time I stored the state in localStorage so that we can save state across page refresh. Security was maintained by our httpOnly cookie.</p><p>This was solved but now users could vote more than once. Imagine allowing this in real government elections of your country.</p><p>Result? You may get the same president every time. 😂</p><p>Everyone may not like that right? (Trump smiling secretly 😝)</p><p>This was a simple fix by introducing a new state variable and updating it if the user has already voted for a story. You press again and your vote gets removed.</p><p>My mentor and I spent some time in trying to fix our httpOnly cookie attributes to work with the latest updates in Chrome. However, none of our solution worked in Chrome because Chrome was probably upset with us and did not set the sameSite attribute of the cookie to none.</p><p>We ended up creating a new sub-domain for our server so that the request is no longer a cross-origin one. 😂</p><p>Now some smart users were able to edit stories of others. Imagine editing and filling your friends stories with shit. 😂</p><p>Devesh (my awesome GSOC partner) saved all F.R.I.E.N.D.S here by updating the client side with a minor fix. Thankfully our server did not betray us here.</p><p>Then came my killer move. A full end-to-end test. Yes, I was able to complete a long test in Cypress to test all our main functionality like login, home page, creating new stories, editing them, commenting and even replying on comments. This will save a lot of time in the future by eliminating the need of manually testing all functionality before merging every patch. We may also consider running this test in the CI soon.</p><h4>What is coming up next?</h4><p>This is officially the last week of GSOC’20. I will make a final report for my project and get it reviewed from my awesome mentors.</p><p>I will extend my Cypress test to cover signup, notifications and logout functionality.</p><p>Finishing touches also make a great impact. I will add some decorations for the final celebration and release to production (heaven for developers). 🎉</p><h4>Did I get stuck anywhere?</h4><p>I firmly believe that as a developer if you are not stuck then you have not seen enough.</p><p>Some corner case bugs were a pain point. I also got stuck when trying to handle multiple cases for filters and pagination. It was a bit tricky to identify the points of optimization for enhancement of user experience but that gave me the real development experience. 🙂</p><p>My never give up attitude helped me to fly high above all obstacles to fix all bugs we identified till now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*tZJ2UwthUKEBKpffMOu_Ug.png" /></figure><p>Time flew and brought us close to the end. I honestly hate saying that and decided not to say a goodbye. Its that simple. Sometimes the best things deserve to be a special part of your life and EOS had already made its place in my heart long back. Loads of 💖 to my EOS family.</p><p>Cheers to a new beginning. Its not the end.</p><p>Signing off. Aditya Sharma.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3566e1d9b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pagination, Privacy Policy, Bug Fixing and Testing in the User Story system in GSOC’20]]></title>
            <link>https://sharmaadityahq.medium.com/pagination-privacy-policy-bug-fixing-and-testing-in-the-user-story-system-in-gsoc20-6304fa8c0070?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/6304fa8c0070</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[strapi]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 10 Aug 2020 16:28:01 GMT</pubDate>
            <atom:updated>2020-08-10T16:28:01.990Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9u3R7WGwc40QHfeIIGYfog.png" /></figure><p>I started this week with a heavy heart. I entered the last coding phase of the best experience of my life. I made my mind that I will keep contributing to this project and organization and make the most of this awesome learning opportunity. I will not let it end here. I can already imagine a smile on my mentors face as they read this. You are the best people I have ever met and worked with. Now lets jump to my magic work. :)</p><h4>What did I do this week?</h4><p>“Many solutions will work but keep solving the problem till you optimize it and reach the best possible solution.” I do not know which genius said this but I my mind got stuck with this and I decided to spend some time to add pagination for our beloved users. This means users can reach any page with a click and we do not have to load all stories in one go. Imagine our free Heroku servers burning on hitting the API to load 500+ stories in one go. LOL!</p><p>The most important thing before going live was telling users how we are going to use their data. I worked on the privacy policy page and created a new model in the back end so that admins can manage its contents and update the privacy policy when needed.</p><p>This also means that we have to notify users of a privacy policy update. I wrote a custom lifecycle hook in Strapi which automatically creates a notification when the old policy is deleted and a new one is created. This special notification is displayed as a popup modal on the home page for users who are already logged in. They have the option to accept the new policy. If they do not accept then they can continue using our system but are logged out. This means they can only read existing stories.</p><p>New users will not see the modal as they can access the updated policy when they register into our system.</p><p>After pushing these heavy changes to production I fixed some bugs related to the my stories page and pagination not working along with product filters.</p><p>Finally I studied Cypress docs for some time. I set up Cypress for our client side so that we can write, run and debug tests easily.</p><h4>What is coming up next?</h4><p>I have identified some bugs on the client side and I will spend some time to fix them.</p><p>I will try to give the remaining time for writing tests as they are really important to future proof our application.</p><p>I have a lot of exciting new features in mind like Slack integration, email notifications etc and I will add them only if time permits.</p><p>I understand that the best things take time and patience and I will keep adding a thousand more features to user story even after GSOC. :)</p><h4>Did I get stuck anywhere?</h4><p>It is natural to get stuck while trying to do the best things.</p><p>I got stuck at multiple places while trying to make the pagination feature work along with other filters. Covering all possible cases for the privacy policy model was also a bit tricky. Discovery of new bugs might be a bit easy but they can be difficult to solve. Cypress and software testing in general was absolutely new to me.</p><p>I do not give up easily and kept trying to overcome all obstacles by the end of the week. All my efforts were really worth it. I learnt a lot.</p><p>I am also blessed to have such awesome mentors for support and motivation. They work really hard everyday and I learn a lot just by observing them. :)</p><p>You can check this out in case you want to dive deep into the client side implementation.</p><p><a href="https://gitlab.com/SUSE-UIUX/eos-user-story">Projects · EOS / eos-user-story</a></p><p>You can refer this for an in depth analysis of the server side implementation.</p><p><a href="https://gitlab.com/SUSE-UIUX/eos-strapi">Projects · EOS / eos-strapi</a></p><p>Thanks for reading. Give a clap if you liked it. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6304fa8c0070" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lifecycle hooks, threading and notification system in the user story system in GSOC’20]]></title>
            <link>https://sharmaadityahq.medium.com/lifecycle-hooks-threading-and-notification-system-in-the-user-story-system-in-gsoc20-40b0896f7c50?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/40b0896f7c50</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 03 Aug 2020 18:23:05 GMT</pubDate>
            <atom:updated>2020-08-04T03:55:48.881Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*yVU-65VC_LGrVEui.png" /></figure><p>A whole new set of awesome features are here for our beloved users. Do not get worried by the heavy terms in the title. Sit back, relax and follow me to catch a glimpse of my implementation for giving you the best possible user experience. You will soon be able to write your own story, share with us how you use our products, relate to other users’ stories, vote them up and we’ll make sure we deliver cohesive solutions to you.</p><h4>What did I do this week?</h4><p>This week it was time to design a personalized notification system for our users to notify them about the latest features when we launch them. Only author and followers(users who have voted) of the launched story should receive the notification so that we do not disturb other users who might be busy writing their own amazing stories.</p><p>The admins update the status of a user story to “launched” via the back end Strapi panel when our team have successfully pushed a new feature to production.</p><p>Now Strapi lifecycle hooks come into action. The lifecycle hooks are functions that get triggered when the Strapi queries are called. They will get triggered automatically when we manage our content in the Admin Panel or when we develop custom code using queries.</p><p>I wrote a asynchronous afterUpdate hook in the user story model which checks if the status of a user story has changed to “Launched” after being updated. If the status has changed then it creates a new notification record on the server with a custom message, seen status, link to the story page and a list of users to whom the notification is to be shown. I did this by utilizing Strapi services which are a set of reusable functions. They are particularly useful to respect the DRY (don’t repeat yourself) programming concept and to simplify controllers logic. Every notification on the server is required to have a different and unique message.</p><p>On the client side I fetch the notifications for the particular authenticated user using GraphQL queries. When the user has seen the notifications then they are marked as seen on our Strapi server too. This is done using GraphQL mutations which update the status of a notification. I made sure that we do not hit our API multiple times to update the status of a notification.</p><p>The next major feature of the week was to add threading in comments. This allows users to reply to a particular comment on a story in a thread. I created a separate model on the server for user story comment replies. Each comment reply belongs to one comment, a user can have multiple comment replies, each reply belongs to one user and one comment can have multiple replies. Such was the complexity of relations between the models schema. You can also see the number of replies and even add your own reply via the client side.</p><p>All these extra efforts will make your user experience super smooth. The blazing fast React re-renders and updates on the client side will be a icing on my cake. :P</p><h4>What is coming up next?</h4><p>I will spend some time to polish and test the existing features.</p><p>I will also work on the user story privacy policy to allow admins to manage and update the policies from the admin panel. Users should receive notifications whenever the privacy policies are updated. The user can then choose to accept them or remove their account.</p><h4>Did I get stuck anywhere?</h4><p>I got stuck at multiple places be it writing hooks and custom controllers in Koafor my server or implementing mutations in an effective and optimized way on the client side.</p><p>However, I did not give up and kept reading more about the topics and technologies involved. This way I was able to learn a lot of new things during the week. Debugging and troubleshooting became super easy after I hit my learning goals and covered all basic concepts properly.</p><p>This ended the week with the second evaluation. I received a really nice feedback from my mentors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*T4Ni06xn2eteKwyvBqxwhg.png" /></figure><p>I expressed my sincere thanks to them for always supporting, motivating and inspiring me to learn more. Stay tuned for the next set of features. This time they will be strong enough to blow your mind away. :)</p><p>You can check this out in case you want to dive deep into the client side implementation.</p><p><a href="https://gitlab.com/SUSE-UIUX/eos-user-story">Projects · EOS / eos-user-story</a></p><p>You can refer this for an in depth analysis of the server side implementation.</p><p><a href="https://gitlab.com/SUSE-UIUX/eos-strapi">Projects · EOS / eos-strapi</a></p><p>Thanks for reading. Give a clap if you liked it. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40b0896f7c50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boosting application security, voting and commenting in the user story system in GSOC’20]]></title>
            <link>https://medium.com/swlh/boosting-application-security-voting-and-commenting-in-the-user-story-system-in-gsoc20-8d30550fbe17?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d30550fbe17</guid>
            <category><![CDATA[strapi]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 27 Jul 2020 18:15:13 GMT</pubDate>
            <atom:updated>2020-07-27T18:15:13.866Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JigV652M5fhmBae8.jpg" /></figure><p>This time I let the title reveal the much awaited features that are up and running by the time you read this. I am really excited to experience that adrenaline rush when I get a chance to vote in the real elections and choose our leaders of tomorrow. For now I can fulfill my desire by contributing in selecting the best and most wanted user story of the season. Follow me to understand how I solved the mystery of votes and relations.</p><h4>What did I do this week?</h4><p>Recall that complex bug where Strapi could not find the schema for our user story model and kept flashing that weird error on my terminal despite repeated attempts. This time I dived deep inside to catch a glimpse of the internals of Strapi and finally solve that.</p><p>The fields of the newly established relations in the user story model were overlapping with each other because Strapi does not drop or migrate the database when a model is deleted or updated. They do so because users may start their application with a production database and a model name may not match with one of the tables in the database. Crash! :/ This is a work in progress and Strapi is improving it. I solved it by choosing a different one sided relation type of one-to-many and renamed it to followers.</p><p>Now I added client side logic for the voting system so that a user cannot vote more than once. Clicking on the like button for the second time removes the vote of the user and so on. Pushing all this to production gave me a sigh of relief. :)</p><p>After a deep breath I moved on to allow users to leave their valuable feedback and suggestions on user stories. Yes, comments. This way we can take into account the views of more users and design our next awesome feature accordingly.</p><p>Now it was time to step up the security as a lot of functionality was already in place. I wrote a custom controller in Koa which checks that the localStorage id matches with the id of the authenticated user and if the same user is the author of the story they are viewing. A positive response will allow the user to edit their story. I also modified the controller which creates a new story and now it can automatically assign the authenticated user to be the author of the story.</p><h4>What is coming up next?</h4><p>I will work on the notification system. It would be great to have three types of notifications — in-app, push and email notifications.</p><p>These will notify the user story author and followers that their user story has been launched. Only organization admins can update the status of a story from the Strapi panel.</p><p>If time permits I will try to setup Cypress for testing our application.</p><h4>Did I get stuck anywhere?</h4><p>The React implementation to allow one time voting for each user was a bit tricky as there are a lot of state variables on our story page. However, I solved this by catching the previous state value by applying functional updates in my useState hooks to overcome the stale state problem which arises due to closures in React.</p><p>Writing controllers for my server in Koa was also new but I was able to learn the basics quickly as it is similar to Express.</p><p>This ended the week on a sweet note. Stay tuned and get ready to receive another set of notifications on your device. Do not worry. We will not throw those sales ads on you again. This time it will be about the launch of your own story. :P</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d30550fbe17" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/boosting-application-security-voting-and-commenting-in-the-user-story-system-in-gsoc20-8d30550fbe17">Boosting application security, voting and commenting in the user story system in GSOC’20</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making and inspecting model relations for user story system in GSOC’20]]></title>
            <link>https://sharmaadityahq.medium.com/making-and-inspecting-model-relations-for-user-story-system-in-gsoc20-e7b99042a788?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7b99042a788</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[strapi]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 20 Jul 2020 17:12:20 GMT</pubDate>
            <atom:updated>2020-07-20T17:12:48.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8TgPjab712dpNSnL.png" /></figure><h3>Making and inspecting model relations for the user story system in GSOC’20</h3><p>The world is full of relationships. Everything around us is connected to each other in some way or the other. Sometimes relations can be hard to figure out. Join me as I help you create a unique relation with our user story system and some of its brand new features.</p><h4>What did I do this week?</h4><p>This week started with full action and thrill as usual and we decided to modify our models to align with our product name. This means all existing models had to be renamed according to the user story theme on the server side. A rename operation seemed like a small and simple task but I soon realized that Strapi does not update the GraphQL schema if we rename a model. This is because existing tables are not deleted or dropped from our MongoDB database and instead new ones are created. This started breaking everything on the server side.</p><p>I rolled back and created new models for user story system and imported all data from our staging database. This time the shadow CRUD functionality generated a perfect new schema for my use case. Server was good to go.</p><p>The schema changed so the next task was to change all GraphQL queries and mutations on the client side and align them with the new user story models. The docs for the schema helped me to complete this with ease.</p><p>Next I created a new model for all the products at EOS and related it to the user story system model. This allows users to filter stories according to the product and enhances user experience by allowing them to navigate faster among hundreds of user stories. I worked on the filter feature on the client side to fetch all products and filter them according to their status and product selected by the user via a drop down.</p><p>I eagerly wanted to allow users to respond to some amazing user stories so I moved on to implement the voting feature. This allowed users to vote for any user story to express their interest. Wait. It just sounds easy but some major problems and bugs were waiting for me at the end of the week before I could push the voting system to production.</p><p><a href="https://stackoverflow.com/questions/20832126/missingschemaerror-schema-hasnt-been-registered-for-model-user">MissingSchemaError: Schema hasn’t been registered for model “user-story”</a></p><p>My terminal kept flashing this message as I tried to figure out the problem in my new user story vote models and relations. It is still a mystery though because the same relations work fine with my comments model. I told you relationships can be hard sometimes. :/</p><h4>What is coming up next?</h4><p>I will work on the voting system for user stories. This involves establishing proper relations between the user story and user models. The mystery will be solved soon.</p><p>Further I would try to think of a nice implementation for the user notification system to tell users that their wait for the next awesome feature is over. This would be implemented later this week. Users really want to make comments so lets give them that privilege first.</p><h4>Did I get stuck anywhere?</h4><p>MongoDB relationships represent how various documents are logically related to each other. I faced a weird problem when I was establishing a one-to-many relation between my user story vote, users and user story models. MongoDB could not identify the schema for my user story model for some reason and kept throwing an error. The bug came to us at the end of the week and I am still trying to solve the mystery with my mentors. Moving forward we created a map of all our relations to get a nice picture of all relationships and find the conflicts and resolve them.</p><p>This ended the week with lots of rain which gave me some relief from the scorching heat. Stay tuned as I solve the mystery behind relationships and add new path breaking features to the user story system. The adventure is yet to begin. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7b99042a788" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comment queries and edit mutations in the feature request system in GSOC’20]]></title>
            <link>https://sharmaadityahq.medium.com/comment-queries-and-edit-mutations-in-the-feature-request-system-in-gsoc20-a403689779cd?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/a403689779cd</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[strapi]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 13 Jul 2020 15:05:35 GMT</pubDate>
            <atom:updated>2020-07-13T15:05:35.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*EOFuVVULBJNOkvRu" /></figure><p>Sometimes we are not able to express all our thoughts and ideas in one go. A great idea may strike later or you may want to comment and give some suggestions and feedback to stories of other users. Come explore with me some exciting features that I added to our feature request system using Strapi , GraphQL and React this week.</p><h4>What did I do this week?</h4><p>A strange bug starts the week with some thrill and action. Our whole application breaks when a user logs in to the system and submits a new user story. Crash!</p><p>We were checking and dividing our user stories on our client side according to their current status. No status gets assigned by default to a new user story as that is an admin or root level permission feature. In Strapi I cannot assign a default status to a relation type field because relations between models can be of various types. I solved the bug on the client side by assigning every new user story a status of “Under Consideration” in my GraphQL mutation.</p><p>A user may want to check out their own stories at some point of time so I implemented a GraphQL query to fetch all user stories based on their user id. Users need to be authenticated to access their own stories. They can check their stories for status updates, votes, likes and comments from other users.</p><p>The next was the most awaited feature of allowing our beloved users to edit their own user stories. However, they cannot change the already added description. Content can just be added to the existing information. This is just to avoid trolls. :P</p><h4>What is coming up next?</h4><p>This week I will create a product model so that we can relate all our products at EOS Design System with a separate user story system. Users can filter their stories for different products.</p><p>I am also working on user comments system so that we can display all comments properly and further allow users to add more comments.</p><h4>Did I get stuck anywhere?</h4><p>Development without getting stuck is no fun. We learn fast from our mistakes. Initially I was happy to complete the edit story functionality and it worked well. Then my mentors could hack into the system easily. Security compromised. :P</p><p>They could edit stories of other users as well after writing into the famous localStorage . I solved the bug easily by implementing a function to verify and allow editing only if the user is the owner of the story.</p><p>This ended the week on a sweet note with quite some features added. Stay tuned for more fun and action. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a403689779cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleash content with Strapi and GraphQL in the feature request system in GSOC’20]]></title>
            <link>https://medium.com/swlh/unleash-content-with-strapi-and-graphql-in-the-feature-request-system-in-gsoc20-577df3f459e5?source=rss-ee110c5b3676------2</link>
            <guid isPermaLink="false">https://medium.com/p/577df3f459e5</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[strapi]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aditya Sharma]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 07:44:08 GMT</pubDate>
            <atom:updated>2020-07-06T08:20:14.434Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rbhTmVIDXyAehemy.jpg" /></figure><p>You definitely received exactly what you wanted and you enjoyed using it. Now you just want to know how this actually works under the hood. Is it real magic? Did god just shaped it according to your needs and sent it down from heaven? Come with me and I’ll answer all your GraphQL queries.</p><h4>What did I do this week?</h4><p>It took me some time to realize that GraphQL is not another programming language. It is a specification or a technical standard. This mean it can have several implementations and variations. GraphQL.js is the JavaScript reference implementation. Legends like Strapi implemented a fully customizable GraphQL plugin which creates a new endpoint /graphql and the <a href="https://github.com/graphql/graphiql">GraphiQL</a> interface. The plugin adds a new layer to easily request the API using GraphQL, without breaking the existing endpoints.</p><p>GraphQL secures all queries by default and the plugin plays well with the users and permissions plugin. When we are making a query with GraphQL we are hitting the same controller’s actions as we were doing with the REST endpoints.</p><p>I utilized the introspection system of GraphQL to fetch all categories available to our user while making a new story.</p><p>I also used a mutation to create a new user story which takes in all data entered by the user as parameter. I pass all my GraphQL queries through a set of custom policies before they hit my custom authentication controllers in the customized Strapi back end. This completed the feature to create a new user story.</p><p>On the server side I created a new model for the comments on the stories which contains 3 fields. The first is a rich text field to write the comment and the remaining two are relation fields with user and feature requests models. This means I also had to add a relation field to the feature request model to connect it with my comments model.</p><p>The next big feature of the week was to add functionality to display all stories on the home page according to their current status. The shadow CRUD feature of Strapi GraphQL plugin automatically generates the type definition, queries, mutations and resolvers based on our models. The feature also lets us make complex query with many arguments such as limit, sort, start and where. This helped me to implement a GraphQL query to fetch the required details of all user stories and sort them according to the highest number of votes and most recently created stories. I used the query response to display the title, description and the no. of votes and comments for all stories on the home page.</p><p>All these features for the week helped me to catch up with GraphQL really fast. It was completely new to me and I was feeling stuck just a week before. Now by the end of the week I am happy that I am able to understand how it works so efficiently deep down the layers.</p><h4>What is coming up next?</h4><p>I will work on displaying all information about each user story on a separate page. This requires a query to fetch all story details by the story id. The date of publishing and author details will be available on this page as well.</p><p>The system needs an edit feature which may allow our beloved users to add information to their story. They will not be allowed to edit the existing description though.</p><h4>Did I get stuck anywhere?</h4><p>Sometimes rare bugs can be difficult to catch and you may feel stuck while trying to solve them. This week I came across something strange.</p><p>All my code and functionality was running successfully on my development environment. After getting merged, the Gitlab CI deployed it to our staging servers and the whole application crashed, both the client and server side.</p><p>I finally solved all bugs and got to learn that Strapi stores all the roles and permissions that we assign to our users in the database. In this case our development and staging servers are using different database. Simple :)</p><p>We just exported all our models data from the testing database to the one used by our staging server.</p><p>Another bug was to specify the exact cors origin which can access our server as I used withCredentials : true in my Axios configuration to store the cookies in the browser and send them back in future requests.</p><p>This ended the week with the first evaluations in which I received an awesome feedback from my mentors and passed with flying colors. I thanked them for all their support and guidance. Looking forward to a great journey ahead :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=577df3f459e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/unleash-content-with-strapi-and-graphql-in-the-feature-request-system-in-gsoc20-577df3f459e5">Unleash content with Strapi and GraphQL in the feature request system in GSOC’20</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>