<?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 Naim Gkamperlo on Medium]]></title>
        <description><![CDATA[Stories by Naim Gkamperlo on Medium]]></description>
        <link>https://medium.com/@ngkamperlo?source=rss-6aa163a8264c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rQWgONB6-L9GoqO5</url>
            <title>Stories by Naim Gkamperlo on Medium</title>
            <link>https://medium.com/@ngkamperlo?source=rss-6aa163a8264c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 06:44:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ngkamperlo/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[How Terraform Powers AWS Control Tower Account Factory for Terraform (AFT)]]></title>
            <link>https://medium.com/@ngkamperlo/how-terraform-powers-aws-control-tower-account-factory-for-terraform-aft-10290903c367?source=rss-6aa163a8264c------2</link>
            <guid isPermaLink="false">https://medium.com/p/10290903c367</guid>
            <category><![CDATA[aws-control-tower]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-account-factory]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[cloud-governance]]></category>
            <dc:creator><![CDATA[Naim Gkamperlo]]></dc:creator>
            <pubDate>Wed, 11 Dec 2024 07:02:35 GMT</pubDate>
            <atom:updated>2024-12-11T07:02:35.648Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>AFT Series Part 1 — How Terraform Powers AWS Control Tower Account Factory for Terraform (AFT)</strong></p><p>In today’s rapidly evolving cloud landscape, organizations are increasingly adopting Infrastructure as Code (IaC) to streamline and automate their cloud operations. <strong>AWS Control Tower has been instrumental in simplifying multi-account AWS environments</strong>, but as organizations grow, the need for a more integrated IaC approach becomes essential. Enter AWS Control Tower Account Factory for Terraform (AFT), a solution that combines AWS’s robust governance capabilities with Terraform’s declarative IaC approach. Welcome to <strong>Part 1</strong> of our blog series on AFT, where we explore its features, architecture, and benefits.</p><p><strong>Understanding AWS Control Tower: A Foundation for Multi-Account Management</strong></p><p>AWS Control Tower offers a centralized platform for setting up and governing secure, multi-account AWS environments. It provides pre-configured best practices through “guardrails,” centralized identity management, and integrated logging. These features enable organizations to enforce security and compliance standards across their AWS accounts with minimal manual effort.</p><p>While AWS Control Tower simplifies multi-account management, its native automation capabilities are primarily tied to AWS-native tools. This limitation often results in gaps for organizations already leveraging Terraform as their preferred IaC tool for cloud infrastructure management. These gaps are exactly what AWS Control Tower Account Factory for Terraform seeks to address.</p><p><strong>What Is AWS Control Tower Account Factory for Terraform (AFT)?</strong></p><p>AWS Control Tower Account Factory for Terraform (AFT) is an IaC solution that integrates Terraform’s automation power with AWS Control Tower’s governance features. AFT provides a streamlined mechanism to provision, configure, and customize AWS accounts in a Control Tower-managed environment using Terraform. By leveraging AFT, organizations can adopt Terraform to define and manage AWS accounts declaratively while ensuring they comply with enterprise-wide standards set by AWS Control Tower.</p><p><strong>Core Benefits of AWS Control Tower AFT</strong></p><p><strong>1. Automation and Efficiency</strong></p><p>AFT automates the process of provisioning AWS accounts, including the customization of resources and settings within each account. This eliminates the need for manual interventions, speeding up deployment times while reducing the risk of errors.</p><p><strong>2. Consistency and Compliance</strong></p><p>Using Terraform configurations ensures that every AWS account is provisioned consistently. Pre-defined templates and policies in Terraform help enforce compliance across organizational standards, improving governance across all accounts.</p><p><strong>3. Scalability</strong></p><p>AFT is designed to grow with your organization. The automated workflows it enables allow you to manage an increasing number of AWS accounts without additional administrative overhead.</p><p><strong>4. Integration with Existing Workflows</strong></p><p>For organizations already using Terraform, AFT reduces the learning curve. Teams can continue working with familiar tools and processes while extending their capabilities to manage AWS accounts in line with AWS Control Tower’s compliance guardrails.</p><p><strong>How AFT Works: An Architecture Overview</strong></p><p>AFT is built around a modular architecture that integrates seamlessly with AWS services:</p><p>• <strong>AFT Management Account</strong>: A dedicated AWS account used to host the AFT pipeline and its resources. This account acts as the control center for managing account provisioning.</p><p>• <strong>Terraform Modules</strong>: AFT includes pre-built Terraform modules that define the desired state for AWS accounts. These modules include configurations for IAM roles, networking setups, and other account-level resources.</p><p>• <strong>Pipeline Automation</strong>: AFT leverages AWS services like AWS CodePipeline, AWS CodeCommit, and AWS Lambda to orchestrate account provisioning and customization workflows.</p><p>• <strong>Customization Hooks</strong>: AFT supports hooks that allow users to run custom scripts or configurations during different stages of the account lifecycle.</p><p><strong>Setting Up AFT: A Quick Overview</strong></p><p>1. <strong>Prerequisites</strong>: Start by setting up an AWS Control Tower landing zone to ensure your environment is ready for multi-account management.</p><p>2. <strong>Provisioning the AFT Management Account</strong>: Create a separate AWS account that will host the AFT pipeline and related resources.</p><p>3. <strong>Deploying AFT</strong>: Use Terraform to deploy the AFT module, which establishes the pipeline for managing AWS accounts.</p><p>4. <strong>Customizing Accounts</strong>: Leverage AFT’s customization hooks to define organization-specific settings for each provisioned account.</p><p>AWS provides detailed documentation to guide users through each step. (<a href="https://docs.aws.amazon.com/controltower/latest/userguide/aft-overview.html">AWS AFT Documentation</a>)</p><p><strong>Why Choose AFT for Your Cloud Environment?</strong></p><p>AWS Control Tower AFT combines the best of both worlds: the governance and security of AWS Control Tower and the automation power of Terraform. This combination empowers organizations to:</p><p>• Simplify and standardize account provisioning processes.</p><p>• Enforce consistent policies across all accounts.</p><p>• Reduce operational overhead through automation.</p><p>• Leverage existing IaC expertise and tooling for managing cloud infrastructure.</p><p><strong>Conclusion: The Road Ahead</strong></p><p>AWS Control Tower Account Factory for Terraform is more than just a provisioning tool; it’s a game-changer for organizations looking to scale their cloud environments securely and efficiently. This blog series will guide you through everything you need to know about AFT — from deployment best practices to advanced customization techniques.</p><p>In <strong>Part 2</strong>, we’ll dive deeper into the setup process, exploring how to configure the AFT pipeline and integrate it with existing Terraform workflows. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10290903c367" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common UI Components with Logic — Web Components]]></title>
            <link>https://medium.com/tech-gwi/common-ui-components-with-logic-web-components-596242892dd0?source=rss-6aa163a8264c------2</link>
            <guid isPermaLink="false">https://medium.com/p/596242892dd0</guid>
            <category><![CDATA[elm]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[micro-front-end]]></category>
            <dc:creator><![CDATA[Naim Gkamperlo]]></dc:creator>
            <pubDate>Wed, 26 Apr 2023 07:40:46 GMT</pubDate>
            <atom:updated>2023-04-26T07:40:46.992Z</atom:updated>
            <content:encoded><![CDATA[<h3>Common UI Components with Logic — Web Components</h3><p><em>How we tackled common UI challenges in our React and Elm-based micro-frontends</em></p><p>In 2019, our team at GWI started its journey with micro-frontends (MFEs) to tackle the challenges of scaling our codebase and making our teams more autonomous. <br>Back then, our framework of choice was single-spa(and it still is), and our main focus was on creating a seamless experience between our Elm and React-based applications. In this blog post, we’ll explore our experience with common UI components with logic — web components — and the solutions we’ve found for various challenges. So, let’s dive in!</p><h3>The Challenges with Common UI Components</h3><p>In the early stages of our MFEs journey, we faced the issue of common functionality needed by both Elm and React-based applications. Instead of duplicating efforts and implementing common functionality in both technologies, we decided to:</p><ol><li>Implement the functionality once, either in React or Elm, and <a href="https://gilfink.medium.com/wrapping-react-components-inside-custom-elements-97431d1155bd">wrap the output in web components</a> for use by both languages.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kuBZxfGFDppe2oCIwQqePg.png" /><figcaption>Built down react/elm based components as web components</figcaption></figure><p>2. Communicate with each MFE in the following way</p><ul><li>The MFE should transmit data <strong><em>to</em></strong> the common component through its HTML attributes.</li><li>The MFE should retrieve data <strong><em>from</em></strong> the common component using the browser’s custom events.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6ihChZBg4PNawPsaL36Bw.png" /></figure><h3>Developing an Internal Storybook for Web Components</h3><p>To make it easier for our team, including front-end engineers, project managers, and designers, we set up an internal storybook for managing web components. This central hub provided several advantages:</p><ol><li>Quick Development: The internal storybook allowed team members to efficiently create, review, and test web components all in one place.</li><li>Stay Updated: By having a central location, the storybook made sure everyone was aware of the latest changes and updates to our shared UI components.</li><li>Better Communication: The internal storybook encouraged discussions between all team members involved in the product, leading to improved collaboration and decision-making.</li></ol><p>In summary, the internal storybook became a crucial tool for handling web components and promoting a more productive and communicative team environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*pDMAKc3xt61I40HDbtgquw.png" /></figure><h3>Creating Single-Page Mini Apps</h3><p>As our MFEs evolved, we realised that there was a need for single-page mini-apps that were:</p><ol><li>Too small for a new MFE.</li><li>Too big for a web component.</li><li>Able to capture the full viewport of the browser.</li></ol><p>We explored two solutions:</p><h4>Solution #1: The BlackBox Pattern for Mini Apps</h4><p>In this approach, we use the <a href="https://medium.com/@naimgaberlo/micro-frontend-blackbox-pattern-295c40b681e4">BlackBox pattern</a> to create single-page mini apps as MFEs. These black-box apps communicate with other applications through custom events and can be rendered or hidden from the DOM as needed.</p><p>Pros:</p><ol><li>Innovative: This pattern offers a fresh and effective way to manage mini apps.</li><li>Centralised Code: The entire single-page mini app’s code is contained in one repository, simplifying maintenance for front-end engineers.</li></ol><p>Cons:</p><ol><li>Elm Limitations: The BlackBox pattern may not work as effectively for Elm-based applications.</li><li>Complex wiring: Front-end engineers might have to create more intricate wiring when using this mini app with other MFEs.</li></ol><h4>Solution #2: Web Components with Independent Repositories for Mini Apps</h4><p>The next solution we implemented involved creating single-page mini apps as web components, regardless of their size, and providing each one with its own Git repository.</p><p>Pros:</p><ol><li>Effective: This method works well for creating and managing mini apps as web components.</li><li>Centralized Code: Each mini app’s code is contained in a single repository, making it easy for front-end engineers to track and maintain.</li></ol><p>Cons:</p><ol><li>Complex Wiring: Front-end engineers might need to set up more sophisticated connections when implementing these mini apps in their MFEs.</li><li>TypeScript Drawbacks: The lack of static typing for TypeScript means that potential errors can only be caught during runtime, which might be challenging for front-end engineers to handle.</li></ol><p>…and we are thinking of also exploring the solutions below in the near future 👇</p><h3>Something changed along the way</h3><h4>The discontinuation of Elm in GWI’s main platform</h4><p>As our development priorities and technology stack continue to evolve, we have made the decision to discontinue the usage of Elm in our main platform. Although Elm has been a valuable asset in the past, our team has recognised the benefits of adopting a unified approach to micro-frontend development with React. By focusing solely on React, we can streamline our development process, making it more efficient and maintainable in the long run as no more web-components will be needed but rather only react-based components, enabling our platform engineering teams to catch issues on build time with the usage of typescript. While we appreciate the contributions of Elm in our platform’s past, we are excited to embrace the React-centric approach and look forward to the new opportunities it presents for creating innovative, high-quality, and scalable apps.</p><h3>Next steps</h3><h4>Solution #3: Merging Mini Apps with the most related MFE’s codebase</h4><p>This method suggests embedding single-page mini-apps into their most related micro-frontend. This works for our specific scenario (don’t try this at home 😂) of sharing the <em>same domain</em> between an MFE and a common component. <br>The next step is to change the communication method from wiring to utilising the browser’s history property for communication.</p><p>Pros:</p><ol><li>Consolidated Repository: Combining related elements in one code repository simplifies development and organisation.</li><li>Elm Support: Elm-based applications can effortlessly interact with the integrated mini-apps, enabling smooth teamwork.</li></ol><p>Cons:</p><ol><li>Complex CI process: Establishing mini-apps within MFEs may create complex CI pipelines for proper building, testing, and deployment.</li><li>TypeScript Limitations: Static typing for TypeScript is not available in this scenario, meaning potential errors will only be detected during runtime, which can lead to unforeseen issues.</li></ol><h4>Solution #4: Transforming Single-Page Mini Apps into Independent MFEs</h4><p>In this approach, we consider elevating the single-page mini-apps to a higher level of independence by turning them into standalone micro-frontends (MFEs).</p><p>Pros:</p><ol><li>Distinct Code Repositories: Each mini-app benefits from having its own code repository, allowing for greater separation and management of the individual components.</li><li>Elm Compatibility: This setup enables Elm-based applications to easily integrate with these independent mini-apps, promoting a smooth collaboration.</li></ol><p>Cons:</p><ol><li>Synchronizing Updates: When such components are updated, all MFEs need to be updated to the latest version as well. This requirement may undermine one of the main advantages of MFE architecture.</li><li>TypeScript Limitations: Static typing for TypeScript is not available in this scenario, meaning potential errors will only be detected during runtime, which can lead to unforeseen issues.</li></ol><h3>Final thoughts</h3><p>In conclusion, our journey with web components has been valuable in addressing common functionality challenges between Elm and React-based applications. However, as we plan to fully adopt React and discontinue using Elm, it’s time to reassess our approach and consider new solutions for single-page mini apps.</p><p>With our focus shifting to React components, we can explore alternative strategies like Module Federation, which enables the seamless sharing of components across applications. We’re now considering implementing Solution 4, although its implementation effort might be significantly bigger compared to Solution 3.</p><p>Solution 3 integrates mini apps directly into their corresponding MFEs, streamlining communication and reducing overhead. However, Solution 4 emphasises independent MFEs, potentially leading to slower implementation.</p><p>As we move forward, it’s essential to carefully evaluate each solution’s pros and cons, considering factors such as team preferences, performance requirements, and maintainability. A good assessment will help us make an informed decision that aligns with our goals and ensures the success of our projects.</p><p>In summary, our experience with web components has equipped us with essential tools to tackle complex UI challenges. As we transition to a React-only approach, it’s crucial to explore new solutions that align with our evolving technology stack. By carefully weighing each strategy’s advantages and disadvantages, we can confidently adapt to change and innovation, ultimately creating outstanding user experiences for our audience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=596242892dd0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tech-gwi/common-ui-components-with-logic-web-components-596242892dd0">Common UI Components with Logic — Web Components</a> was originally published in <a href="https://medium.com/tech-gwi">tech-gwi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Micro-frontend(MFE) versioning]]></title>
            <link>https://medium.com/tech-gwi/micro-frontend-mfe-versioning-97dbe7cc1fdd?source=rss-6aa163a8264c------2</link>
            <guid isPermaLink="false">https://medium.com/p/97dbe7cc1fdd</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Naim Gkamperlo]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 18:08:21 GMT</pubDate>
            <atom:updated>2022-09-28T18:08:21.978Z</atom:updated>
            <content:encoded><![CDATA[<p>Building on the <a href="https://medium.com/tech-gwi/our-journey-with-micro-frontends-f0070595004b">previous post</a>, we will deep dive into how we handle micro-frontend(MFE) versioning in GWI. Take a deep breath!</p><h3>Terms</h3><ul><li><strong>Application: </strong>whole application which includes kernel along with all its MFEs</li><li><strong>Frontend Configuration (or simply fe-config)</strong> — a service that depends on <em>absolutely nothing</em> and provides the kernel with the latest version of all MFEs</li><li><strong>Kernel:</strong> kernel/shell/platform that glues everything i.e the app that holds the menu, and the home page and loads every MFE upon request</li></ul><h3>Tech stack</h3><p>The way we upload MFEs is the following:</p><ul><li>Continuous Integration pipeline in place using <a href="https://www.drone.io/"><strong>Drone</strong></a>:<br> every time the application was built, tested, and merged to a <em>main branch (develop, release, and master are considered as main GitHub branches)</em>, Drone took over and uploaded the build output in a <a href="https://cloud.google.com/storage"><strong>GCS bucket</strong></a><strong> </strong>(<em>Google Cloud Storage</em>) with the first 7 digits of the PR(Pull Request) commit ID</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvd1JoePRbDd3BBtMMRVxQ.png" /></figure><ul><li>Kernel is written using <em>single-spa</em> FE library and is part of our Kubernetes cluster in testing, staging, and production environments</li></ul><h3>The problem</h3><p>Building on the above, what we needed to do was a simple way to connect <em>kernel</em> with <em>MFEs</em> in a way that MFEs can:</p><ul><li>be updated easily by both developers and product managers</li><li>easily maintained by developers</li><li>instantly updated and uncached in all environments</li></ul><p>We decided to approach the above in an agile way i.e small iterations, inspect and adapt. Below is our journey toward finding the best way to keep track of our MFE versions</p><h4>Attempt #1</h4><p>At the very start of our journey, we used to update the latest version of each MFE through a git commit on the kernel. The following problems surfaced :</p><ol><li>every time we had a new version of an MFE the developer was blocked so that their PR(Pull Request) is reviewed</li><li><em>main branch</em> tree was polluted right from the start</li></ol><p>It was clear that another approach would be required leading us to Attempt #2</p><h4>Attempt #2</h4><p>We hacked a new quick and dirty solution that worked in the following way:<br><em>A static golang-based HTML template that had a single input field for the commit ID of the new deployment of our only MFE at that time.</em><br>This approach worked pretty well until several issues started raising:</p><ol><li>Scaling our applications meant we had to copy-paste an HTML template every time.</li><li>Hard-coded values started crippling their way in a microservice whose responsibility was to serve completely unrelated data.</li><li>The task of creating a new MFE template (or even a completely new application) was quite a hard thing.</li></ol><h4>Attempt #3</h4><p>Our first scalable solution was implemented. The solution provided both a front-end UI and a dedicated microservice. This approach solved the following issues:</p><ol><li>Ability to create applications along with their corresponding MFEs.</li><li>Developers, product managers, and designers can easily update their MFEs directly in all environments.</li><li>APIs to get the version of a single MFE along with all the MFEs of an application.</li><li>Scalable UI developed with React.</li><li>Ability to set dynamic values regarding MFE GCS bucket path along with the MFE names — nothing was hard-coded anymore.</li></ol><p>The process in which our current infrastructure works can be depicted in the following picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Ubkd3mkATiAPN9VrkQ3ZCw.png" /></figure><p>However, this solution didn’t provide the following:</p><ol><li>latest branches per MFE/application — the UI provided only the latest MFE</li><li>ability to have long-live feature branches tested by everyone</li><li>make users aware that a new version of their currently used MFE has been updated</li><li>the already implemented design system was not reused</li></ol><h4>Attempt #4</h4><p>Our latest approach involved making our solution robust, scalable, and testable. We architected our new iteration with the following in our mind:</p><ol><li>Ability to test out new features (either internally or externally with our customers) <em>without</em> breaking any stable environment i.e testing, staging, and production i.e feature branches to test long-live branches easily</li><li>New UI that<br> 1. utilizes our design system to not reinvent the wheel as all our UI components are already in place<br> 2. informs the user regarding the latest releases along with timestamps of new version creation<br> 3. gives the ability to create feature branches on the application level in case a feature is constructed by more than a single MFE e.g <em>featureX</em> is making y visible both in MFE A and MFE B and those two MFEs need to be in sync for <em>featureX</em> to work properly.<br>3. Ability to delete feature branches with all the related commits and GCS buckets after merging to <em>a main</em> branch</li><li>Everything that was developed before Approach #4 should continue to work properly.</li><li>The main user flow can be summarised as follows</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*CB5Ls0gwG08SiH9YeidYnQ.png" /></figure><h3>Final thoughts</h3><p>We still revisit our options and try to use the best solution to serve our needs as our platform keeps growing day by day. The next steps include the following:</p><ul><li>ability to directly send a branch to the staging/production environment</li><li>ability to promote functionality from testing to staging and staging to production</li><li>even simpler UI that can be utilized by anyone in the <a href="https://www.end-game.com/blog/the-product-trio-a-101#:~:text=A%20Product%20Trio%20is%20an,Tech%20Lead">Product Trio</a></li></ul><p>Once implemented we will make another blog post on all our learnings!</p><p>Stay tuned for blog posts that make an in-depth analysis on all of the above and more :)</p><h3><strong>Resources</strong></h3><ul><li><a href="https://medium.com/tech-gwi/our-journey-with-micro-frontends-f0070595004b">Series introductory story</a></li><li><a href="https://drone.io/">Drone CI</a></li><li><a href="https://single-spa.js.org/">Single-SPA</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97dbe7cc1fdd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tech-gwi/micro-frontend-mfe-versioning-97dbe7cc1fdd">Micro-frontend(MFE) versioning</a> was originally published in <a href="https://medium.com/tech-gwi">tech-gwi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our journey with micro-frontends]]></title>
            <link>https://medium.com/tech-gwi/our-journey-with-micro-frontends-f0070595004b?source=rss-6aa163a8264c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0070595004b</guid>
            <category><![CDATA[web-components]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[module-federation]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Naim Gkamperlo]]></dc:creator>
            <pubDate>Mon, 27 Jun 2022 12:02:34 GMT</pubDate>
            <atom:updated>2022-06-27T12:02:34.888Z</atom:updated>
            <content:encoded><![CDATA[<p>It was 2019 when our journey started with micro-frontends (or simply MFEs) in GWI. No one in our team had used MFEs in a production environment and the community was just starting its baby steps around them. Our framework of choice was <strong><em>single-spa</em></strong> for our <strong>kernel/shell/<em>platform that glues everything</em></strong> app.</p><h4><strong>Why MFEs though?</strong></h4><p>At that point, GWI had been developing applications using Elm and React. In order to:</p><ul><li>Be able to scale our codebase easily without depending on ‘hacks’ to make everything work properly between the two worlds (of Elm and React).</li><li>A single team can be the owner of a specific MFE which makes the teams all the more autonomous.</li><li>The risk of using a single new FE technology can be contained within a single MFE and not spread in the whole application.</li><li>Having separate deployments helped us establish a cadence of deployments for each team regardless of what the other teams do/deploy.</li></ul><h3><strong>Issues we have faced so far</strong></h3><p>Instead of analysing all the benefits, I would rather list all the issues we faced so far using MFEs</p><h4>MFE versioning</h4><p>At the very start of our journey a great problem surfaced:</p><blockquote><em>How to update an MFE to a new version and make </em><strong>kernel/shell/<em>platform that glues everything</em></strong><em> aware of its latest version?</em></blockquote><p><em>The problem</em></p><ul><li>We did not need fully automated updates of our MFEs as it could add the wrong versions in the production environment.</li><li>We did not want a fully manual solution by having to make a git commit to just update a single MFE.</li></ul><p><em>The solution</em></p><ol><li>Create a service (which we eventually called frontend configuration) that depends on <em>absolutely nothing</em> and provides the kernel with the latest version of all MFEs</li><li>A simple UI that adds a new version of an MFE and directly updates all the clients with the latest version</li><li>The only thing <em>kernel</em> has to do is make a web request to the frontend configuration API to get the latest version of all MFEs every time the application starts</li></ol><h4>Single design system</h4><p>Currently, there is not one design system in place, but instead, we have two implementations</p><ul><li>one for the React-based MFEs</li><li>one for the Elm-based MFEs</li></ul><p>The above causes the following issues:</p><ol><li>Hard to detect UI mismatches between the applications and simple UI components</li><li>Changes made to the design system are not bubbling up directly to all the MFEs but only in the “Elm” or “React” world</li><li>A huge effort of updating UI libraries (e.g material UI from version 4 to 5 used in React world) needs to be propagated to the Elm environment due to web component dependencies ( see down below ) <br>So far we have not found a good enough solution for the issue above.</li></ol><h4>Common UI components with logic — Web components</h4><p>Soon after the first React-based MFEs were deployed in production, we also had some Elm-based MFEs in our development pipelines. <br>The problem at that point was that MFE had common pieces of functionality needed regardless of the technology used to develop them.<br>Instead of implementing common functionality twice in Elm and React-based MFEs, we decided to:</p><p>1. have such functionality implemented only once either in React or in Elm and finally wrap the output down to web components to be used by both technologies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gWhC113Vpp1oXbrG52acaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jjb-xHD-VaaTqGZi" /></figure><p>2. make communication with each MFE by utilizing browser custom events.<br>In addition, the web components described above are stored in an internal storybook so that everyone ( from dev to pm to designer and back) can take a quick look/review, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ML63JJq3E1G86vssS4cJoA.png" /></figure><h4>Creating a single-page <em>mini</em> app</h4><p>Soon after we started our first MFEs another issue was surfaced: there was a need to create a single-page mini-app which was:</p><ol><li>too small for a new MFE and at the same time</li><li>too big for a web component</li><li>able to capture full viewport of the browser</li></ol><p><em>solution #1 — BlackBox pattern</em><br>Our first approach was to create a black-box app that communicates with other applications only using custom events and renders and hides from the DOM as needed. <br>More info on this approach along with the rationale can be found <a href="https://medium.com/@naimgaberlo/micro-frontend-blackbox-pattern-295c40b681e4">here</a>. <br>In addition, we have created a guide on creating an MFE BlackBox with React <a href="https://medium.com/@naimgaberlo/creating-an-mfe-blackbox-with-react-f82fd4dcc509">here</a>.</p><p><em>solution #2 — web component with its git repository </em><br>Unfortunately, solution #1 was not enough mainly because of patterns already used in the Elm-based apps. In more detail, Elm communicated with the browser using web components and since already implemented quite a few of them as stated above, we needed to use the same pattern in our <strong>single-page mini-apps</strong>.<br>Thus, we decided to switch everything to `web components` regardless of the size of the common components created.</p><h4>MFE communication</h4><p>For 2.5 years our application managed to exist with minimal interaction between MFEs. In general, communication between MFEs comes with friction and isn’t that straight forward. <a href="https://webpack.js.org/concepts/module-federation/">Module federation</a> was introduced with Webpack 5 as an attempt to make communication between MFEs easier along with other enhancements. This <a href="https://www.youtube.com/watch?v=tTwoSWJObZs&amp;ab_channel=CITYJSCONFERENCE">video</a> demonstrates a great way to handle MFE communication using module federation.</p><p>Although we are not there yet regarding module federation ( but actively looking into it ) there were certain needs for inter-app communication in our application which made it impossible to keep on neglecting that feature. <br>Currently, we try to tackle the communication by having a shared state between MFEs which is framework and library agnostic, and probably we will share the teachings of that approach in our next blog posts.</p><h4>Final words</h4><p>We still revisit our options and try to use the latest technologies that make sense in our context. Our focus for the near future is:</p><ul><li>module federation</li><li>updating fe-configuration with enhanced versioning functionality</li><li>better React &lt;-&gt; Elm interoperability</li><li>storybook for the UI components without logic</li><li>autogeneration of API contracts in typescript interfaces/types</li></ul><p>Stay tuned for blog posts that make an in-depth analysis on all of the above and more :)</p><p><strong>Resources</strong></p><ul><li><a href="https://www.youtube.com/watch?v=tTwoSWJObZs&amp;ab_channel=CITYJSCONFERENCE">Luca Mezzalira - Micro Frontends With Module Federation</a></li><li><a href="https://webpack.js.org/concepts/module-federation/">Module federation</a></li><li><a href="https://medium.com/@naimgaberlo/micro-frontend-blackbox-pattern-295c40b681e4">Micro-frontend “Blackbox Pattern”</a></li><li><a href="https://medium.com/p/f0070595004b/edit">Creating a micro-frontend blackbox with React</a></li><li><a href="https://medium.com/javascript-by-doing/how-to-create-a-web-component-in-reactjs-62b71116ea36">How to: Create a web component in ReactJS</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0070595004b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tech-gwi/our-journey-with-micro-frontends-f0070595004b">Our journey with micro-frontends</a> was originally published in <a href="https://medium.com/tech-gwi">tech-gwi</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an MFE blackbox with React]]></title>
            <link>https://medium.com/@ngkamperlo/creating-an-mfe-blackbox-with-react-f82fd4dcc509?source=rss-6aa163a8264c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f82fd4dcc509</guid>
            <category><![CDATA[vanilla-javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <dc:creator><![CDATA[Naim Gkamperlo]]></dc:creator>
            <pubDate>Fri, 22 May 2020 22:29:59 GMT</pubDate>
            <atom:updated>2020-05-22T22:37:06.503Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating a micro-frontend blackbox with React</h3><p>Blackbox pattern is a pattern developed to solve a lot of issues that usually come up in MFE development. <br>You can find more here:<br><a href="https://medium.com/@naimgaberlo/micro-frontend-blackbox-pattern-295c40b681e4?source=post_settings_page-----295c40b681e4----------------------">https://medium.com/@naimgaberlo/micro-frontend-blackbox-pattern-295c40b681e4</a></p><p>In this post, we are going to make a deep-dive in blackboxes by going through a step by step guide using React and Webpack.</p><p>Source can be found at the end of the article. So here we go…</p><h4>Step 1 - Create a React Typescript app</h4><p>Steps detailed here:<br><a href="https://create-react-app.dev/docs/adding-typescript/">https://create-react-app.dev/docs/adding-typescript/</a></p><h4>Step 2 - Eject React app to create custom webpack build</h4><pre>npm run eject</pre><h4>Step 3 - Create vanilla.tsx</h4><p>vanilla.tsx is the file which performs the following:</p><ol><li>Create a React renderer for vanilla JS</li><li>Register basic React’s lifecycle events to window</li><li>“Listen” to caller MFE’s ‘openBlackbox’ custom event to render itself on DOM element set in “init” function</li></ol><pre>import React from &quot;react&quot;;</pre><pre>import ReactDOM from &quot;react-dom&quot;;</pre><pre>import App from &quot;./App&quot;;</pre><pre>// buffer of DOM elements rendering React components</pre><pre>let nodes: Element[] = [];</pre><pre>let hostElement: Element;</pre><pre>const reactContentRenderer = {</pre><pre>unmountAll: () =&gt; {</pre><pre>if (nodes.length === 0) {</pre><pre>return;</pre><pre>}</pre><pre>nodes.forEach((node) =&gt; ReactDOM.unmountComponentAtNode(node));</pre><pre>nodes = [];</pre><pre>},</pre><pre>unmount: (node: Element) =&gt; {</pre><pre>ReactDOM.unmountComponentAtNode(node);</pre><pre>},</pre><pre>init: (targetNode: Element) =&gt; {</pre><pre>hostElement = targetNode;</pre><pre>},</pre><pre>render: (props: any, callback: () =&gt; void) =&gt; {</pre><pre>const reactElement = React.createElement(App, props, null);</pre><pre>ReactDOM.render(reactElement as any, hostElement, callback);</pre><pre>nodes.push(hostElement);</pre><pre>return reactElement;</pre><pre>},</pre><pre>};</pre><pre>//register self as window property</pre><pre>window[&quot;blackbox&quot;] = reactContentRenderer;</pre><pre>//and listen to window custom event</pre><pre>//which will be invoked via caller MFE</pre><pre>window.addEventListener(</pre><pre>&quot;openBlackbox&quot;,</pre><pre>(e: any) =&gt; {</pre><pre>const eventDetail = e.detail;</pre><pre>console.log(&quot;Blackbox open with payload&quot;, eventDetail);</pre><pre>reactContentRenderer.render(eventDetail, () =&gt; {});</pre><pre>},</pre><pre>false</pre><pre>);</pre><h4>Step 4 - Custom webpack build</h4><ul><li>Create webpack.vanilla.config.js (a copy of existing webpack.config.js)</li><li>Change the webpack.vanilla.config.js <strong>entry:</strong></li></ul><pre>entry: &#39;./src/vanilla.tsx&#39;</pre><ul><li>and <strong>output:</strong></li></ul><pre>path: path.resolve(__dirname, &#39;../build&#39;) <br>filename: &#39;blackbox.js&#39;</pre><ul><li>remove <strong><em>splitChunks &amp; runtimeChunk </em></strong>in case you need a single file as output</li></ul><h4>Step 5 - Custom build-vanilla.js</h4><p>ConfigFactory variable should be changed to point to freshly created webpack.vanilla.config.js</p><pre>const configFactory = require(&#39;../config/webpack.vanilla.config&#39;);</pre><h4><strong>Step 6 - Fix tsconfig.json</strong></h4><p>Add the following compilerOption in tsconfig.json to suppress any array index(by default number is expected)</p><pre>“suppressImplicitAnyIndexErrors”: true</pre><h4>Step 7 - Add build:vanilla to package.json and run</h4><p>In package.json add the following in scripts line:</p><pre>&quot;build:vanilla&quot;: &quot;node scripts/build-vanilla.js&quot;</pre><p>… and run</p><pre>npm run build:vanilla</pre><p><strong>Step 8 - Ready to test!</strong></p><p>Run the following in terminal:</p><pre>cd build<br>serve -s</pre><p>The above will serve static files produced as output of step 7.</p><p>In your browser if you open the url provided by serve’s output , you will see a blank screen.</p><p>To invoke your blackbox from the browser’s console run the following two commands in your developer tool’s console:</p><pre>window[&quot;blackbox&quot;].init(document.getElementById(&quot;root&quot;));<br>window.dispatchEvent(new CustomEvent(&#39;openBlackbox&#39;,{detail:{test:&#39;string&#39;}}));</pre><p>Result should be the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5zatgW5Aa2AoF1pBlZoFXQ.png" /></figure><h4>Step 9 - Create a custom event to be subscribed by host</h4><p>In case you want to be ready for next post, blackbox should dispatch its own “finish” event as described in blackbox pattern. <br>In order to do so , simply add paste the following in “App.tsx”</p><pre>import React from &quot;react&quot;;</pre><pre>import &quot;./App.css&quot;;</pre><pre>function App() {</pre><pre>const closeBlackbox = () =&gt; {</pre><pre>const event = new CustomEvent(&quot;blackboxClosed&quot;, {</pre><pre>detail: { type: &quot;edit&quot; },</pre><pre>bubbles: true,</pre><pre>});</pre><pre>window.dispatchEvent(event);</pre><pre>};</pre><pre>return (</pre><pre>&lt;div className=&quot;App&quot;&gt;</pre><pre>&lt;header className=&quot;App-header&quot;&gt;</pre><pre>&lt;button onClick={closeBlackbox}&gt;Close blackbox&lt;/button&gt;</pre><pre>&lt;/header&gt;</pre><pre>&lt;/div&gt;</pre><pre>);</pre><pre>}</pre><pre>export default App;</pre><p>In our MFE host we will subscribe to this event to listen to updates from our blackbox. More details in next post ;)</p><h4>Last words</h4><p>This is it for today! <br>In the next post we will create a MFE based app to handle our blackbox using single-spa framework!</p><p>As promised, source code can be found in the following repo:<br><a href="https://github.com/ngkamperlo/blackbox">https://github.com/ngkamperlo/blackbox</a></p><p>Thanks for reading and happy coding guys!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f82fd4dcc509" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Micro-frontend “Blackbox Pattern”]]></title>
            <link>https://medium.com/@ngkamperlo/micro-frontend-blackbox-pattern-295c40b681e4?source=rss-6aa163a8264c------2</link>
            <guid isPermaLink="false">https://medium.com/p/295c40b681e4</guid>
            <category><![CDATA[vanillajs]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[patterns]]></category>
            <category><![CDATA[micro-frontends]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Naim Gkamperlo]]></dc:creator>
            <pubDate>Mon, 04 May 2020 17:44:38 GMT</pubDate>
            <atom:updated>2020-05-04T17:44:38.738Z</atom:updated>
            <content:encoded><![CDATA[<p>TL;DR: In the Micro-Frontend world there is a need for a blackbox (hence the name of the pattern) which has an input, renders itself in the DOM and has its own workflow and produces an output for every other micro-frontend to get its results.</p><h3>The problem</h3><p>In Micro-Frontends, hereafter called “MFEs”, world there is usually a need to create a micro-frontend which can utilised by all the other micro-frontends. However, this is considered an anti-pattern because there are two famous approaches on micro-frontend implementation:</p><ul><li>No communication between MFEs</li><li>Full information exchange between MFEs</li></ul><p>So, our team came across a product requirement where neither of the above solutions was an exact fit. The requirement was to create a component which does the following:</p><ul><li><em>Is invokable by other MFEs</em></li><li><em>Is invokable by every possible front end language (Javascript, Typescript, Elm etc)</em></li><li><em>Renders itself in the DOM</em></li><li><em>Deletes itself from the DOM once its job finishes</em></li><li><em>Always provides the latest version of it to all its consumers (other micro-frontends)</em></li></ul><p>What the team added on top of these requirements was the following:<br><strong><em>Have the least possible communication with other MFEs</em></strong><em><br></em>as in the opposite scenario a lot of issues could be raised:</p><ul><li><em>…what are the names of these custom events again?</em></li><li><em>…I cannot make a proper communication between Angular and React MFEs</em></li><li><em>…misuse of local storage</em></li><li><em>…misuse of pub/sub mechanisms</em></li><li><em>…misuse of web socket mechanisms</em></li><li><em>overengineering</em></li></ul><p>As a result the last requirement of this MFE was:<br><strong><em>Have only one input and only one output event to communicate with its consumers</em></strong></p><h3>The solution</h3><h4>We first thought to just create another MFE…</h4><p>which is invoked by our central orchestrator</p><p>However that would be a bad practice due to the following:<br>1. MFEs should not share state between each other<br>2. This specific MFE should be invokable by every other MFE in the project</p><h4>We then thought of another approach</h4><p>What if we created an MFE which has the following:<br>1. A single input (which could probably be a browser’s custom event)<br>2. Render itself on the DOM (and specifically in a single element provided by each MFE that invokes it) as a vanilla JS application<br>3. A single output (which is a browser’s custom event)</p><p>And so we did. By implementing the use of the blackbox pattern, we have tackled all of our requirements:</p><h4><em>Invokable by other MFEs</em></h4><p>The implementation can be invoked by all of MFEs through browser’s custom events</p><h4><em>Invokable by every possible front end language</em></h4><p>The implementation is invokable by every front end language as it is compiled to vanilla JS</p><h4><em>Renders itself in the DOM</em></h4><p>The only input needed by the blackbox is the DOM element’s id so that it is able to mount its whole logic in a single element. <br>Even if there is a need for SPA, the whole routing of the blackbox’s MFE can be directed from within.</p><h4><em>Deletes itself from the DOM once its job finishes</em></h4><p>Once the blackbox’s job is finished, along with firing the ‘-finished’ event, it unmounts the DOM element that used, along with its scripts.</p><h4><em>Always provides the latest version of it to all its consumers</em></h4><p>The team has created a tool which always provides latest versions of all MFEs, so we just used our current pipeline.</p><h3>A more concrete example</h3><p>Let’s say that in a banking application, every MFE ( <strong>accounts </strong>MFE, <strong>cards </strong>MFE etc ) needs to display a UI for a money transaction (let’s name this <strong>TransactionsProvider </strong>) to take place and get the result of the transaction ( successful , error , error codes etc )<br>By utilising the blackbox pattern, the following solution would be given:</p><ul><li>Invoke the transaction UI with a single event i.e : ‘openTransaction’ along with the following args:</li></ul><pre>{<br>  fromMFE:&#39;accounts&#39;,<br>  payload:{<br>     fromAccount:&#39;accountA&#39;,<br>     toAccount:&#39;accountB&#39;,<br>     amount:50,<br>     currency:&#39;USD&#39;<br>  }<br>}</pre><ul><li><strong>TransactionsProvider </strong>would render itself. The user would perform every action that the UI dictates and after a while makes a money transaction. Upon close of the <strong>TransactionsProvider </strong>UI a new custom event fires which is called ‘transactionFinished’.</li><li>‘transactionFinished’ event is fired upon close of <strong>TransactionsProvider </strong>with the following result:</li></ul><pre>{<br>  resultCode:&#39;success&#39;,<br>  payload:{<br>     status:&#39;pending&#39;<br>  }<br>}</pre><ul><li>The accounts MFE that invoked the <strong>TransactionsProvider </strong>should continue its logic with the blackbox’s result.</li></ul><p>All the above can be depicted as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ohU8Uuy2JpSiAU6HzjYkQ.png" /></figure><h3>Last words</h3><p>Utilising blackbox pattern has the following <strong>perks</strong>:</p><ul><li><em>Single repository for the blackbox</em></li><li><em>Minimal communication between micro-frontends</em></li><li><em>It is technology agnostic as it is rendered by itself and can be communicated with simple vanilla JS functionality</em></li><li><em>No local storage is used and polluted</em></li><li><em>Minimum pub/sub mechanisms used</em></li><li><em>No web socket mechanisms used</em></li><li><em>No over-engineering</em></li><li><em>Is invokable by every MFE</em></li><li><em>Renders itself in the DOM</em></li><li><em>Deletes itself from the DOM once its work is finished</em></li><li><em>Always provides its latest version to all of its consumers (other micro-frontends)</em></li></ul><p>…and the following <strong>cons</strong>:</p><ul><li><em>same dependencies are loaded twice in case of using the same technology<br></em>i.e if the blackbox is implemented in Angular and the caller of it is Angular, then Angular library will be loaded twice. <br>This can be resolved if and only if same framework is used for <strong>every</strong> MFE in the project , as then it can be provided by the caller MFE as an external dependency.</li></ul><p>Code is not included as this post mainly looks on how to approach MFE issues that come up by any frontend technology. <br>However a demo github repo is around the corner!</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=295c40b681e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>