<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nathan Tarbert on Medium]]></title>
        <description><![CDATA[Stories by Nathan Tarbert on Medium]]></description>
        <link>https://medium.com/@nathantarbert?source=rss-b6e5d79de244------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*39T9xL-oN-TxgpQwjs30nA.jpeg</url>
            <title>Stories by Nathan Tarbert on Medium</title>
            <link>https://medium.com/@nathantarbert?source=rss-b6e5d79de244------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:26:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nathantarbert/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My open source project is brand new and already has contributors. Here’s what I did.]]></title>
            <link>https://medium.com/@nathantarbert/my-open-source-project-is-brand-new-and-already-has-contributors-heres-what-i-did-b69577885e58?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/b69577885e58</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Sun, 01 Nov 2026 12:41:35 GMT</pubDate>
            <atom:updated>2026-11-01T12:41:35.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dMWam0wZQOqStMpD.png" /></figure><p>In the spirit of Hacktoberfest, with it being the last day of October, I wanted to share my story about open source and building in public.</p><p>I’m a DevRel. In my day job, I help people who’ve never contributed to open source get their first code shipped. So when I started building <a href="https://github.com/answerLoops/answerLoops">answerLoops</a>, an open source, self-hostable AI support tool, one thing bugged me. Was my own project actually easy to jump into?</p><h3>What is answerLoops?</h3><p>answerLoops turns your knowledge source into answers for your community. It’s self-hostable, so you can run it on your own infrastructure with the AI provider you choose, or use the hosted app.</p><p>Here’s the workflow:</p><ol><li>A question comes in from a community channel like Discord, Slack, Discourse, GitHub, or website chat.</li><li>answerLoops searches your knowledge: your docs, files, GitHub repos, and Notion pages.</li><li>It drafts a reply with the sources attached.</li><li>A second AI agent checks the draft against those sources.</li><li>Your team approves the reply, or you turn on auto-reply for the questions that pass the check.</li><li>Useful resolutions are saved as knowledge, and knowledge gaps show what your docs are missing.</li></ol><p>That workflow is why the labels below make sense. frontend work touches the dashboard where a team reviews and approves replies. backend work touches the pipeline and the channel integrations behind it.</p><p><a href="https://github.com/answerLoops/answerLoops">Explore answerLoops on ⭐️ GitHub</a></p><p>The project is new, so the hard part right now is getting off the ground and getting people to find it. I posted about it on Reddit and X. It didn’t bring in many stars. So I changed where I put my effort. Instead of trying to reach everyone, I focused on developers who want to build something and on making it easy for them to start.</p><p>Over the last week, developers started showing up. They sent pull requests, and I merged them. Some built something from an open issue. Others found a problem on their own and fixed it.</p><p>I can’t prove any of this is cause and effect. I have a handful of data points, and some of them didn’t pick up an issue at all. But I did set a few things up beforehand, and I think they’re worth writing down for anyone starting out.</p><h3>1. I labeled issues by skill, not just by type</h3><p>At first my issues only had the usual labels: enhancement, bug, documentation. That tells a contributor what kind of change it is, but not whether it&#39;s for them.</p><p>I added two labels: frontend and backend. Right now I have <a href="https://github.com/answerLoops/answerLoops/issues">58 open issues</a>, 41 tagged frontend and 33 tagged backend. Someone can click one label and see only the work that matches their skills, without reading all 58.</p><p>I also use good first issue and help wanted. good first issue is the one most people already know. The skill labels are the new part.</p><p>Most of the PRs I merged closed an issue with one of these labels, so they look like they’re doing something. I’m still careful about how much I claim.</p><p>One side effect: only 8 good first issue tickets are open now. Labels only work while there&#39;s something behind them, so I&#39;m writing more.</p><h3>2. I wrote issues like specs</h3><p>I’d have undersold this one if I’d only written about labels.</p><p>The issue my first contributor picked up was tagged frontend, good first issue, and help wanted. It was also written so that someone who had never seen the codebase could start. It had:</p><ul><li>A <strong>Problem</strong> section: the data was already being collected and stored, but nothing in the UI showed it.</li><li>A <strong>Scope</strong> section: exactly what to show, where to start looking in the code, and what the wording should be.</li><li>A <strong>Not in this issue</strong> section: what to leave alone, so nobody drifts into a bigger project.</li><li><strong>Acceptance criteria</strong> as a checklist.</li></ul><p>It also said it was part of a larger tracking issue, so a contributor could see where it fit.</p><p>A vague issue like “show usage on the article page” leaves a newcomer guessing about scope, wording, and what “done” means. A scoped one lets them start. If I had to pick one thing to copy, it’s this.</p><p>Every issue also ends with a link to the <a href="https://github.com/answerLoops/answerLoops/blob/main/CONTRIBUTING.md">contributing guide</a>, and it’s now built into the Issues template.</p><h3>3. I made the project easy to run</h3><p>You can’t contribute to something you can’t start. I rewrote the <a href="https://github.com/answerLoops/answerLoops/blob/main/README.md">README</a> to be a short overview, and added a <a href="https://github.com/answerLoops/answerLoops/blob/main/CONTRIBUTING.md">CONTRIBUTING guide</a> plus issue forms for bugs, features, integrations, and docs, so new reports come in with the details I need.</p><p>The first version of the setup steps wasn’t good enough. It ran the Docker path, then said “or run it natively,” and I couldn’t tell you which one to pick. If I was confused, a newcomer was too. I rewrote it as three steps: clone the app, set the values in one .env, and run it. Then I ran the native steps myself against a fresh database to make sure they work.</p><p>Contributors have already improved the docs from there, including a diagram of the install flow in the self-hosting quickstart.</p><h3>4. Review was fast, and the PRs made it easy</h3><p>The PRs came with a clear description of what changed, why, and how to try it. That made them easy to review, and I could merge quickly.</p><p>Fast feedback matters. A first-time contributor who waits two weeks for a reply rarely comes back.</p><h3>5. I said thank you in public</h3><p>The contributors are credited in the release notes and in the docs, and I thanked them publicly. Open source is mostly volunteers, so it’s the least I can do. It also shows the next person what happens when they contribute.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*zpuH28pjGNDTx93j.png" /></figure><p><em>Thanks Aaqibhafeez Khan for the kind words</em></p><h3>What I got wrong, or am not sure of</h3><ul><li><strong>I don’t know if the labels worked 100%.</strong> Nothing else about the project changed much, but I also posted about it in a few places, which brings people in on its own.</li><li><strong>Not everyone took a labeled issue.</strong> Some contributors found a problem nobody had filed, and the labels can’t explain that.</li><li><strong>Return visits are the real test.</strong> What matters is whether people come back for a second PR.</li><li><strong>The supply runs out.</strong> Contributors finish good first issue tickets quickly. Writing good ones is now a regular chore for me.</li></ul><h3>If you want to try this</h3><ul><li>Label issues by the skill needed, not just the type of change.</li><li>Write one issue as a spec: problem, scope, what’s out of scope, and acceptance criteria.</li><li>Make sure someone can run the project, and test those steps yourself.</li><li>Review fast.</li><li>Thank people in public.</li></ul><p>If you’re new to open source and want help with a first PR, leave a comment or message me. I’m happy to walk you through it. The open issues are here: <a href="https://github.com/answerLoops/answerLoops/issues">https://github.com/answerLoops/answerLoops/issues</a></p><p>And if you maintain a project: what got your first outside contributors to show up?</p><p>P.S. If you’re reading this, starring ⭐️ the <a href="https://github.com/answerLoops/answerLoops">repo</a> also really helps people find it :)</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b69577885e58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own Knowledge-Based RAG Copilot w/ Pinecone, Anthropic, & CopilotKit ]]></title>
            <link>https://levelup.gitconnected.com/build-your-own-knowledge-based-rag-copilot-w-pinecone-anthropic-copilotkit-19537e60b936?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/19537e60b936</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 16:40:32 GMT</pubDate>
            <atom:updated>2025-02-19T14:24:47.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGpL9oVPZlm8t49Xkj15Cg.png" /></figure><h3>TL;DR</h3><p>In this tutorial, we’ll walk you through building an AI-powered RAG Copilot step by step for your product Knowledge Base using the <a href="https://www.anthropic.com/api">Anthropic AI API</a>, <a href="https://www.pinecone.io/">Pinecone API</a>, and <a href="https://go.copilotkit.ai/copilotkit">CopilotKit</a>🪁.</p><p>Here’s what we’ll cover:</p><ul><li>Building a simple product knowledge base using Next.js</li><li>Adding CopilotKit UI components to your app client along with CopilotKit’s API endpoint.</li><li>Integrating Pinecone API to create searchable indexes for your knowledge base articles.</li></ul><p>Let’s get started!</p><h3>What is CopilotKit</h3><p><a href="https://go.copilotkit.ai/copilotkit">CopilotKit</a> is the leading open-source framework for integrating production-ready AI-powered copilots into your applications. It provides a <a href="https://docs.copilotkit.ai/reference/sdk/js/LangGraph">feature-rich SDK</a> that supports various AI copilot use cases, including <a href="https://docs.copilotkit.ai/reference/hooks/useCopilotReadable">context awareness</a>, <a href="https://docs.copilotkit.ai/reference/hooks/useCopilotAction">copilot actions</a>, and <a href="https://docs.copilotkit.ai/guides/generative-ui">generative UIs</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*MzZwj2hGmmB5BDfs.png" /></figure><p>This means you can focus on defining your copilot’s role, rather than getting bogged down in the technicalities of building one from scratch or dealing with complex integrations.</p><p><a href="https://github.com/CopilotKit/CopilotKit">Check out CopilotKit’s GitHub ⭐️</a></p><h3>Prerequisites</h3><p>Before we get started, here are a few things you’ll need:</p><ul><li>Familiarity with building web apps using <a href="https://react.dev/">React.js</a>. A quick note — you’ll also need some knowledge of TypeScript, as we’ll be using it for this project.</li><li>Ensure Node.js &gt;20 is installed on your system. If not, you can download and install it from the <a href="https://nodejs.org/en">official Node.js website</a>.</li></ul><p>Once you’ve covered these, we’ll set up the development environment we’ll be working in.</p><p>Here’s a quick preview of what we’ll be building:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*3bUbC4jDDAdKLZIY.png" /></figure><h3>Setting Up the Project</h3><p>To get started, run these commands to create a new directory for the project, and scaffold the Next.js application boilerplate source files and folders:</p><pre>mkdir product-knowledge-base &amp;&amp; cd product-knowledge-base<br>npx create-next-app product-knowledge-base</pre><p>Follow the setup prompts. You can select as shown below (adjust based on your project requirements).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*hLH2RFOWcwZsAxfb.png" /></figure><p>Once the project is created, navigate to the project directory, and verify everything works by running the development server:</p><pre>cd product-knowledge-base<br>npm run dev</pre><p>At this stage, your app should be running locally at <a href="http://localhost:3000.">http://localhost:3000.</a></p><p>Next, let’s install the necessary dependencies for this project. These include:</p><ul><li>Mantine UI.</li><li>CopilotKit Packages.</li><li>Pinecone SDK.</li><li>Anthropic AI SDK.</li><li>Axios.</li></ul><p>Run the following command to install them:</p><pre>yarn add @anthropic-ai/sdk @mantine/core @mantine/hooks @copilotkit/react-core @copilotkit/react-ui @copilotkit/runtime lucide-react axios @pinecone-database/pinecone</pre><p>Now, let’s set up the file structure for the project. Here is an overview of the main files and directories we’ll create:</p><ul><li>src/app/ui/service/index.ts: To handle API calls to the backend to fetch dummy posts.</li><li>src/app/ui/components/KnowledgeBase.tsx: The main UI component for the knowledge base.</li><li>src/app/lib/types/post.ts:</li><li>src/app/lib/data/data.ts: dummy post data for the knowledge base.</li><li>src/app/api/copilotkit/route.ts: CopilotKit API endpoint.</li><li>src/app/api/posts/route.ts: dummy posts API endpoint.</li></ul><p>Here’s how your project structure will look:</p><pre>product-knowledge-base/<br>├── src/<br>│   ├── app/<br>│   │   ├── ui/<br>│   │   │   ├── service/<br>│   │   │   │   └── index.ts<br>│   │   │   ├── components/<br>│   │   │   │   └── KnowledgeBase.tsx<br>│   │   ├── lib/<br>│   │   │   ├── types/<br>│   │   │   │   └── post.ts<br>│   │   │   ├── data/<br>│   │   │   │   └── data.ts<br>│   │   ├── api/<br>│   │   │   ├── copilotkit/<br>│   │   │   │   └── route.ts<br>│   │   │   ├── posts/<br>│   │   │   │   └── route.ts</pre><p>With this setup, you now have a working development environment for this tutorial.</p><h3>Building the Knowledge Base Frontend</h3><p>First, import the CopilotKit and Mantine UI providers, then wrap your entire app with them so they’re available globally. Here’s how you can update your layout.tsx file:</p><pre>import { MantineProvider } from &quot;@mantine/core&quot;;</pre><pre>import &quot;@mantine/core/styles.css&quot;;<br>import &quot;@copilotkit/react-ui/styles.css&quot;;</pre><pre>import { CopilotKit } from &quot;@copilotkit/react-core&quot;;</pre><pre>export default function RootLayout({<br>  children,<br>}: Readonly&lt;{<br>  children: React.ReactNode;<br>}&gt;) {<br>  return (<br>    &lt;html lang=&quot;en&quot;&gt;<br>      &lt;body&gt;<br>        &lt;CopilotKit runtimeUrl=&quot;/api/copilotkit&quot;&gt;<br>          &lt;MantineProvider&gt;{children}&lt;/MantineProvider&gt;<br>        &lt;/CopilotKit&gt;<br>      &lt;/body&gt;<br>    &lt;/html&gt;<br>  );<br>}</pre><p>When wrapping the app with these providers, remember to pass the runtimeUrl=&quot;&lt;endpoint-url&gt;&quot; prop to the CopilotKit provider.</p><h3>Designing the Knowledge Base Component</h3><p>In this section, we’ll go over the code you need to build the knowledge base component. Let’s start by defining the Post interface. Add the following code in your src/app/lib/types/post.ts:</p><pre>export interface Post {<br>  id: number;<br>  title: string;<br>  summary: string;<br>  content: string;<br>  category: string;<br>  createdAt: string;<br>}</pre><p>Next, navigate to the src/app/ui/service/index.ts file, and add the following code to handle API requests to fetch posts from the app’s backend:</p><pre>import axios from &#39;axios&#39;;<br>import { Post } from &#39;@/app/lib/types/post&#39;;</pre><pre>const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL </pre><pre>export const fetchPosts = async (): Promise&lt;Post[]&gt; =&gt; {<br>  const response = await axios.get(`${API_BASE_URL}/api/posts`);<br>  return response.data;<br>};</pre><p>Let’s create a .env file in the root directory of your project, and add the following base URL.</p><pre>NEXT_PUBLIC_API_BASE_URL=&#39;http://localhost:3000&#39;</pre><p>Now, let’s create the Knowledge Base UI component. Inside the src/app/ui/components/KnowledgeBase.tsx, start by adding the following imports:</p><pre>&quot;use client&quot;</pre><pre>import { useState, useEffect } from &quot;react&quot;;<br>import {<br>  Container,<br>  Title,<br>  Grid,<br>  Card,<br>  Text,<br>  Badge,<br>  Group,<br>  Stack,<br>  Box,<br>  Modal,<br>  List,<br>} from &quot;@mantine/core&quot;;<br>import { BookOpen } from &quot;lucide-react&quot;;<br>import { Post } from &quot;@/app/lib/types/post&quot;;<br>import { fetchPosts } from &quot;@/app/ui/service&quot;;</pre><p>Next, define the KnowledgeBase functional component and initialize the following states:</p><pre>export function KnowledgeBase() {<br>  const [posts, setPosts] = useState&lt;Post[]&gt;([]);<br>  const [loading, setLoading] = useState(true);<br>  const [selectedPost, setSelectedPost] = useState&lt;Post | null&gt;(null);</pre><pre>  if (loading) {<br>    return &lt;Text&gt;Loading...&lt;/Text&gt;;<br>  }</pre><pre>  return (<br>    &lt;Container size=&quot;md&quot; py=&quot;xl&quot; ml=&quot;xl&quot;&gt;<br>      &lt;Stack gap=&quot;xl&quot;&gt;<br>        &lt;Group justify=&quot;center&quot; align=&quot;center&quot;&gt;<br>          &lt;BookOpen size={32} /&gt;<br>          &lt;Title order={1}&gt;CopilotKit Product Knowledge Base&lt;/Title&gt;<br>        &lt;/Group&gt;<br>      &lt;/Stack&gt;<br>    &lt;/Container&gt;<br>  );<br>}</pre><p>Now, let’s define a function to fetch the list of posts from the API:</p><pre>useEffect(() =&gt; {<br>  const loadPosts = async () =&gt; {<br>    try {<br>      const data = await fetchPosts();<br>      setPosts(data);<br>    } catch (error) {<br>      console.error(&quot;Error loading posts:&quot;, error);<br>    } finally {<br>      setLoading(false);<br>    }<br>  };</pre><pre>  loadPosts();<br>}, []);</pre><p>To display the posts fetched from the app’s backend, add the following code. We will render the list of posts in a grid layout with cards:</p><pre>{/* Display posts */}<br>&lt;Grid&gt;<br>  {posts.map((post) =&gt; (<br>    &lt;Grid.Col key={post.id} span={{ base: 12, sm: 6, md: 4 }}&gt;<br>      &lt;Card<br>        shadow=&quot;sm&quot;<br>        padding=&quot;lg&quot;<br>        radius=&quot;md&quot;<br>        withBorder<br>        onClick={() =&gt; setSelectedPost(post)}<br>        style={{ cursor: &quot;pointer&quot; }}<br>      &gt;<br>        &lt;Stack gap=&quot;md&quot;&gt;<br>          &lt;Title order={3}&gt;{post.title}&lt;/Title&gt;<br>          &lt;Badge color=&quot;blue&quot; variant=&quot;light&quot;&gt;<br>            {post.category}<br>          &lt;/Badge&gt;<br>          &lt;Text size=&quot;sm&quot; c=&quot;dimmed&quot;&gt;<br>            {post.summary}<br>          &lt;/Text&gt;<br>          &lt;Text size=&quot;xs&quot; c=&quot;dimmed&quot;&gt;<br>            Posted on: {new Date(post.createdAt).toLocaleDateString()}<br>          &lt;/Text&gt;<br>        &lt;/Stack&gt;<br>      &lt;/Card&gt;<br>    &lt;/Grid.Col&gt;<br>  ))}<br>&lt;/Grid&gt;</pre><p>To show the content of a single post, in this case, we’ll keep things straightforward by displaying dummy content in a modal component when an article card is clicked. To do that, add the following code:</p><pre>{/* Modal for displaying selected post */}<br>{selectedPost &amp;&amp; (<br>  &lt;Modal<br>    opened={!!selectedPost}<br>    onClose={() =&gt; setSelectedPost(null)}<br>    title={selectedPost.title}<br>    centered<br>    size=&quot;xl&quot;<br>  &gt;<br>    &lt;Stack gap=&quot;md&quot;&gt;<br>      &lt;List&gt;<br>        {selectedPost.content<br>          .split(&quot;&quot;)<br>          .filter((item) =&gt; item.trim() !== &quot;&quot;)<br>          .map((item, index) =&gt; (<br>            &lt;List.Item key={index}&gt;{item}&lt;/List.Item&gt;<br>          ))}<br>      &lt;/List&gt;<br>    &lt;/Stack&gt;<br>  &lt;/Modal&gt;<br>)}</pre><p>Next, define the following function to update the selected post state when users click on the post’s card.</p><pre>const handlePostClick = (post: Post) =&gt; {<br>    setSelectedPost(post);<br>  };</pre><p>Finally, to render this component in the browser, import it in your src/app/page.tsx file with the following code (make sure to delete all the boilerplate Next.js code):</p><pre>import KnowledgeBase from &quot;@/app/ui/components/KnowledgeBase&quot;;</pre><pre>export default function Home() {<br>  return (<br>    &lt;div&gt;<br>      &lt;KnowledgeBase /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h3>Adding CopilotKit UI Components</h3><p>The next step involves adding CopilotKit UI components into the knowledge base interface. CopilotKit’s React SDK provides neatly designed and easily customizable UI components. These include sidebars, pop-ups, text areas, and a headless UI component. For this example, we will use the <strong>`CopilotSidebar</strong>` component to render an in-app chatbot interface.</p><p>To add CopilotKit’s UI sidebar component, in your src/app/ui/components/KnowledgeBase.tsx, add the following import:</p><pre>import { CopilotSidebar } from &quot;@copilotkit/react-ui&quot;;</pre><p>Once imported, add the component in the JSX return statement:</p><pre>&lt;Group justify=&quot;center&quot; style={{ width: &quot;100%&quot; }}&gt;<br>  &lt;Box style={{ flex: 1, maxWidth: &quot;350px&quot; }}&gt;<br>    &lt;CopilotSidebar<br>      instructions=&quot;Help the user get the right knowledge base articles for their query&quot;<br>      labels={{<br>        initial: &quot;Welcome! Describe the query you need assistance with.&quot;,<br>      }}<br>      defaultOpen={true}<br>      clickOutsideToClose={false}<br>    /&gt;<br>  &lt;/Box&gt;<br>&lt;/Group&gt;</pre><p>The component accepts various props, including instructions, labels, defaultOpen, and clickOutsideToClose. Importantly, the instructions prop allows you to provide additional context to help the underlying Copilot AI LLM better understand and respond to user queries.</p><h3>Using CopilotKit Hooks for AI Actions</h3><p>The React CopilotKit SDK also provides a set of useful hooks that enable you to define custom actions for your app’s AI Copilot. For this example, we will use the useCopilotAction hook to define the intended action, that is, to retrieve knowledge base articles based on a user query.</p><p>To do that, start by importing the useCopilotAction hook in your KnowledgeBase component file as follows:</p><pre>import { useCopilotAction } from &quot;@copilotkit/react-core&quot;;</pre><p>After importing, you can initialize the hook, and specify the action you want the copilot to perform. In this case, we’ll define an action named “FetchKnowledgebaseArticles” to retrieve relevant articles based on the supplied user query. Let’s write the code for it:</p><pre>useCopilotAction({<br>  name: &quot;FetchKnowledgebaseArticles&quot;,<br>  description: &quot;Fetch relevant knowledge base articles based on a user query&quot;,<br>  parameters: [<br>    {<br>      name: &quot;query&quot;,<br>      type: &quot;string&quot;,<br>      description: &quot;User query for the knowledge base&quot;,<br>      required: true,<br>    },<br>  ],<br>  render: &quot;Getting relevant answers to your query...&quot;,<br>});</pre><p>This action setup includes several important elements. The name attribute provides a unique identifier for the action, while the description explains its purpose and when it should be used.</p><p>Additionally, the parameters array defines the inputs required for the action, such as the user’s query in this case. And lastly, the render property allows you to specify what will be displayed while the action is being executed. For this example, we’ll display a simple status message to keep the user informed about the ongoing process.</p><h3>Integrating the App’s Backend</h3><p>To complete the entire app’s workflow, let’s build the backend by adding endpoints for fetching posts, integrating CopilotKit functionality, and the Pinecone API to create searchable indexes for the knowledge base articles.</p><p>To do that, first, go to this <a href="https://github.com/ItsWachira/Next-Anthropic-AI-Copilot-Product-Knowledge-base/blob/main/src/app/lib/data/data.ts">GitHub repository</a> file containing the dummy posts data, copy, and paste it into your local src/app/lib/data/data.ts file.</p><p>Next, in the src/app/api/posts/route.ts file, add the following code to set up the dummy posts API endpoint:</p><pre>import { NextResponse } from &#39;next/server&#39;;<br>import { posts } from &#39;@/app/lib/data/data&#39;;</pre><pre>export async function GET() {<br>  return NextResponse.json(posts);<br>}</pre><p>At this point, start your dev server and head over to your app’s localhost URL. You should see the list of posts displayed, along with the CopilotKit sidebar component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*1ElCGbGRvxl2AdcW.png" /></figure><p>Going back to the main intent of the guide, which is, integrating an AI Copilot for product knowledge bases. Typically, most product knowledge bases are loaded with all sorts of content — blog articles, FAQs, internal SOPs, API documentation, and more. That’s a lot more than the three dummy posts we’re working with in this example.</p><p>Normally, these knowledge bases have integrated Algolia Search API to let users quickly search through resources. Now for the AI copilot, we want to go beyond just “search-show”.Essentially, we want to take advantage of LLMs’ ability to understand natural language to implement “conversational-like” search functionality for knowledge bases’ resources.</p><p>Instead of simply returning static search results, the Copilot will allow users to “chat” about the resources, ask follow-up questions, and get answers in a much more user-friendly way. This is arguably more intuitive.</p><p>To make this happen, we need to create LLM-searchable indexes — essentially, data sources that the AI can query to fetch the right information. For this, we’ll use Pinecone’s vector database API to create a searchable index for the dummy data.</p><h3>Creating Searchable Indexes using Pinecone API SDK</h3><p><a href="https://www.pinecone.io/">Pinecone</a> is a vector database service designed for fast, scalable, and accurate intelligent search capabilities in applications. It allows you to store and retrieve vector representations of data efficiently, making it ideal for tasks like semantic search and recommendation systems.</p><p>What this means is that instead of relying solely on Anthropic AI LLM powering the Copilot to generate responses based on preexisting training knowledge, you can customize and contextualize the LLM so that your Copilot can address user queries and generate responses based on your app’s data. Ideally, this is why Pinecone becomes useful — it allows you to create vector databases for your data that are easily searchable with large language models.</p><p>Essentially, in this example, we are simply integrating Pinecone to create indexes for our knowledge base data. This way, the Copilot can first search through the data and generate more relevant, contextualized responses, along with accurately addressing follow-up questions based on the same knowledge base data.</p><p>Here’s a quick overview of what we’ll do:</p><ol><li>Set up Pinecone.</li><li>Generating knowledge base content embeddings for the sample articles.</li><li>Indexing and querying the knowledge base data.</li></ol><p>In the src/app/api/copilotkit/route.ts file, let’s start by making the following imports:</p><pre>import { Pinecone } from &#39;@pinecone-database/pinecone&#39;;<br>import {posts} from &quot;@/app/lib/data/data&quot;;</pre><p>Next, define your environment variables for the Pinecone and Anthropic API keys:</p><pre>const ANTHROPIC_API_KEY = process.env.NEXT_PUBLIC_ANTHROPIC_API_KEY;<br> const PINECONE_API_KEY = process.env.NEXT_PUBLIC_PINECONE_API_KEY;</pre><p>It’s a good practice to add a check to ensure these keys are provided Don’t worry — we’ll cover the steps for getting the Anthropic API key later on.</p><pre>if (!ANTHROPIC_API_KEY || !PINECONE_API_KEY) {<br>  console.error(&#39;Missing required API keys. &#39;);<br>  process.exit(1);<br>}</pre><p>Now, initialize the Pinecone SDK, and set up the necessary configurations:</p><pre>const pinecone = new Pinecone({ apiKey: PINECONE_API_KEY });<br>const model = &#39;multilingual-e5-large&#39;;<br>const indexName = &#39;knowledge-base-data&#39;;</pre><p>We can now create the Pinecone index. An index is essentially a structured storage(numerical representations of data), that allows you to efficiently search and retrieve data based on vector similarity.</p><p>Ideally, for a production app, you would typically make API calls to retrieve your posts’ data dynamically. However, in this case, we will use the dummy data to simulate this process.</p><p>To create a vector database for our knowledge base data, we need to initialize a Pinecone index for the data.</p><p>Here’s the function to achieve this:</p><pre>// Function to create the Pinecone index<br>const initializePinecone = async () =&gt; {<br>  const maxRetries = 3;<br>  const retryDelay = 2000;</pre><pre>  for (let i = 0; i &lt; maxRetries; i++) {<br>    try {<br>      const indexList = await pinecone.listIndexes();<br>      if (!indexList.indexes?.some(index =&gt; index.name === indexName)) {<br>        await pinecone.createIndex({<br>          name: indexName,<br>          dimension: 1024,<br>          metric: &#39;cosine&#39;,<br>          spec: {<br>            serverless: {<br>              cloud: &#39;aws&#39;,<br>              region: &#39;us-east-1&#39;,<br>            },<br>          },<br>        });<br>        await new Promise(resolve =&gt; setTimeout(resolve, 5000));<br>      }<br>      return pinecone.index(indexName);<br>    } catch (error) {<br>      if (i === maxRetries - 1) throw error;<br>      console.warn(`Retrying Pinecone initialization... (${i + 1}/${maxRetries})`);<br>      await new Promise(resolve =&gt; setTimeout(resolve, retryDelay));<br>    }<br>  }<br>  return null; <br>};</pre><p>Once it’s set up, you can use it to store and retrieve your knowledge base data.</p><p>Next, we need to generate embeddings for your knowledge base. This step is crucial for enabling your application to efficiently store and search through large volumes of data using vector embeddings.</p><p>Embedding your knowledge base content is simply converting the raw data — typically text — into vectors that represent the semantic meaning of that data. Pinecone then stores these vectors in the index.</p><p>With the index in place, your application can perform operations like similarity search, allowing it to retrieve the most relevant data quickly based on the vector similarity between your queries and stored content.</p><p>To do that, add the following function:</p><pre>// Initialize Pinecone and prepare the index<br>(async () =&gt; {<br>    try {<br>      const index = await initializePinecone();<br>      if (index) {<br>        const embeddings = await pinecone.inference.embed(<br>          model,<br>          posts.map(d =&gt; d.content),<br>          { inputType: &#39;passage&#39;, truncate: &#39;END&#39; }<br>        );</pre><pre>        const records = posts.map((d, i) =&gt; ({<br>          id: d.id.toString(),<br>          values: embeddings[i]?.values ?? [],<br>          metadata: { text: d.content },<br>        }));  <br>        await index.namespace(&#39;knowledge-base-data-namespace&#39;).upsert(<br>          records.map(record =&gt; ({<br>            ...record,<br>            values: record.values || [],<br>          }))<br>        );<br>      }<br>    } catch (error) {<br>      console.error(&#39;Error initializing Pinecone:&#39;, error);<br>      process.exit(1);<br>    }<br>  })();</pre><p>There are a few things we need to note:</p><ul><li>Embeddings: These are vector representations of content, such as text or articles, that capture the semantic meaning of the data. In this case, embeddings are generated using Pinecone’s model, <strong>multilingual-e5-large</strong>, which processes the content and converts it into vectors. Note that you can also use other models, such as OpenAI, which provides an embedding API for this task.</li><li>Namespace: A namespace in Pinecone is a logical partitioning of your index. It allows you to organize data within the index and perform operations within specific segments of your data. In this case, the namespace is set to ‘knowledge-base-data-namespace’, which groups the knowledge base content.</li><li>Records: These represent the data being inserted into Pinecone. Each record consists of an id, values (the embedding), and metadata (e.g., the text of the article). The values are what Pinecone uses to perform similarity searches, while the metadata provides additional context for each record.</li></ul><p>Now, for setup this to work, you will need to get the Pinecone API key.</p><h3>How to Get Your Pinecone API Key:</h3><p>To get your Pinecone AI API Key, follow these steps:</p><ol><li>Head over to the <a href="https://app.pinecone.io/">Pinecone Developer Console</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qu7M2RA6lMUrR6t1.png" /></figure><ol><li>Select the <strong>API Keys</strong> tab, then click <strong>Create API Key</strong>. You can either use the default key or create a new one.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*BsblvxvjMDeOWnhb.png" /></figure><ol><li>Specify the name of the key and click <strong>Create key</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/0*EnrQuIKBHQB69EtP.png" /></figure><p>Once you’ve completed these steps, return to your .env file, and paste the key:</p><pre>NEXT_PUBLIC_PINECONE_API_KEY=your-api-key</pre><h3>Integrating the CopiloKit Node.js Endpoint</h3><p>The final step is to add the CopilotKit Node.js endpoint to handle requests from the frontend.</p><p>Before proceeding, you’ll need to set up the Anthropic API to make requests to their service. To do that:</p><ol><li>Create an Anthropic Account by visiting the <a href="https://docs.anthropic.com/en/api/getting-started#accessing-the-api">Anthropic AI documentation</a> to create an account and set up billing.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*a_jBAoHA1PEJGqbP.png" /></figure><ol><li>After logging into the Anthropic API console, generate your API key.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*gKr8XfIYp2GY37mB.png" /></figure><ol><li>Once you have the API key, add it to your .env file in the root of your project:</li></ol><p>Be sure to set up billing and quotas to enable your app to make API requests.</p><p>Remember, we added the CopilotKit API URL in the app’s client to allow it to forward requests to the CopilotKit backend for processing. To make this work, we need to define the CopilotKit API endpoint to manage and handle those requests. Let’s start by importing the following in the src/app/api/copilotkit/route.ts file:</p><pre>import { CopilotRuntime, AnthropicAdapter, copilotRuntimeNextJSAppRouterEndpoint } from &quot;@copilotkit/runtime&quot;;</pre><pre>import Anthropic from &quot;@anthropic-ai/sdk&quot;;<br>import { NextRequest } from &#39;next/server&#39;</pre><p>The Copilot Runtime is the backend engine of CopilotKit, allowing apps to interact with LLMs. With it, you can define backend action for your copilots. And there are a ton of tasks you could specify, including executing internal database calls and managing different processes and workflows. However, for this specific example, we’ll define an action to query the Pinecone index for relevant articles based on the user query.</p><p>To do that, add the following code:</p><pre>const runtime = new CopilotRuntime({<br>  actions: () =&gt; [<br>    {<br>      name: &#39;FetchKnowledgebaseArticles&#39;,<br>      description: &#39;Fetch relevant knowledge base articles based on a user query&#39;,<br>      parameters: [<br>        {<br>          name: &#39;query&#39;,<br>          type: &#39;string&#39;,<br>          description: &#39;The User query for the knowledge base index search to perform&#39;,<br>          required: true,<br>        },<br>      ],<br>      handler: async ({ query }: { query: string }) =&gt; {<br>        try {<br>          const queryEmbedding = await pinecone.inference.embed(<br>            model,<br>            [query],<br>            { inputType: &#39;query&#39; }<br>          );<br>          const queryResponse = await pinecone<br>            .index(indexName)<br>            .namespace(&#39;knowledge-base-data-namespace&#39;)<br>            .query({<br>              topK: 3,<br>              vector: queryEmbedding[0]?.values || [],<br>              includeValues: false,<br>              includeMetadata: true,<br>            });<br>          return { articles: queryResponse?.matches || [] };<br>        } catch (error) {<br>          console.error(&#39;Error fetching knowledge base articles:&#39;, error);<br>          throw new Error(&#39;Failed to fetch knowledge base articles.&#39;);<br>        }<br>      },    },<br>  ],<br>});</pre><p>Let’s break down this action handler. Ideally, this handle is the core engine for this entire integration. This action handler receives the query parameter passed from the Copilot client.</p><p>Using Pinecone’s query operation, the query is converted into a vector representation, which is then compared to the indexed vectors stored in Pinecone to identify the top three most relevant articles in the index. The result includes the vector values and metadata, which contain the actual matching data for the query.</p><p>Since most product knowledge bases have a ton of article posts, some even cover similar ideas, while others are totally different. It’s therefore practical to return multiple relevant pieces of data matching the query. (You can adjust the topK value to return the number of matching data objects based on your intended use case).</p><p>Finally, go ahead, and add the following code to define the CopilotKit endpoint as follows:</p><pre>const anthropic = new Anthropic({ apiKey: ANTHROPIC_API_KEY });<br>const serviceAdapter = new AnthropicAdapter({ anthropic: anthropic as any });</pre><pre>export const POST = async (req: NextRequest) =&gt; {<br>  const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({<br>    runtime,<br>    serviceAdapter,<br>    endpoint: &#39;/api/copilotkit&#39;,<br>  });</pre><pre>    return handleRequest(req);<br></pre><pre>};</pre><p>Make sure that the same URL you include in the CopilotKit API endpoint (/api/copilotkit) is specified in your frontend.</p><p>To test the entire app, navigate to your main project directory in the terminal and run the following command:</p><p>npm run dev</p><p>Then, head over to localhost:3000 in your browser and ask a question like “What features does CopilotKit offer?” in the Sidebar input field.</p><p>Users can continue asking additional questions; if you have a multitude of articles, instead of sifting through different pages, having the Copilot retrieve the information users need makes the process a whole lot easier.</p><p>For reference, or if you want to build on top of what we’ve covered in this article, you can clone this project’s source code from the <a href="https://github.com/ItsWachira/Next-Anthropic-AI-Copilot-Product-Knowledge-base">GitHub repository</a>.</p><h3>Summary</h3><p>In this guide, we have walked through the steps of building an Anthropic-powered Copilot using <a href="https://copilotkit.ai/">CopilotKit</a>, Anthropic AI API, and Pinecone API for product knowledge bases.</p><p>While we’ve explored a couple of features, we have barely scratched the surface of the countless use cases for CopilotKit, ranging from building interactive AI chatbots to building agentic solutions — in essence, CopilotKit lets you add a ton of useful AI capabilities to your products in minutes.</p><p>If you’re looking to integrate AI-powered Copilots into your existing application, consider <a href="https://www.copilotkit.ai/contact-us">scheduling a demo</a>, join the <a href="https://go.copilotkit.ai/discord">Discord Community</a> of developers, and <a href="https://docs.copilotkit.ai/">get started with the docs</a> to try it out yourself!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19537e60b936" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/build-your-own-knowledge-based-rag-copilot-w-pinecone-anthropic-copilotkit-19537e60b936">Build Your Own Knowledge-Based RAG Copilot w/ Pinecone, Anthropic, &amp; CopilotKit 😎</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a QA bot for your documentation with Langchain ]]></title>
            <link>https://levelup.gitconnected.com/build-a-qa-bot-for-your-documentation-with-langchain-6254ab2bdb5c?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/6254ab2bdb5c</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Thu, 30 May 2024 10:10:18 GMT</pubDate>
            <atom:updated>2024-06-12T14:43:56.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Vcb--y80xB8iwXGrjOEyaw.png" /></figure><h3>TL;DR</h3><p>In this tutorial, we will build an AI-powered Q&amp;A bot for your website documentation.</p><ul><li>🌐 Create a user-friendly Next.js app to accept questions and URLs</li><li>🔧 Set up a Wing backend to handle all the requests</li><li>💡 Incorporate @langchain for AI-driven answers by scraping and analyzing documentation using RAG</li><li>🔄 Complete connection between frontend input and AI-processed responses.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*Q7ki_w4Zznc4Fgt2.gif" /></figure><h3>What is Wing?</h3><p><a href="https://wing.cloud/redirect?utm_source=qa-bot-reddit&amp;redirect=https%3A%2F%2Fwww.winglang.io%2Fblog%2F2024%2F05%2F29%2Fqa-bot-for-your-docs-with-langchain">Wing</a> is an open-source framework for the cloud.</p><p>It allows you to create your application’s infrastructure and code combined as a single unit and deploy them safely to your preferred cloud providers.</p><p>Wing gives you complete control over how your application’s infrastructure is configured. In addition to its easy-to-learn <a href="https://www.winglang.io/docs/language-reference">programming language</a>, Wing also supports Typescript.</p><p>In this tutorial, we’ll use TypeScript. So, don’t worry — your JavaScript and React knowledge is more than enough to understand this tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*-WsYaOHWNoRPDlHL.png" /></figure><p><a href="https://wingla.ng/github">Check out Wing ⭐️</a></p><h3>Building the frontend with Next.js</h3><p>Here, you’ll create a simple form that accepts the documentation URL and the user’s question and then returns a response based on the website’s data.</p><p>First, create a folder containing two sub-folders — frontend and backend. The frontend folder contains the Next.js app, and the backend folder is for Wing.</p><pre>mkdir qa-bot &amp;&amp; cd qa-bot<br>mkdir frontend backend</pre><p>Within the <strong>frontend</strong> folder, create a Next.js project by running the following code snippet:</p><pre>cd frontend<br>npx create-next-app ./</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*D8F6fR82cagpRVnP.png" /></figure><p>Copy the code snippet below into the app/page.tsx file to create the form that accepts the user’s question and the documentation URL:</p><pre>&quot;use client&quot;;<br>import { useState } from &quot;react&quot;;</pre><pre>export default function Home() {<br>    const [documentationURL, setDocumentationURL] = useState&lt;string&gt;(&quot;&quot;);<br>    const [question, setQuestion] = useState&lt;string&gt;(&quot;&quot;);<br>    const [disable, setDisable] = useState&lt;boolean&gt;(false);<br>    const [response, setResponse] = useState&lt;string | null&gt;(null);</pre><pre>    const handleUserQuery = async (e: React.FormEvent) =&gt; {<br>        e.preventDefault();<br>        setDisable(true);<br>        console.log({ question, documentationURL });<br>    };</pre><pre>    return (<br>        &lt;main className=&#39;w-full md:px-8 px-3 py-8&#39;&gt;<br>            &lt;h2 className=&#39;font-bold text-2xl mb-8 text-center text-blue-600&#39;&gt;<br>                Documentation Bot with Wing &amp; LangChain<br>            &lt;/h2&gt;</pre><pre>            &lt;form onSubmit={handleUserQuery} className=&#39;mb-8&#39;&gt;<br>                &lt;label className=&#39;block mb-2 text-sm text-gray-500&#39;&gt;Webpage URL&lt;/label&gt;<br>                &lt;input<br>                    type=&#39;url&#39;<br>                    className=&#39;w-full mb-4 p-4 rounded-md border text-sm border-gray-300&#39;<br>                    placeholder=&#39;https://www.winglang.io/docs/concepts/why-wing&#39;<br>                    required<br>                    value={documentationURL}<br>                    onChange={(e) =&gt; setDocumentationURL(e.target.value)}<br>                /&gt;</pre><pre>                &lt;label className=&#39;block mb-2 text-sm text-gray-500&#39;&gt;<br>                    Ask any questions related to the page URL above<br>                &lt;/label&gt;<br>                &lt;textarea<br>                    rows={5}<br>                    className=&#39;w-full mb-4 p-4 text-sm rounded-md border border-gray-300&#39;<br>                    placeholder=&#39;What is Winglang? OR Why should I use Winglang? OR How does Winglang work?&#39;<br>                    required<br>                    value={question}<br>                    onChange={(e) =&gt; setQuestion(e.target.value)}<br>                /&gt;</pre><pre>                &lt;button<br>                    type=&#39;submit&#39;<br>                    disabled={disable}<br>                    className=&#39;bg-blue-500 text-white px-8 py-3 rounded&#39;<br>                &gt;<br>                    {disable ? &quot;Loading...&quot; : &quot;Ask Question&quot;}<br>                &lt;/button&gt;<br>            &lt;/form&gt;</pre><pre>            {response &amp;&amp; (<br>                &lt;div className=&#39;bg-gray-100 w-full p-8 rounded-sm shadow-md&#39;&gt;<br>                    &lt;p className=&#39;text-gray-600&#39;&gt;{response}&lt;/p&gt;<br>                &lt;/div&gt;<br>            )}<br>        &lt;/main&gt;<br>    );<br>}</pre><p>The code snippet above displays a form that accepts the user’s question and the documentation URL and logs them to the console for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*_cTo6Ttdlxt4i5a9.png" /></figure><p>Perfect! 🎉You’ve completed the application’s user interface. Next, let’s set up the Wing backend.</p><h3>How to set up Wing on your computer</h3><p>Wing provides a CLI that enables you to perform various Wing actions within your projects.</p><p>It also provides <a href="https://marketplace.visualstudio.com/items?itemName=Monada.vscode-wing">VSCode</a> and <a href="https://plugins.jetbrains.com/plugin/22353-wing">IntelliJ</a> extensions that enhance the developer experience with features like syntax highlighting, compiler diagnostics, code completion and snippets, and many others.</p><p>Before we proceed, stop your Next.js development server and install the Wing CLI by running the code snippet below in your terminal.</p><pre>npm install -g winglang@latest</pre><p>Run the following code snippet to ensure that the Winglang CLI is installed and working as expected:</p><pre>wing -V</pre><p>Next, navigate to the backend folder and create an empty Wing Typescript project. Ensure you select the empty template and Typescript as the language.</p><pre>wing new</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*6YpChn5IXg5BIYkg.png" /></figure><p>Copy the code snippet below into the backend/main.ts file.</p><pre>import { cloud, inflight, lift, main } from &quot;@wingcloud/framework&quot;;</pre><pre>main((root, test) =&gt; {<br>    const fn = new cloud.Function(<br>        root,<br>        &quot;Function&quot;,<br>        inflight(async () =&gt; {<br>            return &quot;hello, world&quot;;<br>        })<br>    );<br>});</pre><p>The <strong>main()</strong> function serves as the entry point to Wing.</p><p>It creates a cloud function and executes at compile time. The <strong>inflight</strong> function, on the other hand, runs at runtime and returns a Hello, world! text.</p><p>Start the Wing development server by running the code snippet below. It automatically opens the Wing Console in your browser at <a href="http://localhost:3000.">http://localhost:3000.</a></p><pre>wing it</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*chfY7g8QujzA5PMY.png" /></figure><p>You’ve successfully installed Wing on your computer.</p><h3>How to connect Wing to a Next.js app</h3><p>From the previous sections, you’ve created the Next.js frontend app within the frontend folder and the Wing backend within the backend folder.</p><p>In this section, you’ll learn how to communicate and send data between the Next.js app and the Wing backend.</p><p>First, install the <a href="https://github.com/winglang/winglibs/tree/main/react">Wing React</a> library within the backend folder by running the code below:</p><pre>npm install @winglibs/react</pre><p>Next, update the main.ts file as shown below:</p><pre>import { main, cloud, inflight, lift } from &quot;@wingcloud/framework&quot;;<br>import React from &quot;@winglibs/react&quot;;</pre><pre>main((root, test) =&gt; {<br>    const api = new cloud.Api(root, &quot;api&quot;, { cors: true })<br>    ;</pre><pre>    //👇🏻 create an API route<br>    api.get(<br>        &quot;/test&quot;,<br>        inflight(async () =&gt; {<br>            return {<br>                status: 200,<br>                body: &quot;Hello world&quot;,<br>            };<br>        })<br>    );</pre><pre>    //👉🏻 placeholder for the POST request endpoint</pre><pre>    //👇🏻 connects to the Next.js project<br>    const react = new React.App(root, &quot;react&quot;, { projectPath: &quot;../frontend&quot; });<br>    //👇🏻 an environment variable<br>    react.addEnvironment(&quot;api_url&quot;, api.url);<br>});</pre><p>The code snippet above creates an API endpoint (/test) that accepts GET requests and returns a Hello world text. The main function also connects to the Next.js project and adds the api_url as an environment variable.</p><p>The API URL contained in the environment variable enables us to send requests to the Wing API route. How do we retrieve the API URL within the Next.js app and make these requests?</p><p>Update the RootLayout component within the Next.js app/layout.tsx file as done below:</p><pre>export default function RootLayout({<br>    children,<br>}: Readonly&lt;{<br>    children: React.ReactNode;<br>}&gt;) {<br>    return (<br>        &lt;html lang=&#39;en&#39;&gt;<br>            &lt;head&gt;<br>                {/** ---👇🏻  Adds this script tag 👇🏻 ---*/}<br>                &lt;script src=&#39;./wing.js&#39; defer /&gt;<br>            &lt;/head&gt;<br>            &lt;body className={inter.className}&gt;{children}&lt;/body&gt;<br>        &lt;/html&gt;<br>    );<br>}</pre><p>Re-build the Next.js project by running npm run build.</p><p>Finally, start the Wing development server. It automatically starts the Next.js server, which can be accessed at <strong>http://localhost:3001</strong> in your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*jkhoLTzFtffm84wx.gif" /></figure><p>You’ve successfully connected the Next.js to Wing. You can also access data within the environment variables using window.wingEnv.&lt;attribute_name&gt;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*hG88clBKvLaQl8dz.gif" /></figure><h3>Processing user’s requests with LangChain and Wing</h3><p>In this section, you’ll learn how to send requests to Wing, process these requests with <a href="https://js.langchain.com/docs/get_started/quickstart#llm-chain">LangChain and OpenA</a>I, and display the results on the Next.js frontend.</p><p>First, let’s update the Next.js <strong>app/page.tsx</strong> file to retrieve the API URL and send user&#39;s data to a Wing API endpoint.</p><p>To do this, extend the JavaScript <strong>window</strong> object by adding the following code snippet at the top of the <strong>page.tsx</strong> file.</p><pre>&quot;use client&quot;;<br>import { useState } from &quot;react&quot;;<br>interface WingEnv {<br>    api_url: string;<br>}<br>declare global {<br>    interface Window {<br>        wingEnv: WingEnv;<br>    }<br>}</pre><p>Next, update the handleUserQuery function to send a POST request containing the user&#39;s question and website&#39;s URL to a Wing API endpoint.</p><pre>//👇🏻 sends data to the api url<br>const [response, setResponse] = useState&lt;string | null&gt;(null);</pre><pre>    const handleUserQuery = async (e: React.FormEvent) =&gt; {<br>        e.preventDefault();<br>        setDisable(true);<br>        try {<br>            const request = await fetch(`${window.wingEnv.api_url}/api`, {<br>                method: &quot;POST&quot;,<br>                headers: {<br>                    &quot;Content-Type&quot;: &quot;application/json&quot;,<br>                },<br>                body: JSON.stringify({ question, pageURL: documentationURL }),<br>            });<br>            const response = await request.text();<br>            setResponse(response);<br>            setDisable(false);<br>        } catch (err) {<br>            console.error(err);<br>            setDisable(false);<br>        }<br>    };</pre><p>Before you create the Wing endpoint that accepts the POST request, install the following packages within the backend folder:</p><pre>npm install @langchain/community @langchain/openai langchain cheerio</pre><p><a href="https://js.langchain.com/v0.2/docs/integrations/document_loaders/web_loaders/web_cheerio/">Cheerio</a> enables us to scrape the software documentation webpage, while the <a href="https://js.langchain.com/v0.1/docs/get_started/quickstart/">LangChain packages</a> allow us to access its various functionalities.</p><p>The LangChain OpenAI integration package uses the OpenAI language model; therefore, you’ll need a valid API key. You can get yours from the <a href="https://platform.openai.com/api-keys">OpenAI Developer’s Platform</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*-VVBRxxNmf-f-mET.png" /></figure><p>Next, let’s create the /api endpoint that handle incoming requests.</p><p>The endpoint will:</p><ul><li>accept the questions and documentation URLs from the Next.js application,</li><li>load the documentation page using <a href="https://js.langchain.com/v0.1/docs/modules/data_connection/document_loaders/">LangChain document loaders</a>,</li><li>split the retrieved documents into chunks,</li><li>transform the chunked documents and save them within a <a href="https://js.langchain.com/v0.1/docs/modules/data_connection/vectorstores/">LangChain vector store</a>,</li><li>and create a <a href="https://js.langchain.com/v0.1/docs/modules/data_connection/">retriever function</a> that retrieves the documents from the vector store.</li></ul><p>First, import the following into the main.ts file:</p><pre>import { main, cloud, inflight, lift } from &quot;@wingcloud/framework&quot;;<br>import { ChatOpenAI, OpenAIEmbeddings } from &quot;@langchain/openai&quot;;<br>import { ChatPromptTemplate } from &quot;@langchain/core/prompts&quot;;<br>import { createStuffDocumentsChain } from &quot;langchain/chains/combine_documents&quot;;<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br>import { RecursiveCharacterTextSplitter } from &quot;langchain/text_splitter&quot;;<br>import { MemoryVectorStore } from &quot;langchain/vectorstores/memory&quot;;<br>import { createRetrievalChain } from &quot;langchain/chains/retrieval&quot;;<br>import React from &quot;@winglibs/react&quot;;</pre><p>Add the code snippet below within the main() function to create the /api endpoint:</p><pre>api.post(<br>        &quot;/api&quot;,<br>        inflight(async (ctx, request) =&gt; {<br>            //👇🏻 accept user inputs from Next.js<br>            const { question, pageURL } = JSON.parse(request.body!);</pre><pre>            //👇🏻 initialize OpenAI Chat for LLM interactions<br>            const chatModel = new ChatOpenAI({<br>                apiKey: &quot;&lt;YOUR_OPENAI_API_KEY&gt;&quot;,<br>                model: &quot;gpt-3.5-turbo-1106&quot;,<br>            });<br>            //👇🏻 initialize OpenAI Embeddings for Vector Store data transformation<br>            const embeddings = new OpenAIEmbeddings({<br>                apiKey: &quot;&lt;YOUR_OPENAI_API_KEY&gt;&quot;,<br>            });</pre><pre>            //👇🏻 creates a text splitter function that splits the OpenAI result chunk size<br>            const splitter = new RecursiveCharacterTextSplitter({<br>                chunkSize: 200, //👉🏻 characters per chunk<br>                chunkOverlap: 20,<br>            });</pre><pre>            //👇🏻 creates a document loader, loads, and scraps the page<br>            const loader = new CheerioWebBaseLoader(pageURL);<br>            const docs = await loader.load();</pre><pre>            //👇🏻 splits the document into chunks <br>            const splitDocs = await splitter.splitDocuments(docs);</pre><pre>            //👇🏻 creates a Vector store containing the split documents<br>            const vectorStore = await MemoryVectorStore.fromDocuments(<br>                splitDocs,<br>                embeddings //👉🏻 transforms the data to the Vector Store format<br>            );</pre><pre>            //👇🏻 creates a document retriever that retrieves results that answers the user&#39;s questions<br>            const retriever = vectorStore.asRetriever({<br>                k: 1, //👉🏻  number of documents to retrieve (default is 2)<br>            });</pre><pre>            //👇🏻 creates a prompt template for the request<br>            const prompt = ChatPromptTemplate.fromTemplate(`<br>                Answer this question.<br>                Context: {context}<br>                Question: {input}<br>                `);</pre><pre>            //👇🏻 creates a chain containing the OpenAI chatModel and prompt<br>            const chain = await createStuffDocumentsChain({<br>                llm: chatModel,<br>                prompt: prompt,<br>            });</pre><pre>            //👇🏻 creates a retrieval chain that combines the documents and the retriever function<br>            const retrievalChain = await createRetrievalChain({<br>                combineDocsChain: chain,<br>                retriever,<br>            });</pre><pre>            //👇🏻 invokes the retrieval Chain and returns the user&#39;s answer<br>            const response = await retrievalChain.invoke({<br>                input: `${question}`,<br>            });</pre><pre>            if (response) {<br>                return {<br>                    status: 200,<br>                    body: response.answer,<br>                };<br>            }</pre><pre>            return undefined;<br>        })<br>    );</pre><p>The API endpoint accepts the user’s question and the page URL from the Next.js application, initialises <a href="https://js.langchain.com/v0.2/docs/integrations/chat/openai/">ChatOpenAI</a> and <a href="https://js.langchain.com/v0.2/docs/integrations/text_embedding/openai/">OpenAIEmbeddings</a>, loads the documentation page, and retrieves the answers to the user’s query in the form of documents.</p><p>Then, splits the documents into chunks, saves the chunks in the MemoryVectorStore, and enables us to fetch answers to the question using <a href="https://js.langchain.com/v0.1/docs/modules/data_connection/">LangChain retrievers</a>.</p><p>From the code snippet above, the OpenAI API key is entered directly into the code; this could lead to security breaches, making the API key accessible to attackers. To prevent this data leak, Wing allows you to save private keys and credentials in variables called secrets.</p><p>When you create a secret, Wing saves this data in a .env file, ensuring it is secured and accessible.</p><p>Update the main() function to fetch the OpenAI API key from the Wing Secret.</p><pre>main((root, test) =&gt; {<br>    const api = new cloud.Api(root, &quot;api&quot;, { cors: true });<br>    //👇🏻 creates the secret variable<br>    const secret = new cloud.Secret(root, &quot;OpenAPISecret&quot;, {<br>        name: &quot;open-ai-key&quot;,<br>    });</pre><pre>    api.post(<br>        &quot;/api&quot;,<br>        lift({ secret })<br>            .grant({ secret: [&quot;value&quot;] })<br>            .inflight(async (ctx, request) =&gt; {<br>                const apiKey = await ctx.secret.value();</pre><pre>                const chatModel = new ChatOpenAI({<br>                    apiKey,<br>                    model: &quot;gpt-3.5-turbo-1106&quot;,<br>                });</pre><pre>                const embeddings = new OpenAIEmbeddings({<br>                    apiKey,<br>                });</pre><pre>                //👉🏻 other code snippets &amp; configurations<br>    );</pre><pre>    const react = new React.App(root, &quot;react&quot;, { projectPath: &quot;../frontend&quot; });<br>    react.addEnvironment(&quot;api_url&quot;, api.url);<br>});</pre><ul><li>From the code snippet above,</li><li>The secret variable declares a name for the secret (OpenAI API key).</li><li>The <a href="https://www.winglang.io/docs/typescript/inflights#permissions">lift().grant()</a> grants the API endpoint access to the secret value stored in the Wing Secret.</li><li>The <a href="https://www.winglang.io/docs/typescript/inflights">inflight()</a> function accepts the context and request object as parameters, makes a request to LangChain, and returns the result.</li><li>Then, you can access the apiKey using the ctx.secret.value() function.</li></ul><p>Finally, save the OpenAI API key as a secret by running this command in your terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*J_TPxTYgVLPGpxJC.gif" /></figure><p>Congratulations! You’ve successfully completed the project for this tutorial.</p><p>Here is a brief demo of the application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*_39-kt9FLjZpDJo1.gif" /></figure><p>Let’s dig a little bit deeper into the Wing docs to see what data our AI bot can extract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*D-XN2YtNp4WZHtoh.gif" /></figure><h3>Wrapping It Up</h3><p>So far, we have gone over the following:</p><ul><li>What is Wing?</li><li>How to use Wing and query data using Langchain,</li><li>How to connect Wing to a Next.js application,</li><li>How to send data between a Next.js frontend and a Wing backend.</li></ul><blockquote><a href="https://github.com/winglang/wing"><em>Wing</em></a><em> aims to bring back your creative flow and close the gap between imagination and creation. Another great advantage of Wing is that it is open-source. Therefore, if you are looking forward to building distributed systems that leverage cloud services or contribute to the future of cloud development, </em><a href="https://github.com/winglang/wing"><em>Wing</em></a><em> is your best choice.</em></blockquote><p>Feel free to contribute to the <a href="https://github.com/winglang/wing">GitHub repository,</a> and <a href="https://t.winglang.io/discord">share your thoughts</a> with the team and the large community of developrs.</p><p>The source code for this tutorial is available <a href="https://github.com/NathanTarbert/wing-langchain-nextjs">here</a>.</p><p>Thank you for reading! 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6254ab2bdb5c" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/build-a-qa-bot-for-your-documentation-with-langchain-6254ab2bdb5c">Build a QA bot for your documentation with Langchain 😻</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building your own ChatGPT Graphical Client with NextJS and Wing ]]></title>
            <link>https://levelup.gitconnected.com/building-your-own-chatgpt-graphical-client-with-nextjs-and-wing-01342f5a99b4?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/01342f5a99b4</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Tue, 21 May 2024 22:22:39 GMT</pubDate>
            <atom:updated>2024-05-30T19:14:44.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*yAy4obIhJpo8YsSFV4hPdQ.jpeg" /></figure><h3>TL;DR</h3><p>By the end of this article, you will build and deploy a ChatGPT Client using Wing and Next.js.</p><p>This application can run locally (in a local cloud simulator) or deploy it to your own cloud provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*-wzS81Bimc730ZIE.gif" /></figure><h3>Introduction</h3><p>Building a ChatGPT client and deploying it to your own cloud infrastructure is a good way to ensure control over your data.</p><p>Deploying LLMs to your own cloud infrastructure provides you with both privacy and security for your project.</p><p>Sometimes, you may have concerns about your data being stored or processed on remote servers when using proprietary LLM platforms like OpenAI’s ChatGPT, either due to the sensitivity of the data being fed into the platform or for other privacy reasons.</p><p>In this case, self-hosting an LLM to your cloud infrastructure or running it locally on your machine gives you greater control over the privacy and security of your data.</p><blockquote><a href="https://git.new/wing-repo"><em>Wing</em></a><em> is a cloud-oriented programming language that lets you build and deploy cloud-based applications without worrying about the underlying infrastructure.<br>It simplifies the way you build on the cloud by allowing you to define and manage your cloud infrastructure and your application code within the same language.<br>Wing is cloud agnostic — applications built with it can be compiled and deployed to various cloud platforms.</em></blockquote><p><a href="https://git.new/wing-repo">Check out ⭐ Wing</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*G57_TIBbBObWDjjh.png" /></figure><h3>Let’s get started!</h3><p>To follow along, you need to:</p><ul><li>Have some understanding of Next.js</li><li><a href="https://www.winglang.io/docs/">Install Wing</a> on your machine. Not to worry if you don’t know how to. We’ll go over it together in this project.</li><li>Get your OpenAI API key.</li></ul><h3>Create Your Projects</h3><p>To get started, you need to install Wing on your machine. Run the following command:</p><pre>npm install -g winglang</pre><p>Confirm the installation by checking the version:</p><pre>wing -V</pre><h3>Create your Next.js and Wing apps.</h3><pre>mkdir assistant<br>cd assistant<br>npx create-next-app@latest frontend<br>mkdir backend &amp;&amp; cd backend<br>wing new empty</pre><p>We have successfully created our Wing and Next.js projects inside the assistant directory. The name of our ChatGPT Client is Assistant. Sounds cool, right?</p><p>The frontend and backend directories contain our Next and Wing apps, respectively. wing new empty creates three files: package.json, package-lock.json, and main.w. The latter is the app’s entry point.</p><h3>Run your application locally in the Wing simulator</h3><p>The Wing simulator allows you to run your code, write unit tests, and debug your code inside your local machine without needing to deploy to an actual cloud provider, helping you iterate faster.</p><p>Use the following command to run your Wing app locally:</p><pre>wing it</pre><p>Your Wing app will run on localhost:3000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*vLbQLOUDciyXMg0-.png" /></figure><h3>Setting Up Your Backend</h3><ul><li>Let’s install Wing’s OpenAI and React Libraries. The OpenAI library provides a standard interface to interact with the LLM. The React library allows you to connect your Wing backend to your Next app.</li></ul><pre>npm i @winglibs/openai @winglibs/react</pre><ul><li>Import these packages in your main.w file. Let&#39;s also import all the other libraries we’ll need.</li></ul><pre>bring openai<br>bring react<br>bring cloud<br>bring ex<br>bring http</pre><p>bring is the import statement in Wing. Think of it this way, Wing uses bring to achieve the same functionality as import in JavaScript.</p><p>cloud is Wing’s Cloud library. It exposes a standard interface for Cloud API, Bucket, Counter, Domain, Endpoint, Function and many more cloud resources. ex is a standard library for interfacing with Tables and cloud Redis database, and http is for calling different HTTP methods - sending and retrieving information from remote resources.</p><h3>Get Your OpenAI API Key</h3><p>We will use gpt-4-turbo for our app but you can use any OpenAI model.</p><ul><li>Create an <a href="https://platform.openai.com/signup">OpenAI</a> account if you don’t have one yet. To create a new API key, Go to <a href="http://platform.openai.com/api-keys">platform.openai.com/api-keys</a> and select <strong>Create new secret key.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*W7y0uBzLPTApsS81.png" /></figure><ul><li>Set the <strong>Name</strong>, <strong>Project,</strong> and <strong>Permissions,</strong> then click <strong>Create secret key.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*XU8Z-4P5Rt5m0rhT.png" /></figure><h3>Initializing OpenAI</h3><p>Create a Class to initialize your OpenAI API. We want this to be reusable.</p><p>We will add a personality to our Assistant class so that we can dictate the personality of our AI assistant when passing a prompt to it.</p><pre>let apiKeySecret = new cloud.Secret(name: &quot;OAIAPIKey&quot;) as &quot;OpenAI Secret&quot;;</pre><pre>class Assistant {<br>    personality: str;<br>    openai: openai.OpenAI;</pre><pre>    new(personality: str) {<br>        this.openai = new openai.OpenAI(apiKeySecret: apiKeySecret);<br>        this.personality = personality;<br>    }</pre><pre>    pub inflight ask(question: str): str {<br>        let prompt = `you are an assistant with the following personality: ${this.personality}. ${question}`;<br>        let response = this.openai.createCompletion(prompt, model: &quot;gpt-4-turbo&quot;);<br>        return response.trim();<br>    }<br>}</pre><p>Wing unifies infrastructure definition and application logic using the preflight and inflight concepts respectively.</p><p><strong>Preflight</strong> code (typically infrastructure definitions) runs once at compile time, while <strong>inflight</strong> code will run at runtime to implement your app’s behavior.</p><p>Cloud storage buckets, queues, and API endpoints are some examples of preflight. You don’t need to add the preflight keyword when defining a preflight, Wing knows this by default. But for an inflight block, you need to add the word “inflight” to it.</p><blockquote><em>We have an inflight block in the code above. Inflight blocks are where you write asynchronous runtime code that can directly interact with resources through their inflight APIs.</em></blockquote><h3>Testing and Storing The Cloud Secret</h3><p>Let’s walk through how we will secure our API keys because we definitely want to take <a href="https://techhq.com/2022/09/hardcoded-api-keys-jeopardize-data-in-the-cloud/">security into account</a>.</p><p>Let’s create a .env file in our backend’s root and pass in our API Key:</p><pre>OAIAPIKey = Your_OpenAI_API_key</pre><p>We can test our OpenAI API keys locally referencing our .env file, and then since we are planning to deploy to AWS, we will walk through setting up the <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html">AWS Secrets Manager</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*96vC-A7NIBmAvJE5.png" /></figure><p>First, let’s head over to AWS and sign into the Console. If you don’t have an account, you can create one for free.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*oAaZBcODLRmeZKF8.png" /></figure><p>Navigate to the Secrets Manager and let’s store our API key values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*JJRswbNLqcZIrfXj.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*tN6onLaHcn8H2mzz.png" /></figure><p>We have stored our API key in a cloud secret named OAIAPIKey. Copy your key and we will jump over to the terminal and connect to our secret that is now stored in the AWS Platform.</p><pre>wing secrets</pre><p>Now paste in your API Key as the value in the terminal. Your keys are now properly stored and we can start interacting with our app.</p><h3>Storing The AI’s Responses in the Cloud.</h3><p>Storing your AI’s responses in the cloud gives you control over your data. It resides on your own infrastructure, unlike proprietary platforms like ChatGPT, where your data lives on third-party servers that you don’t have control over. You can also retrieve these responses whenever you need them.</p><p>Let’s create another class that uses the Assistant class to pass in our AI’s personality and prompt. We would also store each model’s responses as txt files in a cloud bucket.</p><pre>let counter = new cloud.Counter();</pre><pre>class RespondToQuestions {<br>    id: cloud.Counter;<br>    gpt: Assistant;<br>    store: cloud.Bucket;</pre><pre>    new(store: cloud.Bucket) {<br>        this.gpt = new Assistant(&quot;Respondent&quot;);<br>        this.id = new cloud.Counter() as &quot;NextID&quot;;<br>        this.store = store;<br>    }</pre><pre>    pub inflight sendPrompt(question: str): str {<br>        let reply = this.gpt.ask(&quot;{question}&quot;);<br>        let n = this.id.inc();<br>        this.store.put(&quot;message-{n}.original.txt&quot;, reply);<br>        return reply;<br>    }<br>}</pre><p>We gave our Assistant the personality “Respondent.” We want it to respond to questions. You could also let the user on the frontend dictate this personality when sending in their prompts.</p><p>Every time it generates a response, the counter increments, and the value of the counter is passed into the n variable used to store the model’s responses in the cloud. However, what we really want is to create a database to store both the user prompts coming from the frontend and our model’s responses.</p><p>Let’s define our database.</p><h3>Defining Our Database</h3><p>Wing has ex.Table built-in - a NoSQL database to store and query data.</p><pre>let db = new ex.Table({<br>    name: &quot;assistant&quot;,<br>    primaryKey: &quot;id&quot;,<br>    columns: {<br>        question: ex.ColumnType.STRING,<br>        answer: ex.ColumnType.STRING<br>    }<br>});</pre><p>We added two columns in our database definition — the first to store user prompts and the second to store the model’s responses.</p><h3>Creating API Routes and Logic</h3><p>We want to be able to send and receive data in our backend. Let’s create POST and GET routes.</p><pre>let api = new cloud.Api({ cors: true });</pre><pre>api.post(&quot;/assistant&quot;, inflight((request) =&gt; {<br>    // POST request logic goes here<br>}));</pre><pre>api.get(&quot;/assistant&quot;, inflight(() =&gt; {<br>    // GET request logic goes here<br>}));</pre><pre>let myAssistant = new RespondToQuestions(store) as &quot;Helpful Assistant&quot;;</pre><pre>api.post(&quot;/assistant&quot;, inflight((request) =&gt; {<br>    let prompt = request.body;<br>    let response = myAssistant.sendPrompt(JSON.stringify(prompt)); <br>    let id = counter.inc(); </pre><pre>    // Insert prompt and response in the database<br>    db.insert(id, { question: prompt, answer: response });</pre><pre>    return cloud.ApiResponse({<br>        status: 200<br>    });<br>}));</pre><p>In the POST route, we want to pass the user prompt received from the frontend into the model and get a response. Both prompt and response will be stored in the database. cloud.ApiResponse allows you to send a response for a user’s request.</p><p>Add the logic to retrieve the database items when the frontend makes a GET request.</p><p>Add the logic to retrieve the database items when the frontend makes a GET request.</p><pre>api.get(&quot;/assistant&quot;, inflight(() =&gt; {<br>    let questionsAndAnswers = db.list();</pre><pre>    return cloud.ApiResponse({<br>        body: JSON.stringify(questionsAndAnswers),<br>        status: 200<br>    });<br>}));</pre><p>Our backend is ready. Let’s test it out in the local cloud simulator.</p><p>Run wing it.</p><p>Lets go over to localhost:3000 and ask our Assistant a question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*SxVuxssrdD82mBWc.png" /></figure><p>Both our question and the Assistant’s response has been saved to the database. Take a look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*c-b_nR_FljoCWmv2.png" /></figure><h3>Exposing Your API URL to The Frontend</h3><p>We need to expose the API URL of our backend to our Next frontend. This is where the react library installed earlier comes in handy.</p><pre>let website = new react.App({<br>    projectPath: &quot;../frontend&quot;,<br>    localPort: 4000<br>});</pre><pre>website.addEnvironment(&quot;API_URL&quot;, api.url);</pre><p>Add the following to the layout.js of your Next app.</p><pre>import { Inter } from &quot;next/font/google&quot;;<br>import &quot;./globals.css&quot;;</pre><pre>const inter = Inter({ subsets: [&quot;latin&quot;] });</pre><pre>export const metadata = {<br>    title: &quot;Create Next App&quot;,<br>    description: &quot;Generated by create next app&quot;,<br>};</pre><pre>export default function RootLayout({ children }) {<br>    return (<br>        &lt;html lang=&quot;en&quot;&gt;<br>            &lt;head&gt;<br>            &lt;script src=&quot;./wing.js&quot; defer&gt;&lt;/script&gt;<br>           &lt;/head&gt;<br>            &lt;body className={inter.className}&gt;{children}&lt;/body&gt;<br>        &lt;/html&gt;<br>    );<br>}</pre><p>We now have access to API_URL in our Next application.</p><h3>Implementing the Frontend Logic</h3><p>Let’s implement the frontend logic to call our backend.</p><pre>import { useEffect, useState, useCallback } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;</pre><pre>function App() {</pre><pre>    const [isThinking, setIsThinking] = useState(false);<br>    const [input, setInput] = useState(&quot;&quot;);<br>    const [allInteractions, setAllInteractions] = useState([]);</pre><pre>    const retrieveAllInteractions = useCallback(async (api_url) =&gt; {<br>            await axios ({<br>              method: &quot;GET&quot;,<br>              url: `${api_url}/assistant`,<br>            }).then(res =&gt; {<br>              setAllInteractions(res.data)<br>            })<br>  }, [])</pre><pre>    const handleSubmit = useCallback(async (e)=&gt; {<br>        e.preventDefault()</pre><pre>        setIsThinking(!isThinking)<br></pre><pre>        if(input.trim() === &quot;&quot;){<br>          alert(&quot;Chat cannot be empty&quot;)<br>          setIsThinking(true)</pre><pre>        }</pre><pre>          await axios({<br>            method: &quot;POST&quot;,<br>            url: `${window.wingEnv.API_URL}/assistant`,<br>            headers: {<br>              &quot;Content-Type&quot;: &quot;application/json&quot;<br>            },<br>            data: input<br>          })<br>          setInput(&quot;&quot;);<br>          setIsThinking(false);<br>          await retrieveAllInteractions(window.wingEnv.API_URL);     </pre><pre>  })</pre><pre>    useEffect(() =&gt; {<br>        if (typeof window !== &quot;undefined&quot;) {<br>            retrieveAllInteractions(window.wingEnv.API_URL);<br>        }<br>    }, []);</pre><pre>    // Here you would return your component&#39;s JSX<br>    return (<br>        // JSX content goes here<br>    );<br>}</pre><pre>export default App;</pre><p>The retrieveAllInteractions function fetches all the questions and answers in the backend’s database. The handSubmit function sends the user’s prompt to the backend.</p><p>Let’s add the JSX implementation.</p><pre>import { useEffect, useState } from &#39;react&#39;;<br>import axios from &#39;axios&#39;;<br>import &#39;./App.css&#39;;</pre><pre>function App() {<br>    // ...</pre><pre>    return (<br>        &lt;div className=&quot;container&quot;&gt;<br>            &lt;div className=&quot;header&quot;&gt;<br>                &lt;h1&gt;My Assistant&lt;/h1&gt;<br>                &lt;p&gt;Ask anything...&lt;/p&gt;<br>            &lt;/div&gt;</pre><pre>            &lt;div className=&quot;chat-area&quot;&gt;<br>                &lt;div className=&quot;chat-area-content&quot;&gt;<br>                    {allInteractions.map((chat) =&gt; (<br>                        &lt;div key={chat.id} className=&quot;user-bot-chat&quot;&gt;<br>                            &lt;p className=&#39;user-question&#39;&gt;{chat.question}&lt;/p&gt;<br>                            &lt;p className=&#39;response&#39;&gt;{chat.answer}&lt;/p&gt;<br>                        &lt;/div&gt;<br>                    ))}<br>                    &lt;p className={isThinking ? &quot;thinking&quot; : &quot;notThinking&quot;}&gt;Generating response...&lt;/p&gt;<br>                &lt;/div&gt;</pre><pre>                &lt;div className=&quot;type-area&quot;&gt;<br>                    &lt;input <br>                        type=&quot;text&quot; <br>                        placeholder=&quot;Ask me any question&quot; <br>                        value={input} <br>                        onChange={(e) =&gt; setInput(e.target.value)} <br>                    /&gt;<br>                    &lt;button onClick={handleSubmit}&gt;Send&lt;/button&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    );<br>}</pre><pre>export default App;</pre><h3>Running Your Project Locally</h3><p>Navigate to your backend directory and run your Wing app locally using the following command</p><pre>cd ~assistant/backend<br>wing it</pre><p>Also run your Next.js frontend:</p><pre>cd ~assistant/frontend<br>npm run dev</pre><p>Let’s take a look at our application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*WvJsKiKE6ERi_nc1.png" /></figure><p>Let’s ask our AI Assistant a couple developer questions from our Next App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*dXu50uLsJVQNg4k9.png" /></figure><h3>Deploying Your Application to AWS</h3><p>We’ve seen how our app can work locally. Wing also allows you to deploy to any cloud provider including AWS. To deploy to AWS, you need <a href="https://terraform.io/downloads">Terraform</a> and <a href="https://docs.aws.amazon.com/cli/">AWS CLI</a> configured with your credentials.</p><ul><li>Compile to Terraform/AWS using tf-aws. The command instructs the compiler to use Terraform as the provisioning engine to bind all our resources to the default set of AWS resources.</li></ul><pre>cd ~/assistant/backend<br>wing compile --platform tf-aws main.w</pre><ul><li>Run Terraform Init and Apply</li></ul><pre>cd ./target/main.tfaws<br>terraform init<br>terraform apply</pre><p>Note: terraform apply takes some time to complete.</p><p>You can find the complete code for this tutorial <a href="https://github.com/NathanTarbert/chatgpt-client-wing-nextjs">here</a>.</p><h3>Wrapping It Up</h3><p>As I mentioned earlier, we should all be concerned with our apps security, building your own ChatGPT client and deploying it to your cloud infrastructure gives your app some very good <a href="https://docs.aws.amazon.com/whitepapers/latest/aws-overview/security-and-compliance.html#:~:text=Keep%20Your%20data%20safe%20%E2%80%94%20The,compliance%20programs%20in%20its%20infrastructure.">safeguards</a>.</p><p>We have demonstrated in this tutorial how <a href="https://git.new/wing-repo">Wing</a> provides a straightforward approach to building scalable cloud applications without worrying about the underlying infrastructure.</p><p>If you are interested in building more cool stuff, Wing has an active community of developers, partnering in building a vision for the cloud. We’d love to see you there.</p><p>Just head over to our <a href="https://t.winglang.io/discord">Discord</a> and say hi!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01342f5a99b4" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/building-your-own-chatgpt-graphical-client-with-nextjs-and-wing-01342f5a99b4">Building your own ChatGPT Graphical Client with NextJS and Wing 🤯</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Ways to Skin a Lambda Function: A DevTools Comparison Guide]]></title>
            <link>https://medium.com/wing-cloud/5-ways-to-skin-a-lambda-function-a-devtools-comparison-guide-ec3234c9c17d?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec3234c9c17d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Wed, 14 Feb 2024 14:48:12 GMT</pubDate>
            <atom:updated>2024-03-25T18:53:53.636Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7VAOsdZVMuJ8sDzj4sGR-Q.gif" /></figure><h3>TL;DR</h3><p>As the saying goes, there are several ways to skin a cat…in the tech world, there are 5 ways to skin a Lambda Function 🤩</p><p>We’ll be comparing 5 DevTools 👇</p><h3>· <a href="#80af">1. Wing</a> <br>· <a href="#1203">2. Pulumi</a><br>· <a href="#b365">3. AWS-CDK</a><br>· <a href="#014e">4. CDK for Terraform</a><br>· <a href="#5367">5. Terraform</a></h3><p>As developers try to bridge the gap between development and DevOps, I thought it would be helpful to compare Programming Languages and DevTools.</p><p>Let’s start with the idea of a simple function that would upload a text file to a Bucket in our cloud app.</p><p>The next step is to demonstrate several ways this could be accomplished.</p><p><strong>Note:</strong> In cloud development, managing permissions and bucket identities, packaging runtime code, and handling multiple files for infrastructure and runtime add layers of complexity to the development process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*Qwl9LrcqQZSnKJez.gif" /></figure><p>Let’s dive into some code!</p><h3>1. <a href="https://github.com/winglang/wing">Wing</a></h3><blockquote><em>After </em><a href="https://www.winglang.io/docs"><em>installing Wing</em></a><em>, let’s create a file: </em><em>main.w</em></blockquote><blockquote><strong><em>If you aren’t familiar with the Wing Programming Language, please check out the open-source repo</em></strong><em> </em><a href="https://github.com/winglang/wing"><em>HERE</em></a></blockquote><pre>bring cloud;</pre><pre>let bucket = new cloud.Bucket();</pre><pre>new cloud.Function(inflight () =&gt; {<br>  bucket.put(&quot;hello.txt&quot;, &quot;world!&quot;);<br>});</pre><p><strong>Let’s do a breakdown of what’s happening in the code above.</strong></p><blockquote><em>bring cloud is Wing&#39;s import syntax</em></blockquote><blockquote><strong><em>Create a Cloud Bucket:</em></strong><em> </em><em>let bucket = new cloud.Bucket(); initializes a new cloud bucket instance.</em></blockquote><blockquote><em>On the backend, the Wing platform provisions a new bucket in your cloud provider’s environment. This bucket is used for storing and retrieving data.</em></blockquote><blockquote><strong><em>Create a Cloud Function:</em></strong><em> The </em><em>new cloud.Function(inflight () =&gt; { ... }); statement defines a new cloud function.</em></blockquote><blockquote><em>This function, when triggered, performs the actions defined within its body.</em></blockquote><blockquote><em>bucket.put(&quot;hello.txt&quot;, &quot;world!&quot;); uploads a file named hello.txt with the content world! to the cloud bucket created earlier.</em></blockquote><h3>Compile &amp; Deploy to AWS</h3><ul><li>wing compile --platform tf-aws main.w</li><li>terraform apply</li></ul><p>That’s it, Wing takes care of the complexity of (permissions, getting the bucket identity in the runtime code, packaging the runtime code into a bucket, having to write multiple files — for infrastructure and runtime), etc.</p><p>Not to mention it generates IAC (TF or CF), plus Javascript that you can deploy with existing tools.</p><p>But while you develop, you can use the local simulator to get instant feedback and shorten the iteration cycles</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/0*E4XMN-__zxgiyGDT.gif" /></figure><p>Wing even has a <a href="https://www.winglang.io/play/?code=YgByAGkAbgBnACAAYwBsAG8AdQBkADsACgAKAGwAZQB0ACAAYgB1AGMAawBlAHQAIAA9ACAAbgBlAHcAIABjAGwAbwB1AGQALgBCAHUAYwBrAGUAdAAoACkAOwAKAAoAbgBlAHcAIABjAGwAbwB1AGQALgBGAHUAbgBjAHQAaQBvAG4AKABpAG4AZgBsAGkAZwBoAHQAIAAoACkAIAA9AD4AIAB7AAoAIAAgAGIAdQBjAGsAZQB0AC4AcAB1AHQAKAAiAGgAZQBsAGwAbwAuAHQAeAB0ACIALAAgACIAdwBvAHIAbABkACEAIgApADsACgB9ACkAOwA%3D">playground</a> that you can try out in the browser!</p><h3>2. <a href="https://www.pulumi.com/">Pulumi</a></h3><blockquote><em>Step 1: Initialize a New Pulumi Project</em></blockquote><pre>mkdir pulumi-s3-lambda-ts<br>cd pulumi-s3-lambda-ts<br>pulumi new aws-typescript</pre><blockquote><em>Step 2. Write the code to upload a text file to S3.</em></blockquote><p>This will be your project structure.</p><pre>pulumi-s3-lambda-ts/<br>├─ src/<br>│  ├─ index.ts              # Pulumi infrastructure code<br>│  └─ lambda/<br>│     └─ index.ts           # Lambda function code to upload a file to S3<br>├─ tsconfig.json            # TypeScript configuration<br>└─ package.json             # Node.js project file with dependencies</pre><p>Let’s add this code to <strong>index.ts</strong></p><pre>import * as pulumi from &quot;@pulumi/pulumi&quot;;<br>import * as aws from &quot;@pulumi/aws&quot;;</pre><pre>// Create an AWS S3 bucket<br>const bucket = new aws.s3.Bucket(&quot;myBucket&quot;, {<br>    acl: &quot;private&quot;,<br>});</pre><pre>// IAM role for the Lambda function<br>const lambdaRole = new aws.iam.Role(&quot;lambdaRole&quot;, {<br>    assumeRolePolicy: JSON.stringify({<br>        Version: &quot;2023-10-17&quot;,<br>        Statement: [{<br>            Action: &quot;sts:AssumeRole&quot;,<br>            Principal: {<br>                Service: &quot;lambda.amazonaws.com&quot;,<br>            },<br>            Effect: &quot;Allow&quot;,<br>            Sid: &quot;&quot;,<br>        }],<br>    }),<br>});</pre><pre>// Attach the AWSLambdaBasicExecutionRole policy<br>new aws.iam.RolePolicyAttachment(&quot;lambdaExecutionRole&quot;, {<br>    role: lambdaRole,<br>    policyArn: aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole,<br>});</pre><pre>// Policy to allow Lambda function to access the S3 bucket<br>const lambdaS3Policy = new aws.iam.Policy(&quot;lambdaS3Policy&quot;, {<br>    policy: bucket.arn.apply(arn =&gt; JSON.stringify({<br>        Version: &quot;2023-10-17&quot;,<br>        Statement: [{<br>            Action: [&quot;s3:PutObject&quot;, &quot;s3:GetObject&quot;],<br>            Resource: `${arn}/*`,<br>            Effect: &quot;Allow&quot;,<br>        }],<br>    })),<br>});</pre><pre>// Attach policy to Lambda role<br>new aws.iam.RolePolicyAttachment(&quot;lambdaS3PolicyAttachment&quot;, {<br>    role: lambdaRole,<br>    policyArn: lambdaS3Policy.arn,<br>});</pre><pre>// Lambda function<br>const lambda = new aws.lambda.Function(&quot;myLambda&quot;, {<br>    code: new pulumi.asset.AssetArchive({<br>        &quot;.&quot;: new pulumi.asset.FileArchive(&quot;./src/lambda&quot;),<br>    }),<br>    runtime: aws.lambda.Runtime.NodeJS12dX,<br>    role: lambdaRole.arn,<br>    handler: &quot;index.handler&quot;,<br>    environment: {<br>        variables: {<br>            BUCKET_NAME: bucket.bucket,<br>        },<br>    },<br>});</pre><pre>export const bucketName = bucket.id;<br>export const lambdaArn = lambda.arn;</pre><p>Next, create a <strong>lambda/index.ts</strong> directory for the Lambda function code:</p><pre>import { S3 } from &quot;aws-sdk&quot;;</pre><pre>const s3 = new S3();</pre><pre>export const handler = async (): Promise&lt;void&gt; =&gt; {<br>    const bucketName = process.env.BUCKET_NAME || &quot;&quot;;<br>    const fileName = &quot;example.txt&quot;;<br>    const content = &quot;Hello, Pulumi!&quot;;</pre><pre>    const params = {<br>        Bucket: bucketName,<br>        Key: fileName,<br>        Body: content,<br>    };</pre><pre>    try {<br>        await s3.putObject(params).promise();<br>        console.log(`File uploaded successfully at <a href="https://${bucketname}.s3.amazonaws.com/$%7BfileName%7D%60);">https://${bucketName}.s3.amazonaws.com/${fileName}`);</a><br>    } catch (err) {<br>        console.log(err);<br>    }<br>};</pre><blockquote><em>Step 3: TypeScript Configuration (tsconfig.json)</em></blockquote><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;ES2018&quot;,<br>    &quot;module&quot;: &quot;CommonJS&quot;,<br>    &quot;strict&quot;: true,<br>    &quot;esModuleInterop&quot;: true,<br>    &quot;skipLibCheck&quot;: true,<br>    &quot;forceConsistentCasingInFileNames&quot;: true<br>  },<br>  &quot;include&quot;: [&quot;src/**/*.ts&quot;],<br>  &quot;exclude&quot;: [&quot;node_modules&quot;, &quot;**/*.spec.ts&quot;]<br>}</pre><p><strong>After creating a Pulumi project, a yaml file will automatically be generated.</strong> <strong>pulumi.yaml</strong></p><pre>name: s3-lambda-pulumi<br>runtime: nodejs<br>description: A simple example that uploads a file to an S3 bucket using a Lambda function<br>template:<br>  config:<br>    aws:region:<br>      description: The AWS region to deploy into<br>      default: us-west-2</pre><h3>Deploy with Pulumi</h3><p>Ensure your lambda directory with the index.js file is correctly set up. Then, run the following command to deploy your infrastructure: pulumi up</p><h3>3. <a href="https://aws.amazon.com/cdk">AWS-CDK</a></h3><blockquote><em>Step 1: Initialize a New CDK Project</em></blockquote><pre>mkdir cdk-s3-lambda<br>cd cdk-s3-lambda<br>cdk init app --language=typescript</pre><blockquote><em>Step 2: Add Dependencies</em></blockquote><pre>npm install @aws-cdk/aws-lambda @aws-cdk/aws-s3</pre><blockquote><em>Step 3: Define the AWS Resources in CDK</em></blockquote><p>File: <strong>index.js</strong></p><pre>import * as cdk from &#39;@aws-cdk/core&#39;;<br>import * as lambda from &#39;@aws-cdk/aws-lambda&#39;;<br>import * as s3 from &#39;@aws-cdk/aws-s3&#39;;</pre><pre>export class CdkS3LambdaStack extends cdk.Stack {<br>  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {<br>    super(scope, id, props);</pre><pre>    // Create the S3 bucket<br>    const bucket = new s3.Bucket(this, &#39;MyBucket&#39;, {<br>      removalPolicy: cdk.RemovalPolicy.DESTROY, // NOT recommended for production code<br>    });</pre><pre>    // Define the Lambda function<br>    const lambdaFunction = new lambda.Function(this, &#39;MyLambda&#39;, {<br>      runtime: lambda.Runtime.NODEJS_14_X, // Define the runtime<br>      handler: &#39;index.handler&#39;, // Specifies the entry point<br>      code: lambda.Code.fromAsset(&#39;lambda&#39;), // Directory containing your Lambda code<br>      environment: {<br>        BUCKET_NAME: bucket.bucketName,<br>      },<br>    });</pre><pre>    // Grant the Lambda function permissions to write to the S3 bucket<br>    bucket.grantWrite(lambdaFunction);<br>  }<br>}</pre><blockquote><em>Step 4: Lambda Function Code</em></blockquote><p>Create the same file struct as above and in the pulumi directory: <strong>index.ts</strong></p><pre>import { S3 } from &#39;aws-sdk&#39;;<br>const s3 = new S3();</pre><pre>exports.handler = async (event: any) =&gt; {<br>  const bucketName = process.env.BUCKET_NAME;<br>  const fileName = &#39;uploaded_file.txt&#39;;<br>  const content = &#39;Hello, CDK! This file was uploaded by a Lambda function!&#39;;</pre><pre>  try {<br>    const result = await s3.putObject({<br>      Bucket: bucketName!,<br>      Key: fileName,<br>      Body: content,<br>    }).promise();</pre><pre>    console.log(`File uploaded successfully: ${result}`);<br>    return {<br>      statusCode: 200,<br>      body: `File uploaded successfully: ${fileName}`,<br>    };<br>  } catch (error) {<br>    console.log(error);<br>    return {<br>      statusCode: 500,<br>      body: `Failed to upload file: ${error}`,<br>    };<br>  }<br>};</pre><h3>Deploy the CDK Stack</h3><p>First, compile your TypeScript code: npm run build, then</p><p>Deploy your CDK to AWS: cdk deploy</p><h3>4. <a href="https://developer.hashicorp.com/terraform/cdktf">CDK for Terraform</a></h3><blockquote><em>Step 1: Initialize a New CDKTF Project</em></blockquote><pre>mkdir cdktf-s3-lambda-ts<br>cd cdktf-s3-lambda-ts</pre><p>Then, initialize a new CDKTF project using TypeScript:</p><pre>cdktf init --template=&quot;typescript&quot; --local</pre><blockquote><em>Step 2: Install AWS Provider and Add Dependencies</em></blockquote><pre>npm install @cdktf/provider-aws</pre><blockquote><em>Step 3: Define the Infrastructure</em></blockquote><p>Edit main.ts to define the S3 bucket and Lambda function:</p><pre>import { Construct } from &#39;constructs&#39;;<br>import { App, TerraformStack } from &#39;cdktf&#39;;<br>import { AwsProvider, s3, lambdafunction, iam } from &#39;@cdktf/provider-aws&#39;;</pre><pre>class MyStack extends TerraformStack {<br>  constructor(scope: Construct, id: string) {<br>    super(scope, id);</pre><pre>    new AwsProvider(this, &#39;aws&#39;, { region: &#39;us-west-2&#39; });</pre><pre>    // S3 bucket<br>    const bucket = new s3.S3Bucket(this, &#39;lambdaBucket&#39;, {<br>      bucketPrefix: &#39;cdktf-lambda-&#39;<br>    });</pre><pre>    // IAM role for Lambda<br>    const role = new iam.IamRole(this, &#39;lambdaRole&#39;, {<br>      name: &#39;lambda_execution_role&#39;,<br>      assumeRolePolicy: JSON.stringify({<br>        Version: &#39;2023-10-17&#39;,<br>        Statement: [{<br>          Action: &#39;sts:AssumeRole&#39;,<br>          Principal: { Service: &#39;lambda.amazonaws.com&#39; },<br>          Effect: &#39;Allow&#39;,<br>        }],<br>      }),<br>    });</pre><pre>    new iam.IamRolePolicyAttachment(this, &#39;lambdaPolicy&#39;, {<br>      role: role.name,<br>      policyArn: &#39;arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole&#39;,<br>    });</pre><pre>    const lambdaFunction = new lambdafunction.LambdaFunction(this, &#39;MyLambda&#39;, {<br>      functionName: &#39;myLambdaFunction&#39;,<br>      handler: &#39;index.handler&#39;,<br>      role: role.arn,<br>      runtime: &#39;nodejs14.x&#39;,<br>      s3Bucket: bucket.bucket, // Assuming the Lambda code is uploaded to this bucket<br>      s3Key: &#39;lambda.zip&#39;, // Assuming the Lambda code zip file is named lambda.zip<br>      environment: {<br>        variables: {<br>          BUCKET_NAME: bucket.bucket,<br>        },<br>      },<br>    });</pre><pre>    // Grant the Lambda function permissions to write to the S3 bucket<br>    new s3.S3BucketPolicy(this, &#39;BucketPolicy&#39;, {<br>      bucket: bucket.bucket,<br>      policy: bucket.bucket.apply(name =&gt; JSON.stringify({<br>        Version: &#39;2023-10-17&#39;,<br>        Statement: [{<br>          Action: &#39;s3:*&#39;,<br>          Resource: `arn:aws:s3:::${name}/*`,<br>          Effect: &#39;Allow&#39;,<br>          Principal: {<br>            AWS: role.arn,<br>          },<br>        }],<br>      })),<br>    });<br>  }<br>}</pre><pre>const app = new App();<br>new MyStack(app, &#39;cdktf-s3-lambda-ts&#39;);<br>app.synth();</pre><blockquote><em>Step 4: Lambda Function Code</em></blockquote><p>The Lambda function code should be written in TypeScript and compiled into JavaScript, as AWS Lambda natively executes JavaScript. Here’s an example <strong>index.ts</strong> for the Lambda function that you need to compile and zip:</p><pre>import { S3 } from &#39;aws-sdk&#39;;</pre><pre>const s3 = new S3();</pre><pre>exports.handler = async () =&gt; {<br>  const bucketName = process.env.BUCKET_NAME || &#39;&#39;;<br>  const content = &#39;Hello, CDKTF!&#39;;<br>  const params = {<br>    Bucket: bucketName,<br>    Key: `upload-${Date.now()}.txt`,<br>    Body: content,<br>  };</pre><pre>  try {<br>    await s3.putObject(params).promise();<br>    return { statusCode: 200, body: &#39;File uploaded successfully&#39; };<br>  } catch (err) {<br>    console.error(err);<br>    return { statusCode: 500, body: &#39;Failed to upload file&#39; };<br>  }<br>};</pre><p>You need to compile this TypeScript code to JavaScript, zip it, and upload it to the S3 bucket manually or using a script.</p><p>Ensure the s3Key in the LambdaFunction resource points to the correct zip file in the bucket.</p><h3>Compile &amp; Deploy Your CDKTF Project</h3><p>Compile your project using npm run build</p><p><strong>Generate Terraform Configuration Files</strong></p><p>Run the cdktf synth command. This command executes your CDKTF app, which generates Terraform configuration files (*.tf.json files) in the cdktf.out directory:</p><p><strong>Deploy Your Infrastructure</strong></p><p>cdktf deploy</p><h3>5. <a href="https://developer.hashicorp.com/terraform">Terraform</a></h3><blockquote><em>Step 1: Terraform Setup</em></blockquote><p>Define your AWS Provider and S3 Bucket<br>Create a file named <strong>main.tf</strong> with the following:</p><pre>provider &quot;aws&quot; {<br>  region = &quot;us-west-2&quot; # Choose your AWS region<br>}</pre><pre>resource &quot;aws_s3_bucket&quot; &quot;lambda_bucket&quot; {<br>  bucket_prefix = &quot;lambda-upload-bucket-&quot;<br>  acl           = &quot;private&quot;<br>}</pre><pre>resource &quot;aws_iam_role&quot; &quot;lambda_execution_role&quot; {<br>  name = &quot;lambda_execution_role&quot;</pre><pre>  assume_role_policy = jsonencode({<br>    Version = &quot;2023-10-17&quot;<br>    Statement = [<br>      {<br>        Action = &quot;sts:AssumeRole&quot;<br>        Effect = &quot;Allow&quot;<br>        Principal = {<br>          Service = &quot;lambda.amazonaws.com&quot;<br>        }<br>      },<br>    ]<br>  })<br>}</pre><pre>resource &quot;aws_iam_policy&quot; &quot;lambda_s3_policy&quot; {<br>  name        = &quot;lambda_s3_policy&quot;<br>  description = &quot;IAM policy for Lambda to access S3&quot;</pre><pre>  policy = jsonencode({<br>    Version = &quot;2023-10-17&quot;<br>    Statement = [<br>      {<br>        Action   = [&quot;s3:PutObject&quot;, &quot;s3:GetObject&quot;],<br>        Effect   = &quot;Allow&quot;,<br>        Resource = &quot;${aws_s3_bucket.lambda_bucket.arn}/*&quot;<br>      },<br>    ]<br>  })<br>}</pre><pre>resource &quot;aws_iam_role_policy_attachment&quot; &quot;lambda_s3_access&quot; {<br>  role       = aws_iam_role.lambda_execution_role.name<br>  policy_arn = aws_iam_policy.lambda_s3_policy.arn<br>}</pre><pre>resource &quot;aws_lambda_function&quot; &quot;uploader_lambda&quot; {<br>  function_name = &quot;S3Uploader&quot;</pre><pre>  s3_bucket = &quot;YOUR_DEPLOYMENT_BUCKET_NAME&quot; # Set your deployment bucket name here<br>  s3_key    = &quot;lambda.zip&quot; # Upload your ZIP file to S3 and set its key here</pre><pre>  handler = &quot;index.handler&quot;<br>  role    = aws_iam_role.lambda_execution_role.arn<br>  runtime = &quot;nodejs14.x&quot;</pre><pre>  environment {<br>    variables = {<br>      BUCKET_NAME = aws_s3_bucket.lambda_bucket.bucket<br>    }<br>  }<br>}</pre><blockquote><em>Step 2: Lambda Function Code (TypeScript)</em></blockquote><p>Create a TypeScript file <strong>index.ts</strong> for the Lambda function:</p><pre>import { S3 } from &#39;aws-sdk&#39;;</pre><pre>const s3 = new S3();</pre><pre>exports.handler = async (event: any) =&gt; {<br>  const bucketName = process.env.BUCKET_NAME;<br>  const fileName = `uploaded-${Date.now()}.txt`;<br>  const content = &#39;Hello, Terraform and AWS Lambda!&#39;;</pre><pre>  try {<br>    await s3.putObject({<br>      Bucket: bucketName!,<br>      Key: fileName,<br>      Body: content,<br>    }).promise();</pre><pre>    console.log(&#39;Upload successful&#39;);<br>    return {<br>      statusCode: 200,<br>      body: JSON.stringify({ message: &#39;Upload successful&#39; }),<br>    };<br>  } catch (error) {<br>    console.error(&#39;Upload failed:&#39;, error);<br>    return {<br>      statusCode: 500,<br>      body: JSON.stringify({ message: &#39;Upload failed&#39; }),<br>    };<br>  }<br>};</pre><p>Finally after uploading your Lambda function code to the specified S3 bucket, run terraform apply.</p><p>I hope you enjoyed this comparison of five simple ways to write a function in our cloud app that uploads a text file to a Bucket.</p><p>As you can see, most of the code becomes very complex, except for one.</p><h3>Conclusion!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*61SLUKxumF6gkIDr.gif" /></figure><p>Click on the picture ⬆️</p><blockquote><em>If you are intrigued about Wing and like how we are simplifying the process of cloud development, please give us a ⭐ star.</em></blockquote><p><a href="https://github.com/winglang/wing">Please star ⭐ Wing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec3234c9c17d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wing-cloud/5-ways-to-skin-a-lambda-function-a-devtools-comparison-guide-ec3234c9c17d">5 Ways to Skin a Lambda Function: A DevTools Comparison Guide</a> was originally published in <a href="https://medium.com/wing-cloud">Wing Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Developer’s Toolkit: Your Essential Open-Source DevTools]]></title>
            <link>https://medium.com/wing-cloud/the-developers-toolkit-your-essential-open-source-devtools-f4912f1c62fc?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4912f1c62fc</guid>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Thu, 08 Feb 2024 17:33:02 GMT</pubDate>
            <atom:updated>2024-03-25T18:54:21.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2PI5Oz-gYMoC9t55QzaTcA.gif" /></figure><p>Every developer needs a toolkit to streamline their workflow, increase productivity, and tackle some of the most complex tasks efficiently.</p><p>This could be development, testing, or project management, having the right tools in your back pocket can make or break your development process.</p><p>Let’s take a look at some of my favorites, and I hope they become your favorites too!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*3C_ZkXKyJArw_O7H.gif" /></figure><p><strong>Let’s get started!</strong>👇</p><h3>1. <a href="https://github.com/winglang/wing">Wing</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/0*OZkNzbC-j2tZHaIQ.gif" /></figure><ul><li>🔥 A programming language for the cloud</li><li>🔥 A unified programming model combining infrastructure and runtime code into one language</li></ul><p><a href="https://github.com/winglang/wing">Please star ⭐ Wing</a></p><h3>2. <a href="https://github.com/elie222/inbox-zero">Inbox Zero</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*chYCYKR06b7BuuIs.gif" /></figure><ul><li>👉 Clean Up Your Inbox In Minutes</li><li>👉 Newsletter cleaner, AI automation, cold email blocker, and analytics</li></ul><p><a href="https://github.com/elie222/inbox-zero">Please star ⭐ Inbox Zero</a></p><h3>3. <a href="https://github.com/mfts/papermark">Papermark</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/0*S6nBZtco0mqxADZ8.gif" /></figure><ul><li>🚨 The Open-Source DocSend Alternative</li><li>🚨 Share pitch decks, sales proposals, and other docs securely with real-time analytics and white-labeling options</li></ul><p><a href="https://github.com/mfts/papermarkr">Please star ⭐ Papermark</a></p><h3>4. <a href="https://github.com/aptabase/aptabase">Aptabase</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*hFAp0Mm0QTiEuZOk.gif" /></figure><ul><li>📣 Analytics for Apps</li><li>📣 Works with the framework of your choice! (JS | NextJS etc.)</li></ul><p><a href="https://github.com/aptabase/aptabase">Please star ⭐ SoapUI</a></p><h3>5. <a href="https://github.com/documenso/documenso">Documenso</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/0*ObyN0CIhPpAzSz2v.gif" /></figure><ul><li>🚀 The open-source document signing</li><li>🚀 Integrates with all your favorite tools — Send, connect, receive, and embed everywhere</li></ul><p><a href="https://github.com/documenso/documenso">Please star ⭐ Documenso</a></p><h3>6. <a href="https://github.com/flipt-io/flipt">Flipt</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*DSplzU9v68Ve-n94.gif" /></figure><ul><li>⚡ GitOps-enabled feature management platform for modern engineering teams.</li><li>⚡ Follow modern DevOps best practices such as trunk-based development, continuous delivery, and software kill switches all without needing to restart your applications.</li></ul><p><a href="https://github.com/flipt-io/flipt">Please star ⭐ Flipt</a></p><h3>7. <a href="https://github.com/openstatusHQ/openstatus">OpenStatus</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*xrRGbSw2HksEQRbV.gif" /></figure><blockquote><strong><em>Build trust:</em></strong></blockquote><ul><li>✨ Showcase your reliability to your users, and reduce the number of customer service tickets.</li></ul><blockquote><strong><em>Custom domain</em></strong></blockquote><ul><li>✨ Bring your own domain, and give the status page a personal touch.</li></ul><p><a href="https://github.com/openstatusHQ/openstatus">Please star ⭐ OpenStatus</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4912f1c62fc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wing-cloud/the-developers-toolkit-your-essential-open-source-devtools-f4912f1c62fc">The Developer’s Toolkit: Your Essential Open-Source DevTools</a> was originally published in <a href="https://medium.com/wing-cloud">Wing Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ 9 Trending Open Source Projects to Watch for in 2024]]></title>
            <link>https://medium.com/wing-cloud/9-trending-open-source-projects-to-watch-for-in-2024-3e06cf356172?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e06cf356172</guid>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 18:34:10 GMT</pubDate>
            <atom:updated>2024-03-25T18:55:10.228Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*LDRVdpGO8kaJ0zFjouOM2A.gif" /><figcaption>open</figcaption></figure><p>As a developer, who’s passionate about open source, I’m constantly watching up-and-coming projects, libraries, and services.</p><p>You know the ones, that seem to have that special sauce.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*v3Kj0FephO-UIRc9.gif" /></figure><p>I’ve put together a small list of what I’ve seen trending or expect them to in this new year.</p><p>Let’s take a look at some of the most surprising and impressive projects I’ve come across lately.</p><h3>1. <a href="https://github.com/winglang/wing">Wing</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*yL29kP1dQ06AnF_m.gif" /></figure><p>Wing has developed a cloud-oriented programming language called <a href="https://www.winglang.io/"><strong>Winglang</strong></a>, designed specifically to address the needs and challenges faced by cloud developers.</p><p>Combining infrastructure and runtime code in one language, with a built-in local simulator and observability &amp; debugging console.</p><p>Wing reduces cognitive load and context switching, enabling developers to stay in their creative flow.</p><p>How Wing boosts your development:</p><ul><li>Faster iteration cycles</li><li>Localized testing via the Wing Simulator</li><li>Deploy to the cloud by writing less code</li></ul><p><a href="https://github.com/winglang/wing">Please star ⭐ Winglang</a></p><h3>2. <a href="https://github.com/maybe-finance/maybe">Maybe</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*T4LYH7pi6gKTAEUw.gif" /></figure><p>Maybe has recently open-sourced their personal finance + wealth management app</p><p>Some features include:</p><ul><li>Investment benchmarking</li><li>Investment portfolio allocation</li><li>Debt insights</li></ul><p><a href="https://github.com/maybe-finance/maybe">Please star ⭐ Maybe</a></p><h3>3. <a href="https://github.com/erebe/wstunnel?tab=readme-ov-file">Wstunnel</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*uOm3l0vaGmmfC-UG.gif" /></figure><p>Wstunnel uses the WebSocket protocol which is compatible with http to bypass firewalls and proxies.</p><p>This allows you to tunnel whatever traffic you want and access whatever resources/sites you need.</p><p><a href="https://github.com/erebe/wstunnel?tab=readme-ov-file">Please star ⭐ wstunnel</a></p><h3>4. <a href="https://github.com/KRTirtho/spotube">Spotube</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*BnjSUV0EqDNf9wUf.gif" /></figure><p>An open-source, cross-platform Spotify client compatible across multiple platforms utilizing Spotify’s data API and YouTube (or Piped.video or JioSaavn) as an audio source,<br>eliminating the need for Spotify Premium.</p><p>Btw it’s not another Electron app😉</p><p><a href="https://github.com/KRTirtho/spotube">Please star ⭐ Spotube</a></p><h3>5. <a href="https://github.com/martinvonz/jj">Jujutsu</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*liLuVww3ErSJO9Ul.gif" /></figure><p>Jujutsu is a version control system for software projects, written in Rust.</p><p>You use it to:</p><ul><li>get/make a copy of your code</li><li>track changes to the code</li><li>publish those changes for others to see and use.</li></ul><p><a href="https://github.com/martinvonz/jj">Please star ⭐ Jujutsu</a></p><h3>6. <a href="https://github.com/wasp-lang/wasp">Wasp</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*N2SIA57NApQvTDtJ.gif" /></figure><p>Wasp (Web Application Specification) is a Rails-like framework for React, Node.js, and Prisma.</p><p>Build your app in a day and deploy it with a single CLI command!</p><ul><li>Quick start</li><li>No Boilerplate</li><li>No lock-in</li></ul><p><a href="https://github.com/wasp-lang/wasp">Please star ⭐ Wasp</a></p><h3>7. <a href="https://github.com/refinedev/refine">Refine</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*6SPBiQ0yzKVu179Q.gif" /></figure><p>A React Framework for building internal tools, admin panels, dashboards &amp; B2B apps with unmatched flexibility.</p><p>Instead of being limited to a set of pre-styled components, Refine provides collections of:</p><ul><li>Helper hooks</li><li>Components</li><li>Providers</li></ul><p><a href="https://github.com/refinedev/refine">Please star ⭐ Refine</a></p><h3>8. <a href="https://github.com/dbgate/dbgate">DbGate</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*O2PkHZ5uHkVKhDS8.gif" /></figure><p>DbGate is a cross-platform database manager, designed to be simple to use and effective when working with more databases simultaneously.</p><p><strong>Supported databases:</strong></p><ul><li>MySQL</li><li>PostgreSQL</li><li>SQL Server</li><li>Oracle (experimental)</li><li>MongoDB</li><li>Redis</li><li>SQLite</li><li>Amazon Redshift</li><li>CockroachDB</li><li>MariaDB</li></ul><p><a href="https://github.com/dbgate/dbgate">Please star ⭐ DBGate</a></p><h3>9. <a href="https://github.com/unifyai/ivy">Ivy</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*as2Ffosj4KFUH9J3.gif" /></figure><p>Ivy is an open-source machine learning framework:</p><ul><li>Autotune your model</li><li>Convert code into any framework</li><li>Write framework-agnostic code</li></ul><p><a href="https://github.com/unifyai/ivy">Please star ⭐ Ivy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e06cf356172" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wing-cloud/9-trending-open-source-projects-to-watch-for-in-2024-3e06cf356172">😎 9 Trending Open Source Projects to Watch for in 2024</a> was originally published in <a href="https://medium.com/wing-cloud">Wing Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[⚡⚡ Level Up Your Cloud Experience with These 7 Open Source Projects ️]]></title>
            <link>https://medium.com/wing-cloud/level-up-your-cloud-experience-with-these-7-open-source-projects-%EF%B8%8F-2f40f7065c97?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f40f7065c97</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Mon, 11 Dec 2023 16:10:30 GMT</pubDate>
            <atom:updated>2024-03-25T18:55:30.079Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*X2eyr-c06pnrasY7Jhvi3A.gif" /></figure><p>The seven open-source projects I will mention are not only essential tools for cloud-native innovation, but they also offer a strategic advantage in today’s fast-paced digital world.</p><p>In this article, I have put together key points that set these open-source projects to the level of <strong>AWESOME</strong>! 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*tA3j3lHi7mIqlI_1.gif" /></figure><h3>1. <a href="https://dub.sh/wing-cloud">Winglang</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*gvnX9ZdS1-0P4IZW.gif" /></figure><p>Wing has introduced a programming language called <strong>Winglang</strong>, a cloud-oriented programming language that allows developers to build distributed systems, leveraging cloud services as first-class citizens.</p><p>The language introduces two execution phases, <strong>preflight</strong> and <strong>inflight</strong>, which are connected in a way that delegates the creation of IAM policies and network topologies to the compiler.</p><p>This connection helps to explain the value of the inflight and preflight concepts, as it allows developers to focus on business logic instead of cloud mechanics, thereby accelerating iteration cycles and improving the creative flow.</p><p>The magic is in the <strong>preflight</strong> and <strong>inflight</strong> execution phases:</p><ul><li><strong>Preflight:</strong> Code that runs once, at compile time, and generates the infrastructure configuration of your cloud application. For example, setting up databases, queues, storage buckets, API endpoints, etc.</li><li><strong>Inflight:</strong> Code that runs at runtime and implements your application’s behavior. For example, handling API requests, processing queue messages, etc. Inflight code can be executed on various computing platforms in the cloud, such as function services (such as AWS Lambda or Azure Functions), containers (such as ECS or Kubernetes), VMs, or even physical servers. 👇</li></ul><p><a href="https://dub.sh/wing-cloud">Please star ⭐ Winglang</a></p><h3>2. <a href="https://github.com/fission/fission">Fission</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*2gGHtpI1gwQwHiOp.gif" /></figure><p>Fission is a framework for serverless functions on Kubernetes.</p><ul><li>Write short-lived functions in any language, and map them to HTTP requests (or other event triggers).</li><li>Deploy functions instantly with one command. There are no containers to build, and no Docker registries to manage.</li></ul><p><a href="https://github.com/fission/fission">Please star ⭐ Fission</a></p><h3>3. <a href="https://github.com/openfaas/faas">OpenFaaS</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*V68keln4YblSvaWL.gif" /></figure><p>Run your code anywhere with the same unified experience and deploy OpenFaaS anywhere you have Kubernetes.</p><ul><li>Deploy a new function to production within a few minutes, knowing it will scale to meet demand.</li><li>Invoke functions through events from Apache Kafka, AWS SQS, Postgresql, Cron, and MQTT.</li></ul><p><a href="https://github.com/openfaas/faas">Please star ⭐ OpenFaaS</a></p><h3>4. <a href="https://github.com/spacecloud-io/space-cloud">Space Cloud</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*R0BAWoe0c_0Yt4H8.gif" /></figure><p>Space Cloud is an open-source, kubernetes based platform that lets you build, scale, and secure cloud-native apps at scale.</p><ul><li>It provides instant GraphQL and REST APIs for your database and microservices that can be consumed directly from your front end in a secure manner.</li><li>Deploys and scales your docker images on Kubernetes.</li></ul><p><a href="https://github.com/spacecloud-io/space-cloud">Please star ⭐ Space Cloud</a></p><h3>5. <a href="https://github.com/pulumi/pulumi">Pulumi</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*qXzlwhNc0JnQ-wWH.gif" /></figure><p>Manage infrastructure, secrets, and configurations intuitively on any cloud.</p><ul><li>Author infrastructure code using programming languages you know and love. Write statements to define infrastructure using your IDE with autocomplete, type checking, and documentation.</li><li>Test your code with unit tests and deliver it through CI/CD pipelines to validate and deploy to any cloud.</li></ul><p><a href="https://github.com/pulumi/pulumi">Please star ⭐ Pulumi</a></p><h3>6. <a href="https://github.com/gitpod-io/gitpod">Gitpod</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*QF0Qqt9PvYOSZ0UV.gif" /></figure><p>Be inspired,<br>check dependencies, checkout branch, viewreadme.txt, install tools, run build, run test,<br>start building.</p><ul><li>Context-switch between environments, no waiting, no conflicts.</li><li>Share preview environments per branch for faster feedback from developers to designers to QA.</li></ul><p><a href="https://github.com/gitpod-io/gitpod">Please star ⭐ Gitpod</a></p><h3>7. <a href="https://github.com/knative/serving">Knative</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*CZKwVs8pKihkJngx.gif" /></figure><p>Knative Serving builds on Kubernetes to support deploying and serving of applications and functions as serverless containers.</p><ul><li>Rapid deployment of serverless containers</li><li>Automatic scaling up and down to zero</li><li>Routing and network programming</li><li>Point-in-time snapshots of deployed code and configurations</li></ul><p><a href="https://github.com/knative/serving">Please star ⭐ Knative</a></p><p>Thank you for checking out these seven POWERFUL open-source projects that you should consider when building in the cloud.🥇</p><p><strong>One of the best ways to support open-source software is with a star 🌟</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f40f7065c97" width="1" height="1" alt=""><hr><p><a href="https://medium.com/wing-cloud/level-up-your-cloud-experience-with-these-7-open-source-projects-%EF%B8%8F-2f40f7065c97">⚡⚡ Level Up Your Cloud Experience with These 7 Open Source Projects 🌩️</a> was originally published in <a href="https://medium.com/wing-cloud">Wing Cloud</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ The Zebras Guide to Showcase Markdown Images in Light & Dark Mode ]]></title>
            <link>https://medium.com/@nathantarbert/the-zebras-guide-to-showcase-markdown-images-in-light-dark-mode-94d59abb018e?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/94d59abb018e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Mon, 20 Nov 2023 18:26:31 GMT</pubDate>
            <atom:updated>2024-03-25T18:55:58.919Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*GLhQy6hBprt81lJ3l6ogvw.gif" /></figure><p>Warning: Opinions expressed may not be suitable for all audiences! 😂</p><h3>TL;DR</h3><p>By the end of this article, you’ll know and be able to showcase your Markdown images based on user preference — <strong>Dark</strong> or <strong>Light </strong>modes.</p><ol><li>I will walk through how to add two images in a GitHub README.md — based on the selected theme, your images will properly respond.</li><li>I will guide you through the process of incorporating images in Markdown and demonstrate how to make them responsive using React. 😎</li></ol><blockquote><strong>Table of Contents</strong><br>− <strong>Do you use Light or Dark?<br>− Improving User Experience<br>− Responsive Images in Your GitHub README<br>− Responsive Images in Markdown Using React<br>− React File<br>− Markdown File</strong></blockquote><h3>Do you use Light or Dark?</h3><p>I don’t know about you but no matter the platform, if they have the option to switch between Light and Dark mode, well it’s no contest.</p><p>That light theme is getting switched to dark, in fact as I’m writing this of course!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*5QDCAiljb1AfoFKZ.png" /></figure><p>That being said, in the rapid pace of software development, creating a seamless user experience is paramount.</p><p>Part of this experience involves accommodating user preferences, such as light and dark modes.</p><p>I can remember back a few years ago when Github announced the option for a user to switch to “Dark Mode” and it was a pretty big deal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*f8Yu0kZ8n0dXhr_0.png" /></figure><p><a href="https://t.co/HEotvXVJ7R">The big moment that Github reveals Dark theme</a> 🤩</p><p>December 8, 2020 🎆</p><p>In recent years, the advent of dark and light mode options in user interfaces has become a popular trend.</p><p>I’m definitely not the only one who prefers using the dark theme option, according to Android users, <a href="https://www.androidauthority.com/dark-mode-poll-results-1090716/">91.8% of the users prefer dark mode</a> so we can guess the number is pretty high across all OS.</p><p>This of course can be a heated debate so I will do my best to keep my opinions to a minimum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*NPg6w5terVvI90_7.png" /></figure><h3>Improving User Experience</h3><p>The main goal is to improve user experience by offering options in your app.</p><p>There are several ways to create multiple versions of each image and in this tutorial we won’t get into the nitty gritty.</p><p>Just make sure your images that stand out in both themes with a transparent background and you’ll be golden.</p><p><strong><em>Let’s get the party started!</em></strong></p><h3>Responsive Images in Your GitHub README</h3><p>Do you have a project and want to make your GitHub project README.md really pop?</p><p>This is where no matter what light theme the user is using, we will need a method to specify which theme (light or dark) an image should be displayed in Markdown.</p><p>This is particularly useful when you want to optimize the display of images based on the user’s chosen color scheme, and it involves using the <strong>HTML </strong><strong>&lt;picture&gt;</strong> element in combination with the prefers-color-scheme media feature shown below.</p><p>Go ahead and drag your image files directly into GitHub and place after the srcset=.</p><pre>&lt;picture&gt;<br>  &lt;source media=&quot;(prefers-color-scheme: dark)&quot; srcset=&quot;https://github.com/boxyhq/.github/assets/66887028/df1c9904-df2f-4515-b403-58b14a0e9093&quot;&gt;<br>  &lt;source media=&quot;(prefers-color-scheme: light)&quot; srcset=&quot;https://github.com/boxyhq/.github/assets/66887028/e093a466-72ea-41c6-a292-4c39a150facd&quot;&gt;<br>  &lt;img alt=&quot;BoxyHQ Banner&quot; src=&quot;https://github.com/boxyhq/jackson/assets/66887028/b40520b7-dbce-400b-88d3-400d1c215ea1&quot;&gt;<br>&lt;/picture&gt;</pre><p>And voila!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*fZUqeimh3PRMznR1.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*etu592i1-XxmHxBp.png" /></figure><p>Great, do you have 5 seconds?</p><p><a href="https://github.com/boxyhq/jackson">Please star ⭐ the SAML Jackson repo</a></p><h3>Responsive Images in Markdown Using React</h3><p>Lets say today I’m going to be writing a blog in Markdown like I normally do, and publish it to my website.</p><p>The images I use need to be responsive based on both user preferences but it’s not possible in Markdown to listen for a theme change in local storage and set state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/0*6DgaqOVvCT_6SOul.png" /></figure><p>Well thankfully there is a way to handle this dilemma if we import React into our Markdown file but lets first create a component.</p><h3>React File</h3><pre>src/components/LightDarkToggle.js</pre><pre>import React, { useEffect, useState } from &#39;react&#39;;</pre><pre>function ToggleImages() {</pre><pre>// Define a state variable to track the user&#39;s login status<br>const [currentTheme, setcurrentTheme] = useState(localStorage.getItem(&#39;theme&#39;));</pre><pre>// Add an event listener for the &#39;storage&#39; event inside a useEffect<br>useEffect(() =&gt; {<br>  const handleStorageChange = (event) =&gt; {<br>    console.log(&#39;Storage event detected:&#39;, event);</pre><pre>    // Check the changed key and update the state accordingly<br>    console.log(&quot;event&quot;, event.key)<br>    if (event.key === &#39;theme&#39;) {<br>      setcurrentTheme(event.newValue);<br>    }<br>  };</pre><pre>  window.addEventListener(&#39;storage&#39;, handleStorageChange);</pre><pre>  // Clean up the event listener when the component unmounts<br>  return () =&gt; {<br>    window.removeEventListener(&#39;storage&#39;, handleStorageChange);<br>  };<br>}, []); // The empty dependency array ensures that this effect runs once when the component mounts</pre><pre>  return (<br>    &lt;div className=&quot;image-container&quot;&gt;<br>      {currentTheme == &#39;light&#39;? (<br>        &lt;img<br>        id=&quot;light-mode-image&quot;<br>        src=&quot;/img/blog/boxyhq-banner-light-bg.png&quot;<br>        alt=&quot;Light Mode Image&quot;<br>        &gt;&lt;/img&gt;<br>      ):(<br>        &lt;img<br>        id=&quot;dark-mode-image&quot;<br>        src=&quot;/img/blog/boxyhq-banner-dark-bg.png&quot;<br>        alt=&quot;Dark Mode Image&quot;<br>        &gt;&lt;/img&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}</pre><pre>export default ToggleImages;</pre><p>I’ve added comments and a couple console logs in the code to help walk through what’s happening but lets quickly break it down.</p><ul><li>The React useState hook manages the state of currentTheme, which represents the user&#39;s chosen theme stored in the local storage.</li><li>The useEffect hook is used to add an event listener for the ‘storage’ event. When the storage event occurs (indicating a change in local storage), the component checks if the changed key is theme and updates the currentTheme state accordingly.</li><li>The component renders different images based on the user’s chosen theme, displaying a light mode image if the theme is light and a dark mode image if the theme is anything else.</li></ul><p>Cool, lets move on!</p><h3>Markdown File</h3><p>Let’s create a .md file for our new blog.</p><pre>---<br>slug: light-and-dark-mode-responsive-images<br>title: &#39;Light and Dark Mode Responsive Images&#39;<br>tags_disabled:<br>  [<br>    developer,<br>    react,<br>    javascript,<br>    open-source,<br>  ]<br>image: /img/blog/light-dark.png<br>author: Nathan Tarbert<br>author_title: &quot;Community Engineer @BoxyHQ&quot;<br>author_url: https://github.com/NathanTarbert<br>author_image_url: https://boxyhq.com/img/team/nathan.jpg<br>---</pre><pre>import ToggleImages from &#39;../src/components/LightDarkToggle.js&#39;;</pre><pre>## 🤩 Let&#39;s start this blog off with a bang! </pre><pre>Our business logo is now responsive with each user&#39;s preference, whether it&#39;s **light** or **dark** mode!<br></pre><pre>&lt;div&gt;<br>  &lt;ToggleImages /&gt;<br>&lt;/div&gt;<br></pre><pre>More blog words...</pre><p>At this point we are simply importing our React component and rendering it in our Markdown file.</p><p>Since this is a Next.js app let’s fire up the server npm run dev and see the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*Mc7iG6oXjDjHG-gR.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*UvZgfX3pTvkBuWzE.png" /></figure><p>and switch over to light theme</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/0*jZlSaYltUCibnO5p.png" /></figure><p>Lets open the console to see our events</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/0*w5g-LVvVhHVMvk4F.png" /></figure><p>There you have it!</p><p>Those are a couple of ways to showcase your responsive images in Markdown and one of the examples uses React to help us set the state in local storage.</p><p>I hope you liked this article and if you love developing please follow me on <a href="https://twitter.com/nathan_tarbert">X (Twitter)</a> and I’ll see you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94d59abb018e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ 6 Top-Secret Open-Source Projects You Didn’t Know About ]]></title>
            <link>https://medium.com/@nathantarbert/%EF%B8%8F-6-top-secret-open-source-projects-you-didnt-know-about-5a53e4f29b62?source=rss-b6e5d79de244------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a53e4f29b62</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nathan Tarbert]]></dc:creator>
            <pubDate>Mon, 13 Nov 2023 13:02:04 GMT</pubDate>
            <atom:updated>2024-03-25T18:56:19.482Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*quJ1sXIW076tYvOP-mMHdg.gif" /></figure><p>As a developer who went through a boot camp a few years ago, I can tell you the number one subject that was never touched upon was <strong>SECURITY</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*ASFPYtSstqAIyLzc.gif" /></figure><p>On one hand, I get it. Starting your development journey can be quite challenging, especially when you’re working to establish a strong foundation.</p><p>From learning a programming language, setting up routes, running servers, and conducting unit tests, to fetching data from databases, there’s already a lot to handle.</p><p>Looking back, I can only imagine how overwhelming it would have been if security concerns were piled on top of all that.</p><p>While login security was always a consideration, the broader topic of security, ranging from Application Security (AppSec) to Cloud security, etc. was a vast and somewhat elusive subject.</p><p>My perspective shifted when I joined communities discussing security and my eyes were opened to a bigger picture.</p><p>I began uncovering the intricacies of concepts like SQL injection and vulnerabilities that are introduced through open-source dependencies.</p><p>The reason <strong>top-secret open-source</strong> projects often remain a mystery to newcomers is that to those new to development, security can seem like a distant realm.</p><p>So, let’s explore some services that can enhance the security of your application at various stages.</p><p>It’s important to note that while this list isn’t exhaustive, one thing remains clear: never underestimate the importance of security.</p><p>It should always be a top priority because, as the saying goes, it’s not a matter of if a security breach will occur, but when.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/0*fhnHwN8yn6UP5PTu.png" /></figure><p>This leads us to the significance of maintaining comprehensive logs, especially in the event of such an incident.</p><p><strong>Let’s dive in and take a closer look!</strong></p><h3>[1] <a href="https://github.com/retracedhq/retraced">Retraced</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*D7oMbVTCUyzLyUwj.gif" /></figure><p>One integrated API, <strong>BoxyHQ’s Audit Logs</strong> will provide you or your customers the ability to record and search events that happen within your application.</p><ul><li>an exportable record of read/write events. It also provides an API to send audit events and several different methods for customers to view and extract events.</li><li>For all companies but in particular large companies, the ability to monitor the flow of data and be alerted to any breaches is essential.</li><li>Audit logs help to pinpoint any misuse of information and ensure that data policies are followed</li></ul><p><a href="https://dub.sh/retraced-hq">Please star ⭐ Retraced</a></p><h3>[2] <a href="https://github.com/dotenv-org/dotenv-vault">Dotenv — Vault</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*hQG3TZbpSww_r8yu.gif" /></figure><p>The secrets manager for .env files which allows you to sync your .env files with a single command, deploy them with an encrypted .env.vault file, and say goodbye to scattered secrets across multiple platforms and tools.</p><p>Here’s a quick rundown of how to use it:</p><ul><li>Make changes to your .env file.</li><li>Push those changes up using the command: $ npx dotenv-vault@latest push.</li><li>Add the .env.vault file to your git repository: $ git add .env.vault.</li><li>Commit the changes: $ git commit -am &quot;Add .env.vault.</li><li>Push the changes to your git repository: $ git push.</li></ul><p><a href="https://github.com/dotenv-org/dotenv-vault">Please star ⭐ Dot Env</a></p><h3>[3] <a href="https://github.com/external-secrets/external-secrets">External Secrets</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*PDauuZ38ay9fTeQI.gif" /></figure><p>A Kubernetes operator that integrates external secret management systems like AWS Secrets Manager, HashiCorp Vault, Google Secrets Manager, Azure Key Vault, IBM Cloud Secrets Manager, and many more. The operator reads information from external APIs and automatically injects the values into Kubernetes Secrets.</p><ul><li>synchronize secrets from external APIs into Kubernetes</li><li>ESO is a collection of custom API resources — ExternalSecret, SecretStore, and ClusterSecretStore that provide a user-friendly abstraction for the external API that stores and manages the lifecycle of the secrets for you.</li></ul><p><a href="https://github.com/external-secrets/external-secrets">Please star ⭐ External Secrets</a></p><h3>[4] <a href="https://github.com/trufflesecurity/trufflehog">Trufflehog</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*fL7b47QzGuM0eKf0.gif" /></figure><p>Scan all platform’s version history for hidden secrets. Secrets get exposed in much more than code repositories.</p><ul><li>Stop secrets from entering your platforms with various TruffleHog integrations (pre-commit hooks, CI integrations, etc.)</li><li>Remediation workflows puts power in the hands of the developers to fix these issues as they are found without having to engage security or triage false positives.</li></ul><p>Here’s how to use it:</p><ul><li>To scan a GitHub repo, use the command: trufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments.</li><li>To scan a GitHub repo using SSH authentication in docker, use the command: docker run --rm -v &quot;$HOME/.ssh:/root/.ssh:ro&quot; trufflesecurity/trufflehog:latest git ssh://github.com/trufflesecurity/test_keys.</li></ul><p><a href="https://github.com/trufflesecurity/trufflehog">Please star ⭐ Trufflehog</a></p><h3>[5] <a href="https://github.com/Qovery/Replibyte">Replibyte</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*veQ4jvO6HMyKUaOu.gif" /></figure><p>Replibyte is a tool that is used to seed databases with production data while keeping sensitive data safe. It’s a fast and easy-to-use tool that doesn’t require anything special to get started.</p><ul><li>Create a development dump from production.</li><li>Subset your production dump into a more reasonable size.</li><li>Hide sensitive data via customizable Transformers.</li><li>Make your development dump easily accessible from any remote and local databases.</li></ul><p><a href="https://github.com/Qovery/Replibyte">Please star ⭐ Replibyte</a></p><h3>[6] <a href="https://github.com/sqlmapproject/sqlmap">sqlmap</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*rGh9FaGukvHMc9yj.gif" /></figure><p>Sqlmap, an open-source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over database servers.</p><p>It comes with a powerful detection engine, many niche features for the ultimate penetration tester, and a broad range of switches lasting from database fingerprinting to fetching data from the database.</p><ul><li>Support to directly connect to the database without passing via a SQL injection, by providing DBMS credentials, IP address, port and database name.</li><li>Support to enumerate users, password hashes, privileges, roles, databases, tables, and columns.</li><li>Automatic recognition of password hash formats and support for cracking them using a dictionary-based attack.</li><li>And more…</li></ul><p><a href="https://github.com/sqlmapproject/sqlmap">Please star ⭐ Sqlmap</a></p><p>Don’t underestimate the significance of security; the beauty of open-source lies in the availability of countless tools that can kickstart your journey.</p><p>This is a lifelong adventure woven into the fabric of software development throughout your Software Development Life Cycle (SDLC).</p><p>I’d be genuinely interested in knowing the tools you’ve incorporated into your security practices, so please feel free to share them in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a53e4f29b62" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>