<?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: Ayas Hussein</title>
    <description>The latest articles on DEV Community by Ayas Hussein (@ayas_tech_2b0560ee159e661).</description>
    <link>https://dev.to/ayas_tech_2b0560ee159e661</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1576337%2F49566009-1b3e-4060-af5a-f18dab0b0e57.jpg</url>
      <title>DEV Community: Ayas Hussein</title>
      <link>https://dev.to/ayas_tech_2b0560ee159e661</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayas_tech_2b0560ee159e661"/>
    <language>en</language>
    <item>
      <title>Beyond Function Calling: Why MCP is the "USB-C" of AI Integrations</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Fri, 05 Jun 2026 10:59:47 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/beyond-function-calling-why-mcp-is-the-usb-c-of-ai-integrations-14h0</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/beyond-function-calling-why-mcp-is-the-usb-c-of-ai-integrations-14h0</guid>
      <description>&lt;p&gt;If you’ve been building with Large Language Models (LLMs) lately, you’ve undoubtedly wrestled with connecting them to your data. For the past couple of years, the go-to solution has been "Tools" (or Function Calling). But recently, a new paradigm has emerged: the Model Context Protocol (MCP).&lt;/p&gt;

&lt;p&gt;If you’re wondering, "Isn't MCP just another way to do tools?" You’re not alone. Let’s break down what MCP is, how it fundamentally differs from traditional tool use, and why it might just be the missing link in your AI architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Old Way: Traditional AI "Tools" (Function Calling)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To understand MCP, we first need to look at how we’ve been connecting LLMs to the outside world.&lt;br&gt;
Traditional "tools" rely on Function Calling. As a developer, you define a function (e.g., get_weather(location: string)), provide a JSON schema describing it, and pass it to the LLM. If the model decides it needs the weather, it outputs a structured request, your code intercepts it, runs the function, and passes the result back to the model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Pain Points:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vendor Lock-in &amp;amp; Fragmentation:&lt;/strong&gt; You often have to write custom tool definitions and handlers for each AI provider (OpenAI, Anthropic, Google, etc.) because their schemas and implementation details differ slightly.&lt;br&gt;
&lt;strong&gt;Siloed Development:&lt;/strong&gt; If you build a great tool for your internal chatbot, you can’t easily plug it into a different AI app without rewriting the integration.&lt;br&gt;
&lt;strong&gt;Context Blindness:&lt;/strong&gt; Tools are great for actions (e.g., "send an email"), but they are clunky for providing rich, dynamic context (e.g., "read the last 50 lines of this specific log file and understand the database schema").&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The New Way: What is MCP?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter the Model Context Protocol (MCP). Introduced as an open standard, MCP is designed to be the universal language for connecting AI systems to data sources.&lt;br&gt;
Think of MCP as the USB-C port for AI. Just as USB-C standardized how devices connect to power and data regardless of the brand, MCP standardizes how AI assistants discover, read, and interact with external systems (databases, file systems, APIs, SaaS platforms).&lt;br&gt;
Instead of building bespoke tool integrations for every AI app, you build an MCP Server once. Any MCP-compatible AI client (like Claude Desktop, custom enterprise apps, or open-source agents) can connect to it and instantly understand what resources and actions are available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s Look at the Code&lt;/strong&gt;&lt;br&gt;
The best way to understand the difference is to see them side-by-side. Let’s build a simple feature: fetching a user profile by ID.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Traditional Tool Approach such (OpenAI/Anthropic)
Notice how much boilerplate is required, and how the schema is completely disconnected from the actual Python function.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;get_user_tool&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"get_user_profile"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Get the profile of a user by their ID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"parameters"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"object"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"user_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
                &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The unique ID of the user"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"required"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"user_id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  2. The Actual Implementation (Disconnected from the schema above)
&lt;/h1&gt;

&lt;p&gt;def get_user_profile(user_id: str) -&amp;gt; str:&lt;br&gt;
    # If you change the parameter name here, you MUST remember to &lt;br&gt;
    # update the JSON schema above, or the LLM will break.&lt;br&gt;
    return database.query(f"SELECT name, email FROM users WHERE id = '{user_id}'")&lt;/p&gt;

&lt;h1&gt;
  
  
  3. You must manually pass 'get_user_tool' in the API call to the LLM provider.`
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;2. The MCP Approach&lt;/strong&gt;&lt;br&gt;
With MCP (using the official Python SDK), the schema is generated automatically from your code’s type hints and docstrings. It’s DRY (Don't Repeat Yourself), clean, and universal.&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%2F4w842uhihx8acascmdzp.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%2F4w842uhihx8acascmdzp.png" alt=" " width="799" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do You Still Need Traditional Tools?&lt;/strong&gt;&lt;br&gt;
Yes, but their role is evolving.&lt;/p&gt;

&lt;p&gt;MCP is incredibly powerful for context retrieval and standardizing common integrations (Slack, GitHub, PostgreSQL, local file systems). However, traditional function calling is still highly relevant for:&lt;br&gt;
Highly specialized, one-off actions that don’t warrant spinning up a full MCP server.&lt;br&gt;
Strictly controlled environments where you don’t want the overhead of an external protocol.&lt;br&gt;
Legacy systems where building an MCP wrapper isn’t feasible yet.&lt;br&gt;
In the near future, the best architectures will likely use MCP for broad data access and context, supplemented by custom tools for highly specific, proprietary business logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Bottom Line&lt;/strong&gt;&lt;br&gt;
The AI industry is moving from a "wild west" of custom, fragmented integrations to a mature, interoperable ecosystem. MCP is leading this charge. By decoupling the data source from the AI client, it saves developers countless hours of boilerplate and gives AI models the rich, dynamic context they need to be truly useful.&lt;br&gt;
If you haven’t explored MCP yet, now is the time. Check out the official &lt;a href="http://modelcontextprotocol.io/docs/getting-started/intro" rel="noopener noreferrer"&gt;Model Context Protocol documentation&lt;/a&gt; and try building your first MCP server.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>llm</category>
      <category>mcp</category>
    </item>
    <item>
      <title>From Naive to Agentic: A Developer's Guide to RAG Architectures</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Sat, 28 Mar 2026 17:56:42 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/from-naive-to-agentic-a-developers-guide-to-rag-architectures-4hap</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/from-naive-to-agentic-a-developers-guide-to-rag-architectures-4hap</guid>
      <description>&lt;p&gt;If you've built even one LLM application, you've likely encountered the &lt;strong&gt;hallucination problem&lt;/strong&gt;. Your model sounds confident but makes things up. Or worse, it knows nothing about your company's private data because its training cutoff was two years ago.&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;RAG (Retrieval-Augmented Generation)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;RAG is the standard pattern for connecting LLMs to external knowledge. But here's the catch: &lt;strong&gt;Not all RAG pipelines are created equal.&lt;/strong&gt; A simple "retrieve-and-read" setup might work for a demo, but it will fail in production.&lt;/p&gt;

&lt;p&gt;In this article, we'll break down the &lt;strong&gt;4 main types of RAG architectures&lt;/strong&gt;, what specific problems they solve, and how to choose the right one for your use case.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧱 1. Naive RAG (The "Hello World")
&lt;/h2&gt;

&lt;p&gt;This is the baseline implementation you see in most tutorials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;User Query → Vector Search → Top K Chunks → LLM → Answer&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem It Solves (and Creates)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Solves:&lt;/strong&gt; Basic knowledge grounding. It stops the model from relying solely on parametric memory.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Creates:&lt;/strong&gt; Low precision and recall. You often retrieve irrelevant chunks or miss critical info due to poor chunking. It struggles with ambiguous queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🛠️ When to Use
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Prototyping MVPs.&lt;/li&gt;
&lt;li&gt;  Simple Q&amp;amp;A over clean, well-structured documents.&lt;/li&gt;
&lt;li&gt;  Low-stakes internal tools.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 2. Advanced RAG (The Production Standard)
&lt;/h2&gt;

&lt;p&gt;Advanced RAG takes the naive pipeline and optimizes every stage: &lt;strong&gt;Pre-retrieval, Retrieval, and Post-retrieval.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;Query → [Rewriting/Expansion] → Hybrid Search → [Re-Ranking] → LLM → Answer&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem It Solves
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Noise Reduction:&lt;/strong&gt; Naive RAG sends irrelevant context to the LLM, confusing it. Advanced RAG uses &lt;strong&gt;re-ranking models&lt;/strong&gt; (like Cross-Encoders) to sort results by relevance before generation.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Semantic Gap:&lt;/strong&gt; Users ask questions differently than documents are written. Advanced RAG uses &lt;strong&gt;query transformation&lt;/strong&gt; (HyDE, step-back prompting) to bridge this gap.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Chunking Issues:&lt;/strong&gt; Solves the "lost in the middle" phenomenon by optimizing chunk sizes and using &lt;strong&gt;parent-document retrievers&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🛠️ When to Use
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Customer-facing support bots.&lt;/li&gt;
&lt;li&gt;  Enterprise search where accuracy is critical.&lt;/li&gt;
&lt;li&gt;  When you notice the LLM ignoring relevant context or hallucinating despite retrieval.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 3. Modular RAG (The Composable Architecture)
&lt;/h2&gt;

&lt;p&gt;Modular RAG treats retrieval as a set of interchangeable functions rather than a linear pipeline. You can mix and match modules like search, memory, fusion, and routing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;Query → [Router] → [Search Module OR Memory Module OR API] → [Fusion] → LLM&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem It Solves
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;One-Size-Fits-All Failure:&lt;/strong&gt; Some queries need SQL, others need vector search, others need keyword search. Modular RAG uses a &lt;strong&gt;router&lt;/strong&gt; to pick the right tool.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Complex Context:&lt;/strong&gt; It enables patterns like &lt;strong&gt;Recursive Retrieval&lt;/strong&gt; (fetching small chunks, then their parent documents) or &lt;strong&gt;Iterative Retrieval&lt;/strong&gt; (searching multiple times based on previous findings).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🛠️ When to Use
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Systems with multiple data sources (SQL + PDFs + APIs).&lt;/li&gt;
&lt;li&gt;  Complex domains where queries vary wildly in intent.&lt;/li&gt;
&lt;li&gt;  When you need fine-grained control over the retrieval logic.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🤖 4. Agentic RAG (The Autonomous Workflow)
&lt;/h2&gt;

&lt;p&gt;This is the bleeding edge. Here, the LLM isn't just a generator; it's an &lt;strong&gt;agent&lt;/strong&gt; that plans, executes, and reflects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Flow:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;Agent Plans → Tool Use (Search/Calc) → Self-Correction → Final Answer&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem It Solves
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Multi-Hop Reasoning:&lt;/strong&gt; Naive RAG fails when the answer requires combining info from Document A and Document B. Agentic RAG can retrieve A, realize it needs B, retrieve B, then synthesize.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Dynamic Verification:&lt;/strong&gt; The agent can critique its own retrieved context. If the info looks outdated or conflicting, it can &lt;strong&gt;self-correct&lt;/strong&gt; and search again.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Tool Selection:&lt;/strong&gt; It decides dynamically whether to search the vector DB, query a SQL database, or call a web search API.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🛠️ When to Use
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Complex research assistants.&lt;/li&gt;
&lt;li&gt;  Financial or legal analysis requiring multi-step verification.&lt;/li&gt;
&lt;li&gt;  Workflows where latency is less critical than accuracy and reasoning depth.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📊 Quick Comparison Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Architecture&lt;/th&gt;
&lt;th&gt;Complexity&lt;/th&gt;
&lt;th&gt;Latency&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Naive&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;MVPs, Demos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Advanced&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Production Apps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modular&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Multi-source Data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Agentic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Very High&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Very High&lt;/td&gt;
&lt;td&gt;Complex Reasoning&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧭 How to Choose? (A Decision Framework)
&lt;/h2&gt;

&lt;p&gt;Don't start with Agentic RAG. You'll overengineer it. Follow this ladder:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Start with Naive:&lt;/strong&gt; Build a basic pipeline with LangChain or LlamaIndex. Evaluate it.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Move to Advanced:&lt;/strong&gt; If accuracy is &amp;lt;80%, add &lt;strong&gt;Hybrid Search&lt;/strong&gt; and a &lt;strong&gt;Re-Ranker&lt;/strong&gt;. Optimize your chunking strategy.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Go Modular:&lt;/strong&gt; If you have diverse data types (tables + text), implement a &lt;strong&gt;Router&lt;/strong&gt; to direct queries to the right retriever.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Evolve to Agentic:&lt;/strong&gt; Only if users need multi-step reasoning (e.g., "Compare Q1 sales to Q2 marketing spend") should you introduce agent loops.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  💡 Key Takeaway
&lt;/h2&gt;

&lt;p&gt;RAG isn't a single technique; it's a spectrum of architectures.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Naive&lt;/strong&gt; proves connectivity.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Advanced&lt;/strong&gt; ensures reliability.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Modular&lt;/strong&gt; ensures flexibility.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Agentic&lt;/strong&gt; ensures reasoning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most production systems today thrive with &lt;strong&gt;Advanced RAG&lt;/strong&gt;. Save the complexity of Agentic workflows for problems that truly require reasoning, not just retrieval.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>llm</category>
      <category>rag</category>
    </item>
    <item>
      <title>Building a REST API in Rust with Rocket (Part 2)</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Wed, 25 Feb 2026 06:22:09 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/building-a-rest-api-in-rust-with-rocket-part-2-491f</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/building-a-rest-api-in-rust-with-rocket-part-2-491f</guid>
      <description>&lt;p&gt;Welcome back! In &lt;a href="https://dev.to/ayas_tech_2b0560ee159e661/getting-started-with-rust-why-how-and-whats-next-1ep8"&gt;Part 1&lt;/a&gt;, we installed Rust, explored the basics of ownership, and set up our development environment. Now, it's time to build something real.&lt;/p&gt;

&lt;p&gt;Today, we are building a &lt;strong&gt;REST API&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;While there are several web frameworks in Rust (like Axum or Actix), we are choosing &lt;strong&gt;Rocket&lt;/strong&gt; for this tutorial. Why? Because Rocket prioritizes developer ergonomics. It uses macros to make routing and data handling feel magical, allowing you to focus on logic rather than boilerplate.&lt;/p&gt;

&lt;p&gt;By the end of this post, you will have a working API that can create and retrieve tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Ensure you have completed Part 1:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Rust installed (&lt;code&gt;rustc&lt;/code&gt; and &lt;code&gt;cargo&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;[ ] VS Code with &lt;code&gt;rust-analyzer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;[ ] A tool to test APIs (like &lt;strong&gt;Postman&lt;/strong&gt;, &lt;strong&gt;Insomnia&lt;/strong&gt;, or just &lt;code&gt;curl&lt;/code&gt; in your terminal).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Project Setup
&lt;/h2&gt;

&lt;p&gt;Let's create a new project specifically for our API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo new task_api
&lt;span class="nb"&gt;cd &lt;/span&gt;task_api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding Dependencies
&lt;/h3&gt;

&lt;p&gt;Open &lt;code&gt;Cargo.toml&lt;/code&gt;. We need to add &lt;strong&gt;Rocket&lt;/strong&gt; for the web server and &lt;strong&gt;Serde&lt;/strong&gt; for handling JSON data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[dependencies]&lt;/span&gt;
&lt;span class="py"&gt;rocket&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0.5"&lt;/span&gt;
&lt;span class="py"&gt;serde&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="py"&gt;version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="py"&gt;features&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"derive"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="py"&gt;serde_json&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"1.0"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: We are using Rocket 0.5, which supports Stable Rust. You do not need to install the nightly toolchain.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Defining Data Models
&lt;/h2&gt;

&lt;p&gt;In a REST API, we usually send and receive JSON. In Rust, we represent JSON objects as &lt;strong&gt;Structs&lt;/strong&gt;. We use the &lt;code&gt;serde&lt;/code&gt; library to automatically convert (serialize/deserialize) between Rust structs and JSON.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;src/main.rs&lt;/code&gt; and add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[macro_use]&lt;/span&gt; &lt;span class="k"&gt;extern&lt;/span&gt; &lt;span class="k"&gt;crate&lt;/span&gt; &lt;span class="n"&gt;rocket&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;rocket&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;serde&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;json&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;serde&lt;/span&gt;&lt;span class="p"&gt;::{&lt;/span&gt;&lt;span class="n"&gt;Deserialize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Serialize&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// 1. Define what a Task looks like&lt;/span&gt;
&lt;span class="nd"&gt;#[derive(Debug,&lt;/span&gt; &lt;span class="nd"&gt;Serialize,&lt;/span&gt; &lt;span class="nd"&gt;Deserialize)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Define what data the client sends to create a task&lt;/span&gt;
&lt;span class="c1"&gt;// (We don't need an ID, the server will generate that)&lt;/span&gt;
&lt;span class="nd"&gt;#[derive(Debug,&lt;/span&gt; &lt;span class="nd"&gt;Deserialize)]&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;NewTask&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;#[derive(Serialize)]&lt;/code&gt;: Allows Rust to turn this struct into JSON.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;#[derive(Deserialize)]&lt;/code&gt;: Allows Rust to turn incoming JSON into this struct.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;pub&lt;/code&gt;: Makes the fields accessible outside the module.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Managing State (In-Memory)
&lt;/h2&gt;

&lt;p&gt;A real API needs a database. However, setting up SQL adds a lot of complexity for a first tutorial. To keep things focused on &lt;strong&gt;Rocket&lt;/strong&gt;, we will store tasks in memory using a &lt;code&gt;Vec&lt;/code&gt; wrapped in a &lt;code&gt;Mutex&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Vec:&lt;/strong&gt; A growable list.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Mutex:&lt;/strong&gt; Allows safe access to data across multiple threads (important for web servers).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Add this below your structs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;sync&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Mutex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Our application state&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;AppState&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Mutex&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Creating Routes (Endpoints)
&lt;/h2&gt;

&lt;p&gt;Rocket uses &lt;strong&gt;macros&lt;/strong&gt; to define routes. This makes the code very readable.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Get All Tasks
&lt;/h3&gt;

&lt;p&gt;This endpoint will handle &lt;code&gt;GET /tasks&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[get(&lt;/span&gt;&lt;span class="s"&gt;"/tasks"&lt;/span&gt;&lt;span class="nd"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;get_tasks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nn"&gt;rocket&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;AppState&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;Vec&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Lock the mutex to read the data&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="py"&gt;.tasks&lt;/span&gt;&lt;span class="nf"&gt;.lock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.unwrap&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;// Return the list as JSON&lt;/span&gt;
    &lt;span class="nf"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Create a Task
&lt;/h3&gt;

&lt;p&gt;This endpoint will handle &lt;code&gt;POST /tasks&lt;/code&gt;. It accepts JSON in the body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[post(&lt;/span&gt;&lt;span class="s"&gt;"/tasks"&lt;/span&gt;&lt;span class="nd"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;format&lt;/span&gt; &lt;span class="nd"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"json"&lt;/span&gt;&lt;span class="nd"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;data&lt;/span&gt; &lt;span class="nd"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"&amp;lt;new_task&amp;gt;"&lt;/span&gt;&lt;span class="nd"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;create_task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nn"&gt;rocket&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;AppState&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="n"&gt;new_task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;NewTask&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Json&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Lock the mutex to write data&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;tasks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="py"&gt;.tasks&lt;/span&gt;&lt;span class="nf"&gt;.lock&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.unwrap&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="c1"&gt;// Generate a new ID (simple increment for demo)&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;new_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="nf"&gt;.is_empty&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="nf"&gt;.last&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.unwrap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="py"&gt;.id&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="c1"&gt;// Create the full Task&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;new_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;new_task&lt;/span&gt;&lt;span class="py"&gt;.title&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="c1"&gt;// Save it&lt;/span&gt;
    &lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="nf"&gt;.push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="nf"&gt;.clone&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

    &lt;span class="c1"&gt;// Return the created task&lt;/span&gt;
    &lt;span class="nf"&gt;Json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;&amp;amp;rocket::State&amp;lt;AppState&amp;gt;&lt;/code&gt;: This is how Rocket injects our shared state into the function.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Json&amp;lt;T&amp;gt;&lt;/code&gt;: Rocket automatically parses incoming JSON into &lt;code&gt;T&lt;/code&gt; and serializes outgoing &lt;code&gt;T&lt;/code&gt; into JSON.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;lock().unwrap()&lt;/code&gt;: We must lock the Mutex to safely modify the vector.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Putting It All Together (Main)
&lt;/h2&gt;

&lt;p&gt;Finally, we need to tell Rocket to launch, register our routes, and manage our state.&lt;/p&gt;

&lt;p&gt;Update your &lt;code&gt;main&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#[launch]&lt;/span&gt;
&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;rocket&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Initialize state with some dummy data&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AppState&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;tasks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nn"&gt;Mutex&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;vec!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Learn Rust"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Build API"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="nn"&gt;rocket&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;.manage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// Register the state&lt;/span&gt;
        &lt;span class="nf"&gt;.mount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;routes!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;get_tasks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;create_task&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// Register routes&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Run and Test
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Run the Server
&lt;/h3&gt;

&lt;p&gt;In your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see output indicating the server is running on &lt;code&gt;http://127.0.0.1:8000&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Test GET Request
&lt;/h3&gt;

&lt;p&gt;Open your browser or terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:8000/tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Response:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Learn Rust"&lt;/span&gt;&lt;span class="p"&gt;},{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Build API"&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Test POST Request
&lt;/h3&gt;

&lt;p&gt;Use curl to send JSON data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:8000/tasks &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"{&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;title&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Deploy to Production&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Response:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Deploy to Production"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run the GET request again, you will see the new task in the list!&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary of What We Built
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Dependencies:&lt;/strong&gt; We added Rocket and Serde via &lt;code&gt;Cargo.toml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Models:&lt;/strong&gt; We created Rust structs that automatically map to JSON.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;State:&lt;/strong&gt; We used a &lt;code&gt;Mutex&lt;/code&gt; to safely share data between requests.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Routes:&lt;/strong&gt; We used &lt;code&gt;#[get]&lt;/code&gt; and &lt;code&gt;#[post]&lt;/code&gt; macros to define endpoints.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Launch:&lt;/strong&gt; We mounted routes and launched the server.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Limitations &amp;amp; What's Next
&lt;/h2&gt;

&lt;p&gt;This API is great for learning, but it has a major limitation: &lt;strong&gt;Data is stored in memory.&lt;/strong&gt; If you restart the server, all tasks are lost.&lt;/p&gt;

&lt;p&gt;In a production application, you need a database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Part 3&lt;/strong&gt;, we will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Integrate SQL database&lt;/li&gt;
&lt;li&gt; Learn how to handle asynchronous database queries.&lt;/li&gt;
&lt;li&gt; Implement &lt;strong&gt;DELETE&lt;/strong&gt; and &lt;strong&gt;UPDATE&lt;/strong&gt; endpoints.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You now have the foundation to build web services in Rust. Try adding a &lt;code&gt;DELETE&lt;/code&gt; endpoint on your own before the next tutorial!&lt;/p&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>rust</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Getting Started with Rust: Why, How, and What's Next (Part 1)</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Wed, 25 Feb 2026 06:07:15 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/getting-started-with-rust-why-how-and-whats-next-1ep8</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/getting-started-with-rust-why-how-and-whats-next-1ep8</guid>
      <description>&lt;p&gt;If you've been following tech trends, you've heard the buzz about &lt;strong&gt;Rust&lt;/strong&gt;. It's been voted the "most loved programming language" on Stack Overflow for several years running. But what exactly is it? Is it worth the learning curve? And how do you actually get started?&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll cover the fundamentals of Rust, why you should consider adding it to your toolkit, how to install it, and how its ecosystem works. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Stay tuned for Part 2, where we'll use these basics to build a high-performance REST API.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use Rust?
&lt;/h2&gt;

&lt;p&gt;Rust isn't just another scripting language. It sits in a unique spot between low-level control (like C++) and high-level ergonomics (like Python). Here are the three main reasons developers are switching:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Memory Safety Without Garbage Collection
&lt;/h3&gt;

&lt;p&gt;In languages like Java or Python, a "Garbage Collector" cleans up memory for you, which can cause unpredictable pauses. In C or C++, you manage memory manually, which often leads to crashes and security vulnerabilities.&lt;/p&gt;

&lt;p&gt;Rust introduces a unique system called &lt;strong&gt;Ownership&lt;/strong&gt;. It checks memory safety at &lt;em&gt;compile time&lt;/em&gt;. If your code tries to access memory it shouldn't, the compiler refuses to build the program. This means &lt;strong&gt;no segfaults, no data races, and no garbage collector.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Blazing Performance
&lt;/h3&gt;

&lt;p&gt;Because Rust doesn't have a runtime or garbage collector, it is incredibly fast. It is comparable to C++ in performance, making it perfect for systems programming, game engines, high-frequency trading, and web backends.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Modern Tooling
&lt;/h3&gt;

&lt;p&gt;Rust comes with a built-in package manager and build tool called &lt;strong&gt;Cargo&lt;/strong&gt;. It handles dependencies, builds, testing, and documentation out of the box. No more configuring &lt;code&gt;webpack&lt;/code&gt; or &lt;code&gt;pip&lt;/code&gt; environments manually.&lt;/p&gt;




&lt;h2&gt;
  
  
  Installation: Getting Up and Running
&lt;/h2&gt;

&lt;p&gt;Installing Rust is straightforward thanks to a tool called &lt;code&gt;rustup&lt;/code&gt;. It manages your Rust version and tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Rustup
&lt;/h3&gt;

&lt;p&gt;Open your terminal (Command Prompt, PowerShell, or Bash) and run the following command:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;macOS / Linux:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;--proto&lt;/span&gt; &lt;span class="s1"&gt;'=https'&lt;/span&gt; &lt;span class="nt"&gt;--tlsv1&lt;/span&gt;.2 &lt;span class="nt"&gt;-sSf&lt;/span&gt; https://sh.rustup.rs | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;br&gt;
Download and run &lt;a href="https://rustup.rs/" rel="noopener noreferrer"&gt;&lt;code&gt;rustup-init.exe&lt;/code&gt;&lt;/a&gt; from the official website.&lt;/p&gt;

&lt;p&gt;During installation, press &lt;strong&gt;Enter&lt;/strong&gt; to confirm the default settings. This will install the compiler (&lt;code&gt;rustc&lt;/code&gt;), the package manager (&lt;code&gt;cargo&lt;/code&gt;), and standard libraries.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Verify Installation
&lt;/h3&gt;

&lt;p&gt;Close and reopen your terminal, then type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rustc &lt;span class="nt"&gt;--version&lt;/span&gt;
cargo &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see version numbers printed out. If so, you're ready!&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Editor Setup
&lt;/h3&gt;

&lt;p&gt;Rust code can be complex, so you need an editor that understands it. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download &lt;strong&gt;VS Code&lt;/strong&gt; (recommended).&lt;/li&gt;
&lt;li&gt;Install the &lt;strong&gt;rust-analyzer&lt;/strong&gt; extension. 

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Note: Do not install the old "Rust" extension. &lt;code&gt;rust-analyzer&lt;/code&gt; is the official and most powerful tool.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Understanding the Ecosystem (Not "Frameworks")
&lt;/h2&gt;

&lt;p&gt;A common question coming from languages like JavaScript (Node.js) or Python (Django) is: &lt;strong&gt;"What is the Rust framework?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The answer is: &lt;strong&gt;There isn't just one.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rust relies on an ecosystem of libraries called &lt;strong&gt;Crates&lt;/strong&gt;. You pick and choose the crates you need to build your application. This gives you flexibility but requires you to make choices.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;Web Development and APIs&lt;/strong&gt; (which we will cover in the next post), these are the top contenders:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Framework&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Axum&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Ergonomics &amp;amp; Type Safety&lt;/td&gt;
&lt;td&gt;Currently the most recommended. Built on Tokio, very modular.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Actix-web&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Known for being incredibly fast, though slightly steeper learning curve.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Rocket&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Ease of Use&lt;/td&gt;
&lt;td&gt;Very expressive and easy to read, but historically had slower release cycles.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For our upcoming REST API tutorial, we will be using &lt;strong&gt;Axum&lt;/strong&gt;, as it represents the modern standard for Rust web development.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Basics: Your First Project
&lt;/h2&gt;

&lt;p&gt;Let's create a project to understand how Rust code is structured.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Create a Project
&lt;/h3&gt;

&lt;p&gt;Navigate to your coding folder and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo new hello_rust
&lt;span class="nb"&gt;cd &lt;/span&gt;hello_rust
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Explore the Structure
&lt;/h3&gt;

&lt;p&gt;Open the folder in VS Code. You'll see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;Cargo.toml&lt;/code&gt;: The configuration file (like &lt;code&gt;package.json&lt;/code&gt;). This is where you add dependencies.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;src/main.rs&lt;/code&gt;: The entry point of your application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Write Some Code
&lt;/h3&gt;

&lt;p&gt;Open &lt;code&gt;src/main.rs&lt;/code&gt;. You'll see this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, world!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's make it slightly more interesting to see Rust's basics in action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Variables are immutable by default&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Developer"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

    &lt;span class="c1"&gt;// Use 'mut' to make a variable mutable&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Welcome to Rust"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, {}! {}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Update the mutable variable&lt;/span&gt;
    &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Let's build something fast"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Run It
&lt;/h3&gt;

&lt;p&gt;Back in your terminal, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cargo run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, Developer! Welcome to Rust
Let's build something fast
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;You now have Rust installed, you understand why it's powerful, and you've written your first program. But the real power of Rust shines when you build networked applications. In the next , I am going to create some endpoints using Rocket.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>rust</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>AI Agents Architecture</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Mon, 22 Dec 2025 20:32:26 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/ai-agents-architecture-4284</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/ai-agents-architecture-4284</guid>
      <description>&lt;p&gt;&lt;strong&gt;“What Does a Real-World AI Agent Architecture Actually Look Like?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Forget the hype. Let's talk about the &lt;strong&gt;minimal, modular architecture&lt;/strong&gt; that’s simple enough to understand and robust enough to scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 4-Layer Blueprint&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every effective AI agent is built on four distinct layers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Interface Layer: “How the World Talks to the Agent”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This layer’s job is pure translation: normalize all input and render all output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Input Handlers:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Chat&lt;/strong&gt; → Raw text&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Voice&lt;/strong&gt; → Speech-to-text (e.g. Whisper)&lt;/li&gt;
&lt;li&gt;  &lt;em&gt;Future-proof for:&lt;/em&gt; UI actions, file uploads, sensor data&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  &lt;strong&gt;Output Renderers:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;  Text replies&lt;/li&gt;
&lt;li&gt;  Text-to-speech (for voice bots)&lt;/li&gt;
&lt;li&gt;  Structured data (for APIs)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Rule of Thumb:&lt;/strong&gt; Keep this layer &lt;strong&gt;stateless&lt;/strong&gt;. Let the orchestration layer manage context and session.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2. Orchestration Layer: “The Agent’s Central Nervous System”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the command center. It manages the conversation flow, decides on actions, and maintains state.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;State Management:&lt;/strong&gt; Tracks the conversation history, user intent, and active goals.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Tool Routing:&lt;/strong&gt; Decides &lt;em&gt;when&lt;/em&gt; and &lt;em&gt;how&lt;/em&gt; to act. Should the agent answer directly, search knowledge, or call an API?&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Workflow Control:&lt;/strong&gt; Handles conditional logic, multi-step processes, and error recovery.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Reasoning &amp;amp; Memory Layer: “The Brain with a Filing System”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Powered by an LLM, but never left to its own devices. This layer is about &lt;strong&gt;grounded intelligence&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Core Model:&lt;/strong&gt; Your LLM of choice (hosted like GPT-4, or self-hosted like Llama 3).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Retrieval-Augmented Generation (RAG):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Knowledge Base:&lt;/strong&gt; Documents stored as embeddings in a vector database (I use &lt;strong&gt;Pinecone&lt;/strong&gt; for cloud, &lt;strong&gt;Chroma&lt;/strong&gt; for local).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Process:&lt;/strong&gt; Query (user input + context) fetches relevant chunks, which are injected into the LLM prompt for grounded responses.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  &lt;strong&gt;Memory:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Short-term:&lt;/strong&gt; Conversation history (cached in Redis or memory).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Long-term:&lt;/strong&gt; User profiles, past interactions, preferences (stored in a traditional SQL/NoSQL DB or knowledge graph).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Core Principle:&lt;/strong&gt; Never let the LLM “guess.” Always ground its reasoning in retrieved data or validated tool outputs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;4. Action &amp;amp; Integration Layer: “Getting Real Work Done”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This turns your agent from a conversationalist into an &lt;strong&gt;automation engine&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Tool Library:&lt;/strong&gt; A curated set of typed, idempotent functions with built-in error handling and auth.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Examples:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;  Call a REST API to check an order status.&lt;/li&gt;
&lt;li&gt;  Update a record in Salesforce or HubSpot.&lt;/li&gt;
&lt;li&gt;  Execute a query in your product database.&lt;/li&gt;
&lt;li&gt;  Trigger a CI/CD pipeline or a Slack notification.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Bottom Line&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The best AI agent isn’t the one with the fanciest model. It’s the one with the most &lt;strong&gt;robust architecture&lt;/strong&gt;,solving a real problem without breaking in production.&lt;/p&gt;

&lt;p&gt;Start with a layer. Nail it. Then scale.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>agents</category>
      <category>ai</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Golang Tutorial: Using Mutex with Goroutines</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Sat, 24 May 2025 21:24:58 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/golang-tutorial-using-mutex-with-goroutines-1b6</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/golang-tutorial-using-mutex-with-goroutines-1b6</guid>
      <description>&lt;p&gt;When working with goroutines , you often need to share data between them. However, concurrent access to shared variables can lead to race conditions ,where multiple goroutines try to read/write the same variable at the same time, leading to unpredictable behavior.&lt;/p&gt;

&lt;p&gt;To solve this, Go provides a synchronization mechanism called Mutex from the sync package.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Mutex?&lt;/strong&gt;&lt;br&gt;
A mutex (short for mutual exclusion) allows only one goroutine to access a critical section of code at a time.&lt;br&gt;
In Go, it's represented by the sync.Mutex type.&lt;br&gt;
You call Lock() before accessing the shared resource and Unlock() after you're done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example with Mutex&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
    "sync"
    "time"
)

func main() {
    counter := 0
    var mu sync.Mutex{} // Create a mutex

    var wg sync.WaitGroup // To wait for all goroutines

    for i := 0; i &amp;lt; 1000; i++ {
        wg.Add(1)
        go func() {
            defer wg.Done()
            mu.Lock()   // Lock the mutex before accessing counter
            counter++   // Critical section
            mu.Unlock() // Unlock after done
        }()
    }

    wg.Wait() // Wait until all goroutines complete
    fmt.Println("Final counter:", counter)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Final counter: 1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🚀 Tips&lt;br&gt;
Always use defer mu.Unlock() to ensure unlocking even if there’s a panic or early return.&lt;br&gt;
Avoid holding locks for too long to prevent performance issues.&lt;br&gt;
Use the -race flag when running your program to detect race conditions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run -race main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>ai agents</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Thu, 08 May 2025 13:55:58 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/ai-agents-mc0</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/ai-agents-mc0</guid>
      <description></description>
      <category>ai</category>
    </item>
    <item>
      <title>Build a Simple ToDo App with React and GraphQL</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Thu, 17 Apr 2025 19:45:13 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/build-a-simple-todo-app-with-react-and-graphql-27f2</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/build-a-simple-todo-app-with-react-and-graphql-27f2</guid>
      <description>&lt;p&gt;Have you ever wondered how to build a full-stack app using GraphQL instead of REST? In this tutorial, we’ll walk through how to create a simple ToDo app using React and GraphQL with Apollo.&lt;/p&gt;

&lt;p&gt;🎯 By the end, you’ll have a working app where you can view, add, and toggle tasks — powered by a GraphQL API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up the GraphQL Server (Backend)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir graphql-server
cd graphql-server
npm init -y
npm install apollo-server graphql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create index.js for the backend&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { ApolloServer, gql } = require('apollo-server');

const typeDefs = gql`
  type Todo {
    id: ID!
    title: String!
    completed: Boolean!
  }

  type Query {
    todos: [Todo]
  }

  type Mutation {
    addTodo(title: String!): Todo
    toggleTodo(id: ID!): Todo
  }
`;

let todos = [
  { id: "1", title: "Learn GraphQL", completed: false },
  { id: "2", title: "Build a ToDo App", completed: false },
];

const resolvers = {
  Query: {
    todos: () =&amp;gt; todos,
  },
  Mutation: {
    addTodo: (_, { title }) =&amp;gt; {
      const newTodo = { id: Date.now().toString(), title, completed: false };
      todos.push(newTodo);
      return newTodo;
    },
    toggleTodo: (_, { id }) =&amp;gt; {
      const todo = todos.find(t =&amp;gt; t.id === id);
      todo.completed = !todo.completed;
      return todo;
    },
  },
};

const server = new ApolloServer({ typeDefs, resolvers });
server.listen().then(({ url }) =&amp;gt; {
  console.log(`🚀 Server ready at ${url}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Set Up the React App (Frontend)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app graphql-todo
cd graphql-todo
npm install @apollo/client graphql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in src/index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';

const client = new ApolloClient({
  uri: 'http://localhost:4000',
  cache: new InMemoryCache(),
});

ReactDOM.render(
  &amp;lt;ApolloProvider client={client}&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/ApolloProvider&amp;gt;,
  document.getElementById('root')
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in src/App.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';
import { useQuery, useMutation, gql } from '@apollo/client';

const GET_TODOS = gql`
  query {
    todos {
      id
      title
      completed
    }
  }
`;

const ADD_TODO = gql`
  mutation($title: String!) {
    addTodo(title: $title) {
      id
      title
      completed
    }
  }
`;

const TOGGLE_TODO = gql`
  mutation($id: ID!) {
    toggleTodo(id: $id) {
      id
      completed
    }
  }
`;

function App() {
  const { data, loading } = useQuery(GET_TODOS);
  const [addTodo] = useMutation(ADD_TODO, {
    refetchQueries: [{ query: GET_TODOS }],
  });
  const [toggleTodo] = useMutation(TOGGLE_TODO);
  const [input, setInput] = useState('');

  if (loading) return &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;;

  const handleAdd = () =&amp;gt; {
    if (input.trim()) {
      addTodo({ variables: { title: input } });
      setInput('');
    }
  };

  return (
    &amp;lt;div style={{ padding: '2rem' }}&amp;gt;
      &amp;lt;h2&amp;gt;📝 GraphQL ToDo List&amp;lt;/h2&amp;gt;
      &amp;lt;input value={input} onChange={e =&amp;gt; setInput(e.target.value)} placeholder="New task" /&amp;gt;
      &amp;lt;button onClick={handleAdd}&amp;gt;Add&amp;lt;/button&amp;gt;
      &amp;lt;ul&amp;gt;
        {data.todos.map(todo =&amp;gt; (
          &amp;lt;li key={todo.id} onClick={() =&amp;gt; toggleTodo({ variables: { id: todo.id } })}&amp;gt;
            &amp;lt;span style={{ textDecoration: todo.completed ? 'line-through' : 'none' }}&amp;gt;
              {todo.title}
            &amp;lt;/span&amp;gt;
          &amp;lt;/li&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3 : Start the app&lt;/strong&gt;&lt;br&gt;
in backend&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in frontend&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🚀 You Did It!&lt;/strong&gt;&lt;br&gt;
You now have a working React app powered by GraphQL. You can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;View todos&lt;/li&gt;
&lt;li&gt;Add a new task&lt;/li&gt;
&lt;li&gt;Toggle them done/undone&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What's Next?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add delete functionality&lt;/li&gt;
&lt;li&gt;Store data in MongoDB or PostgreSQL&lt;/li&gt;
&lt;li&gt;Deploy to Vercel or Netlify&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Creating a GoLang API that allows uploading files to an Amazon S3 bucket</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Mon, 23 Dec 2024 19:41:37 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/creating-a-golang-api-that-allows-uploading-files-to-an-amazon-s3-bucket-3kj3</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/creating-a-golang-api-that-allows-uploading-files-to-an-amazon-s3-bucket-3kj3</guid>
      <description>&lt;p&gt;&lt;strong&gt;Step 1: Setup AWS S3&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in to your AWS Management Console.&lt;/li&gt;
&lt;li&gt;Navigate to S3 and create a bucket or you can use any that has been already created.
&lt;strong&gt;Step 2: Initialize Your Go Project&lt;/strong&gt;
Create a folder / dir and run below commands
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init s3-upload-api
go get github.com/aws/aws-sdk-go-v2 github.com/aws/aws-sdk-go-v2/config github.com/aws/aws-sdk-go-v2/service/s3
go get github.com/gorilla/mux

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Create the API&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "context"
    "fmt"
    "log"
    "mime/multipart"
    "net/http"
    "os"

    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/service/s3"
    "github.com/gorilla/mux"
)

var (
    s3Client   *s3.Client
    bucketName = "your-bucket-name" // Replace with your S3 bucket name
    region     = "your-region"     // Replace with your S3 bucket region
)

// initializeS3Client initializes the S3 client
func initializeS3Client() {
    cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
    if err != nil {
        log.Fatalf("unable to load SDK config, %v", err)
    }
    s3Client = s3.NewFromConfig(cfg)
}

// uploadToS3 uploads a file to S3
func uploadToS3(file multipart.File, fileName string) error {
    _, err := s3Client.PutObject(context.TODO(), &amp;amp;s3.PutObjectInput{
        Bucket: &amp;amp;bucketName,
        Key:    &amp;amp;fileName,
        Body:   file,
    })
    return err
}

// uploadHandler handles file uploads
func uploadHandler(w http.ResponseWriter, r *http.Request) {
    // Parse the incoming request
    err := r.ParseMultipartForm(10 &amp;lt;&amp;lt; 20) // Limit upload size to 10MB
    if err != nil {
        http.Error(w, "Unable to parse form", http.StatusBadRequest)
        return
    }

    file, handler, err := r.FormFile("file")
    if err != nil {
        http.Error(w, "Unable to retrieve file", http.StatusBadRequest)
        return
    }
    defer file.Close()

    // Upload file to S3
    err = uploadToS3(file, handler.Filename)
    if err != nil {
        http.Error(w, fmt.Sprintf("Failed to upload file: %v", err), http.StatusInternalServerError)
        return
    }

    w.WriteHeader(http.StatusOK)
    fmt.Fprintf(w, "File uploaded successfully: %s", handler.Filename)
}

func main() {
    initializeS3Client()

    r := mux.NewRouter()
    r.HandleFunc("/upload", uploadHandler).Methods("POST")

    port := "8080"
    log.Printf("Starting server on port %s...", port)
    log.Fatal(http.ListenAndServe(":"+port, r))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Test the API&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you are able to send a POST request to &lt;strong&gt;&lt;a href="http://localhost:8080/upload" rel="noopener noreferrer"&gt;http://localhost:8080/upload&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
with a file name. Try this in postman or your frontend app.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is a Data Pipeline?</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Fri, 20 Dec 2024 20:46:53 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/what-is-a-data-pipeline-1i70</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/what-is-a-data-pipeline-1i70</guid>
      <description>&lt;p&gt;A &lt;strong&gt;data pipeline&lt;/strong&gt; is a set of processes or tools that systematically transfer data from one system to another, often involving transformation, enrichment, validation, and loading into a target system. It automates the flow of data between different systems, applications, or storage locations while ensuring the data's quality, consistency, and usability.&lt;/p&gt;

&lt;p&gt;Data pipelines are critical in modern data-driven applications, enabling efficient and reliable data handling for analytics, machine learning, real-time decision-making, and reporting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Data Pipelines&lt;/strong&gt;&lt;br&gt;
Data pipelines can be classified based on their architecture, data movement patterns, or the kind of data they process. Here's an overview of the most common types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Batch Data Pipelines&lt;br&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; These pipelines process and move data in batches at scheduled intervals. All the data is collected, transformed, and processed together at a specific time.&lt;br&gt;
&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;br&gt;
Processing historical data for analytics&lt;br&gt;
Generating periodic reports&lt;br&gt;
Data warehousing&lt;br&gt;
&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;
Extract, Transform, Load (ETL) processes&lt;br&gt;
Hadoop MapReduce jobs&lt;br&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; Apache Hadoop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-Time (Streaming) Data Pipelines&lt;br&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; These pipelines process and transfer data as it is generated, enabling near-instantaneous data processing.&lt;br&gt;
Use Cases:&lt;br&gt;
Monitoring sensor data in IoT devices&lt;br&gt;
Fraud detection in financial transactions&lt;br&gt;
Real-time analytics for dashboards&lt;br&gt;
&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;
Streaming stock prices&lt;br&gt;
Processing clickstream data from a website&lt;br&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; Apache Kafka, Apache Flink, Google Dataflow, AWS Kinesis&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloud-Native Data Pipelines&lt;br&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; Designed to work seamlessly in cloud environments, these pipelines leverage cloud services for scalability, reliability, and integration.&lt;br&gt;
Use Cases:&lt;br&gt;
Cloud-to-cloud data transfers&lt;br&gt;
Migrating data from on-premises to cloud systems&lt;br&gt;
&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;
Data replication across cloud regions&lt;br&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; AWS Data Pipeline, Google Cloud Dataflow, Azure Data Factory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event-Driven Data Pipelines&lt;br&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; These pipelines are triggered by specific events or conditions, enabling immediate data flow in response to certain actions.&lt;br&gt;
&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;br&gt;
Updating a database when a file is uploaded to a server&lt;br&gt;
Triggering workflows upon receiving API calls&lt;br&gt;
Examples:&lt;br&gt;
Sending notifications when a user signs up&lt;br&gt;
Processing logs when an application crashes&lt;br&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; Apache Airflow, AWS Lambda&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hybrid Data Pipelines&lt;br&gt;
&lt;strong&gt;Definition:&lt;/strong&gt; These pipelines combine batch and real-time processing, allowing organizations to handle both large-scale historical data and continuous data streams.&lt;br&gt;
&lt;strong&gt;Use Cases:&lt;/strong&gt;&lt;br&gt;
Real-time dashboard updates with daily batch summaries&lt;br&gt;
Online stores processing both live orders and historical trends&lt;br&gt;
&lt;strong&gt;Examples:&lt;/strong&gt;&lt;br&gt;
E-commerce platforms combining clickstream analysis and sales trends&lt;br&gt;
Tools: Apache Beam, Snowflake&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Steps in a Data Pipeline Workflow&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Data Ingestion: Collect data from various sources (databases, APIs, IoT devices, etc.).&lt;/li&gt;
&lt;li&gt;Data Transformation: Process, clean, and transform the data into a usable format.&lt;/li&gt;
&lt;li&gt;Data Validation: Ensure the data meets quality standards (e.g., no duplicates, correct types).&lt;/li&gt;
&lt;li&gt;Data Storage: Store the processed data in a target system (e.g., data warehouse, cloud storage).&lt;/li&gt;
&lt;li&gt;Data Visualization or Analysis: Make the data available for analytics, dashboards, or machine learning models.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Data pipelines are the backbone of any data-driven organization, enabling efficient data processing and movement. By understanding the types of pipelines and their use cases, you can choose the right tools and architecture to meet your business needs. Whether processing large historical datasets or real-time data streams, a well-designed data pipeline ensures data quality, reliability, and usability.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Unleashing the Power of SQL in Machine Learning</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Sat, 30 Nov 2024 17:17:52 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/unleashing-the-power-of-sql-in-machine-learning-80j</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/unleashing-the-power-of-sql-in-machine-learning-80j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Unleashing the Power of SQL in Machine Learning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🚀 &lt;strong&gt;Machine Learning&lt;/strong&gt; is not just about fancy algorithms and frameworks; it's also about how you prepare, manipulate, and query your data. Enter &lt;strong&gt;SQL&lt;/strong&gt;—a timeless tool for data wrangling that's as relevant in ML as it is in traditional data analysis.&lt;/p&gt;

&lt;p&gt;Here’s why SQL is a must-have skill for machine learning practitioners: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔑 Why SQL Matters in ML&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Preparation&lt;/strong&gt;: Cleaning and transforming raw data into a structured format.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feature Engineering&lt;/strong&gt;: Creating new features directly in your database using SQL queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalable Querying&lt;/strong&gt;: Processing large datasets efficiently with SQL's powerful functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration with ML Pipelines&lt;/strong&gt;: Seamless compatibility with Python, R, and ML frameworks.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;💡 Common Use Cases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exploratory Data Analysis (EDA)&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt; 
   &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;department&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'IT'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get insights directly from your database!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feature Engineering&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; 
       &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
       &lt;span class="k"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amount_spent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;total_spent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
       &lt;span class="k"&gt;COUNT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;order_count&lt;/span&gt; 
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; 
   &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aggregate data for feature creation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data Labeling&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; 
       &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
       &lt;span class="k"&gt;CASE&lt;/span&gt; 
           &lt;span class="k"&gt;WHEN&lt;/span&gt; &lt;span class="n"&gt;total_spent&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt; &lt;span class="s1"&gt;'High Spender'&lt;/span&gt; 
           &lt;span class="k"&gt;ELSE&lt;/span&gt; &lt;span class="s1"&gt;'Low Spender'&lt;/span&gt; 
       &lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;spender_category&lt;/span&gt; 
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;user_data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Joining Tables for Model Inputs&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; 
       &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
       &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;purchase_history&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
       &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clicks&lt;/span&gt; 
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;purchases&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; 
   &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="n"&gt;web_activity&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; 
   &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Combine multiple data sources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚙️ SQL and Machine Learning Pipelines&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tools like &lt;strong&gt;BigQuery ML&lt;/strong&gt; and &lt;strong&gt;Snowflake&lt;/strong&gt; now integrate SQL directly into ML pipelines! You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Train models directly in SQL:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="n"&gt;MODEL&lt;/span&gt; &lt;span class="n"&gt;my_model&lt;/span&gt;
   &lt;span class="k"&gt;OPTIONS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'logistic_regression'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt;
   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;training_data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Query predictions:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;predicted_label&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;ML&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PREDICT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MODEL&lt;/span&gt; &lt;span class="n"&gt;my_model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;test_data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🎯 SQL for ML Success&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start Small&lt;/strong&gt;: Practice with common SQL queries on datasets like Titanic or Iris.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scale Gradually&lt;/strong&gt;: Explore tools like BigQuery or Snowflake for larger datasets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrate&lt;/strong&gt;: Use libraries like &lt;code&gt;pandasql&lt;/code&gt; in Python to mix SQL with your ML workflows.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Choosing the Right Relational Database</title>
      <dc:creator>Ayas Hussein</dc:creator>
      <pubDate>Fri, 29 Nov 2024 20:48:54 +0000</pubDate>
      <link>https://dev.to/ayas_tech_2b0560ee159e661/choosing-the-right-relational-database-31e7</link>
      <guid>https://dev.to/ayas_tech_2b0560ee159e661/choosing-the-right-relational-database-31e7</guid>
      <description>&lt;p&gt;Relational databases are the backbone of countless applications, from small startups to enterprise-level solutions. But with options like MySQL, Oracle, PostgreSQL, and SQL Server, how do you decide which is the right fit for your project?&lt;/p&gt;

&lt;p&gt;From my experience working on diverse applications across industries such as travel, HR, e-commerce, mobile money, and the metaverse, I’ve seen how the choice of database can profoundly impact a project’s scalability, performance, and cost-efficiency. Here's what I've learned:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. MySQL: The Lightweight Powerhouse&lt;/strong&gt;&lt;br&gt;
Best for web and mobile applications with moderate complexity and high read-heavy workloads.&lt;/p&gt;

&lt;p&gt;Strengths: Simplicity, open-source, great community support, and easy integration with popular frameworks like Laravel and Django.&lt;br&gt;
Use Case: I’ve used MySQL for learning management systems and smaller e-commerce platforms where fast development cycles were crucial.&lt;br&gt;
&lt;strong&gt;2. Oracle: The Enterprise&lt;/strong&gt;&lt;br&gt;
Best for mission-critical, high-volume transactional systems with advanced analytics and data security needs.&lt;/p&gt;

&lt;p&gt;Strengths: Robust performance, scalability, and unmatched reliability for large-scale enterprise applications.&lt;br&gt;
Use Case: In one of my projects involving enterprise-grade insurance solutions, Oracle's advanced features like partitioning and parallel query execution were game-changers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. PostgreSQL&lt;/strong&gt;&lt;br&gt;
Best for complex data modeling, geospatial data, and advanced analytics.&lt;/p&gt;

&lt;p&gt;Strengths: Feature-rich (e.g., JSONB support, window functions), highly extensible, and great for hybrid workloads combining OLTP and OLAP.&lt;br&gt;
Use Case: I relied on PostgreSQL for a health data platform that required handling both relational data and complex queries for analytics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. SQL Server&lt;/strong&gt;&lt;br&gt;
Best for enterprise applications in the Microsoft ecosystem where seamless integration is key.&lt;/p&gt;

&lt;p&gt;Strengths: Tight integration with tools like Power BI, Azure, and SSIS, along with excellent support for stored procedures and triggers.&lt;br&gt;
Use Case: I’ve implemented SQL Server in corporate HR systems where the integration with Microsoft Active Directory streamlined user authentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters&lt;/strong&gt;&lt;br&gt;
Each relational database shines in specific scenarios, and choosing the wrong one can lead to challenges like:&lt;/p&gt;

&lt;p&gt;Scalability issues: A growing user base may overwhelm the system.&lt;br&gt;
Cost inefficiency: Licensing and operational costs can spiral if not planned.&lt;br&gt;
Limited flexibility: Some databases may not support future requirements ( NoSQL-style queries or advanced analytics).&lt;br&gt;
Key Takeaways.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When selecting a database:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand your application's data structure and volume.&lt;/li&gt;
&lt;li&gt;Define your scalability and performance requirements.&lt;/li&gt;
&lt;li&gt;Consider your team’s skill set and ecosystem compatibility.&lt;/li&gt;
&lt;li&gt;Factor in long-term cost implications (open-source vs. licensed).&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
