<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PurityGwaro</title>
    <description>The latest articles on DEV Community by PurityGwaro (@purity_gwaro).</description>
    <link>https://dev.to/purity_gwaro</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F639164%2F6407ea43-373b-4171-87b1-741891138005.jpg</url>
      <title>DEV Community: PurityGwaro</title>
      <link>https://dev.to/purity_gwaro</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/purity_gwaro"/>
    <language>en</language>
    <item>
      <title>Building an A2A Agent for telex.im using Mastra</title>
      <dc:creator>PurityGwaro</dc:creator>
      <pubDate>Mon, 03 Nov 2025 11:57:45 +0000</pubDate>
      <link>https://dev.to/purity_gwaro/building-an-a2a-agent-for-telexim-using-mastra-2208</link>
      <guid>https://dev.to/purity_gwaro/building-an-a2a-agent-for-telexim-using-mastra-2208</guid>
      <description>&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;For my HNGi13 Stage 3 backend task, I needed to create an Agent-to-Agent (A2A) integration with Telex.IM using JavaScript/TypeScript. I had to use Mastra AI which was both exciting and a bit challenging since I was new to building AI agents.&lt;br&gt;
I built a book suggestion agent that suggested 5 books to a user depending on the topic they submit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Learning the Ropes with Mastra AI
&lt;/h3&gt;

&lt;p&gt;I began by setting up a Mastra project, which came with a weather agent example. This was super helpful because it showed me how everything fits together. The example covered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to set up an agent&lt;/li&gt;
&lt;li&gt;Adding tools and workflows&lt;/li&gt;
&lt;li&gt;Handling API requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Building My Book Suggestion Agent
&lt;/h3&gt;

&lt;p&gt;Using the weather agent as a guide, I built my book suggestion agent. Here's how it went:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Setting Up&lt;/strong&gt;: I organized the code and set up TypeScript to catch my mistakes early.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Book Tool&lt;/strong&gt;: Created a tool that fetches book recommendations from Open Library.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conversation Flow&lt;/strong&gt;: Made sure the agent could handle different types of requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling&lt;/strong&gt;: Added friendly messages for when things don't go as planned.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Tricky Part: Telex.IM Integration
&lt;/h3&gt;

&lt;p&gt;This is where things got challenging. I struggled with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connecting my A2A agent to telex from my hosted mastra site&lt;/li&gt;
&lt;li&gt;Getting the message format just right - had some issues with the string but I figured it out&lt;/li&gt;
&lt;li&gt;making requests was initially slow and also giving results I did not want but with a couple of code fixes and more deploys I managed to make it work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The HNG team provided a &lt;a href="https://fynix.dev/blog/telex-x-mastra" rel="noopener noreferrer"&gt;helpful blog post&lt;/a&gt; that explained how to connect Mastra with Telex.IM which made things much more easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;The best part? It worked! Now I can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get book recommendations through Telex.IM&lt;/li&gt;
&lt;li&gt;See how people interact with my agent&lt;/li&gt;
&lt;li&gt;Fix issues when they come up&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can check out the interaction logs &lt;a href="https://api.telex.im/agent-logs/019a4961-93ef-7f8b-b911-2f08a6d9a8e5.txt" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see it in action.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Big Takeaways
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Examples are gold&lt;/strong&gt;: The weather agent was my best teacher.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask for help&lt;/strong&gt;: Other interns saved me hours of frustration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep trying&lt;/strong&gt;: The solution often comes right after you want to give up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use what you're given&lt;/strong&gt;: The HNG team's resources were a lifesaver.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This project was a huge learning experience. I went from knowing nothing about AI agents to building something that actually works. These skills will be super useful in any agent I work on next!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>agents</category>
      <category>ai</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>HNG13 Internship Stage 0 BE Task</title>
      <dc:creator>PurityGwaro</dc:creator>
      <pubDate>Sun, 19 Oct 2025 22:08:48 +0000</pubDate>
      <link>https://dev.to/purity_gwaro/hng13-internship-stage-0-be-task-5h7d</link>
      <guid>https://dev.to/purity_gwaro/hng13-internship-stage-0-be-task-5h7d</guid>
      <description>&lt;p&gt;I joined HNG Internship this month.&lt;br&gt;
The stage 0 task involved one displaying their profile details and a random cat fact from a provided external API.&lt;br&gt;
Here is an image to the hosted response I sent:&lt;/p&gt;

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

&lt;p&gt;While creating this simple task I got to relearn a few things to do with cors, error handling, using environment variables and hosting(used railway.com). It was a fun task to do. Looking forward to the next one.&lt;/p&gt;

</description>
      <category>hnginternship</category>
    </item>
    <item>
      <title>Data Structures and Algorithms: Big O Notation</title>
      <dc:creator>PurityGwaro</dc:creator>
      <pubDate>Wed, 16 Aug 2023 11:09:03 +0000</pubDate>
      <link>https://dev.to/purity_gwaro/data-structures-and-algorithms-big-o-notation-1m3b</link>
      <guid>https://dev.to/purity_gwaro/data-structures-and-algorithms-big-o-notation-1m3b</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Big O Notation is a way to formalize fuzzy counting.&lt;br&gt;
It allows us to talk formally about how the runtime of an algorithm grows as the inputs grow.&lt;br&gt;
It is used to analyze the performance of an algorithm.&lt;/p&gt;

&lt;p&gt;A good performing algorithm is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;faster&lt;/li&gt;
&lt;li&gt;occupies less memory during its operation&lt;/li&gt;
&lt;li&gt;is readable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Big O we majorly concentrate on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time Complexity&lt;/li&gt;
&lt;li&gt;Space Complexity&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Time Complexity
&lt;/h2&gt;

&lt;p&gt;This is the number of operations the computer has to perform during the execution of an algorithm. This remains constant no matter what computer we are on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function addUpTo(n){
    return n * (n + 1) / 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function has 3 operations: *, +, and / whether the input is 1 or 1000000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function addUpTo(n) {
    let total = 0;
    for(let i = 1; i &amp;lt;= n; i++){
        total +=1;
    }
    return total;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This second function on the other hand has these operations from the first to the last if you consider n to be 3:&lt;br&gt;
(total = 0), (let i = 1), &amp;lt;=n(i &amp;lt;= n) three times, +(i++) three times, +=(total +=1) three times.&lt;br&gt;
Now consider an input like n = 1000, those will be 1000 times more operations in the for loop.&lt;/p&gt;

&lt;p&gt;Given the examples above, the way Big O Notation is represented for the scenarios is as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;constant operations: O(1) - no. of operations remains the same despite the input value&lt;/li&gt;
&lt;li&gt;inconsistent no. of operations: O(n) - no. of operations increases as the input value increases&lt;/li&gt;
&lt;li&gt;for a for loop inside another for loop: O(n * n)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Space Complexity
&lt;/h2&gt;

&lt;p&gt;The space that an algorithm takes up as the size of the input increases.&lt;/p&gt;

&lt;p&gt;When we talk about space complexity we mostly refer to &lt;code&gt;Auxiliary Space Complexity&lt;/code&gt; which refers to the space required by the algorithm, not including space taken up by the inputs.&lt;/p&gt;
&lt;h3&gt;
  
  
  Rules of Thumb
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Most primitives(boolean, numbers, undefined, null) are constant space.&lt;/li&gt;
&lt;li&gt;Strings require O(n) space (where n is the string length)&lt;/li&gt;
&lt;li&gt;Reference types are generally O(n), where n is the length (for arrays) or the number of keys (for objects)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function addUpTo(n) {
    let total = 0;
    for(let i = 1; i &amp;lt;= n; i++){
        total +=1;
    }
    return total;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we have two variables taking up space while the algorithm executes: &lt;code&gt;total&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt;. Regardless of the size of the input there will always be two spaces used hence the function above represents &lt;code&gt;O(1)&lt;/code&gt; space complexity.&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function double(arr) {
    let newArr = [];
    for(let i = 0; i &amp;lt; arr.length; i++){
        newArr.push(2 * arr[i])
    }
    return newArr;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function on the other hand is &lt;code&gt;O(n)&lt;/code&gt; since the array length grows hence more space occupied depending on the items in the input array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Logarithms
&lt;/h2&gt;

&lt;p&gt;Sometimes Big O expressions involve more complex mathematical expressions i.e logarithms.&lt;/p&gt;

&lt;p&gt;A logarithm is the inverse of exponentiation. Just like division and multiplication are a pair, the two are.&lt;br&gt;
The logarithm of a number roughly measures the number of times you can divide that number by 2 before you get a value that's less than or equal to 1.&lt;/p&gt;

&lt;h3&gt;
  
  
  Importance of Logarithms in Big O
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Certain &lt;code&gt;Searching Algorithms&lt;/code&gt; have Logarithmic Time Complexity&lt;/li&gt;
&lt;li&gt;Efficient &lt;code&gt;Sorting Algorithms&lt;/code&gt; involve Logarithms&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Recursion&lt;/code&gt; sometimes involves Logarithmic Space Complexity&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Analyzing Performance of Arrays and Objects in the lense of Big O Notation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Objects
&lt;/h3&gt;

&lt;p&gt;They are unordered key value pairs&lt;/p&gt;

&lt;p&gt;They work well when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You don't need order&lt;/li&gt;
&lt;li&gt;You need fast access / insertion and removal&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Big O of Objects
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Insertion - O(1)&lt;/li&gt;
&lt;li&gt;Removal - O(1)&lt;/li&gt;
&lt;li&gt;Searching - O(n)&lt;/li&gt;
&lt;li&gt;Access - O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Big O of Object Methods
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Objects.keys - O(n)&lt;/li&gt;
&lt;li&gt;Objects.values - O(n)&lt;/li&gt;
&lt;li&gt;Objects.entries - O(n)&lt;/li&gt;
&lt;li&gt;hasOwnProperty - O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Arrays
&lt;/h3&gt;

&lt;p&gt;These are ordered lists&lt;/p&gt;

&lt;p&gt;They work well when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need order&lt;/li&gt;
&lt;li&gt;You need fast access / insertion and removal&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Big O of Arrays
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Insertion - depends on where we are inserting: end - O(1), beginning - O(n)&lt;/li&gt;
&lt;li&gt;Removal - depends on where we are removing: end - O(1), beginning - O(n)&lt;/li&gt;
&lt;li&gt;Searching - O(n)&lt;/li&gt;
&lt;li&gt;Access - O(1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Big O of Array Methods
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;push - O(1)&lt;/li&gt;
&lt;li&gt;pop - O(1)&lt;/li&gt;
&lt;li&gt;shift - O(n)&lt;/li&gt;
&lt;li&gt;unshift - O(n)&lt;/li&gt;
&lt;li&gt;concat - O(n)&lt;/li&gt;
&lt;li&gt;slice - O(n)&lt;/li&gt;
&lt;li&gt;sort - O(n * log n)&lt;/li&gt;
&lt;li&gt;for each/map/filter/reduce... - O(n)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>algorithms</category>
      <category>datastructures</category>
    </item>
  </channel>
</rss>
