<?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 Abhijith M S on Medium]]></title>
        <description><![CDATA[Stories by Abhijith M S on Medium]]></description>
        <link>https://medium.com/@ams_132?source=rss-93ef70aee8c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jYWE0Ldgmzrctv-63kLlwQ.jpeg</url>
            <title>Stories by Abhijith M S on Medium</title>
            <link>https://medium.com/@ams_132?source=rss-93ef70aee8c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:36:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ams_132/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[Building Hyphora: A Distributed KV Store with a Bitcask Soul]]></title>
            <link>https://medium.com/@ams_132/building-hyphora-a-distributed-kv-store-with-a-bitcask-soul-3f44c4ff9ba8?source=rss-93ef70aee8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f44c4ff9ba8</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[key-value-store]]></category>
            <category><![CDATA[homelab]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Abhijith M S]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 07:28:14 GMT</pubDate>
            <atom:updated>2025-11-16T07:28:14.259Z</atom:updated>
            <content:encoded><![CDATA[<p>This is about my experience building <a href="https://github.com/AMS003010/Hyphora"><strong><em>Hyphora</em></strong></a> and why I built it 😅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptpoKDh38uBfQpyH3_5ywA.jpeg" /><figcaption>Generated on Leonardo.ai</figcaption></figure><p>Hyphora is a distributed Key-Value store with a bitcask storage backend inspired by how each unit in the mycelium maintains consensus of their biological composition with each other.</p><pre># Hyphora<br><br>Derived from Hyphae (/ˈhʌɪfə/) -- the branching filaments that<br>make up the mycelium of a fungus</pre><p>Are you one of those people who’d rather tinker your way through a problem in the hardest possible way instead of simply spending money 💸 and choosing the easy route?<br> Well, I definitely am 😝.</p><p>That’s exactly what happened when I built my makeshift home lab. It gave me a sense of freedom like nothing else (and also kept me from breaking things on my academic laptop 😅).</p><p>I enjoy diving into random topics I stumble across on the internet from <a href="https://mrsauravsahu.medium.com/getting-started-with-linux-a-guide-to-distro-hopping-2cd4c58bfb22"><em>distro hopping</em></a> to <a href="https://github.com/rs/zerolog"><em>zero allocation logging</em></a>, from <a href="https://www.reddit.com/search/?q=ricing+linux&amp;cId=e4ba3ea5-50de-4642-b9b4-d7b3ae5a2086&amp;iId=5c257236-2abc-446e-9c93-66868b290908"><em>appreciating random rices</em></a> to exploring <a href="https://flatbuffers.dev/"><em>flat buffers</em></a> and of course, playing Minecraft.</p><p>I always wanted something in my home lab that could</p><ul><li>store <em>{ “WORLD_SEED” = “712394561” }</em> in each of my servers (mostly <em>raspberry pi’s</em> 😝) in my home lab</li><li>allow for a file on one node (like <em>rockyou.txt </em>😈<em>)</em> to be available across multiple nodes</li></ul><p>Building a distributed key-value store seemed like the solution (also because I wanted to build something this cool 😏 from a long time).</p><p><a href="https://arpitbhayani.me/blogs/bitcask/"><em>Bitcask</em></a> having one of the most easy to understand architectures and still very performant became my first choice for a storage engine!!</p><p>So this the story of <a href="https://github.com/AMS003010/Hyphora"><em>Hyphora</em></a> and how it came to be 🤘</p><h3>Main components of Hyphora🌿</h3><ul><li><strong><em>Key-Value store</em></strong> (Built from scratch)</li><li><strong><em>Raft</em></strong> (Using Hashicorp’s Raft library)</li><li><strong><em>Bitcask</em></strong> (Built from scratch)</li></ul><h4>Key-Value store</h4><p><em>This is a data storage paradigm where data is stored as { key : value } pairs. Simply think of it as a database where every value that you store is associated and identified by its key. So if you want to modify it then the current value of the key is modified and if you delete the key then the whole { key : value } pair is deleted.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*XcsjyrnYx-AnIVDEoe-PTw.png" /><figcaption>Representation of a key value store</figcaption></figure><h4>Raft</h4><p><em>A consensus algorithm is a core part of any distributed system and a consensus algorithm simply means an algorithm responsible to ensure that all the nodes in a cluster agree upon a value to consider it as a valid value. Raft is a consensus algorithm responsible to distribute a state machine across a cluster of machines. It achieves consensus via a elected leader. Here every write operation that happens is sent to the leader which appends it to its log and replicates it to others as AppendEntries before executing it. As for a read operation it can be done on any of the nodes </em>(<em>Be careful of the stale values</em>)<em>. Know more about it at </em><a href="https://raft.github.io/"><em>Raft</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*fo5YpQKUGMKlb63jwDAqVg.png" /><figcaption>Raft is a leader follower consensus algorithm</figcaption></figure><h4>Bitcask</h4><p><em>Bitcask is a storage paradigm designed to handle high Read-Write throughput. Just think of it as designing a storage engine which can perform pretty well under high load situations. A storage engine is simply a makes-it-sound-cool term for a core part of the database which will handle all the primary functions.</em></p><p>These are the primary functions for the <em>bitcask</em> backend</p><ul><li>Store a <em>{ key : value }</em></li><li>Get the <em>value</em> for a <em>key</em></li><li>Delete a <em>key</em></li></ul><p>The main components of <em>bitcask</em> are</p><ul><li>An in-memory hashmap of <em>{ key : value } </em>pairs</li><li>A set of append-only files which will serve as a persistent store ( they are simply a folder with data-*.db files )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEOWCspzlRf9-KKuoRXtLQ.png" /><figcaption>Components of Bitcask</figcaption></figure><p>I’ll tell later why there are duplicate values for the several keys in the <em>data-*.db</em> files in the image. Hold tight ! 🙃</p><p><em>So how does it work </em>🧐 <em>Lets take an example</em></p><p>Suppose you store a <em>{ ore_spawn_rate: 0.004 }</em></p><ul><li>This is added to a append-only file (here <em>data-1.db</em>).</li><li>Added to the <em>hashmap</em> as well</li></ul><p>This allows for 2 things</p><ul><li>Fast reads for the value of a key from the <em>hashmap </em>as a it provides O(1) access to the value</li><li>If the key is not there already, then the <em>{ key : value } </em>pair is appended to <em>data-1.db</em>. If the key is already there, you do not go through all the files and get the latest value instead you simply append it !! This helps with handling high write situations as you do not hold the lock too long.</li></ul><p>After adding <em>{ ore_spawn_rate: 0.004 }, </em>it will look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDeWtlIAjJRQAvfm7AKGcQ.png" /><figcaption>After adding <em>{ ore_spawn_rate: 0.004 }</em></figcaption></figure><p>What if I now add <em>{ ore_spawn_rate: 0.6 } </em>🧐</p><p>the pair will be appended to the data-1.db (instead of updating the previous entry of <em>ore_spawn_rate</em>) and then the value for <em>ore_spawn_rate </em>in the<em> hashmap </em>will be updated. It will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c9ORxVSj4vLjS2THZDhAjg.png" /><figcaption>After adding <em>{ ore_spawn_rate: 0.6 }</em></figcaption></figure><p>Cool 😄 now we have a system to get the value to a key in O(1) and also allow addition of <em>{ key : value } </em>pairs without having to hold the lock too long. 🎊</p><p>Now how does delete happen 🧐</p><p>Here if we were to delete <em>ore_spawn_rate </em>then a<em> tombstone </em>is inserted into the<em> data-1.db</em> and the key is removed from the<em> hashmap. </em>A<em> tombstone </em>is simply a marker value to indicate that the key has been deleted.</p><p>This is how it will look …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9SVV9cmERj8x1CSKtrmgQ.png" /><figcaption>After deleting <em>ore_spawn_rate</em></figcaption></figure><p>Superb 🥳 we have all these working !!</p><ul><li>Add a <em>{ key : value }</em></li><li>Get a <em>key</em></li><li>Delete a <em>key</em></li></ul><p>Lets now talk about the append-only files …</p><p>Whenever the size of a append-only file reaches a threshold (could be the size of the file) then it closes that file and opens the next one to append the <em>{ key : value } </em>pair. So the files go on as <em>data-0.db</em>, <em>data-1.db</em>, <em>data-2.db</em>, <em>data-3.db</em> etc.</p><p>Have you noticed something, what if we kept entries to the same <em>key, </em>the append-only files will grow and become huge and you will notice the ratio of size taken by append-only files to the size of the actual <em>{ key : value } </em>pairs will be high number due to high redundancy. This is solved by a process called compaction.</p><p><em>Compaction is a process where you run through all the files and get all the keys along with their latest value and then write it to a new set of append-only files replacing the old one, due to which you massively reduce the number of files. Compaction is a very expensive operation and it happens periodically to ensure the database does not grow too big.</em></p><p>Lets now talk about the in-memory <em>hashmap</em> …</p><p>One of the major drawbacks of the <em>Bitcask</em> paradigm is that the size of the in-memory <em>hashmap</em> is limited by the available RAM. In general, keys tend to be small, while values can range from a single word to an entire file. So imagine storing a <em>hashmap</em> whose values are <em>insanely</em> large in RAM — <br> this will inevitably lead to an out-of-memory problem! 💀</p><p>A solution to this is to store the <em>key</em> and the file-name and seek-value for the <em>value </em>in the<em> hashmap.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9Gf4xprPCedbJBLgATGHA.png" /></figure><p>So here the <em>hashmap</em> says that the latest value to key <em>favourite_book</em> is in file <em>data-1.db</em> and at an offset of 44 from the beginning of the file. This allows you to immediately get (<em>seek</em>) the latest value from the exact file and helps the <em>hashmap</em> to exist in in-memory (without growing too big).</p><h3>Conclusion</h3><p>Looks like we have a distributed key-value store now allowing for add, get, delete operations with a compaction process running periodically. This satisfies my 1st requirement 🥳.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYeHCdvxEnIWHlxVnzrXZg.png" /><figcaption>A cluster of nodes</figcaption></figure><p>My 2nd requirement is being able to replicate a file to all nodes. Imagine I’m working on <em>Node D</em> having file <em>File_1.txt</em>. I want the same file to be available in other nodes. 😤 (<em>For some weird reason </em>😅)</p><p>Since I already had a functional distributed key-value store, I decided to reuse it 😅 because a file can be represented as <em>{ key : value } </em>pair where <em>file_name</em> can serve as the <em>key</em> and the <em>file_content</em> can serve as the <em>value</em>.</p><p>Cool !! We have met both requirements. Looks like we just built ourselves a distributed key-value store with a <em>bitcask</em> backend. ☺️</p><p>Check out <a href="https://github.com/AMS003010/Hyphora"><em>Hyphora</em></a><em> </em>!!</p><h4>References</h4><ul><li><a href="https://arpitbhayani.me/blogs/bitcask/">https://arpitbhayani.me/blogs/bitcask</a></li><li><a href="https://notes.eatonphil.com/minimal-key-value-store-with-hashicorp-raft.html">https://notes.eatonphil.com/minimal-key-value-store-with-hashicorp-raft.html</a></li><li><a href="https://a3y3.dev/distributed-systems/2022/07/24/kv-store.html">https://a3y3.dev/distributed-systems/2022/07/24/kv-store.html</a></li><li><a href="https://rowjee.com/the_replicated_log/0002">https://rowjee.com/the_replicated_log/0002</a></li></ul><p><em>Do </em>👏<em> If you liked the article and check out my articles </em><a href="https://medium.com/@ams_132"><em>@ams_132</em></a><em> !!!</em></p><p><em>Sayonara until next time…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f44c4ff9ba8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSOC 2025: Center for Translational Data Science]]></title>
            <link>https://medium.com/@ams_132/gsoc-2025-center-for-translational-data-science-fda147e16cf6?source=rss-93ef70aee8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fda147e16cf6</guid>
            <category><![CDATA[gsoc-2025]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Abhijith M S]]></dc:creator>
            <pubDate>Sat, 30 Aug 2025 19:58:02 GMT</pubDate>
            <atom:updated>2025-08-30T20:14:55.254Z</atom:updated>
            <content:encoded><![CDATA[<p>Towards a Data Commons Operations Center with Observability and Monitoring</p><figure><img alt="Google Summer of Code Logo" src="https://cdn-images-1.medium.com/max/1024/1*dcK8hQubRKbWF0UbQ7o2gA.png" /><figcaption>Source of <a href="https://opensource.googleblog.com/2023/11/google-summer-of-code-2024-celebrating-20th-year.html">Image</a></figcaption></figure><p>Contributor: <a href="https://github.com/AMS003010">Abhijith M S</a></p><p>Mentor: <a href="https://github.com/jawadqur">J. Qureshi</a></p><h3>Introduction:</h3><p>As <strong>GSoC 2025</strong> comes to an end, I realize that I have never learned so much in such a short span of time, and for that, I will remain forever grateful. While I have always been interested in contributing to open source, this experience has truly fueled my passion to continue doing so.</p><p>One of the most rewarding parts of this journey was being exposed to new tools and technologies, many of which have now become a part of my daily development workflow. I had the opportunity to work with and learn about powerful systems and protocols such as <strong>Keycloak</strong>, <strong>gRPC</strong>, <strong>WebSockets</strong>, and <strong>SPDY</strong>, all of which significantly broadened my technical understanding and hands-on experience.</p><p>I would like to extend my heartfelt thanks to my mentor, <strong>Jawad Qureshi</strong>, for his constant guidance, patience, and encouragement throughout the project. His support not only helped me navigate challenges but also inspired me to push my limits and grow as a developer.</p><p>This blog is about my GSOC experience working under the CTDS organization. All my commits can be found <a href="https://github.com/uc-cdis/gen3-admin/pull/55">here</a>.</p><h4><strong>About the organization:</strong></h4><p><strong>The Center for Translational Data Science </strong>at the University of Chicago develops and operates large-scale data platforms to support research in topics of societal interest.</p><p>The organization operates a data ecosystem with their partners, comprising over a dozen data commons that make over 10 PB of data available to the research community. These are all based on the open-source Gen3 data platform, which includes the Gen3 data commons, Gen3 Framework Services, and Gen3 Workspaces.</p><p>I was involved in contributing to the CSOC Dashboard which would serve as a multiple gen3 cluster observation dashboard in terms of Observability and Monitoring.</p><h4><strong><em>CSOC</em></strong></h4><p>The Gen3 CSOC Dashboard is a centralized platform designed to facilitate the management of multiple Gen3 deployments and Kubernetes clusters. Built with scalability and enterprise requirements in mind, it provides system administrators and operators with a comprehensive set of tools to deploy, monitor, and manage their Gen3 ecosystems effectively across cloud-native environments.</p><h4><strong>About the project:</strong></h4><ul><li>The project focused on building a <strong>centralized platform to deploy and manage Gen3 clusters efficiently</strong>, providing a single point of control for administrators.</li><li>My contributions were primarily centered around enhancing the platform’s functionality and user experience. I worked on <strong>integrating Keycloak for authentication and access management</strong>, <strong>developing an environment overview feature</strong> to give users better visibility into cluster resources, and <strong>implementing a shell access feature</strong> that allows users to connect directly to a container inside a pod through the UI.</li><li>The project leveraged a modern tech stack, including <strong>Gin (Golang)</strong> for the backend, <strong>Next.js</strong> for the frontend, and container orchestration tools such as <strong>Docker</strong>, <strong>Kubernetes</strong>, and <strong>Helm</strong>.</li></ul><h4>Why I chose this project:</h4><ul><li>I wanted to gain hands-on exposure to <strong>cloud technologies</strong>, and this project gave me exactly that -working directly with a deployed Gen3 cluster on Rackspace was an exciting opportunity 😋.</li><li>Having explored <strong>Golang</strong> and frontend technologies like <strong>Next.js</strong>, <strong>React.js</strong>, and <strong>Tailwind CSS</strong> for some time, I was eager to put my skills into action by contributing to open source, and CTDS provided the perfect platform for it. The frontend used <strong>Mantine UI</strong> (Something I was excited to use for the first time 😊)</li><li>What really drew me in was the project’s complexity: so many components interacting with each other over a network, using different <strong>protocols and architectures</strong>. That challenge was both exciting and motivating, making it the ideal project for me to learn and grow !!</li></ul><h4>Deliverables of the project:</h4><ul><li>Integration of <strong>Keycloak </strong>for authentication and access management</li><li>Developing an <strong>environment overview</strong> of a cluster</li><li>Implementing a<strong> shell access feature</strong> that allows users to connect directly to a container inside a pod through the UI</li></ul><h4>Keycloak Integration:</h4><p>Keycloak is an <strong>open-source identity and access management solution</strong> that provides features like single sign-on (SSO), user federation, and role-based access control. It allows developers to secure applications and services without having to handle authentication and authorization logic manually. Keycloak supports modern protocols such as <strong>OAuth2.0, OpenID Connect, and SAML</strong>, making it easy to integrate with a wide range of applications. It is widely used to centralize authentication, manage users, and streamline secure access across distributed systems.</p><p>The authentication and authorization workflow was designed so that users log into the <strong>CSOC portal</strong> through the <strong>Keycloak login page</strong>, which issues both <strong>access tokens (JWTs)</strong> and <strong>refresh tokens</strong>. This flow was integrated with <strong>NextAuth</strong> to manage user sessions and automatically refresh tokens when needed. Keycloak embeds user-specific roles and groups directly into the access token, which is then sent by the frontend with each request to the backend server (built with <strong>Gin</strong>) for access control.</p><p>On the backend, the server parses the JWT to extract details such as user information, roles, and groups, and enforces authorization policies accordingly. The system supports three role types — <strong>Read</strong>, <strong>Write</strong>, and <strong>Superadmin</strong> — all of which can be managed centrally through the <strong>Keycloak admin console</strong>.</p><h4>Environment Overview Dashboard:</h4><p>CSOC is designed to simplify the management of not only clusters as a whole but also the individual resources within them and it supports managing <strong>multiple clusters</strong> seamlessly. The <strong>Environment Overview</strong> dashboard provides key metrics such as overall CPU and memory usage, per-pod CPU and memory consumption, and the real-time status of each pod. It also displays all cluster events while highlighting critical ones separately, enabling users to monitor the cluster’s health and activity at a glance.</p><p>The dashboard was built using <strong>Mantine UI</strong>, which offered a rich set of ready-to-use components including icons, charts, and interactive UI elements, that made development faster and the interface more user-friendly.</p><h4>Container Shell Access:</h4><p>This feature enables administrators to open an <strong>interactive shell session</strong> directly within any pod of their cluster, without leaving the <strong>CSOC portal</strong>. The terminal interface is built using <strong>xterm.js</strong>, providing a fully interactive, in-browser terminal experience.</p><p><strong>SPDY</strong> is a now-deprecated Google protocol that laid the foundation for HTTP/2, designed to reduce latency by enabling multiplexed streams over a single TCP connection. Kubernetes still relies on SPDY for certain operations such as kubectl exec, port forwarding, and attach. In this project, the <strong>SPDY executor</strong> was used to establish and manage low-level streams between the Kubernetes client and container.</p><p><strong>WebSockets</strong>, on the other hand, provide a <strong>full-duplex communication channel</strong> over a single TCP connection, making them ideal for interactive, real-time use cases like terminal sessions. In this implementation, WebSocket traffic between the frontend and backend is further routed through <strong>gRPC secure (gRPCs) channels</strong> between the CSOC server and the cluster agents, ensuring encrypted, efficient, and reliable communication.</p><p>The workflow begins when the frontend sends an <strong>HTTP request</strong> to the backend server (Gin). This request is <strong>upgraded to a WebSocket connection</strong>, which is then tunneled over the <strong>gRPCs channel</strong> to the corresponding <strong>cluster agent</strong>. The agent leverages the <strong>Kubernetes client-go library</strong> to create a Kubernetes client and uses the <strong>SPDY executor</strong> to initiate an exec session into the target container. All required metadata—such as the <strong>container name, namespace, and cluster identifier</strong>—is included in the initial request to establish the correct execution context.</p><p>This architecture enables secure, low-latency, bi-directional communication between the browser-based terminal and the container, effectively replicating <strong>kubectl exec</strong> functionality inside the CSOC dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8dhTJ4-SIBW7SM41e6Szyw.png" /><figcaption>Container Shell Access Workflow</figcaption></figure><h4><strong>Testing:</strong></h4><p>The code was primarily validated using <strong>manual unit tests</strong>, given the distributed nature of the project and the multiple components interacting across different layers.</p><p>The tests covered not only the core functionality but also a variety of edge cases, such as <strong>invalid or false authorization attempts</strong>, <strong>sustaining long-running terminal sessions</strong>, and <strong>handling incorrect Keycloak realm configurations</strong>. This ensured that the system remained robust and reliable under different scenarios.</p><h4>Future Scopes:</h4><ul><li><strong>Terraform integration</strong> to streamline infrastructure provisioning and automated deployments.</li><li>Enhanced observability through proper integration of <strong>Mimir</strong> (for metrics) and <strong>Loki</strong> (for log aggregation).</li></ul><h4>Challenges I faced</h4><ul><li><strong>Familiarizing with the repository</strong> took longer than expected, but with my mentor’s guidance in pointing out the most relevant areas, I was able to navigate it effectively.</li><li><strong>Adapting to Mantine UI</strong> was initially challenging, as its component patterns felt quite different compared to the more familiar frameworks I had worked with, like Next.js.</li><li><strong>Optimizing concurrency with goroutines</strong> required a learning curve to understand best practices and ensure the code was both efficient and reliable.</li></ul><h4>What I learnt in GSoC</h4><ul><li>Proper use of <strong>GitHub</strong> and best practices</li><li><strong>Go concurrency</strong> with goroutines, waitgroups, and channels</li><li><strong>gRPC</strong>, <strong>protobufs</strong>, and protocols like WebSockets &amp; SPDY</li><li>Working with the <strong>Kubernetes API</strong></li><li>Explored <strong>FlatBuffers</strong> and <strong>zero-allocation logging</strong></li></ul><h3>My GSOC journey (May 2025 — September 2025)</h3><h4>Community Bonding Period (May 8 — June 1)</h4><ul><li>During this phase, I spent time getting familiar with what the community does, their projects and practices.</li><li>I joined their slack and introduced myself</li></ul><h4>Coding Period I (June 2 — July 18)</h4><ul><li>During this phase, I spent time getting familiar with the project repository, exploring the codebase, and setting up my development environment.</li><li>I also got to know my mentor and discussed the scope of work, milestones, and expectations for the summer.</li><li>Implemented the environment overview dashboard</li><li>Researched into how to integrate Keycloak into CSOC and started implemention</li></ul><h4>Coding Period II (July 18 — August 25)</h4><ul><li>Completely implemented Keycloak Integration</li><li>Looked into making the environment overview dashboard better</li><li>Implemented shell access for container in a pod</li><li>Added documentation of how to configure keycloak</li></ul><h3>Overall Experience</h3><p>Participating in <strong>GSoC 2025</strong> has been one of the most rewarding experiences of my journey so far. It gave me the chance to work on real-world problems, improve my technical skills, and gain confidence in contributing to open source. Beyond just coding, I learned how to approach problems systematically, collaborate effectively, and deliver work that others can build upon.</p><p>I’m truly grateful for this opportunity and excited to continue contributing to open source in the future. Hopefully, this is just the beginning, and I look forward to taking on even bigger challenges in the years to come.</p><p>Thank you for reading the blog! Please leave your feedback in the comment section.</p><p>Abhijith M S</p><p>GSoC Contributor, 2025</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fda147e16cf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cache It or Lose It: The Power⚡of LRU]]></title>
            <link>https://medium.com/@ams_132/cache-it-or-lose-it-the-power-of-lru-b669b43e527b?source=rss-93ef70aee8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b669b43e527b</guid>
            <category><![CDATA[system]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[lru-cache]]></category>
            <category><![CDATA[optimisation]]></category>
            <category><![CDATA[cache]]></category>
            <dc:creator><![CDATA[Abhijith M S]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 07:11:50 GMT</pubDate>
            <atom:updated>2025-01-08T07:11:50.171Z</atom:updated>
            <content:encoded><![CDATA[<p>All that you need to know about Caching and a implementation of LRU Caching in Rust 🦀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RPnlhU4_oqvHf6CAab_pxQ.jpeg" /><figcaption>Generated with <a href="https://leonardo.ai/"><strong>Leonardo.ai</strong></a></figcaption></figure><h3>What is a Cache ?</h3><p>In computing, a Cache is a software or hardware component in a system which aids the system by increasing its performance. It stores data so that any future requests for that data can be served faster. The data stored could be the result of an earlier computation or a copy of the data stored elsewhere. It basically helps a system increase its performance by improving the availability of required data through a compromise of memory by storing the required data elsewhere.</p><p>A <strong>Cache Hit </strong>✅ occurs when the requested data was found in the cache and a <strong>Cache Miss </strong>❎ occurs when the requested data was not found in the cache.</p><p>We will be primarily be discussing about caches with respect to software.</p><h3>Software Caches 💽</h3><p>So these caches basically store data in order to speed up the process of data retrieval by having better availability of the requested data. It could be anything from storage unit to just a simple data structure like a HashMap. It could be in different formats like:</p><ol><li><strong>Disk cache 💾 </strong>: A disk cache is a type of cache that stores frequently accessed or recently used data on a disk (such as a hard drive or solid-state drive).</li><li><strong>Web cache </strong>🗄️: Here proxy servers could be setup in a network to store data that is frequently accessed by many users. It could cache web pages or images to speed up the process when a client requests for a certain web page.</li><li><strong>Memoization </strong>📝 <strong>:</strong> It is a optimization techniques that involves caching the result for compute intensive function calls onto a Hashtable for faster retrieval. It is done to avoid repetitive computation.</li><li><strong>CDN </strong>🚚<strong> : Content Delivery Network</strong> speed up the delivery of static content, such as HTML pages, images and videos by replicating the content in multiple servers around the world and delivering it to users based on location.</li></ol><h3>Cache Implementation in Rust 🦀</h3><p>Here we will see how to build a basic yet efficient Least Recently Used (<strong>LRU</strong>) cache system in Rust, with an eviction policy.</p><p>We will start with a basic implementation and then move on with adding features like efficient tracking of item usage, concurrency support ( and will probably add the integration of eviction callbacks to handle resource cleanup upon item removal 😋)</p><h4>Basic Approach</h4><pre>// Implementing a basic key-value cache without an eviction policy<br><br>use std::collections::HashMap;<br>use std::hash::Hash;<br><br>pub struct Cache&lt;K,V&gt; where K: Eq + Hash + Clone {<br>    storage: HashMap&lt;K, V&gt;,<br>}<br><br>impl&lt;K, V&gt; Cache&lt;K, V&gt; where K: Eq +  Hash + Clone {<br>    pub fn new() -&gt; Self {<br>        Cache {<br>            storage: HashMap::new(),<br>        }<br>    }<br><br>    pub fn set(&amp;mut self, key: K, value: V) {<br>        self.storage.insert(key, value);<br>    }<br><br>    pub fn get(&amp;self, key: &amp;K) -&gt; Option&lt;&amp;V&gt; {<br>        self.storage.get(key)<br>    }<br>}<br><br>fn main(){<br>    let mut cache = Cache::new();<br><br>    cache.set(&quot;key1&quot;,&quot;value1&quot;);<br>    cache.set(&quot;key2&quot;,&quot;value2&quot;);<br><br>    if let Some(value) = cache.get(&amp;&quot;key1&quot;) {<br>        println!(&quot;Found value: {}&quot;, value);<br>    } else {<br>        println!(&quot;value not found&quot;);<br>    }<br><br>    match cache.get(&amp;&quot;key2&quot;) {<br>        Some(val) =&gt; println!(&quot;Found value: {}&quot;, val),<br>        None =&gt; println!(&quot;Value not found&quot;)<br>    }<br><br>    match cache.get(&amp;&quot;key4&quot;) {<br>        Some(val) =&gt; println!(&quot;Found value: {}&quot;, val),<br>        None =&gt; println!(&quot;Value not found&quot;)<br>    }<br>}</pre><p>Here we initialize a struct <strong><em>Cache</em></strong> which creates a HashMap on instantiating the <strong><em>Cache</em></strong> struct. A HashMap is a data structure that is used to store and retrieve values based on keys. <strong><em>set</em></strong> and <strong><em>get</em></strong> methods are added in order to insert key-value pairs and retrieve value based on the key respectively.</p><p>This is a very basic implementation of a cache. Now let’s add more features and make it more efficient. 😋</p><h4>Implementing an eviction policy</h4><p>The cache will have a fixed size due to which we will have to decide which data to keep and which data to remove. It could be on different factors like priority, least recently used etc. Different eviction policies:</p><ul><li>Least Recently Used (LRU)</li><li>First In, First Out (FIFO)</li><li>Least Frequently Used (LFU)</li><li>Time-Based Expiration (TTL or Time-to-Live)</li><li>Weighted Least Recently Used (WLRU)</li><li>Segmented LRU (SLRU)</li><li><em>and many more …</em></li></ul><p>We will be using Least Recently Used (LRU) as the eviction policy. An LRU cache evicts the least recently accessed item when the cache reaches its capacity in order to add new items into the cache.</p><p>We will enhance the previous example by adding a fixed capacity to the cache and also track the usage of each item in the cache using a combination of a <strong><em>HashMap</em></strong> and a <strong><em>VecDeque</em></strong> (a double ended queue). The <strong><em>VecDeque</em></strong> is used to store the order of usage of the items stored while the <strong><em>HashMap </em></strong>is used to store the actual data as key-value pairs.</p><pre>// Implementing a key-value cache with an LRU policy using a HashMap and double ended queue<br><br>use std::collections::{HashMap, VecDeque};<br>use std::hash::Hash;<br><br>pub struct LRUCache&lt;K, V&gt; where K: Eq +  Hash + Clone {<br>    storage: HashMap&lt;K, V&gt;,<br>    capacity: usize,<br>    usage_order: VecDeque&lt;K&gt;,<br>}<br><br>impl&lt;K, V&gt; LRUCache&lt;K, V&gt; where K: Eq + Hash + Clone {<br>    pub fn new(capacity: usize) -&gt; Self {<br>        assert!(capacity&gt;0, &quot;Cache size cannot be 0&quot;);<br>        LRUCache {<br>            storage: HashMap::new(),<br>            capacity: capacity,<br>            usage_order: VecDeque::new(),<br>        }<br>    }<br><br>    pub fn set(&amp;mut self, key: K, value: V) {<br>        self.storage.insert(key.clone(),value);<br>        self.update_usage(&amp;key);<br>        if self.storage.len() &gt; self.capacity {<br>            if let Some(least_used_key) = self.usage_order.pop_back() {<br>                self.storage.remove(&amp;least_used_key);<br>            }<br>        }<br>    }<br><br>    pub fn get(&amp;mut self, key: &amp;K) -&gt; Option&lt;&amp;V&gt; {<br>        if self.storage.contains_key(key) {<br>            self.update_usage(key);<br>            self.storage.get(key)<br>        } else {<br>            None<br>        }<br>    }<br><br>    // Updates the position of keys<br>    fn update_usage(&amp;mut self, key: &amp;K) {<br>        self.usage_order.retain(|existing_key| existing_key!=key);<br>        self.usage_order.push_front(key.clone());<br>    }<br>}<br><br>fn main() {<br>    let mut cache = LRUCache::new(2);<br>    cache.set(&quot;key1&quot;,&quot;val1&quot;);<br>    cache.set(&quot;key2&quot;,&quot;val2&quot;);<br>    cache.set(&quot;key4&quot;,&quot;val4&quot;);<br>    println!(&quot;key1 : {:?}&quot;,cache.get(&amp;&quot;key1&quot;));<br>    cache.set(&quot;key3&quot;,&quot;val3&quot;);<br>    match cache.get(&amp;&quot;key4&quot;) {<br>        Some(val) =&gt; println!(&quot;key4 : {}&quot;,val),<br>        None =&gt; println!(&quot;No value found&quot;)<br>    }<br>}</pre><p>Here you can notice that the cache is instantiated with a capacity of 2, meaning it can store a maximum of 2 items. Key-value &lt;key1:val1&gt; is stored onto the cache followed by Key-value &lt;key2:val2&gt;, then Key-value &lt;key4:val4&gt; is stored. On trying to add Key-value &lt;key4:val4&gt;, Key-value &lt;key1:val1&gt; is evicted as it is the least recently used key-value pair. Then Key-value &lt;key4:val4&gt; is added to the cache.</p><p>The above example is modified by using doubly-linked list for efficient tracking.</p><pre>// Implementing a key-value cache with an LRU policy using a HashMap and doubly linked list for better order tracking<br><br>use std::collections::HashMap;<br>use std::rc::{Rc, Weak};<br>use std::cell::RefCell;<br>use std::hash::Hash;<br><br>struct Node&lt;K, V&gt; {<br>    key: K,<br>    value: V,<br>    prev: Option&lt;Weak&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;&gt;,<br>    next: Option&lt;Rc&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;&gt;,<br>}<br><br>impl&lt;K, V&gt; Node&lt;K, V&gt; {<br>    fn new(key: K, value: V) -&gt; Rc&lt;RefCell&lt;Self&gt;&gt; {<br>        Rc::new(RefCell::new(Node {<br>            key,<br>            value,<br>            prev: None,<br>            next: None,<br>        }))<br>    }<br>}<br><br>pub struct LRUCache&lt;K, V&gt; where K: Eq + Hash + Clone {<br>    capacity: usize,<br>    map: HashMap&lt;K, Rc&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;&gt;,<br>    head: Option&lt;Rc&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;&gt;,<br>    tail: Option&lt;Rc&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;&gt;,<br>}<br><br>impl&lt;K: Eq + Hash + Clone, V: Clone&gt; LRUCache&lt;K, V&gt; {<br>    pub fn new(capacity: usize) -&gt; Self {<br>        assert!(capacity &gt; 0, &quot;Cache capacity must be greater than 0&quot;);<br>        LRUCache {<br>            capacity,<br>            map: HashMap::new(),<br>            head: None,<br>            tail: None,<br>        }<br>    }<br>    <br>    pub fn set(&amp;mut self, key: K, value: V) {<br>        if let Some(node) = self.map.get(&amp;key).cloned() {<br>            node.borrow_mut().value = value;<br>            self.detach(&amp;node);<br>            self.attach(node);<br>        } else {<br>            let new_node = Node::new(key.clone(), value);<br>            if self.map.len() &gt;= self.capacity {<br>                if let Some(lru_key) = self.tail.as_ref().map(|node| node.borrow().key.clone()) {<br>                    self.remove(&amp;lru_key);<br>                }<br>            }<br>            self.map.insert(key, new_node.clone());<br>            self.attach(new_node);<br>        }<br>    }<br><br>    pub fn get(&amp;mut self, key: &amp;K) -&gt; Option&lt;V&gt; {<br>        self.map.get(key).cloned().map(|node| {<br>            let value = node.borrow().value.clone();<br>            self.detach(&amp;node);<br>            self.attach(node);<br>            value<br>        })<br>    }<br><br>    fn remove(&amp;mut self, key: &amp;K) -&gt; Option&lt;V&gt; {<br>        self.map.remove(key).map(|node| {<br>            self.detach(&amp;node);<br>            node.borrow().value.clone()<br>        })<br>    }<br><br>    fn detach(&amp;mut self, node: &amp;Rc&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;) {<br>        let mut node = node.borrow_mut();<br>        <br>        match (node.prev.take(), node.next.take()) {<br>            (None, None) =&gt; {<br>                // Node was the only one in the list<br>                self.head = None;<br>                self.tail = None;<br>            }<br>            (None, Some(next)) =&gt; {<br>                // Node was the head<br>                next.borrow_mut().prev = None;<br>                self.head = Some(next);<br>            }<br>            (Some(prev), None) =&gt; {<br>                // Node was the tail<br>                if let Some(prev) = prev.upgrade() {<br>                    prev.borrow_mut().next = None;<br>                    self.tail = Some(prev);<br>                }<br>            }<br>            (Some(prev), Some(next)) =&gt; {<br>                // Node was in the middle<br>                if let Some(prev) = prev.upgrade() {<br>                    prev.borrow_mut().next = Some(next.clone());<br>                    next.borrow_mut().prev = Some(Rc::downgrade(&amp;prev));<br>                }<br>            }<br>        }<br>    }<br><br>    fn attach(&amp;mut self, node: Rc&lt;RefCell&lt;Node&lt;K, V&gt;&gt;&gt;) {<br>        match self.head.take() {<br>            Some(old_head) =&gt; {<br>                old_head.borrow_mut().prev = Some(Rc::downgrade(&amp;node));<br>                node.borrow_mut().next = Some(old_head.clone());<br>                self.head = Some(node);<br>            }<br>            None =&gt; {<br>                // List was empty<br>                self.head = Some(node.clone());<br>                self.tail = Some(node);<br>            }<br>        }<br>    }<br>}<br><br>fn main() {<br>    let mut cache = LRUCache::new(2);<br>    cache.set(&quot;key1&quot;, &quot;value1&quot;);<br>    cache.set(&quot;key2&quot;, &quot;value2&quot;);<br>    println!(&quot;Retrieved: {:?}&quot;, cache.get(&amp;&quot;key1&quot;)); // Access key1, making it most recently used<br>    cache.set(&quot;key3&quot;, &quot;value3&quot;); // Should evict key2 as it is the least recently used<br>    match cache.get(&amp;&quot;key2&quot;) {<br>        Some(value) =&gt; println!(&quot;Retrieved: {:?}&quot;, value),<br>        None =&gt; println!(&quot;Key2 was evicted&quot;), // Expected outcome<br>    }<br>    // Verify key3 is in the cache<br>    match cache.get(&amp;&quot;key3&quot;) {<br>        Some(value) =&gt; println!(&quot;Key3 is in cache with value: {:?}&quot;, value),<br>        None =&gt; println!(&quot;Key3 is not in cache (unexpected)&quot;),<br>    }<br>}</pre><p>Each node in the list contains a key-value pair, and the list maintains pointers to the most and least recently used items. When an item is accessed or added, it’s moved to the front of the list. If the cache exceeds its capacity, the item at the end of the list (the least recently used item) is removed.</p><h3>References</h3><ol><li><a href="https://medium.com/dev-genius/a-simple-cache-system-in-rust-7cf3d2489607">https://medium.com/dev-genius/a-simple-cache-system-in-rust-7cf3d2489607</a></li><li><a href="https://en.wikipedia.org/wiki/Cache_(computing)">https://en.wikipedia.org/wiki/Cache_(computing)</a></li></ol><p>Hope you enjoyed it !!!</p><p>Stay tuned and Do make sure to check out my articles <a href="https://medium.com/@ams_132">@ams_132</a> !!!</p><p><em>Do </em>👏<em> If you liked the article</em></p><p>So always remember <em>Everything’s faster when you cache your way through life.</em>😉</p><p><em>Sayonara until next time…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b669b43e527b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerizing a Rust application with Multi-Stage Builds]]></title>
            <link>https://medium.com/@ams_132/dockerizing-a-rust-application-with-multi-stage-builds-31ac8a5ce7c7?source=rss-93ef70aee8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/31ac8a5ce7c7</guid>
            <category><![CDATA[efficiency]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[alpine]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[microservice-architecture]]></category>
            <dc:creator><![CDATA[Abhijith M S]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 15:22:06 GMT</pubDate>
            <atom:updated>2024-12-11T17:21:32.603Z</atom:updated>
            <content:encoded><![CDATA[<p>Create a Docker image for your Rust application with minimal image size ⚒️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3TVI8eOhADFj2lPfLFbrA.png" /><figcaption>Sourced from <a href="https://www.21analytics.ch/blog/docker-from-scratch-for-rust-applications/">https://www.21analytics.ch/blog/docker-from-scratch-for-rust-applications/</a></figcaption></figure><p>New to Docker 🧐,</p><p>Ever tried building the docker image of your application with just simple/base Dockerfiles, giving you large image sizes ( &gt;800Mb ) which ended up eating up all your RAM.😭</p><p>Don’t worry 😙, you aren’t alone….</p><p>Here, I am going to be talking specifically about building a lightweight image for your Rust Application. Will be releasing for other applications in the (not so distant 😅) future…</p><blockquote>According to <a href="https://aws.amazon.com/docker/#:~:text=Docker%20is%20a%20software%20platform,tools%2C%20code%2C%20and%20runtime.">AWS</a>,</blockquote><blockquote>Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called <a href="https://aws.amazon.com/containers/">containers</a> that have everything the software needs to run including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know your code will run.</blockquote><blockquote>Chill<em>😄</em> It’s basically solves the problem of “It RUNS of my MACHINE”. It allows you to run your application as a container on any OS having the Docker Daemon ( right now which is practically any OS )</blockquote><p>Let’s talk about methods that can be used to make your image as light as possible:</p><ol><li>Using Multi-Stage builds</li><li>Using light weight images like <em>alpine</em>, <em>slim</em> etc. to run your executable</li></ol><p>Building an image using these methods vs building with a simple/base Dockerfile has a lot of difference in terms of the image size. ( I’m talking about 1Gb &lt;==&gt; 20Mb )</p><p>That can make quite a lot of difference when dealing with an actual infrastructure. 😤And the best way to understand the difference is to do it firsthand and compare the sizes. 😉</p><p>( Psst🐱 I’ll be using a simple Rust app for creating the image )</p><blockquote><em>Repo link </em><a href="https://github.com/AMS003010/Rust-Docker"><em>https://github.com/AMS003010/Rust-Docker</em></a></blockquote><h3>Create an Image with a Simple Dockerfile</h3><p><strong>Prerequisites:</strong></p><ol><li>Rust installed</li><li>Cargo installed ( Package manager for Rust📦 )</li></ol><p><strong>Steps:</strong></p><pre>cargo new simple</pre><pre>cd simple<br>nano Dockerfile</pre><p>Paste in the below, to the <em>Dockerfile</em></p><pre># Use the official Rust image from Docker Hub<br>FROM rust:latest<br><br># Set the working directory inside the container<br>WORKDIR /usr/src/myapp<br><br># Copy the project files into the container<br>COPY . .<br><br># Build the project<br>RUN cargo build --release<br><br># Set the default command to run the application<br>CMD [&quot;./target/release/myapp&quot;]</pre><p>Now since we have the docker configuration file ready lets build it ( Make sure to have your Docker Daemon😈 running… )</p><pre>Docker build -t simple-rust-app .</pre><p>After the image has been built, check for in the docker images</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TyajarnDpILjEMLmoJOtoA.png" /></figure><p>You can see that the image “simple-rust-app” that we built has a size of 1.42Gb 🤯.</p><p>Let’s now see the optimized way to do it…</p><h3>Create an Image with Multi-Stage Builds</h3><p>Here we are going to be using the same Rust application but with changes only to the <em>Dockerfile.</em></p><p>Just notice, how by adding few more lines to your <em>Dockerfile</em> will give you a light and optimized build.</p><p>So what are we doing in Multi-Stage Build🧐…</p><p>Our main focus here is to have only the final executable which is run on a minimal <em>distro </em>like<em> alpine </em>to give us the most optimized performance. This includes compilers like <em>rustc, </em>package managers like <em>cargo</em> and even build artifacts which are not actually required and should not be included in the final image. So all the unnecessary components have to be removed.</p><p>For this we build our application and fetch all the required dependencies in a image like <em>rust:1.75.0 </em>and then we transfer the necessary files from the build stage to another base image like <em>alpine</em> and run the executable there.</p><p>Also, some security practices tips 💡</p><ol><li>The executable should be run on the base image as a non-privileged user and not as root user.</li><li>The number of packages should be kept minimal as necessary, because fewer packages means fewer vulnerability risks ( also smaller size😤 ).</li></ol><p>Now that we have understood Multi-Stage Builds let’s implement. Paste the below into your Dockerfile.</p><pre>ARG RUST_VERSION=1.75.0<br>ARG APP_NAME=singularity<br><br>FROM rust:${RUST_VERSION}-alpine AS build<br>ARG APP_NAME<br>WORKDIR /app<br><br>RUN apk add --no-cache clang lld musl-dev git<br><br>RUN --mount=type=bind,source=src,target=src \<br>    --mount=type=bind,source=Cargo.toml,target=Cargo.toml \<br>    --mount=type=bind,source=Cargo.lock,target=Cargo.lock \<br>    --mount=type=cache,target=/app/target/ \<br>    --mount=type=cache,target=/usr/local/cargo/git/db \<br>    --mount=type=cache,target=/usr/local/cargo/registry/ \<br>cargo build --locked --release &amp;&amp; \<br>cp ./target/release/$APP_NAME /bin/server<br><br><br>FROM alpine:3.18 AS final<br><br>ARG UID=10001<br>RUN adduser \<br>    --disabled-password \<br>    --gecos &quot;&quot; \<br>    --home &quot;/nonexistent&quot; \<br>    --shell &quot;/sbin/nologin&quot; \<br>    --no-create-home \<br>    --uid &quot;${UID}&quot; \<br>    appuser<br>USER appuser<br><br># Copy the executable from the &quot;build&quot; stage.<br>COPY --from=build /bin/server /bin/<br><br># What the container should run when it is started.<br>CMD [&quot;/bin/server&quot;]</pre><p>Also remember to paste your Rust Version in the “ARG RUST_VERSION=&lt;rust_version&gt;”.</p><p>You can find that with</p><pre>cargo --version</pre><p>Now build it with</p><pre>docker build -t rust-app-with-multi-stage-build .</pre><p>Once the build has completed, let’s compare the build sizes 🤔</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mrj2MwAGkuXZKRf9gV6wWQ.png" /></figure><p>From 1.42 Gb to 12 Mb, is the power of Multi-Stage Builds 😌</p><p>Hope you enjoyed it !!!</p><p>Stay tuned and Do make sure to check out my articles <a href="https://medium.com/@ams_132">@ams_132</a> !!!</p><p><em>Do </em>👏<em> If you liked the article</em></p><p>So always remember <em>keeping your Dockerfile minimal will keep your Docker image maximum.</em>😉</p><p><em>Sayonara until next time…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31ac8a5ce7c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple MERN App To Get You Off The Ground]]></title>
            <link>https://medium.com/@ams_132/simple-mern-app-to-get-you-off-the-ground-b8b4d1296755?source=rss-93ef70aee8c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8b4d1296755</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[mern-stack]]></category>
            <category><![CDATA[cool-projects]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Abhijith M S]]></dc:creator>
            <pubDate>Tue, 23 Apr 2024 12:47:53 GMT</pubDate>
            <atom:updated>2024-07-13T10:02:53.216Z</atom:updated>
            <content:encoded><![CDATA[<p>A Deep dive into building your first MERN application from scratch</p><figure><img alt="MERN Stack image" src="https://cdn-images-1.medium.com/max/900/1*z5nMFDpKgGiBAag7KA0gYg.jpeg" /><figcaption>Photo from <a href="https://www.talentverse.co/blog/mean-vs-mern-choose-the-right-stack-for-your-business">talentverse</a></figcaption></figure><p><em>CAUTION⚠️ THIS IS A COMPREHENSIVE STARTER FRIENDLY GUIDE TO MERN</em></p><blockquote>Hello Guys<em>,</em></blockquote><blockquote><em>Here we gonna build a simple library management application using the </em>MERN<em> stack, making sure all the basics regarding the stack is covered from building an API with </em>Express.js<em> to building a full blown application in which the </em>React<em> app interacts with a backend Database.</em></blockquote><p>🚨🚨🚨 MAKE SURE TO HAVE <a href="https://nodejs.org/en/download/current">NODE</a> INSTALLED.🚨🚨🚨</p><blockquote><em>So let’s start right away!!</em></blockquote><p><em>This is gonna be a beginner friendly, so don’t worry </em>😁</p><p>If you just want to skip to the repository, find the Github repo link below</p><blockquote><em>Github Repo link — </em><a href="https://github.com/AMS003010/SimpleMernApp">https://github.com/AMS003010/SimpleMernApp</a></blockquote><p>Show your support by starring ⭐ the repo</p><h4><em>What we’re covering</em></h4><ul><li>What a Web Framework is?</li><li>Configuring a <em>MongoDB Atlas</em> Cluster</li><li>Building a API with <em>Express.js</em></li><li>Creating a React App</li><li>Setting a Proxy from your Backend API server to the Frontend React App</li><li>Styling and making Requests from the frontend</li></ul><h3><strong>What is a Web Framework?</strong></h3><p>You might have heard of Unintelligible acronyms like <em>MERN</em>, <em>MEVN</em>, <em>MEAN</em>, <em>LAMP</em>, <em>PERN</em> <em>etc. </em>These are examples of some of the most popular web frameworks. A Web Framework is essentially a collection of tools or libraries that helps to build a full blown web application. Using frameworks, helps make the web development process faster, flexible and more transparent.</p><p>MERN — <em>MongoDB</em>, <em>Express.js</em>, <em>React.js</em>, <em>Node.js</em></p><p>MEVN — <em>MongoDB</em>,<em> Express.js</em>, <em>Vue.js</em>, <em>Node.js</em></p><p>MEAN — <em>MongoDB</em>, <em>Express.js</em>, <em>Angular.js</em>, <em>Node.js</em></p><p>PERN — <em>PostgreSQL</em>, <em>Express.js</em>, <em>React.js</em>, <em>Node.js</em></p><p>BEHM — <em>Bun</em>, <em>Elysia</em>, <em>HTMX</em>, <em>MongoDB</em></p><p>and many more (seriously there’s no end to that😅)</p><blockquote><strong>Fun fact</strong>: HTMX has been making waves in the community due to its ability to be written in a hypertext format (that is what HTML is <em>😌</em>) and being able to give you access to <a href="https://htmx.org/docs/#ajax">AJAX</a>, <a href="https://htmx.org/docs/#css_transitions">CSS Transitions</a>, <a href="https://htmx.org/docs/#websockets">WebSockets</a> and <a href="https://htmx.org/docs/#sse">Server Sent Events</a> directly in HTML, using <a href="https://htmx.org/reference/#attributes">attributes</a>.</blockquote><h3><strong>Configuring a <em>MongoDB Atlas</em> Cluster</strong></h3><p>Lets configure a <a href="https://www.mongodb.com/cloud/atlas/register"><em>MongoDB Atlas</em></a> cluster. Here MongoDB will be used as a Database to store the books (with their details). You can either download <a href="https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows/"><em>MongoDB</em></a> locally on your device (<a href="https://www.mongodb.com/try/download/compass"><em>MongoDB Compass</em></a> is a GUI tool to query and analyze the database) or use <a href="https://www.mongodb.com/cloud/atlas/register"><em>MongoDB Atlas</em></a> to store your data in a serverless environment. I am going to using <em>MongoDB Atlas</em></p><p>Create a account on <a href="https://www.mongodb.com/cloud/atlas/register"><em>https://www.mongodb.com/cloud/atlas/register</em></a></p><p>Click on <strong>Create a deployment</strong></p><p><em>Steps</em></p><ul><li>Choose a <strong>configuration</strong> of your liking( I chose <strong>M0</strong> which was Free and suitable for our application )</li><li>Choose your provider( I chose the default choice )</li><li>Click <strong>Create Deployment</strong></li></ul><p>This should bring you to a Dashboard, Click on <strong>Connect</strong></p><p><em>Steps</em></p><ul><li>Add a username and password</li><li>For connection methods, choose Drivers and then choose Node (with your node version)</li><li>Copy the <strong>connection string</strong>, it looks like the one below</li></ul><pre>mongodb+srv://&lt;username&gt;:&lt;password&gt;@cluster0.tpgdder.mongodb.net/?retryWrites=true&amp;w=majority&amp;appName=Cluster0</pre><ul><li>Replace the <strong>username</strong> and <strong>password</strong> in the string</li><li>For connection methods, choose <strong>Drivers</strong> and then choose Node (with your node version)</li><li>Click on <strong>Network Access</strong> and add your <strong>IP Address</strong></li></ul><p>Now You are all done Configuring MongoDB !!! 🎉</p><h3><strong>Building a API with <em>Express.js</em></strong></h3><blockquote>An API is an acronym for a <strong>Application Programming Interface.</strong> An API is an interface which helps two services to communicate and interact with each other through requests and responses.</blockquote><p>Lets get to building an API !!!😁</p><p>First make the Project Folder</p><pre>mkdir SimpleMernApp<br>mkdir backend<br>cd backend<br>touch .env<br>npm init -y<br>npm install nodemon -g</pre><p>Lets install the dependencies</p><pre>npm install express mongoose dotenv cors express-async-errors</pre><p>Open your <em>package.json</em> file ( This file handles your dependencies ) and add the below code in under the <em>scripts</em> section</p><pre>&quot;start&quot;: &quot;node server.js&quot;,<br>&quot;dev&quot;: &quot;nodemon server.js&quot;</pre><p>Create a <em>.env</em> file and add your environment variables into it</p><pre>MONGO_URI=mongodb+srv://&lt;username&gt;:&lt;password&gt;@cluster0.tpgdder.mongodb.net/?retryWrites=true&amp;w=majority&amp;appName=Cluster0<br>PORT=6000</pre><p>Create a file called <em>db.js</em> and paste the below code. This uses the <em>mongoose</em> module to connect to the <em>MongoDB Atlas</em> Cluster with your mongo connection string.</p><pre>//Contents of db.js<br>const mongoose = require(&#39;mongoose&#39;);<br>require(&#39;dotenv&#39;).config() //module for managing environment variables<br><br>const connection = async () =&gt; {<br>    const connectionParams = {<br>        useNewUrlParser: true,<br>        useUnifiedTopology: true,<br>    };<br>    try {<br>        await mongoose.connect(process.env.MONGO_URI,connectionParams);<br>        console.log(&quot;Connected to Database&quot;);<br>    } catch (error) {<br>        console.log(&quot;Not Connected to Databse&quot;,error);<br>    }<br>}<br>module.exports = connection;</pre><p>Create a <em>model.js</em> file and paste the code below. This file contains the MongoDB database schema, which defines the rules that each field in a document follows. In MongoDB, each record in a database is represented as a document.</p><pre>//Contents of model.js<br>const mongoose = require(&#39;mongoose&#39;);<br><br>const Schema = mongoose.Schema<br><br>const userSchema = new Schema({<br>    name: {<br>        type: String,<br>        required: true,<br>        unique: true<br>    },<br>    author: {<br>        type: String,<br>        required: true<br>    },<br>    publication: {<br>        type: String,<br>        required: true<br>    },<br>    series: {<br>        type: String,<br>        required: true<br>    },<br>    borrowed: {<br>        type: String,<br>        default: null<br>    },<br>    borrowed_on: {<br>        type: Number,<br>        default: null<br>    }<br>});<br><br>const DataModel = mongoose.model(&#39;library_data&#39;,userSchema);<br><br>module.exports = {DataModel};</pre><p>Create a <em>route.js</em> file and paste the below code. This file defines the Express routes and their respective controller functions. Controller functions are simply functions that define the action to be taken upon making an API request at that route.</p><pre>//Contents of route.js<br>const express = require(&#39;express&#39;);<br>const {DataModel} = require(&#39;./model&#39;);<br><br>const router = express.Router()<br><br>router.get(&quot;/getbooks&quot;,async (req,res) =&gt; {<br>    const data = await DataModel.find();<br>    res.status(200).send({&quot;data&quot;:data});<br>} )<br><br>router.post(&quot;/addbook&quot;, async (req,res) =&gt; {<br>    const body = await req.body;<br>    const sendObj = await new DataModel({<br>        &quot;name&quot;: body.name,<br>        &quot;author&quot;: body.author,<br>        &quot;publication&quot;: body.publication,<br>        &quot;series&quot;: body.series<br>    }).save();<br>    res.status(200).send({&quot;msg&quot;:&quot;Book added&quot;});<br>});<br><br>module.exports = router;</pre><p>Create a file called <em>server.js</em> and paste the below code. This file runs the express server at the assigned “PORT”.</p><pre>//Contents of server.js<br>require(&#39;dotenv&#39;).config();<br>require(&#39;express-async-errors&#39;);<br>const express = require(&#39;express&#39;);<br>const app = express();<br>const connection = require(&#39;./db&#39;);<br>const cors = require(&#39;cors&#39;); //Takes care of cross-orign requests<br>const Routes = require(&#39;./route&#39;); //Routes being imported from route.js <br><br>connection();<br><br>app.use(express.json());<br>app.use((req,res,next) =&gt; {<br>    console.log(req.path,req.method)<br>    next()<br>})<br>app.use(cors());<br><br>app.use(&#39;/api&#39;,Routes);<br><br>app.listen(process.env.PORT,() =&gt; {<br>    console.log(&quot;Connected and listening on Port &quot;,process.env.PORT);<br>})</pre><blockquote>“npm run dev” runs nodemon server.js. This module helps speed up the development process. Trust me <em>🫡😌</em></blockquote><p>Run the server ( during the developing phase ) with command.</p><pre>npm run dev</pre><p>Run the server ( during the production phase ) with command</p><pre>npm start</pre><p>Running either of these commands, gets an <em>Express</em> server running at <em>port 6000 </em>ready and waiting to receive requests.</p><p>Also make sure to test out the API endpoints with an application like <a href="http://Run the server ( during the developer phase ) with command npm run dev"><em>POSTMAN</em></a>, <a href="https://jmeter.apache.org/download_jmeter.cgi"><em>Apache JMeter</em></a><em> etc.</em></p><p>Yahoo!!! You just Created an API🎉</p><h3><strong>Creating a React App</strong></h3><p>Let’s now get into some frontend, which will define how your website will behave and look.</p><p>Type the below command to create a react app. Do this in the root folder.</p><pre>npx create-react-app frontend</pre><p>This creates a react app named frontend ( You can name it anything you like )</p><p>Once it is complete, type the command</p><pre>npm install react-router-dom<br>npm start</pre><p>This will run the <em>React App</em> at port 3000. Navigate to <a href="http://localhost:3000/"><em>http://localhost:3000/</em></a></p><p>Check for a window similar to the below. If you do, then you have successfully installed a <em>React App.</em>🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnt7rzRw5WmESqPz4CR6Qg.png" /></figure><h3>Setting a Proxy from your Backend API server to the Frontend React App</h3><p>Type the below code in the <em>package.json</em> file of your frontend</p><pre>&quot;proxy&quot;: &quot;http://localhost:6000&quot;</pre><p>By doing this any request made to your development server (the one serving your frontend application) will be forwarded to http://localhost:4000. This is often used when you have a separate backend server running on localhost:4000, and you want to avoid issues related to cross-origin requests during development.</p><p>Now, you can be sure that requests made on the frontend( React ) will be proxied( forwarded ) to the backend ( Express ). 😉</p><h3>Styling and making Requests from the frontend</h3><p>Now let’s get on to styling 🎨 and make the frontend look Gooood….</p><p>Here 😼 is where good old CSS and HTML comes in</p><p>This below is the frontend folder structure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*-xcdopZ8iJsAGykewWJaug.png" /><figcaption>Repository Image</figcaption></figure><p>Only the above files in the <em>src</em> folder is necessary for this project, the rest of the files can be removed like <em>App.test.js</em>, <em>reportWebVitals.js</em> <em>etc</em>.</p><blockquote>Also check the repository, as I had made some changes to the <em>index.js </em>file. Also add the screw.png image to your img folder</blockquote><p>To use some custom fonts in my project, I downloaded the respective <em>.ttf</em> file and stored them in the <em>fonts</em> folder and copied the below code into the <em>App.css</em> file</p><pre>@font-face {<br>  font-family: &quot;Old English&quot;;   /*Can be any text*/<br>  src: local(&quot;Old English&quot;),<br>    url(https://medium.com/&quot;./fonts/OldeEnglish.ttf&quot;) format(&quot;truetype&quot;);<br>}<br><br>@font-face {<br>  font-family: &quot;Subway&quot;;   /*Can be any text*/<br>  src: local(&quot;Subway&quot;),<br>    url(https://medium.com/&quot;./fonts/subway.ttf&quot;) format(&quot;truetype&quot;);<br>}<br>w  <br>@font-face {<br>  font-family: &quot;Quad Serif&quot;;   /*Can be any text*/<br>  src: local(&quot;Quad Serif Line&quot;),<br>    url(https://medium.com/&quot;./fonts/QuadSerifLine.ttf&quot;) format(&quot;truetype&quot;);<br>}<br><br>@font-face {<br>  font-family: &quot;Krakoan&quot;;   /*Can be any text*/<br>  src: local(&quot;Krakoan&quot;),<br>    url(https://medium.com/&quot;./fonts/Krakoan.ttf&quot;) format(&quot;truetype&quot;);<br>}</pre><p>The React framework is considered very developer-friendly because of its component-based architecture. Components in React are reusable and encapsulated pieces of code that can represent parts of a user interface, such as a button, form, or even entire sections or pages of a web application. By breaking down the UI into components, React promotes code organization, reusability, and maintainability, making it easier for developers to manage and scale their projects.</p><blockquote>All the components in this project is added to the “components” folder</blockquote><pre>//Contents of addBook.js<br>import {useState} from &#39;react&#39;;<br><br>const AddBook = ({cardState,setCardState}) =&gt; {<br>    const [name,setName] = useState(&#39;&#39;);<br>    const [author,setAuthor] = useState(&#39;&#39;);<br>    const [pub,setPub] = useState(&#39;&#39;);<br>    const [ser,setSer] = useState(&#39;&#39;);<br>    const [res,setRes] = useState(&#39;&#39;);<br><br>    const handleClick = async () =&gt; {<br>        const response = await fetch(&#39;/api/addbook&#39;, {<br>            method: &#39;POST&#39;,<br>            headers: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>            body: JSON.stringify({<br>                &quot;name&quot;:name,<br>                &quot;author&quot;:author,<br>                &quot;publication&quot;:pub,<br>                &quot;series&quot;:ser<br>            })<br>        });<br><br>        if (!response.ok) {<br>            console.log(&quot;Unable to add a book&quot;);<br>            return;<br>        }<br><br>        const data = await response.json();<br>        console.log(data.msg);<br>        setRes(data.msg)<br>        if(data.msg === &quot;Book added&quot;) {<br>            setCardState(0);<br>        }<br>    };<br><br>    return(<br>        &lt;div className=&quot;cardMainContainer&quot;&gt;<br>            Book name: &lt;input <br>                type=&quot;text&quot; <br>                className=&quot;input1&quot;<br>                onChange={(e) =&gt; {setName(e.target.value)}}<br>                value={name}<br>            /&gt;<br>            Author: &lt;input <br>                type=&quot;text&quot; <br>                className=&quot;input2&quot;<br>                onChange={(e) =&gt; {setAuthor(e.target.value)}}<br>                value={author}<br>            /&gt;<br>            Publications: &lt;input <br>                type=&quot;text&quot; <br>                className=&quot;input3&quot;<br>                onChange={(e) =&gt; {setPub(e.target.value)}}<br>                value={pub}<br>            /&gt;<br>            Series: &lt;input <br>                type=&quot;text&quot; <br>                className=&quot;input4&quot;<br>                onChange={(e) =&gt; {setSer(e.target.value)}}<br>                value={ser}<br>            /&gt;<br>            &lt;button className=&quot;actionButton&quot; onClick={handleClick}&gt;Add!!&lt;/button&gt;<br>            &lt;div&gt;{res ? res : &lt;p&gt;&lt;/p&gt;}&lt;/div&gt;<br>        &lt;/div&gt;<br>    )<br>}<br><br>export default AddBook;</pre><pre>//Contents of nothBook.js<br>const NotBook = () =&gt; {<br>    return(<br>        &lt;p style={{fontSize:&#39;1.5rem&#39;,fontWeight:&#39;900&#39;}}&gt;...&lt;/p&gt;<br>    )<br>}<br><br>export default NotBook;</pre><pre>//Contents of home.js<br>import {useState} from &#39;react&#39;;<br><br>import AddBook from &#39;./addBook&#39;;<br>import NotBook from &#39;./nothBook&#39;;<br>import screw from &#39;../img/screw.png&#39;<br><br>const Home = () =&gt; {<br>    const [cardState,setCardState] = useState(0);<br>    const cardList = [&lt;NotBook /&gt;,&lt;AddBook cardState={cardState} setCardState={setCardState}/&gt;]<br>    return(<br>        &lt;div className=&#39;mainContainer&#39;&gt;<br>            &lt;h1 className=&quot;mainHeading&quot;&gt;Infino&lt;/h1&gt;<br>            &lt;h1 className=&quot;mainsubHead&quot;&gt;keeper . of . the . books&lt;/h1&gt;<br>            &lt;div className=&quot;mainWrapper&quot;&gt;<br>                &lt;div className=&quot;div1&quot; onClick={() =&gt; setCardState(1)}&gt;Add a book&lt;/div&gt;<br>                &lt;div className=&quot;div2&quot; onClick={() =&gt; setCardState(1)}&gt;Borrow a book&lt;/div&gt;<br>                &lt;div className=&quot;div3&quot; onClick={() =&gt; setCardState(1)}&gt;Return a book&lt;/div&gt;<br>                &lt;div className=&quot;div4&quot; onClick={() =&gt; setCardState(1)}&gt;Delete a book&lt;/div&gt;  <br>                &lt;div className=&quot;div5&quot;&gt;<br>                    &lt;div className=&quot;dot1&quot;&gt;.&lt;/div&gt;<br>                    &lt;div className=&quot;dot2&quot;&gt;.&lt;/div&gt;<br>                    &lt;div className=&quot;dot3&quot;&gt;.&lt;/div&gt;<br>                &lt;/div&gt;<br>                &lt;div className=&#39;screwComp&#39;&gt;<br>                    &lt;img src={screw} alt=&#39;s&#39;/&gt;<br>                    &lt;img src={screw} alt=&#39;s&#39;/&gt;<br>                    &lt;img src={screw} alt=&#39;s&#39;/&gt;<br>                &lt;/div&gt;  <br>            &lt;/div&gt;<br>            &lt;div className=&#39;cardWrapper&#39;&gt;{cardList[cardState]}&lt;/div&gt;<br>            &lt;div className=&#39;madeWithLove&#39;&gt;made with ❣️ by &amp;nbsp;&lt;span&gt;abhijith&lt;/span&gt;&lt;/div&gt;<br>        &lt;/div&gt;<br>    )<br>}<br><br>export default Home;</pre><pre>/*Contents of index.css*/<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Poor+Story&amp;display=swap&#39;);<br><br>body,html {<br>  margin: 0px;<br>  padding: 0px;<br>  background: linear-gradient(to right,rgb(235, 232, 233),rgb(240, 233, 233));<br>}<br><br>.pages {<br>  align-items: center;<br>  text-align: center;<br>}<br><br>.mainContainer {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  flex-direction: column;<br>}<br><br>.mainWrapper {<br>  font-family: Quad Serif;<br>  width: 20rem;<br>  height: 20rem;<br>  border: 3px solid  brown;<br>  position: relative;<br>  margin-top: 5rem;<br>  border-radius: 10px;<br>  margin-bottom: 1rem;<br>}<br><br>.mainHeading {<br>  font-family: Quad Serif;<br>  font-size: 6rem;<br>  margin-bottom: 0;<br>  margin-top: 5rem;<br>}<br><br>.mainsubHead {<br>  font-family: Quad Serif;<br>  font-size: 1rem;<br>}<br><br>.div1 {<br>  position: absolute;<br>  font-size: 2rem;<br>  padding: 0.4rem;<br>  width: 9rem;<br>  height: 9rem;<br>  border: 2px dashed black;<br>  left: 0.5rem;<br>  top: 0.5rem;<br>  border-radius: 5px;<br>  transform: scale(1);<br>  transition: transform ease 0.5s;<br>  background: linear-gradient(to right,rgb(235, 232, 233),rgb(230, 204, 204));<br>}<br><br>.div1:hover {<br>  transform: scale(1.2);<br>  cursor: pointer;<br>}<br><br>.div2 {<br>  position: absolute;<br>  font-size: 1.2rem;<br>  padding: 0.4rem;<br>  width: 5rem;<br>  height: 5rem;<br>  border: 2px dashed black;<br>  right: 0.5rem;<br>  top: 0.5rem;<br>  border-radius: 5px;<br>  transform: scale(1);<br>  transition: transform ease 0.5s;<br>  background: linear-gradient(to right,rgb(235, 232, 233),rgb(230, 204, 204));<br>}<br><br>.div2:hover {<br>  transform: scale(1.4);<br>  cursor: pointer;<br>}<br><br>.div3 {<br>  position: absolute;<br>  font-size: 1.5rem;<br>  padding: 0.4rem;<br>  width: 7rem;<br>  height: 7rem;<br>  border: 2px dashed black;<br>  left: 0.5rem;<br>  bottom: 0.5rem;<br>  border-radius: 5px;<br>  transform: scale(1);<br>  transition: transform ease 0.5s;<br>  background: linear-gradient(to right,rgb(235, 232, 233),rgb(230, 204, 204));<br>}<br><br>.div3:hover {<br>  transform: scale(1.4);<br>  cursor: pointer;<br>}<br><br>.div4 {<br>  position: absolute;<br>  padding: 0.4rem;<br>  font-size: 1.6rem;<br>  width: 6rem;<br>  height: 6rem;<br>  border: 2px dashed black;<br>  right: 0.5rem;<br>  bottom: 0.5rem;<br>  border-radius: 5px;<br>  transform: scale(1);<br>  transition: transform ease 0.5s;<br>  background: linear-gradient(to right,rgb(235, 232, 233),rgb(232, 216, 216));<br>}<br><br>.div4:hover {<br>  transform: scale(1.4);<br>  cursor: pointer;<br>}<br><br>.div5 {<br>  position: absolute;<br>  width: 1rem;<br>  height: 3rem;<br>  font-size: 2.3rem;<br>  left: 56%;<br>}<br><br>@keyframes flashColor1 {<br>  0% {<br>    color: rgb(238, 215, 215);<br>  }<br>  50% {<br>    color: rgb(90, 68, 68); /* Change to the color you want during the flash */<br>  }<br>  100% {<br>    color: rgb(155, 144, 144);<br>  }<br>}<br><br>@keyframes flashColor2 {<br>  0% {<br>    color: rgb(155, 144, 144);<br>  }<br>  50% {<br>    color: rgb(238, 215, 215); /* Change to the color you want during the flash */<br>  }<br>  100% {<br>    color: rgb(90, 68, 68);<br>  }<br>}<br><br>@keyframes flashColor3 {<br>  0% {<br>    color: rgb(90, 68, 68);<br>  }<br>  50% {<br>    color: rgb(155, 144, 144); /* Change to the color you want during the flash */<br>  }<br>  100% {<br>    color: rgb(238, 215, 215);<br>  }<br>}<br><br>.div5 .dot1 {<br>  color: rgb(123, 104, 104);<br>  font-family: &#39;Courier New&#39;, Courier, monospace;<br>  animation: flashColor1 1s infinite alternate;<br>}<br><br>.div5 .dot2 {<br>  color: rgb(78, 58, 58);<br>  font-family: &#39;Courier New&#39;, Courier, monospace;<br>  animation: flashColor2 1s infinite alternate;<br>}<br><br>.div5 .dot3 {<br>  color: rgb(148, 129, 129);<br>  font-family: &#39;Courier New&#39;, Courier, monospace;<br>  animation: flashColor3 1s infinite alternate;<br>}<br><br>.cardWrapper {<br>  position: relative;<br>  border: 4px solid black;<br>  border-radius: 10px;<br>  width: 20rem;<br>  height: max-content;<br>  background: linear-gradient(to right,rgb(247, 242, 242),rgb(242, 221, 221));<br>  margin-bottom: 5rem;<br>}<br><br>.cardMainContainer {<br>  display: flex;<br>  flex-direction: column;<br>  text-align: left;<br>  padding: 0.8rem;<br>}<br><br>.cardMainContainer .input1,.input2,.input3,.input4 {<br>  width: 10rem;<br>  height: 1.5rem;<br>  border-radius: 5px;<br>  margin-top: 0.5rem;<br>  border-style: dashed;<br>  margin-bottom: 0.2rem;<br>}<br><br>.actionButton {<br>  border: 2px dashed #767676;<br>  border-radius: 5px;<br>  width: max-content;<br>  padding-left: 1rem;<br>  padding-right: 1rem;<br>  padding-top: 0.3rem;<br>  padding-bottom: 0.3rem;<br>  margin-top: 1rem;<br>}<br><br>.actionButton:hover {<br>  border-style: solid;<br>  border-color: black;<br>  cursor: pointer;<br>}<br><br>.madeWithLove {<br>  font-family: Poor Story;<br>  text-align: right;<br>  width: 100%;<br>  font-size: 1.5rem;<br>  padding: 1rem;<br>  padding-right: 1.5rem;<br>}<br><br>.madeWithLove span {<br>  font-family: Krakoan;<br>  letter-spacing: 0.2rem;<br>  margin-right: 1rem;<br>}<br><br>.screwComp {<br>  display: flex;<br>  flex-direction: column;<br>  position: absolute;<br>  right: 9rem;<br>  bottom: 1rem;<br>}<br><br>.screwComp img {<br>  width: 1rem;<br>  height: 1rem;<br>  margin-bottom: 0.8rem;<br>}<br></pre><p>Now lets talk about the most important file in React, which is the <em>App.js. </em>It is in this file where we control which component gets rendered for which route.</p><pre>//Contents of App.js<br>import { BrowserRouter, Routes, Route} from &#39;react-router-dom&#39;;<br>import &quot;./App.css&quot;;<br><br>import Home from &#39;./components/home&#39;;<br><br>function App() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;BrowserRouter&gt;<br>        &lt;div className=&#39;pages&#39;&gt;<br>          &lt;Routes&gt;<br>            &lt;Route <br>            path=&#39;/&#39;<br>            element={&lt;Home /&gt;}<br>            /&gt;<br>          &lt;/Routes&gt;<br>        &lt;/div&gt;<br>      &lt;/BrowserRouter&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>export default App;</pre><p>Congrats you just completed your MERN Project 🎊🥳</p><p>Lets run it. Make sure you are in your root directory. Also make sure you have the <em>.env</em> file in your backend folder with the your environment variables. Now run these commands.</p><pre>cd backend/<br>npm install<br>npm start</pre><p>The output is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nK-bUv1bU2dUD7Ip9sUpwA.png" /><figcaption>Terminal output</figcaption></figure><p>Now open another terminal in the root directory. Run the below command</p><pre>cd frontend/<br>npm install<br>npm start</pre><p>The output is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QLK_YaAWT7oSsN0fMDkzFw.png" /><figcaption>Terminal output</figcaption></figure><p>Open <a href="http://localhost:3000/"><em>http://localhost:3000</em></a><em> </em>to view your react application</p><p>It will look like the below (The UI isn’t the best, I know 😅)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SsaiKo8FdtUfkfDv0_druw.png" /><figcaption><a href="http://localhost:3000/">http://localhost:3000</a></figcaption></figure><p>Only the addbook route has been written😅, so only the “Add A Book” feature works. Consider adding the following features</p><ul><li>Borrow a Book</li><li>Return a Book</li><li>Delete a Book</li></ul><p>Good luck !! 😁👍</p><p><em>Do </em>👏<em> If you liked the article</em></p><p>Stay tuned and Do make sure to check out my articles <a href="https://medium.com/@ams_132">@ams_132</a> !!!</p><p><em>Sayonara… Until next time</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8b4d1296755" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>