<?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 karl devooght on Medium]]></title>
        <description><![CDATA[Stories by karl devooght on Medium]]></description>
        <link>https://medium.com/@karl.devooght?source=rss-1e1f9fbe8912------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*56wQVJDSuyV6Q5zrifi2bQ.jpeg</url>
            <title>Stories by karl devooght on Medium</title>
            <link>https://medium.com/@karl.devooght?source=rss-1e1f9fbe8912------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:03:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karl.devooght/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[Efficient Tool Selection for LLM Agents with Semantic Similarity]]></title>
            <link>https://medium.com/@karl.devooght/efficient-tool-selection-for-llm-agents-with-semantic-similarity-6187ac9e5fd7?source=rss-1e1f9fbe8912------2</link>
            <guid isPermaLink="false">https://medium.com/p/6187ac9e5fd7</guid>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[llm-function-calling]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[karl devooght]]></dc:creator>
            <pubDate>Wed, 22 Jan 2025 13:53:17 GMT</pubDate>
            <atom:updated>2025-01-22T13:53:17.830Z</atom:updated>
            <content:encoded><![CDATA[<p>When building systems for LLM agents to call external functions, selecting the right tool can be challenging. Passing all tool descriptions to an LLM might seem viable, but token limits and costs quickly become significant barriers. Here’s a concise and scalable solution: <strong>semantic similarity</strong>.</p><h3>The Problem</h3><p>LLMs like OpenAI’s models have input token limits, making it impractical to pass extensive tool descriptions for every query. Additionally, the cost of processing large inputs grows with token usage. This creates a need to pre-filter tools intelligently before querying the LLM — or skip the LLM altogether when possible.</p><h3>The Solution</h3><p>Semantic similarity allows us to compare the meaning of a user’s query with tool descriptions, ranking tools by relevance. This ensures only the most relevant tools are considered, saving both tokens and costs.</p><h3>Code Example</h3><p>Here’s a TypeScript implementation using Hugging Face’s sentence-transformers/all-MiniLM-L6-v2:</p><pre>const HF_API_URL = &#39;https://api-inference.huggingface.co/models/sentence-transformers/all-MiniLM-L6-v2&#39;;<br>const HF_API_KEY = &#39;YOUR_API_KEY&#39;; // Replace with your Hugging Face API key<br><br>async function compareSemantically(text: string, sentencesToCompare: string[]): Promise&lt;any[]&gt; {<br>    const response = await fetch(HF_API_URL, {<br>        method: &#39;POST&#39;,<br>        headers: {<br>            &#39;Authorization&#39;: `Bearer ${HF_API_KEY}`,<br>            &#39;Content-Type&#39;: &#39;application/json&#39;<br>        },<br>        body: JSON.stringify({<br>            &quot;inputs&quot;: {<br>                &quot;source_sentence&quot;: text,<br>                &quot;sentences&quot;: sentencesToCompare<br>            }<br>        })<br>    });<br><br>    if (!response.ok) throw new Error(`Error: ${response.statusText}`);<br><br>    const result = await response.json();<br>    if (!Array.isArray(result)) throw new Error(&#39;Unexpected response format.&#39;);<br><br>    return sentencesToCompare.map((sentence, index) =&gt; ({<br>        index,<br>        sentence,<br>        score: result[index]<br>    })).sort((a, b) =&gt; b.score - a.score);<br>}<br><br>// Example usage<br>const toolDescriptions = [<br>    { name: &quot;image_optimizer&quot;, description: &quot;Compresses and optimizes image files for better web performance.&quot; },<br>    { name: &quot;text_to_speech&quot;, description: &quot;Converts written text into audio for accessibility or multitasking.&quot; },<br>    { name: &quot;task_manager&quot;, description: &quot;Manages tasks and to-do lists for productivity.&quot; },<br>    { name: &quot;text-to-speech&quot;, description: &quot;Converts written text into audio for accessibility or multitasking&quot; },<br>    { name: &quot;email-generator&quot;, description: &quot;Drafts emails based on specific instructions or templates.&quot; }<br>    // Add more and more tools<br>];<br><br>const userQuery = &quot;Can you optimize this image for my website?&quot;;<br><br>compareSemantically(userQuery, toolDescriptions.map(tool =&gt; tool.description))<br>    .then(results =&gt; console.log(results.slice(0, 3))); // Log top 3 matche for instance</pre><h3>Why It Works</h3><ol><li><strong>Pre-Filtering</strong>: Ranks tools by relevance, reducing input size.</li><li><strong>Cost Savings</strong>: Avoids passing all tool descriptions to the LLM.</li><li><strong>Scalable</strong>: Handles growing toolsets without changing logic.</li><li><strong>Efficient</strong>: Can select tools directly without involving the LLM for simple queries.</li></ol><h3>Final Thoughts</h3><p>Using semantic similarity simplifies tool selection for LLM agents, making it scalable and cost-effective. Whether pre-filtering tools for an LLM or directly choosing the best match, this approach is both practical and efficient.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6187ac9e5fd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Revolutionizing Todo Lists with Generative AI: A User-Driven Exploration]]></title>
            <link>https://medium.com/@karl.devooght/revolutionizing-todo-lists-with-generative-ai-a-user-driven-exploration-db24e1a0be65?source=rss-1e1f9fbe8912------2</link>
            <guid isPermaLink="false">https://medium.com/p/db24e1a0be65</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[karl devooght]]></dc:creator>
            <pubDate>Fri, 01 Dec 2023 15:31:38 GMT</pubDate>
            <atom:updated>2023-12-01T21:50:40.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*QFt0U_PaEBS-KwoOh6BUgw.png" /></figure><p>In the realm where frontend development meets the potential of generative AI, a transformative journey unfolds. This exploration focuses on leveraging the power of generative AI to reshape the familiar landscape of todo lists, those humble companions of productivity.</p><p><strong>Setting the Stage</strong></p><p>Todo lists, fundamental in task management, have served us well in navigating daily complexities. Imagine elevating this essential tool through seamless integration with generative AI. Join us as we unravel the symbiotic relationship between frontend development and generative AI, using the todo list as our canvas.</p><p><strong>The Evolution of Interactions</strong></p><p>Traditionally, todo list interactions involve manual inputs, updates, deletions, and searches, each requiring conscious effort. This exploration aims to redefine these interactions with generative AI, turning the frontend into a dynamic gateway for intuitive and context-aware task management.</p><p>Envision a future where frontend development and generative AI converge, offering not just a technological upgrade but a fundamental shift in how we engage with tools shaping our daily productivity.</p><p><strong>The Playground</strong></p><p>Experience the synergy of Frontend and Generative AI through a minimalist approach. Our journey begins with a foundational React project, elegantly styled with Tailwind CSS, encapsulating the essence of a standard to-do list application.</p><p>Incorporating the power of the OpenAI API and Function Calling, we eschew elaborate prompt engineering. Instead, we introduce the “Just Do It” function — a syntactically concise yet potent tool that replaces business logic implementation. This function serves also as a state manager, instantiating the new to-do list after each operation. It looks like this:</p><pre>const justDoIt =  <br>{<br>  &quot;name&quot;: &quot;just_do_it&quot;,<br>  &quot;description&quot;: &quot;Just do it on task list. Never guess the tasks&quot;,<br>  &quot;parameters&quot;: {<br>    &quot;type&quot;: &quot;object&quot;, <br>    &quot;properties&quot;: {<br>        &quot;todos&quot;: {<br>          &quot;type&quot;: &quot;array&quot;,<br>          &quot;description&quot;: &quot;The new list of tasks after having applied the operation&quot;,<br>          &quot;items&quot;: {<br>            &quot;type&quot;: &quot;string&quot;,<br>          }<br>        },<br>    }<br>  }<br>};</pre><p>That’s it. This marks the completion of our implementation for the features. While it may not be production-ready at this point, the ultimate goal extends beyond its current state.</p><p>You can find the project on <a href="https://github.com/kawan16/next-gen-todolist">our Github repository</a>, presenting a clean and simple interface upon launch. While not extravagant, we showcase the transformative potential of generative AI with the addition of voice command capability and a list of initially empty to-dos.</p><p>Now, let’s explore together features such as adding, updating, removing, and filtering tasks, all through the lens of powerful generative AI. It’s worth mentioning that each example given in the article has undergone rigorous testing within the GitHub Proof of Concept project.</p><h3>Create</h3><p>In this playground of possibilities, the traditional task creation process transcends manual inputs and clicks.</p><p>Let’s start with one task “Make a cake”.</p><pre><strong>Classic UI</strong><br>Input the text &quot;Make a cake&quot; then click / enter<br><br><strong>Next-Gen UI</strong><br>Say &quot;Make a cake&quot;</pre><p><strong>Multiple.</strong> Okay, now you have a busy day with 10 tasks to plan.</p><pre><strong>Classic UI</strong><br>(input the i-th task text then click / enter) X 10<br><br><strong>Next-Gen UI<br></strong>Say &quot;Make my bed, Make a cake, Go to the shop, etc.&quot; </pre><p>The Next-Gen approach significantly saves time for handling multiple tasks seamlessly.</p><p><strong>Natural language. </strong>Writing tasks label can sometimes be an art. AI can help to just take the meaningful information. For instance:</p><pre><strong>Classic UI</strong><br>Find the right text (a potentially challenging process).<br><br><strong>Next-Gen UI</strong><br>Just say &quot;Remind me please I must make a cake for the birthday&quot; <br>and you will obtain the nice task label &quot;Make a cake for the birthday&quot;</pre><h3>Update</h3><p>Updating is common in frontend applications. Most of the time, we don’t have the choice to let the user updating item by item due to classic UI interface constraints.</p><p>Utilizing natural language, we have the capability to express changes ranging from simple to highly complex. Let’s begin with a straightforward example.</p><pre><strong>Classic UI</strong><br>Select the task, update the text and confirm<br><br><strong>Next-Gen UI</strong><br>Say &quot;Replace Go to the beach by Stay Home&quot;</pre><p>A significant distinction is that we no longer have to select a task; instead, we can simply mention it. This marks a game-changing advantage for exceptionally lengthy lists!</p><p><strong>Approximate. </strong>Unsure if we need to provide the entire task label for updating. Why not keep it natural and convey the minimum information to let the system understand your update intention, as demonstrated below:</p><pre><strong>Classic UI</strong><br>Continue to select the text (cross your fingers <br>you don&#39;t have to scroll until the end of the list).<br><br><strong>Next-Gen UI</strong><br>Say &quot;Replace the beach task by Stay Home&quot;</pre><p><strong>Divide.</strong> We move seamlessly beyond traditional CRUD. Imagine having a task that you wish to break down into smaller tasks. With the Next-Gen Todo List, just articulate your request.</p><pre><strong>Classic UI</strong><br>Hold on, let&#39;s take it slow; how can we design this <br>without unnecessary complexity?<br><br><strong>Next-Gen UI</strong><br>Say &quot;Instead of Organize the birthday <br>add Make a cake for the birthday and send invitations&quot; <br>given alist with the task &quot;Organize the birthday&quot;</pre><p>The list will incorporate the smaller tasks, and the original task will be eliminated.</p><p><strong>Merge.</strong> Replicate the process with the reverse operation. For example, combine the tasks from the two previous examples into the task “Prepare birthday.”</p><pre><strong>Classic UI</strong><br>Wow, I apologize; this seems overwhelming. Can we stick <br>to classic CRUD, please?<br><br><strong>Next-Gen UI</strong><br>Say &quot;Replace Make a cake for the birthday and send invitations <br>by Organize the birthday&quot;</pre><p>The list will be removed from the two tasks, and the new task “Prepare birthday” will be added.</p><p><strong>Duplicate. </strong>As a final step to delve a bit further with updating, let’s duplicate a task with specific guidance on how we want the duplication to occur.</p><pre><strong>Classic UI</strong><br>This one I know. Add a button &quot;Duplicate&quot; and <br>when the duplicated todo will be added to the list with the same label... <br>Mmm, no, maybe with a suffix &quot;(Copy)&quot;, much better<br><br><strong>Next-Gen UI</strong><br>Say &quot;Duplicate the cake task but for Alice and Bob&quot; <br>given an existing &quot;Make a cake for John&quot; task</pre><p>And you can expect to get 3 tasks such as “Make a cake for John”, “Make a cake for Alice” and “Make a cake for Bob”.</p><h3>Remove</h3><p>Using generative AI makes the task removal process quick and intuitive. Simply provide sufficient information to identify the task and instruct to remove it.</p><pre><strong>Classic UI</strong><br>Select the to-do and/or click on the remove button<br><br><strong>Next-Gen UI</strong><br>Verbally command, &quot;Remove the birthday task&quot; <br>given an existing &quot;Organize the birthday&quot; task</pre><p><strong>Multiple.</strong> For multiple tasks, adopt a similar approach as updating:</p><pre><strong>Classic UI</strong><br>Select each task individually for removal.<br><br><strong>Next-Gen UI</strong><br>Verbally state, &quot;Remove all birthday-related tasks,&quot; <br>considering existing tasks such as &quot;Make a cake for the birthday&quot; <br>and &quot;Send birthday invitations.&quot;</pre><p><strong>Contextual position.</strong> Utilize contextual position for task designation, where task position serves as a valuable cue:</p><pre><strong>Classic UI</strong><br>Select the i-th todo and/or click on the remove button<br><br><strong>Next-Gen UI</strong><br>Say &quot;Remove the first task from the list&quot; </pre><h3>Search</h3><p>To conclude, let’s delve into one of the most crucial features across all fields: searching. Recall those user interfaces cluttered with numerous search filters, sometimes causing you to forget what you were initially looking for? With Next-Gen User Interfaces, envision a scenario where there are no filters except the ones you specify.</p><p><strong>Regular expressions.</strong> Regular expressions often come into play when filtering a list with partially matching words. In a classic UI, you might have an input field with special syntax like “*” or “+”. In the Next-Gen Todo List, simply vocalize your search criteria:</p><pre><strong>Classic UI</strong><br>Input text augmented with specific syntax &quot;*birthday*&quot; or &quot;birthday+cake&quot;<br><br><strong>Next-Gen UI</strong><br>Say &quot;Display only tasks including the word birthday&quot; or Just show tasks including both birthday and cake&quot;</pre><p><strong>Semantic filtering.</strong> Semantic filtering offers a new dimension to task management. Imagine your to-do list contains tasks related to celebrations, such as “Organizing birthday” or “Go to the party on Saturday.” In a classic UI, finding such tasks might be challenging. However, with GenAI:</p><pre><strong>Classic UI</strong><br>You are lucky and know exactly the right words to find celebration-related tasks<br><br><strong>Next-Gen UI</strong><br>Say &quot;Display only tasks related to celebrations&quot;</pre><p><strong>Pagination.</strong> Pagination, a common feature in frontend development, traditionally involves page number navigation or setting the number of items per page. However, with user expressiveness in Next-Gen UI:</p><pre><strong>Classic UI</strong><br>Select the page 1 or 3 or last one. Filter the number of items to <br>the predefined value (10, 20, 50)<br><br><strong>Next-Gen UI</strong><br>Say &quot;Display the 10 first tasks&quot; or &quot;Show me tasks from the second position <br>to the fifth position in the list&quot;</pre><p>Consider that, given the robust filtering capabilities, does pagination retain its usefulness?</p><h3>Everything Everywhere All At Once</h3><p>Thus far, I trust you sense a transformative shift in the gaming landscape, where the mundane old CRUD (Create, Read, Update, Delete) transcends into a realm of heightened excitement. In my perspective, it’s not a matter of “if” AI will permeate our Frontend development, but rather “when” (and my intuition suggests sooner rather than later).</p><p>The emergence of generative AI has unveiled capabilities and potential far surpassing those of traditional frontend operations. As if that weren’t sufficient, the ability to seamlessly integrate and execute multiple tasks concurrently adds an additional layer of versatility:</p><pre><strong>Classic UI</strong><br>Do one operation at a time (and that can take a long long time...)<br><br><strong>Next-Gen UI</strong><br>Say &quot;Remove shop-related tasks and just show me birthday-related tasks <br>and for each, add at the end of the text Bob&#39;s birthday between parenthesis&quot;</pre><p>So, what else ?</p><p>Consider this introductory piece as a preliminary warm-up exercise. Naturally, we’ve merely skimmed the surface thus far. Putting yourself to the test will invariably unveil errors and illuminate any misunderstandings in the system. Of course, there exist certain limitations (such as cost, optimization concerns, not production-ready, and the need for a clear functional scope) that we’ll likely delve into later. Nevertheless, with just a basic setup featuring a todo list, a voice button, and a call to an OpenAI function, we can achieve fundamental CRUD operations and beyond!</p><p>Now, let’s venture deeper into the intersection of frontend and AI by extending our exploration into this simple yet powerful Todo List (always an excellent Frontend Proof of Concept topic :) ). Future articles will take us on a journey to uncover new dimensions in this incredible fusion. Stay connected, and share your perspective as a frontend developer or UX/UI designer on your Generative AI adventure.</p><p>As you embark on this exploration, here’s a question to ponder: How do you envision Generative AI reshaping the landscape of frontend development, and what unique opportunities or challenges do you foresee?</p><p>PS: <a href="https://github.com/kawan16/next-gen-todolist">If you want to play with the Next-Gen Todolist Github Repository</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db24e1a0be65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passbolt Frontend Migration]]></title>
            <link>https://medium.com/passbolt/passbolt-frontend-migration-438d3f208406?source=rss-1e1f9fbe8912------2</link>
            <guid isPermaLink="false">https://medium.com/p/438d3f208406</guid>
            <category><![CDATA[passbolt]]></category>
            <category><![CDATA[code-style-guide]]></category>
            <category><![CDATA[webextensions]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[karl devooght]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 12:59:31 GMT</pubDate>
            <atom:updated>2021-10-08T06:24:38.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHYEnwvsA-Du6UgfJHY76Q.png" /></figure><h3>How we migrated Passbolt front-end to React</h3><h4>This article will give you an overview of this React migration journey. Most of the discussed technical details come from the <a href="https://github.com/passbolt/passbolt_styleguide">style guide repository</a>.</h4><p>Any technology company must face a delicate dilemma.</p><p>On one hand your product must meet an appropriate time to market. Even if you propose the best product of the world, you can’t afford to be slow.</p><p>On the other hand one must control the technical debt. If you neglect your technical debt, the time to reach the next milestones will increase along with the product complexity. For instance, early architectural misconceptions can cause difficulties to integrate new features easily if not reworked. Hence, having an impact on your future time to market.</p><p>In some way, speed and technological debt represent the Yin and the Yang in IT. In Passbolt, we try to get the right balance between them. So, we felt that it was the right time to push the Passbolt frontend a step further.</p><p>Let’s discuss why and how.</p><h3>CanJS was not enough anymore</h3><p>Until recently, Passbolt frontend part was implemented by using <a href="https://canjs.com/">CanJs</a>. It really helped a lot at the beginning because it is quite easy to use with understandable concepts. We liked the modular and the clean Model View Controller approach. Believe it or not, when we started the project CanJS was still called JavascriptMVC. Moreover React and Vue didn’t exist yet and there were very few javascript frameworks to choose from.</p><p>Nonetheless, over the last few years, we felt that the original architecture was reaching the end of the rope with the more recent frontend developments. Implementing new features started to be a mess and upgrading dependencies more and more difficult!</p><p>Moreover, Passbolt is an open-source product with a significant community of users and contributors. Thanks to their feedback, we realized that CanJS was not synchronized with their preferences anymore nor with popular frontend practices in general.</p><p>In a word, it was time to change. Okay, but for what instead?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*SDm3dXil-Q2yXXQtNjrG5A.png" /></figure><h3>React as the perfect candidate</h3><p>There’s no shortage of Frontend framework / libs choices. In the last decade there has not a month without a new “blazing fast” frontend library. The real three first criteria we prioritized in order to select the right tool were: maturity, efficiency and the “not-too-much-opinionateness”. After a lot of comparisons and an in-depth analysis, we opted for React as the perfect candidate. Let’s discuss the reasons through a number of technical points.</p><h3>No deps please</h3><p>One of our first priorities was to minimize the number of dependencies. Passbolt is a password manager, so security matters. Every single external piece integrated to the project must have been well scrutinized by us or a larger community of security researchers. So the less the dependencies, the better.</p><p>Also, we needed mature, flexible, tiny footprint tool with a light learning curve. We didn’t want a framework to manage every aspect of the application, but rather one that focused on a few things and did it well. Some amazing frameworks such as Angular would not fit our purpose for instance: too many dependencies and a strongly opinionated solution.</p><p>On the other hand, React is definitely the perfect candidate for that. VueJS could have been another one but the team was just more equipped with React in regard of their backgrounds. For example we already had a chance to work with React when collaborating with <a href="https://github.com/toberndo">Thomas</a> on the <a href="https://github.com/mailvelope/mailvelope">Mailvelope</a> extension (another great web extension that allows you to encrypt your emails using OpenPGP)</p><p>While one can use the amazing number of open-source React community contributions, one can also opt to only use the lightweight core library and do the job perfectly. This is exactly what we’ve done. You will only find the react/ react-dom and react-router as dependencies. One exception is the use of the r<a href="https://github.com/caseywebdev/react-list">eact-list</a> which proposes a better user experience in case of a significant number of passwords in your Passbolt instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*NhZ8Ts1Xe0SlreW2Ljzo6g.png" /><figcaption><a href="https://www.reddit.com/r/ProgrammerHumor/comments/6s0wov/heaviest_objects_in_the_universe/">Sauce</a></figcaption></figure><h3>Hook or Be Hooked ?</h3><p>Quickly, the question of whether using React Hooks was put on the table. How to deal with new trendy concepts such as Hooks. Should we directly embed this more functional approach and accept its lot of uncertainties or trust a road that has been more traveled such as the oriented-class approach?</p><p>Well, if years of developer experience teach you something is that taking a wise decision begins by doubting everything and admitting you know few things. First, every magic piece comes with a (future) price. So, don’t let yourself be abused by magic or popular effects at first. Second, your priority concern should be the team, not the technology.</p><p>So, to the question “Is everybody in the team comfortable with the use of Hooks and its immediate benefit for the project?”, we first heard a silence. Then a few discussions were needed to conclude that no, the project team is not comfortable with it right now.</p><p>It was a tough decision not to go for the excitement of a trendy modern approach and stick to less “sexy” standards, so we decided to adopt a future-proof approach so that we’ll always have the freedom to change it in the future if needed. We approached the React migration such as that tomorrow we can include React Hooks (if needed) the smoothest way. To prepare for that, it’s a matter of architecture choices which we’ll discuss in the next section.</p><h3>React Context</h3><p>To the core of the current front-end philosophy are components. A modern front-end application is basically a tree of components. Behind this simple idea hides a first crucial challenge: how to define our tree of components such that it remains future-proof?</p><p>We made a deep use of React Context with this simple idea: separate pure UI components (or what we called “dumb” components) with the business logic components defined as React context (providers).</p><p>The definition of React context was guided by the Passbolt business entities. For instance, specific contexts can be found related to the password workspace, users workspace or the administration part of the application. They are the keepers of the application state, shared among the different UI components. These latter ones are context consumers in React terms.</p><p>In Passbolt, the React contexts are used as publisher / subscriber pattern’s implementation. The context provider allows to store and change the dedicated parts of the application state while the React consumers, mainly the dumb components, are provided by this state information. This way, the dumb components can react to any state’s update and, for instance, refresh their view accordingly.</p><p>Besides, a useful characteristic of the React context is the ability to separate the definition of a context from the providers of this context. The context provider is based upon the definition of the context but it can override with its own interpretation and implementation. Suppose a context that stores and manages a set of passwords, for instance<em> {passwords: [], onPasswordUpdated: () =&gt; {}}.</em> We have the capability to define two (context) providers of this and implement the function field <em>onPasswordUpdated </em>in two distinct ways. In software engineering, we would probably call this the <a href="https://en.wikipedia.org/wiki/Bridge_pattern">bridge pattern</a>. In passbolt, we applied this pattern to share the same React context in the Frontend API part and Frontend browser extension part. In the near future, we intend to explore how we can make a better use of this.</p><p>All in all, we intended to approach a pure state management approach such as Redux, Mobx, useReducer hook, and so on by decoupling UI reaction from its resolution.. This is something we started to do with the <a href="https://github.com/passbolt/passbolt_styleguide/blob/v3.0.0-beta.1/src/react-extension/contexts/AuthenticationContext.js">AuthenticationContext</a> for instance.</p><h3>Source organization</h3><p>Another point of focus was the way to organize our source code through folders. We wanted it business-oriented and, for that, use the recommendations one may find in Angular for instance.</p><p>The structure of folders are 3-level scaffolded and follow these rules:</p><ul><li>The top folders represent business entities such as passwords, users, folders</li><li>Inside these entities folders, the components folders related to the business entity.</li></ul><p>We force ourselves to name these folders to the business feature it is supposed to cover. We use a “&lt;Verb&gt;&lt;Object&gt;” naming convention to highlight the related action.</p><ul><li>Finally, in each component folder, we find its related JS(X) file using the folder naming.</li></ul><p>This way, the developer knows exactly that any other source code file in this folder exists and is used as part of the main feature component and is not shared somewhere else in the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIIZhCJaKa4heDHQO1MpaQ.png" /><figcaption>Example of component with the associated page, data and test</figcaption></figure><h3>Micro-frontends despite ourselves</h3><p>By essence, the Passbolt front-end is split into two parts: the part served by the Passbolt browser extension and the part served by the server when the browser extension is not installed yet (what we called the API front-end). The whole enchiladas forms the Passbolt front-end which must appear as smooth as possible. This is typically the<a href="https://micro-frontends.org/"> micro-frontend approach</a>.</p><p>Using React to embrace this approach is very straightforward. The same page can have several entry points and so different micro-frontends. For instance, Passbolt authentication is a standalone React app while the pure React “logged-in’’ functional part is another one. For security reasons, we favor iframes to organize our micro front-ends. Often considered as an “old school” approach, it still remains the safest way from a pure front-end point of view.</p><p>Behind the charming advantages of this approach, sooner or later you have to deal with issues. What if two micro-frontends need to communicate? How to handle route management especially in the case of iframes? Answering these questions would probably deserve a whole article. In the current state, we opted for an agnostic event-driven approach when it is strictly required. The browser extension is the conductor orchestra which receives the events from micro-frontends and dispatch to whom may be concerned the messages using the dedicated workers. It provides a more secure communication path while micro-frontends does not need to know each other.</p><h3>Next Steps</h3><p>With this frontend migration, the sky is now blue for the next upcoming features. It will enable the Passbolt team to ship features faster and increase the overall <a href="https://www.passbolt.com/roadmap">roadmap</a> delivery velocity, which makes us all excited. In the near future, we also plan to bring improvements to this first React implementation</p><p>First, as discussed, we will focus to have a clean state management oriented use of React context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*3nzRRhL8u3kiEWkIilIfXQ.jpeg" /></figure><p>Besides, we use the local storage as a pivot point between the React part and the Browser extension part. Even if it has interesting advantages such as a common source of truth, we need to rethink the way we use it especially in the case of local storage updates. For instance, the React part listens to local storage changes to update the views with fresh data. This is a good point but it over-engineers a bit the pure React frontend. We probably want to tend to something less opinionated and abstract a bit this strong relation with the local storage.</p><p>Another point of interest is the pagination of our fetched data. Even though it was historically not a priority for the first versions of the software, Passbolt has now grown in popularity and some of our users are using it with massive numbers of passwords, hence creating new challenges. Consequently, this priority changed from low to high. Several solutions are possible in such a scenario. Server pagination could seem to be the most logical one. Well, due to Passbolt particularities, that might not be the best choice. Another one is to use a browser local database such as IndexDB which has proven to be very helpful in case of offline consideration and handling queries in a serverless way. Anyway, you can expect soon even more UI fluidity in your Passbolt journey!</p><p>Last but not least, new coolest features are in the plan. With this React migration, we have a comfortable playground to free our mind. With your helpful suggestions, we are ready to push Passbolt to the next level.</p><p>So, stay tuned! And in the meantime feel free if you have questions to join us on the <a href="https://community.passbolt.com/">community forum</a> or in the comments below. We will be happy to hear any feedback or ideas!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=438d3f208406" width="1" height="1" alt=""><hr><p><a href="https://medium.com/passbolt/passbolt-frontend-migration-438d3f208406">Passbolt Frontend Migration</a> was originally published in <a href="https://medium.com/passbolt">passbolt</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>