<?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 Dmytro Chaban on Medium]]></title>
        <description><![CDATA[Stories by Dmytro Chaban on Medium]]></description>
        <link>https://medium.com/@dmytro.ch?source=rss-60ac21763a01------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WhX_wBWuvs0cscSR6eLbaQ.jpeg</url>
            <title>Stories by Dmytro Chaban on Medium</title>
            <link>https://medium.com/@dmytro.ch?source=rss-60ac21763a01------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 12:23:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dmytro.ch/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[Beginner’s Guide to Agent2Agent (A2A) Communication: Build a DuckDuckGo Web-Search Agent with…]]></title>
            <link>https://medium.com/llmx/beginners-guide-to-agent2agent-a2a-communication-build-a-duckduckgo-web-search-agent-with-1da7a8c58ad1?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/1da7a8c58ad1</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[a2a]]></category>
            <category><![CDATA[agent2agent]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Wed, 14 May 2025 00:00:08 GMT</pubDate>
            <atom:updated>2026-03-04T06:29:48.326Z</atom:updated>
            <content:encoded><![CDATA[<h3>Beginner’s Guide to Agent2Agent (A2A) Communication: Build a DuckDuckGo Web-Search Agent with Python &amp; LangGraph</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52Pr7huaCtaAfdsJDXG7TQ.png" /></figure><p>In this beginner’s guide, you’ll learn how to implement Agent2Agent (A2A) communication by building a DuckDuckGo web-search agent using Python, FastAPI, and LangGraph. Let’s integrate the DuckDuckGo search API and master A2A agent development best practices.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#what-is-agent-to-agent-a2a-communication--why-use-it">What is Agent-to-Agent (A2A) Communication &amp; Why Use It?</a></h3><p>Agent 2 Agent(A2A) communication is a way for people and agents to communicate with other agents. In simple words, you can think of it as a standard of communication (like HTTP) for agents and clients. This standard of communication essentially creates a network of agents, with possibility of self-discovery and self-organization.</p><p>If we take Model-Context-Protocol(MCP), we can say that it beefs up one agent with a lot of tools, but eventually, it’ll become super bloated and will increase mistaces, tool misuse, etc. There’re ways to handle it(e.g tool lookup), but it’s still makes MCP a bit messy.</p><p>A2A on the other hand, distributes horizontally the load of tool usage. Instead of stuffing one agent with a lot of tools, we can distribute the load of tool usage to multiple agents, and assign each agent their specific role.</p><p>You can think of MCP as a freelancer, and A2A as a company with multiple employees, there’ll be delegators, developers, designers, etc.</p><p>With that in mind, let’s jump into the implementation of simple A2A agent. Let’s do something useful, and implement a tool that can search the web for links for us.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#using-the-a2a-template-with-python--langgraph">Using the A2A Template with Python &amp; LangGraph</a></h3><p>If I’ll share all of the code for the project, it’ll become a book :) A2A is quintessence of many different frameworks and paradigms, so it’s not that simple to just share parts of code. Also, we have LLMs and what not, so if you have very specific question — just ask on a code, or write to me, happy to help.</p><p>So, let’s start with cloning(using) our A2A template: <a href="https://github.com/new?template_name=a2a-template-langgraph&amp;template_owner=llmx-de">Use our template</a></p><p>You should then clone your forked repository to your local machine.</p><pre>git clone https://github.com/{your-username}/a2a-template-langgraph.git</pre><p>Next is to initialize the project so you can start working with it.</p><pre>cd a2a-template-langgraph<br>uv install</pre><p>In case you want to use persistance with PostgreSQL, you need to startup a postgres:</p><pre>docker-compose up -d postgres</pre><p>Now, we need to create a .env file and set the following variables:</p><pre>OPENAI_API_KEY={your_openai_api_key}<br>OPENAI_MODEL=o4-mini # Optional, defaults to o4-mini</pre><p>And, that’s it! You can now start the project by running:</p><pre>python main.py</pre><p>You can do a curl to see if the server is running:</p><pre>curl http://localhost:10000/.well-known/agent.json<br>{&quot;name&quot;:&quot;LangGraph Agent&quot;,&quot;description&quot;:&quot;A versatile agent...</pre><p>Perfect! Before we push it to production, of course, we need to add some functionality to it.</p><p>Let’s go first over logic and how it works in general, and what core components are present.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#understanding-the-structure-of-a2a">Understanding the structure of A2A</a></h3><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#tasks-and-messages">Tasks and Messages</a></h3><p>In core of A2A communication lies a task and a message.</p><p>The structure corresponsds to something like this:</p><pre>Task<br>  Status<br>  State<br>  Message<br>    Role<br>    Parts<br>  Artifacts<br>    Parts<br>    Index<br>    Append</pre><p>Each task contains a status with possible message, and artifacts. This will be our main data types to work with.</p><p>With tempalte you don’t really need to define it, but it’s good to know the structure.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#agent">Agent</a></h3><p>Now we can look at internal part that you’re most familiar with — agent.</p><p>There’s no limit on which framework you can use in A2A, so you can pick any. Agent is more abstract part, and just needs to receive queries(text to reply to). This means you can also easily swap them later, if you don’t like functionality of one.</p><p>Template uses LangGraph, but feel free to have a look at other examples here: <a href="https://github.com/google/A2A/tree/main/samples/python/agents.">https://github.com/google/A2A/tree/main/samples/python/agents.</a></p><p>For LLM, we’ll be using gpt-4.1(big context, good quality, and not too expensive).</p><p>Feel free to explore <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/.a2a_service/agent.py">.a2a_service/agent.py</a>. But one item we&#39;re most interested is SYSTEM_INSTRUCTION.</p><pre># .a2a_service/agent.py</pre><pre>from langchain_core.tools import tools<br>...</pre><pre>class Agent:</pre><pre>    SYSTEM_INSTRUCTION = &quot;&quot;&quot;<br>    You are a helpful AI assistant that can answer questions on a wide range of topics.<br>    Your goal is to provide accurate, helpful information to the user.<br>    &quot;&quot;&quot;</pre><p>This is a system instruction for our agent. It’s a good place to define what the agent is for, and what it’s capable of.</p><p>While defining system instruction, keep in mind the role of the agent, if he’ll be dedicating tasks to other agents. In our case, we’re creating a “worker”, he’ll only receive a task and will need to return a result or ask for clarifications. We’ll be looking at other types of agents in future articles, but for now, let’s keep it simple.</p><p>Other than that, system instructions work the same way as in any other LLM.</p><p>Now we have our “working gear”, let’s see how we actually juggle requests from clients.</p><h4><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#agent-tools">Agent tools</a></h4><p>Besides system instruction, agent also has tools, it’s super easy to define them. Template already comes with <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/a2a_service/tools/search.py">mocked tool</a>, and it’s easy to define your own. Just add new file, tag it with @tool, and add it to the tools list in <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/a2a_service/agent.py#L46">Agent</a> class.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#juggling-tasks-with-task-manager">Juggling tasks with Task Manager</a></h3><p>Task manager is a core component that will be handling requests from clients. It’s your job to define how it works, if you can accept parallel requests, how you throttle them, etc. Our template provides a simple <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/a2a_service/task_managers/db_task_manager.py">persistant(PostgreSQL)</a> and <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/a2a_service/task_managers/async_inmem_task_manager.py">non-persistent(in-memory)</a> task manager.</p><h4><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#memory-management">Memory management</a></h4><p>Every task manager should have some type of memory. Non-persistant task manager(or mostly in-memory) are basically good for either really simple use cases, or testing.</p><p>I really encourage you to use persistant task manager, as it’ll make your life easier along the way :)</p><h4><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#synchronous-vs-streaming-task-managers">Synchronous vs Streaming Task Managers</a></h4><p>When it comes to handling tasks, you might also consider the difference between synchronous and streaming task managers.</p><p>Synchronous task managers process tasks as http requests, without returning results in realtime, but waitign for whole reply to be completed, and then returning it.</p><p>Streaming task managers are returning results in realtime, as they come in. In practice it’s usually parts of LLM responses, files, etc.</p><p>For now, we recommend sticking to simplicity with synchronous task managers.(and also our template is not supporting streaming yet)</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#agent-card">Agent Card</a></h3><p>Agent card is a way to define what the agent is capable of. It’s a way to expose functionality of the agent to the outside world.</p><p>We define it in <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/main.py#L33">main.py</a> file</p><p>We’ll cover agent card in more detail in future articles, here’s a quick onboarding:</p><ol><li>Name, Description, Version — basic info about the agent, name, description that will be visible for other agents and clients, and version of the agent(in semver).</li><li>Default input and output modes — which content types the agent can handle on input and output, for now we’re sticking to text([&quot;text&quot;, &quot;text/plain&quot;])</li><li>Capabilities — list of capabilities the agent has, we’ll cover this in more detail in future articles.</li></ol><ul><li>Streaming — whether the agent can handle streaming of data(a.k.a if Task Manager knows how to stream)</li><li>pushNotifications — if agent supports push notifications when long running tasks are completed</li></ul><ol><li>Skills — Detailed information about skills the agent has, this is really important part, as it’ll be used by other agents to find out what the agent can do.</li></ol><pre>agent_card = AgentCard(<br>    name=&quot;LangGraph Agent&quot;,<br>    description=&quot;A versatile agent that can answer questions using search tools&quot;,<br>    url=f&quot;http://{HOST}:{PORT}/&quot;,<br>    version=&quot;1.0.0&quot;,<br>    defaultInputModes=Agent.SUPPORTED_CONTENT_TYPES,<br>    defaultOutputModes=Agent.SUPPORTED_CONTENT_TYPES,<br>    capabilities=capabilities,<br>    skills=[skill],<br>)</pre><p>If you define new functionality you want other clients or agents to know, you most likely want to expose it via skills, e.g:</p><pre>temperature_check_skill = AgentSkill(<br>    id=&quot;temperature_check&quot;,<br>    name=&quot;Temperature Check&quot;,<br>    description=&quot;Checks the temperature of the water&quot;,<br>    tags=[&quot;temperature&quot;, &quot;water&quot;],<br>    examples=[&quot;What is the temperature of the water?&quot;, &quot;Is the water too hot?&quot;, &quot;Is the water too cold?&quot;],<br>)</pre><p>Now, we can add this skill to our agent card:</p><pre>agent_card.skills = [temperature_check_skill]</pre><p>Obvious that you need define what the agent really can do, otherwise you’ll receive requests to do something you cannot do.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#a2a-server">A2A server</a></h3><p>Last part of A2A framework is the server that powers everything. As with Agent, you can pick any framework you want, as well as language. We’re sticking to python and FastAPI.</p><p>A2A server is available in <a href="https://github.com/llmx-de/a2a-template-langgraph/blob/main/a2a_service/server.py#L11">.a2a_service/server.py</a> file.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#modifying-the-template-to-be-useful">Modifying the template to be useful</a></h3><p>Now that we know the setup, we can modify the template to be useful.</p><p>In our case, let’s update search tool to use DuckDuckGo and really do a web search.</p><p>Let’s install duckduckgo-search:</p><pre>uv add duckduckgo-search</pre><p>And now update search tool:</p><pre>from langchain_core.tools import tool<br>from typing import Optional<br>from duckduckgo_search import DDGS<br>@tool<br>def search_web(query: str, max_results: Optional[int] = 5) -&gt; str:<br>    &quot;&quot;&quot;Search the web for information using DuckDuckGo.<br>    <br>    Args:<br>        query: The search query.<br>        max_results: Maximum number of results to return (default: 5)<br>        <br>    Returns:<br>        Information found from the search.<br>    &quot;&quot;&quot;<br>    try:<br>        with DDGS() as ddgs:<br>            results = list(ddgs.text(query, max_results=max_results))<br>        <br>        if not results:<br>            return &quot;No results found.&quot;<br>            <br>        formatted_results = []<br>        for i, result in enumerate(results, 1):<br>            title = result.get(&#39;title&#39;, &#39;No Title&#39;)<br>            body = result.get(&#39;body&#39;, &#39;No Content&#39;)<br>            href = result.get(&#39;href&#39;, &#39;No URL&#39;)<br>            <br>            formatted_results.append(f&quot;{i}. {title}\n   {body}\n   URL: {href}\n&quot;)<br>            <br>        return &quot;\n&quot;.join(formatted_results)<br>    except Exception as e:<br>        return f&quot;Error performing search: {str(e)}&quot;</pre><p>Let’s start the server and try to ask to search the web:</p><pre>=========  starting a new task ======== </pre><pre>What do you want to send to the agent? (:q or quit to exit): Search me in web &quot;news may 12 2025&quot;</pre><pre>{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;3eab69eb046c418e816e406d3e3d93c8&quot;,&quot;result&quot;:{&quot;id&quot;:&quot;486fc7f248ab429f91657ef19b3b93ca&quot;,&quot;status&quot;:{&quot;state&quot;:&quot;completed&quot;,&quot;message&quot;:{&quot;role&quot;:&quot;agent&quot;,&quot;parts&quot;:[{&quot;type&quot;:&quot;text&quot;,&quot;text&quot;:&quot;Here are some of the top news round-ups and sources for May 12, 2025:\n\n1. “Monday Morning News: May 12, 2025” (wng.org)\n   – Highlights include:\n....</pre><p>You’ll also see in logs queries to duckduckgo:</p><pre>INFO:primp:response: https://html.duckduckgo.com/html 200</pre><p>Perfect! Now we have a working web search tool.</p><h3><a href="https://llmx.de/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/#how-to-test-the-agent">How to test the agent?</a></h3><p>I recommend trying a UI tool called <a href="https://github.com/llmx-de/a2a-validation-tool">a2a-validation-tool</a> that helps you visually see the results, making them easier to read and share with others. This tool provides a more user-friendly way to examine your agent’s responses compared to viewing raw output in the terminal.</p><p>Just download the tool from <a href="https://github.com/llmx-de/a2a-validation-tool/releases/latest">latest release</a>, and run it(instructions how to install for linux are in readme).</p><p>On first start, you should already get a agent on 10000 port, so you can just hit refresh button on it and it should connect and display live information. If everything is working, you should see green circle on the agent card:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*VGDr2BzOkfRCsAFuzo3inw.png" /><figcaption>Example of green circle in Agent2Agnet a2a-validation-tool, meaning that A2A agent connected</figcaption></figure><p>You can then click on agent and message window will open, where you can send messages to the agent. Here’s testing result from my side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52Pr7huaCtaAfdsJDXG7TQ.png" /><figcaption>Example of communication via a2a-validation-tool and Agent2Agent(a2a) agent</figcaption></figure><p>Now you completed your first A2A agent! Next step will be to explore other types of agents, and how to integrate them in practice.</p><p>If you have any questions, feel free to write to me, happy to help :)</p><p><em>Originally published at </em><a href="https://llmx.tecg/blog/beginners-guide-to-agent2agent-a2a-communication-build-duckduckgo-web-search-agent-with-python-and-langgraph/"><em>https://llmx.</em>tech</a><em> on May 14, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1da7a8c58ad1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/llmx/beginners-guide-to-agent2agent-a2a-communication-build-a-duckduckgo-web-search-agent-with-1da7a8c58ad1">Beginner’s Guide to Agent2Agent (A2A) Communication: Build a DuckDuckGo Web-Search Agent with…</a> was originally published in <a href="https://medium.com/llmx">LLMx</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LlamaIndex VectorDB Filtering: Advanced Techniques for Smarter AI Search]]></title>
            <link>https://medium.com/llmx/llamaindex-vectordb-filtering-advanced-techniques-for-smarter-ai-search-9c04074abe1a?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c04074abe1a</guid>
            <category><![CDATA[llamaindex]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[vector]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 00:00:19 GMT</pubDate>
            <atom:updated>2026-03-04T06:31:11.974Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmwel-jNerUCaRziH_XJMQ.png" /><figcaption>LlamaIndex VectorDB Filtering</figcaption></figure><p>As an AI developer working with innovative businesses daily, I’ve consistently found that traditional keyword-based searches often fail to deliver the fast, accurate insights my clients demand. That’s why I combine LlamaIndex with sophisticated vector database filtering — an approach that powers next-generation semantic search, drastically improving both speed and relevancy.</p><p>When managing large-scale data in a multi-user environment, simply using vector search without filters can quickly become impractical — or even risky. Imagine managing a digital library where a user searching for philosophy texts ends up with unrelated financial documents, or worse, accesses sensitive content unintentionally. Clearly, basic vector searches aren’t sufficient when precision, efficiency, and security matter.</p><p>In this article, you’ll see how to use LlamaIndex’s metadata filtering to ensure your searches remain relevant, secure, and fast.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#the-problem-why-basic-vector-search-isnt-enough">The Problem: Why Basic Vector Search Isn’t Enough</a></h3><p>Imagine you’re managing a huge library of books, and a user searches for philosophy-related content but ends up with financial reports instead. Or worse, a user gains access to restricted books they shouldn’t be able to read. Without proper filtering, search results become irrelevant or even a security risk. This is why filtering isn’t just about improving search — it’s about controlling what data is included or excluded based on context.</p><p>When dealing with large-scale VectorDBs, especially in multi-user environments, the ability to filter or include data isn’t just a nice-to-have — it’s a necessity. Here are some examples where this becomes critical:</p><ul><li>Handling Multiple Clients on the Same VectorDB: If multiple users are querying the same database, you need a way to scope searches so that each client only sees relevant results.</li><li>Topic-Based Filtering: Users can filter results by domain knowledge or interests, ensuring they only get content that matters to them.</li><li>Security &amp; Access Control: Not all data should be accessible to everyone. There needs to be a mechanism to enforce restrictions based on security groups or user permissions.</li></ul><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#understanding-metadata-in-llamaindex">Understanding Metadata in LlamaIndex</a></h3><p>Before diving into solutions, let’s introduce metadata with a practical example: a book database. Imagine you’re managing a digital library, and each book document carries essential metadata like book name, filename, category, and access level. This metadata helps structure, track, and filter content efficiently, ensuring users can retrieve relevant books based on their needs.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#what-is-metadata">What is Metadata?</a></h3><p>Metadata is additional information attached to each document that categorizes and structures data, making it easier to filter and retrieve relevant information. In our book database example, metadata might include attributes like:</p><ul><li>Book Name: Title of the book (e.g., “The Art of War”)</li><li>Filename: The stored file name (e.g., art_of_war.pdf)</li><li>Category: Genre or subject (e.g., “Philosophy”)</li><li>Access Level: User permission level required to view (e.g., “public”, “restricted”)</li></ul><p>LlamaIndex allows you to embed this metadata directly into documents, enabling efficient filtering during searches. Metadata does not have a strict format — it can be expanded with additional fields depending on use case requirements. Whether it’s adding an author field, publication year, or custom tags, metadata can be adapted to suit different filtering needs.</p><p>Example with a Book Document:</p><pre>from llama_index.core import Document<br>document = Document(<br>    text=&quot;Sun Tzu&#39;s strategic wisdom on warfare and leadership.&quot;,<br>    metadata={<br>        &quot;book_name&quot;: &quot;The Art of War&quot;,<br>        &quot;filename&quot;: &quot;art_of_war.pdf&quot;,<br>        &quot;category&quot;: &quot;Philosophy&quot;,<br>        &quot;access_level&quot;: &quot;public&quot;<br>    }<br>)</pre><p>This ensures that every document carries useful metadata, making it easier to filter and retrieve specific information when needed.</p><p>LlamaIndex also allows automatic metadata assignment when loading book files. Suppose we want to auto-tag book filenames as metadata:</p><pre>from llama_index.core import SimpleDirectoryReader<br>filename_fn = lambda filename: {&quot;filename&quot;: filename.split(&#39;/&#39;)[-1], &quot;category&quot;: &quot;Literature&quot;, &quot;access_level&quot;: &quot;public&quot;}<br>documents = SimpleDirectoryReader(<br>    &quot;./data&quot;, file_metadata=filename_fn<br>).load_data()</pre><p>This method automatically assigns metadata to each document based on its filename, ensuring that all documents are structured correctly for indexing and filtering.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#how-to-deal-with-filtering-in-llamaindex">How to Deal with Filtering in LlamaIndex</a></h3><p>LlamaIndex provides multiple ways to filter metadata before performing a vector similarity search, allowing for more targeted and efficient retrieval. Filters can be applied to refine results based on exact matches, numerical ranges, or combined conditions.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#1-exact-match-filtering">1. Exact Match Filtering</a></h3><p>The ExactMatchFilter allows filtering documents based on an exact metadata key-value match. This is particularly useful for restricting searches to a specific user, category, or document type.</p><p>Example:</p><pre>from llama_index.core.vector_stores import MetadataFilters, ExactMatchFilter<br>filters = MetadataFilters(<br>    filters=[ExactMatchFilter(key=&quot;author&quot;, value=&quot;John Doe&quot;)]<br>)</pre><p>If multiple clients share the same VectorDB, each search should be restricted to that specific client’s data. This can be done by tagging documents with client IDs and using metadata filtering.</p><p>Example:</p><pre>from llama_index import VectorStoreIndex, SimpleDirectoryReader<br>from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters<br># Load documents<br>documents = SimpleDirectoryReader(&#39;path_to_your_data&#39;).load_data()<br># Create an index<br>index = VectorStoreIndex.from_documents(documents)<br># Define client-specific filter<br>filters = MetadataFilters(filters=[<br>    ExactMatchFilter(key=&quot;client_id&quot;, value=&quot;client_123&quot;)<br>])<br># Query with client-specific filter<br>query_engine = index.as_query_engine(filters=filters)<br>response = query_engine.query(&quot;Internal reports on market trends&quot;)</pre><p>Now, only documents tagged with client_123 will be retrieved, keeping other clients&#39; data separate.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#2-range-filtering">2. Range Filtering</a></h3><p>For numeric metadata like years, prices, or scores, LlamaIndex supports range filtering using operators such as:</p><ul><li>Greater than (&gt;)</li><li>Less than (&lt;)</li><li>Greater than or equal to (&gt;=)</li><li>Less than or equal to (&lt;=)</li></ul><p>Example:</p><pre>from llama_index.core.vector_stores import MetadataFilters, MetadataFilter, FilterOperator<br>filters = MetadataFilters(<br>    filters=[<br>        MetadataFilter(key=&quot;year&quot;, value=2020, operator=FilterOperator.GT)  # year &gt; 2020<br>    ]<br>)</pre><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#3-combining-multiple-filters">3. Combining Multiple Filters</a></h3><p>Filters can be combined to refine results based on multiple criteria. Example:</p><pre>filters = MetadataFilters(<br>    filters=[<br>        ExactMatchFilter(key=&quot;author&quot;, value=&quot;John Doe&quot;),<br>        ExactMatchFilter(key=&quot;topic&quot;, value=&quot;AI&quot;)<br>    ]<br>)</pre><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#important-considerations-for-filtering">Important Considerations for Filtering</a></h3><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#database-specific-limitations">Database-Specific Limitations</a></h3><p>Not all vector databases support every filtering functionality. For example, <a href="https://docs.llamaindex.ai/en/stable/examples/vector_stores/DuckDBDemo/">DuckDB on Windows</a> does not support OR filters at the time of writing. It&#39;s important to verify the filtering capabilities of your chosen database before implementation.</p><h4><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#bypassing-limitations">Bypassing Limitations</a></h4><p>If your database lacks support for certain filtering features, a workaround is to perform multiple searches — each with a single filter — and then combine, sort, and trim the results to the required amount. This approach allows you to approximate more complex filtering logic while staying within the constraints of your database.</p><p>Example:</p><pre>from llama_index import VectorStoreIndex<br>from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters<br>def combined_query(index, query, filters_list, top_k=10):<br>    results = []<br>    for filters in filters_list:<br>        query_engine = index.as_query_engine(filters=filters)<br>        response = query_engine.query(query)<br>        results.extend(response)<br>    <br>    # Sort results based on relevance (assuming similarity scores are available)<br>    results = sorted(results, key=lambda x: x.score, reverse=True)<br>    <br>    # Trim to required top_k results<br>    return results[:top_k]<br># Define separate filters<br>filters_1 = MetadataFilters(filters=[ExactMatchFilter(key=&quot;category&quot;, value=&quot;AI&quot;)])<br>filters_2 = MetadataFilters(filters=[ExactMatchFilter(key=&quot;category&quot;, value=&quot;Finance&quot;)])<br># Execute the combined query<br>final_results = combined_query(index, &quot;Latest industry trends&quot;, [filters_1, filters_2], top_k=10)</pre><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#auto-retrieval-in-llamaindex">Auto-Retrieval in LlamaIndex</a></h3><p>Auto-retrieval in LlamaIndex leverages large language models (LLMs) to dynamically generate optimized query strategies, including metadata filters and query refinements, creating a more intelligent retrieval system that goes beyond basic vector similarity search.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#how-auto-retrieval-works">How Auto-Retrieval Works</a></h3><p>Instead of manually specifying filters, auto-retrieval uses an LLM to:</p><ol><li>Parse the natural language query</li><li>Infer appropriate metadata filters based on the query content</li><li>Determine the best search strategy</li><li>Generate a query bundle containing the optimized query string and metadata filters</li><li>Execute this bundle against the vector database</li></ol><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#implementing-auto-retrieval">Implementing Auto-Retrieval</a></h3><p>LlamaIndex provides an AutoVectorRetriever that automates this process:</p><pre>from llama_index.core import VectorStoreIndex, SimpleDirectoryReader<br>from llama_index.core.retrievers import AutoVectorRetriever<br>from llama_index.core.vector_stores import VectorStore<br>from llama_index.core.selectors import LLMSingleSelector<br># Load and index documents with metadata<br>documents = SimpleDirectoryReader(&quot;data&quot;).load_data()<br>index = VectorStoreIndex.from_documents(documents)<br>vector_store = index.vector_store<br># Create the retriever<br>retriever = AutoVectorRetriever(<br>    vector_store=vector_store,<br>    selector=LLMSingleSelector(),<br>    top_k=5,<br>)<br># Query with auto-retrieval<br>query = &quot;Find me recent books about AI published after 2020&quot;<br>nodes = retriever.retrieve(query)</pre><h4><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#specifying-metadata-for-auto-retrieval">Specifying Metadata for Auto-Retrieval</a></h4><p>For auto-retrieval to effectively leverage metadata, you need to provide structured information about your vector store and the metadata fields available for filtering. This is done using the VectorStoreInfo and MetadataInfo classes:</p><pre>from llama_index.core.retrievers import VectorIndexAutoRetriever<br>from llama_index.core.vector_stores.types import MetadataInfo, VectorStoreInfo<br><br># Define vector store information with metadata specifications<br>vector_store_info = VectorStoreInfo(<br>    content_info=&quot;collection of books with various topics and attributes&quot;,<br>    metadata_info=[<br>        MetadataInfo(<br>            name=&quot;category&quot;,<br>            type=&quot;str&quot;,<br>            description=&quot;Category of the book, e.g., Philosophy, Science, Business&quot;<br>        ),<br>        MetadataInfo(<br>            name=&quot;year&quot;,<br>            type=&quot;int&quot;,<br>            description=&quot;Publication year of the book&quot;<br>        ),<br>        MetadataInfo(<br>            name=&quot;author&quot;,<br>            type=&quot;str&quot;,<br>            description=&quot;Author of the book&quot;<br>        ),<br>        MetadataInfo(<br>            name=&quot;access_level&quot;,<br>            type=&quot;str&quot;,<br>            description=&quot;Access level required: public, restricted, or private&quot;<br>        ),<br>    ],<br>)<br><br># Create auto-retriever with vector store info<br>retriever = VectorIndexAutoRetriever(<br>    index, <br>    vector_store_info=vector_store_info<br>)<br><br># Run query that will intelligently use metadata<br>results = retriever.retrieve(&quot;Find philosophy books published after 2020&quot;)</pre><p>The MetadataInfo objects provide crucial information to the LLM about:</p><ul><li>Field names: What metadata fields are available for filtering</li><li>Data types: The expected type of each field (string, integer, etc.)</li><li>Descriptions: Human-readable explanations of what each field represents</li></ul><p>With this information, the LLM can intelligently determine which fields to filter on for any given query. For example, with the query “Find philosophy books published after 2020”, the system would:</p><ol><li>Recognize “philosophy” maps to the category field</li><li>Understand “after 2020” requires filtering on the year field with a “greater than” operation</li><li>Generate appropriate filters: {&quot;category&quot;: &quot;Philosophy&quot;, &quot;year&quot;: {&quot;$gt&quot;: 2020}}</li><li>Execute the query with these filters against the vector database</li></ol><p>A detailed log of an auto-retrieval execution might look like:</p><pre>INFO: Using query str: books<br>INFO: Using filters: {&#39;category&#39;: &#39;Philosophy&#39;, &#39;year&#39;: {&#39;$gt&#39;: 2020}}<br>INFO: Using top_k: 5</pre><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#benefits-of-auto-retrieval">Benefits of Auto-Retrieval</a></h3><ol><li>Dynamic Query Interpretation: Understands the intent behind natural language queries</li><li>Contextual Filter Generation: Creates filters based on query context without explicit programming</li><li>Flexible Retrieval Strategy: Can decide between filtering, semantic search, or both</li><li>Improved Relevance: Often retrieves more relevant information than basic vector search</li><li>Reduced Development Overhead: Eliminates the need for complex filter logic in application code</li></ol><p>Auto-retrieval makes filtering and search in VectorDBs even more intelligent by letting the LLM handle query optimization on the fly.</p><h3><a href="https://llmx.de/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/#best-practices-for-metadata-filtering">Best Practices for Metadata Filtering</a></h3><ol><li>Consistent Metadata: Ensure uniform metadata keys across documents.</li><li>Efficient Pre-Filtering: Reduce dataset size before similarity search.</li><li>Combine with Top-K: Use similarity_top_k with filtering for optimized results.</li><li>Consider Performance: Complex filtering may impact query efficiency on large datasets.</li></ol><p>Filtering isn’t just about search speed — it’s about getting the right results to the right people. Interested in implementing these optimizations for your company? Reach out to discuss how we can tailor a solution to your needs.</p><p><em>Originally published at </em><a href="https://llmx.tech/blog/llamaindex-vectordb-filtering-making-search-smarter-and-faster/"><em>https://llmx.</em>tech</a><em> on April 28, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c04074abe1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/llmx/llamaindex-vectordb-filtering-advanced-techniques-for-smarter-ai-search-9c04074abe1a">LlamaIndex VectorDB Filtering: Advanced Techniques for Smarter AI Search</a> was originally published in <a href="https://medium.com/llmx">LLMx</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to be 10x More Productive with AI Agents]]></title>
            <link>https://medium.com/llmx/how-to-be-10x-more-productive-with-ai-agents-51fc6b2253e9?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/51fc6b2253e9</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Wed, 19 Mar 2025 08:29:31 GMT</pubDate>
            <atom:updated>2025-03-19T08:29:31.100Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Productive developer oversees multiple AI agents" src="https://cdn-images-1.medium.com/max/1024/0*9jfuAUDC_5N3Y5Qv.png" /></figure><p>Have you ever noticed how traditional workplaces often assign just one person per task? This method, although conventional, creates bottlenecks, slows down project timelines, and limits overall productivity. Many organizations have introduced AI tools like ChatGPT to enhance productivity, yet they still cling to outdated workflows. The true potential of AI remains untapped.</p><p>Here’s the issue: the traditional approach of assigning single tasks to single individuals doesn’t scale. As work grows complex, multitasking and rapid context switching become essential, but humans struggle to manage this efficiently. That’s where AI agents come into play.</p><p>AI agents are automated programs leveraging Large Language Models (LLMs) to execute tasks with minimal human intervention. They don’t just assist-they automate overhead tasks like research, data summarization, scheduling, coding, and content generation. Just as LLMs previously accelerated work by 10x, AI Agents now multiply that efficiency again, transforming individual contributors into high-level project managers.</p><p>But what exactly can AI agents handle today, and how can you communicate effectively with them?</p><p>AI Agents can:</p><ul><li><strong>Automate workflows</strong>: From drafting emails to full-stack coding tasks.</li><li><strong>Use context</strong>: They can use the context of the project to make decisions.</li><li><strong>Use different tools</strong>: From reading project folders to accessing databases, Confluence, Slack, etc.</li><li><strong>Ask for input</strong>: When they need more information, they can ask for it.</li></ul><p>Successful communication with AI agents comes down to effective prompting:</p><ul><li><strong>Clear, structured prompts:</strong> Clearly define what you want, outlining the expected results explicitly.</li><li><strong>Provide context:</strong> Include relevant background information so the agent has sufficient context for nuanced decisions.</li><li><strong>Iterative refining:</strong> Refine your prompts based on initial responses, tweaking to optimize accuracy and efficiency over time.</li></ul><p>Here’s the new paradigm: leveraging AI agents transforms you into a high-level manager of multiple parallel tasks. Instead of doing each task manually, your role becomes about effective context switching, delegating specific tasks to AI agents, and overseeing the broader workflow. This shift allows you to scale your output significantly.</p><p>Effective context switching is about balancing multiple projects simultaneously without losing productivity:</p><ul><li><strong>Optimized prompt templates:</strong> Store and reuse prompts that consistently yield good results.</li><li><strong>Memory-enabled agents:</strong> Utilize Multi-Context Prompting (MCP) tools to remember past interactions, streamlining future tasks.</li><li><strong>Personalized knowledge bases:</strong> Integrate personalized data repositories to inform AI agents precisely.</li><li><strong>Manage parallel streams:</strong> Keep multiple projects open simultaneously, overseeing agents and quickly switching contexts as required.</li></ul><p>To efficiently become a manager of your tasks, choosing the right tools is crucial:</p><p>Tools like <a href="https://www.cursor.com/">Cursor</a> and <a href="https://codeium.com/windsurf">Windsurf</a> are great for managing AI agents. They have integrated agents in the IDE so you can manage your tasks directly from the IDE, requiring just switching between project tabs.</p><p>Here’s important thing is to setup a good notification system so you can be notified when the agent is done with the task.(sounds, notifications). Another thing is to allow them to use non-harmful tools without asking for your permission(e.g Yolo mode in Cursor.)</p><p>Create for yourself detailed project rules for each project so agent won’t drift off or start re-implementing existing features. Additionally, utilize Notepads to quickly append context and requirements for specific features.</p><p>I’ll tell more about Cursor and Windsurf setup in a separate articles :)</p><p>AI-Powered Chrome extensions, Github Actions, and other tools can additionaly de-clutter your memory. Example would be an AI-powered Github bot that will help you do basic Pull Request modifications without going back to IDE, cloning the branch, refreshing, etc. Instead, you can just write a comment to the PR and the bot will do the rest.</p><p>MCP standardizes data connections between AI agents and various systems, enhancing their capabilities significantly:</p><p>Connect most relevant MCPs to AI Agents to access documentation, logs, databases, etc. Keep in mind that generic MPCs will probably not give you the best results. The best is to invest in personalized MCPs for each source. For example, a Confluence connector with Caching for Confluence instead of just generic search via API will give you a much better experience.</p><p>Automating workflows using tools like:</p><ul><li><strong>n8n:</strong> A versatile, code-friendly platform that integrates AI smoothly into workflows, automating tasks across apps.</li><li><strong>Make.com:</strong> Offers intuitive automation, connecting various tools and services with AI-driven logic.</li></ul><p>These tools help businesses significantly streamline operations, reduce overhead, and enhance productivity. By using LLMs and AI agents, you can automate even more complex workflows to streamline your work.</p><p>Imagine managing multiple projects simultaneously with AI agents:</p><ul><li>One works on a data analysis</li><li>Another implements a new feature in a codebase</li><li>Another prepares documentation based on the specific codebase section</li></ul><p>And everything happens at the same time, the only thing you need to do is to switch between projects and tell them what to do next once they are done.</p><p>With this setup, you’re free to focus on strategy and high-level oversight, while AI handles routine but critical operational details. Businesses using this approach report:</p><ul><li><strong>Efficiency gains:</strong> Reducing project completion time by over 40%.</li><li><strong>Cost reduction:</strong> Lowering operational expenses significantly by automating repetitive tasks.</li><li><strong>Increased scalability:</strong> Managing more projects simultaneously without increasing human resources.</li></ul><p>The future of work isn’t just using AI; it’s transforming how we approach tasks altogether.</p><p>Harnessing AI agents as a core part of your workflow is the key to scaling productivity, maintaining a competitive edge, and becoming more profitable. Are you ready to step up your productivity game? It’s time to embrace the power of AI agents and start managing your tasks more effectively.</p><p>Ready to explore what AI can do for your business? Let’s talk about implementing customized AI agents tailored to your workflows.</p><p><em>Originally published at </em><a href="https://llmx.de/blog/how-to-be-10x-more-productive-with-ai-agents/"><em>https://llmx.de</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51fc6b2253e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/llmx/how-to-be-10x-more-productive-with-ai-agents-51fc6b2253e9">How to be 10x More Productive with AI Agents</a> was originally published in <a href="https://medium.com/llmx">LLMx</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apple VisionOS development — #1 How to install XCode15 Beta 2]]></title>
            <link>https://medium.com/@dmytro.ch/apple-visionos-development-1-how-to-install-xcode15-beta-2-eca154595a4c?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/eca154595a4c</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Sun, 25 Jun 2023 09:53:34 GMT</pubDate>
            <atom:updated>2023-06-25T09:53:34.790Z</atom:updated>
            <content:encoded><![CDATA[<h3>Apple VisionOS development — #1 How to install XCode15 Beta 2</h3><p>I must admit, I was pleasantly surprised by the capabilities of Vision OS, even with its original operating system. The potential it holds for developers is immense, especially considering its affordability once the price drops, making it accessible to a wider audience.</p><p>With Vision OS, you can not only create games but also connect it to your computer, providing a coding environment with a large screen and immersive features. Unlike other platforms, Vision OS is designed to cater to day-to-day usage, offering exceptional resolution and intuitive movement tracking. No more dealing with cumbersome sticks and accessories; Vision OS aims to provide a seamless and user-friendly experience. It’s evident that Apple is headed in the right direction with this venture, despite the occasional memes and skepticism that might surround it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F9jGNadNZPqA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9jGNadNZPqA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F9jGNadNZPqA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dd371fac033f39e90ed6b6a7035e821/href">https://medium.com/media/4dd371fac033f39e90ed6b6a7035e821/href</a></iframe><h3>Getting Started with Vision OS Development</h3><p>To begin your Vision OS development journey, visit <a href="https://developer.apple.com/xcode/">https://developer.apple.com/xcode/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bOZ4aJjpAVNmQZmglV4KHg.png" /></figure><p>Here you can find Xcode 15 beta, currently in beta but likely to have advanced to a newer version by the time you read this post. If you’re curious, feel free to explore the details provided on the website.</p><p>Once you’ve logged in, navigate to the downloads section and locate Xcode 15 beta 2 for Mac OS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2JH44GA7HABMZ_oarATUpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avYRjAGea2_wMdpjuMrZeA.png" /></figure><p>To proceed, open the Terminal and navigate to the Downloads folder. Execute the command “<strong>xip -x Xcode_15_beta_2.xip</strong>” and you will have the Xcode beta file at your disposal. Now that you have Xcode beta ready, open it and initiate the installation. You will be presented with a pop-up window allowing you to choose what you want to install. Specifically, select Xcode beta and click the button to proceed with Vision OS.</p><p>A new window will appear, offering various options to create a new project. Select “Vision OS” and then click on “App.” You will also have the option to download the wearable version of Vision OS. Simply accept the prompt to proceed with the download, which might take up several gigabytes of storage. Moving forward, you can specify additional details, such as the initial scene and immersive space, based on your preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mkD9QN5t704Ge_YEOdCwPg.png" /></figure><p>Next, choose the location on your Mac OS where you want to create the project. Once you have made the selection, you will have your test project ready, complete with all the necessary source code. The Continuum immersive view will allow you to explore and develop applications seamlessly within the Vision OS environment.</p><h4>What’s Next?</h4><p>Congratulations! You have successfully set up your test project for Vision OS. In our upcoming blog post, we will explore how to run your applications on the emulator, enabling you to test and refine your creations. Stay tuned for an exciting continuation of our Vision OS development series!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eca154595a4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here’s how I reached German B1 in around 6 months]]></title>
            <link>https://medium.com/@dmytro.ch/heres-how-i-reached-german-b1-in-around-6-months-3a52d69111bb?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a52d69111bb</guid>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 08:42:58 GMT</pubDate>
            <atom:updated>2023-04-15T08:42:58.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4VXcUOihYrlBjtKI-ZCzDA.jpeg" /><figcaption>My B1 Certificate</figcaption></figure><p>4 years. It was 4 years ago when I first accidentally played one German song and started learning German language for fun. At the start of 2022 I finally decided to finalise my “fun” and this summer I finally passed B1 level at Goethe-Institut e.V. and got 99/100 Points on Writing.</p><h4>1. Dedication</h4><p>As you see, I started learning 4 years ago with no real target or weekly hours, but ended up learning everything needed in 6 months this year. I spend around 3 hours daily learning German. Weekends included. You need to just get into the flow.</p><h4>2. Smart learning hours</h4><p>I noticed that 2 lessons by 1.5h was more than enough. 2h lessons were frying my brains. Try to find the best time for you. From here also follows that you need private lessons instead of going to courses.</p><h4>3. Sports, Health and Schedule</h4><p>At the start of 2022, I was going to gym or jogging at least every other day. Take your vitamins, try to take L-glutamine, Omega-3. Or don’t, I would say jogging was primarily source of my alertness. And especially important to have schedule, go to sleep at the same time every day and wake up, you won’t feel tired.</p><h4>4. Study the exam material</h4><p>You may know German on B1, and fail at exam at the same time. Study every step of the exam, every part of every exercise. It’ll pay off. When I was passing writing, it was too easy because behind my head there were tens of prepared statements on how to greet, explain the situation and finish the email.</p><h4>5. Take separate exams</h4><p>It’ll be more expansive, but your brain will thank you. You can prepare specifically for a single exam. I had the next sequence: Reading, Listening, 2-week pause, Writing, 2-week pause, Speaking. In every 2-week pause, I was preparing for every next exam.</p><h4>6. Learn Anki cards</h4><p>Just google “B1 Wortliste DTZ Goethe”, a lot of words. Commuting to work — learn, Working from home — go commute somewhere randomly and learn.</p><h4>7. Start your journal in German</h4><p>You can try dayoneapp.com or whatever works for you, every day write something about your day in German. Even if you don’t speak well, as long as you’re expressing something, it’ll be beneficial.</p><p>I started to learn German by some random audiobook, and I clearly remember winter nights where I was enabling this audiobook and going shopping. 20 minutes to shopping mall, cold weather and “der die das” in my headphones. After that, I travelled to Germany and wanted to learn more about this awesome culture, where I ended up relocating at 2020.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a52d69111bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 things to reuse between your startups]]></title>
            <link>https://medium.com/startgap/10-things-to-reuse-between-your-startups-d5e13f633a98?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5e13f633a98</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[work]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 06:28:33 GMT</pubDate>
            <atom:updated>2022-09-06T06:28:33.942Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ytnVlpYgaxz1ryY9VPVzog.gif" /></figure><p>Since up to 90% of startups will fail, you’ll probably need to create not just one startup, but 10 or even more, before you’ll have something successful. If you think about this process as a continuous loop, you can quite easily optimize it, so you won’t need to re-do some parts of it over and over again. The cars are not being manufactured from scratch every time — they’re being assembled from modular parts that, at the end, shape a new car. Some parts can be used in different cars. Same analog can be applied for your Startup. You can re-use some parts of it quite easily by just thinking about it in advance and designing it modular. Here are 10 things that you can easily re-use in your next startup that will save you in total more than 140 hours.</p><h3>1. Tech stack</h3><p>Time saved: 20+ hours</p><p>When you start with your first startup, idea phase will go smoothly, and once you’ll hit the implementation phase — you’ll encounter a few day delays before you start writing logic. This is where you’ll configure your development environment, investigate how to use your framework, unexpected “unknown unknowns”, programming language barrier, docker image creation… the list goes on for ages. Even if you have a team of great senior engineers, you’ll still have such problems since you never worked together before.</p><p>When startup owners start their next startup, they might see some shiny new tech stack that promises time savers and decide to use it instead of their old tech stuck. While such thing can be true — most likely you’ll need to repeat same problems that you experienced with your old tech stack.</p><p>Instead — spend one time a few hours on different technologies, pick the one that is comfortable with good community, and stick with it. Performance issues are usually not that important when you have 0$ in revenue. Once you’ll reach significant number of users, you can then start thinking about scaling the app, changing the tech stack. Again — don’t forget that we’re working on something that might be thrown into the bin in a few months or years.</p><h3>2. Authorisation</h3><p>Time saved: 20+ hours</p><p>This is a big thing that you will probably spend at least a day or two. How will your backend communicate with a frontend? OAuth, JWT? Self-made OAuth server, Firebase? What about Google sign-in? Apple sign-in? TFA? Password recovery? The best part of re-using it is that it can almost completely be modularized. The only thing that you’ll need to extract from such thing is usually user or token that you can use. Also, if you’ll change your tech stack, you’ll need to do the same thing all over again.</p><p>I’m a real fan of Firebase, quite easy to use on any language, saves time.</p><h3>3. App navigation</h3><p>Time saved: 8+ hours</p><p>App navigation is a really painful topic for applications that’ll have nested screens. If it’s a web app, you’ll need to think about routing for every screen. If it’s a mobile app — you’ll need to think how deep links can work.</p><p>Most of the projects will usually have registration, main screen, profile, settings. This navigation logic can be saved and re-used in every other startup apps with small modifications.</p><p>You can also have permissions and different user roles — so saving both authentication and navigation may be beneficial 🙂</p><h3>4. Payment logic</h3><p>Time saved : 30+ hours</p><p>Getting paid is a really complex logic that requires a lot of attention. Some small problems — your clients won’t be able to pay — you lose money. While this initial logic can be hard to set up, copying it to another project usually takes way less time.</p><p>Additional tip to this point: write a step-by-step guide on how you configured the payment. Since payment logic is partially code, primarily you’ll need to get an SHA hash and submit it to the payment platform, configure keys, permissions and similar stuff. After a few months, you’ll completely forget on how to set it up again and will have many issues that are hard to figure out why they’re happening. So record every step you take first time, and re-use it later, you’ll thank me later.</p><h3>5. API communication</h3><p>Time saved: 20 hours</p><p>Unless you have one of those backend-less applications, you’ll probably need some backend, and for that you’ll need to define how to communicate with it.</p><p>One optimization that you can do right away is to use something like OpenApi or Swagger. You’ll auto-generate your API definition, and then on frontend you’ll have abstraction for schema generation.</p><h3>6. Settings screen</h3><p>Time saved: 3+ hours</p><p>Settings screen is not something of high priority, but this is something that you’ll need to have either way. Even without investing much time, this may take up a few hours of work. If you can save the logic and re-use it across 10 different projects — that’ll be at least 27 hours saved :)</p><h3>7. Analytics and Marketing setup</h3><p>Time saved: 10+ hours</p><p>This logic lives partially outside the code, but may take up a large portion of your time if you set it up every time again and again.</p><p>One example that you can extract is analytics for your app. You’ll want to know in every app how many users e.g. bought your subscription, or how many users clicked on some particular button. This analytics initialization and how to push events can be easily saved for future.</p><p>Another example can be conversion events. For example, S2S conversion tracking can easily be extracted. If your app is web-based, you can have a look at Google Tag Manager and how to set it up for new applications.</p><h3>8. Team</h3><p>Time saved: unlimited+ hours</p><p>Keeping the same team of passionate, fast-paced, familiar people can save you more time than you can imagine. If you’ll ask any Berlin or New York startup on what is their main struggle — almost all of them will answer that it’s super hard to find good people into the team. Being an engineer myself, I never could believe it, up till a moment when I had to hire someone.</p><p>Adding to that topic, keeping good people that already know your stack and have developed every screen of your previous project will create a new one a lot faster than hiring a new people.</p><h3>9. Marketing channels</h3><p>Time saved: 10+ hours</p><p>It can be really hard to come up with marketing channels initially, but once defined, this list will only grow.</p><p>Here are a few organic channels that you can explore:</p><ol><li>Social Media(facebook, instagram)</li><li>Slack channels</li><li>Linkedin skills</li><li>Google Maps</li><li>Reddit</li><li>Product hunt</li></ol><p>Additionally, you can record the process of posting something to a specific channel. For Instagram you can have steps on how to best create a picture, where to look for tags. If you’ll opt for paid ads, for Facebook, you can specify what categories to look for or how much to pay per lead.</p><h3>10. Legal stuff</h3><p>Saved: 20+ hours and mental health</p><p>Setting up a company can be really problematic, especially if you’re an expat in a non-native language country. There’re a few shortcuts that you can take such as Estonian E-Residency, Stripe Atlas, Xolo.</p><p>Though you can keep some records on how you opened your company and next time it’ll be much simpler.</p><p>Another point on Legal stuff is the Google Play and App Store legal listing. You’ll need to have terms of service and similar pages, which is good to define once, maybe even pay, and then re-use.</p><p>And this is how you can save at least 140+ hours just by reusing logic and configurations. This all of course varies from startup to startup and the number is just approximate time you might spend. Still, it’s good to think about re-usage earlier than later and plan your future projects accordingly. If you have any other things that might be helpful to reuse, please comment them below, so the next reader can have a look as well ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5e13f633a98" width="1" height="1" alt=""><hr><p><a href="https://medium.com/startgap/10-things-to-reuse-between-your-startups-d5e13f633a98">10 things to reuse between your startups</a> was originally published in <a href="https://medium.com/startgap">StartGap</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Swagger with Quarkus and React]]></title>
            <link>https://medium.com/quarkify/setting-up-swagger-with-quarkus-and-react-a811c7ca5ace?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/a811c7ca5ace</guid>
            <category><![CDATA[quarkus]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Mon, 01 Jun 2020 14:33:23 GMT</pubDate>
            <atom:updated>2020-06-07T09:17:37.849Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S1YJrRY4xOhmV_aF.png" /></figure><p>Initialize a full-stack app is an easy task. Connect two seamlessly is a bit trickier. You can call /hello endpoint without any Swagger or other libraries. But when you have, say, 20 endpoints to work with, it&#39;s good to standardize your API calls.</p><p>This article covers:</p><ol><li>More complex than /hello REST API on Quarkus that will be used by our frontend</li><li>Setup Swagger both on Quarkus and React</li><li>Create Networking React class that will be used to fetch our data</li></ol><p>Other articles of this Series:</p><ol><li><a href="https://quarkify.net/build-run-and-deploy-react-app-with-quarkus/">Build, run and deploy React app with Quarkus</a></li><li>This article</li><li>Handle Security with Swagger(Upcoming)</li></ol><blockquote>For better experience, please <a href="https://quarkify.net/setting-up-swagger-with-quarkus-and-react/">open this article on Quarkify</a></blockquote><h3>Initial setup</h3><p>We gonna use same project that we created in previous article called quarkus-react</p><pre>git clone https://github.com/quarkifynet/quarkus-react.git &amp;&amp; cd quarkus-react</pre><p>If you want to see final version, use next command</p><pre>git clone --single-branch --branch feature/swagger-complete https://github.com/quarkifynet/quarkus-react.git &amp;&amp; cd quarkus-react</pre><h3>Create REST API to use later</h3><p>We gonna need some API to work with. If you cloned the repo, you should already have them at your disposal.</p><p>Alternatively you can come up with your own logic and follow this guide along the way. Or, if you already have a project, just skip to next part.</p><p>We gonna create ‘Downwork’, a competitor for well-known freelancing portal. So our basic schema looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*UF43K79TlqtisCu9.png" /></figure><p>You might see that user is super empty, that’s fine for now, we gonna fill it up in next part with adding JWT Security, for now, let’s declare entity objects</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1098c77542cc5827c302d15139f1b275/href">https://medium.com/media/1098c77542cc5827c302d15139f1b275/href</a></iframe><p>Now, let’s create a resource for us as well. So Idea is that user can register and log in(not in this section), submit jobs and proposals for them. We’ll need only JobPostResource for now, this resource will hold all the logic for job posts and proposals.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d2e16816a76092cb2fbc5a0043646de/href">https://medium.com/media/7d2e16816a76092cb2fbc5a0043646de/href</a></iframe><h3>operationId</h3><p>One thing to mention here is @Operation(operationId = &quot;getPosts&quot;). This annotation helps us to name method call that will be used from React, instead of calling get__posts, you gonna call getPosts. It doesn&#39;t look like much, but when you look at getJobProposals, without this annotation you&#39;ll have to call get_posts__id__proposals, which is hard to memorize. I left both options so you can compare how you want to call them, but you should know that you can call endpoint without operationId if needed(e.g external api)</p><p>We also need to define database. In this article, we gonna use H2. This database requires no additional setup except few lines in application.properties</p><pre>quarkus.datasource.url=jdbc:h2:file:./test<br>quarkus.datasource.driver=org.h2.Driver<br>quarkus.datasource.username=test<br>quarkus.datasource.password=test<br>quarkus.hibernate-orm.database.generation=drop-and-create<br>quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect<br><br>quarkus.http.cors=true</pre><p>You can see that we also added quarkus.http.cors=true. This is required for React application to communicate from other port or even host. And last thing, let&#39;s add src/main/resources/import.sql</p><pre>insert into jobpost values(1,&#39;You will be entitled to work on Quarkus project&#39;, &#39;JavaEE Quarkus Developer&#39;, null);<br>insert into jobpost values(2,&#39;You will work with nodejs and React&#39;, &#39;React Developer&#39;, null);</pre><blockquote><em>For now, we will omit User entity until next article about security</em></blockquote><h3>Setting up OpenAPI</h3><p>Best thing about Quarkus is that whole Swagger setup will take only one command:</p><pre>./mvnw quarkus:add-extensions -Dextension=&quot;openapi&quot;</pre><p>That’s it. Now if you run the app with ./mvnw quarkus:dev you can find OpenAPI schema at <a href="http://localhost:8080/openapi">http://localhost:8080/openapi</a></p><p>There’s also Swagger UI which is super handy to look at all available API, it’s located at <a href="http://localhost:8080/swagger-ui/#/">http://localhost:8080/swagger-ui/#/</a>, let’s open it up and look at current swagger schema</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cx-po_hbFtmPKhoP.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YqQLlJpm7dGH2db0.png" /></figure><p>You can see that Quarkus magically transformed all the returned objects into Schemas and all the annotated methods into endpoints.</p><h3>React Swagger setup</h3><p>Now let’s consume this data from React. The greatest part of Javascript, specifically, in this case, is that you don’t need to build anything for it to work. If you take Android development, you need to generate code via Swagger codegen, verify if all dependencies satisfy your build and import generated module into the android project itself. In Javascript, you only need to create a new object with the OpenAPI URL.</p><p>Firstly, we need to add single additional dependency:</p><pre>yarn add swagger-client</pre><p>Now, let’s create additional Networking.js file with the following content</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adccbb6049a22862965f40aa2c07a5c1/href">https://medium.com/media/adccbb6049a22862965f40aa2c07a5c1/href</a></iframe><p>We gonna look at exec method in a second, I firstly wanna talk about client object.</p><h3>Using vanilla SwaggerClient</h3><p>To use the Swagger library, the only requirement is to import swagger-client and initialize a new variable from it. Next you can execute any endpoint by next template:</p><pre><strong>this</strong>.<em>client</em>.then(<br>    client =&gt; client.<strong>apis</strong>.<strong>default</strong>.getPosts(),<br>    error =&gt; <strong><em>console</em></strong>.error(<strong>&#39;Failed to load the spec: &#39;</strong>, error)<br>).then(<br>    result =&gt; doStuff(result.<strong>body</strong>),<br>    error =&gt; <strong><em>console</em></strong>.error(<strong>&#39;Failure on api call: &#39;</strong>, error)<br>)</pre><p>I made a handy method called exec, you&#39;re not obligated to use it, but it will save you few lines of code for each place where you&#39;ll call API once we&#39;ll introduce security. What&#39;s going on here? Well, firstly, you should know that Javascript&#39;s functions are first-class citizens, which means that you can put them in any place you want. In our case, we put them into the method&#39;s default value for parameters. We can rewrite code above to something like this:</p><pre>static <em>exec </em>= function (endpoint, object, success, failure, security) {<br>  if(failure == null) {<br>    failure = res =&gt; <em>console</em>.log(&#39;failed on api call: &#39; + res)<br>  }<br>  ...<br>}</pre><h3>Execute Quarkus endpoints from React</h3><p>Now that we have our network stuff managed, let’s finally use some of our API.</p><p>I wanted to do something more interesting than Todo app that does every second guide, but this had its own drawbacks with the creation of a second file. Our final UI has a list of job posts, and when you click on one, you see a list of proposals. Everything is visible to everyone, we’ll change it once we introduce security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/0*HFyITUAlvfYg6mgN.png" /></figure><p>Let’s firstly modify main screen, here’s full code for App.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0979e8468105048d90fdaa50258a88ee/href">https://medium.com/media/0979e8468105048d90fdaa50258a88ee/href</a></iframe><p>If you’re not a JavaScript developer, useState(default) basically declares variable and setter for this screen. useEffect(func, [conditions]) declares a function that will be executed only if conditions change. Don&#39;t try to put networking directly into App function, because every time screen changes it will execute code(and if this call changes UI you&#39;ll get endless loop)</p><p>Basically our main App screen is a container for a list of job posts. This is not a good practice but for simplicity of this article I had to do it, otherwise, we’ll end up with 5–8 additional code samples. When we load the screen, GET /posts executed and we set jobs variable via setJobs()</p><p>We also have an input view, which will set newJobConent via setNewJobContent() when the input changes itself.</p><p>We declared a job view as &lt;Job job={it}/&gt;, but we haven&#39;t created this class yet. Let&#39;s add Job.js with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3ffea903e802856297315006e254f6f/href">https://medium.com/media/a3ffea903e802856297315006e254f6f/href</a></iframe><p>Here’s additional styles that you can put into App.css if you want your ui to match mine.</p><pre>.App-header {<br>background-color: #282c34;<br>min-height: 100vh;<br>display: flex;<br>flex-direction: column;<br><strong>align-items: start;<br>justify-content: start;</strong><br>font-size: calc(10px + 2vmin);<br>color: white;<br>}<br><br>.<strong>job-container </strong>{<br>  <strong>margin</strong>: 5<strong>vh</strong>;<br>  <strong>margin-bottom</strong>: 1<strong>vh</strong>;<br>  <strong>display</strong>: <strong>flex</strong>;<br>  <strong>flex-direction</strong>: <strong>column</strong>;<br>  <strong>align-items</strong>: <strong>start</strong>;<br>}<br><br>.<strong>job-desc </strong>{<br>  <strong>font-size</strong>: <strong>calc</strong>(10<strong>px</strong>);<br>}</pre><h3>Verify if it’s working</h3><p>Now, let’s start dev environment with ./mvnw quarkus:dev in java root folder and npm start in other window</p><pre>./mvnw quarkus:dev <br># Other terminal <br>cd ./src/main/webapp &amp;&amp; npm start</pre><p>Go to <a href="http://localhost:3000/">http://localhost:3000/</a> and look at the available list of jobs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/0*AlHuJyoevPHERDr_.png" /></figure><p>Write something in a input below, (e.g Fullstack developer) and click Submit job. You&#39;ll see a new job created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*S-_2nGPUo_usD2EB.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*wxjBpxzaREJZXQMb.png" /></figure><p>Click expand on a job, and do the same actions: fill in input with some data, click Submit Offer and you&#39;ll see offer created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/0*URUtDKCZrEEcLyuH.png" /></figure><p>You can reload the page and see that everything is saved on the backend</p><h3>In conclusion</h3><p>Even though Javascript is really flexible language and you can write your own networking class, Swagger can still help you by managing some of the handy logic(e.g having operationId)</p><p>A large portion of the article was dedicated to React itself, mostly because Quarkus setup requires one additional extension, but it doesn’t mean that there’s nothing to modify, in the next article we gonna see how to manage security and authentication(JWT and basic) between Quarkus and React.</p><p><em>Originally published at </em><a href="https://quarkify.net/setting-up-swagger-with-quarkus-and-react/"><em>https://quarkify.net</em></a><em> on June 1, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a811c7ca5ace" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quarkify/setting-up-swagger-with-quarkus-and-react-a811c7ca5ace">Setting up Swagger with Quarkus and React</a> was originally published in <a href="https://medium.com/quarkify">Quarkify</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build, run and deploy React app with Quarkus]]></title>
            <link>https://medium.com/quarkify/build-run-and-deploy-react-app-with-quarkus-6cc4f6074d6?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cc4f6074d6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[quarkus]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Tue, 26 May 2020 14:53:34 GMT</pubDate>
            <atom:updated>2020-06-05T19:39:25.070Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YOJZ2jj4L49-_pDs.png" /></figure><p>If your project needs UI, React probably is a good option for any middle-size service. With Quarkus, it’s super easy to serve your React app.</p><p>This article covers:</p><ol><li>Setup node and dependencies required for React</li><li>Init basic React project</li><li>Configure React to serve from Quarkus</li><li>Build and watch React project from maven</li><li>Deploy minified React on maven package</li></ol><blockquote>For a better experience, go to Q<a href="https://quarkify.net/build-run-and-deploy-react-app-with-quarkus/">uarkify website</a></blockquote><h3>Initial setup</h3><p>In order to React with JSX and other features, we’ll need to install node, npm, and create-react-app. Feel free to skip this section if you already have it.</p><h4>Nodejs and npm</h4><p>Thank to Nodejs team, they finally made installers that you can use to install both nodejs and npm. Go to <a href="https://nodejs.org/en/download/">https://nodejs.org/en/download/</a> and download any of your.</p><h4>Macos and Windows</h4><p>For macOS and Windows just download the installer and click on it, this part is straightforward. This article doesn’t covers windows though, be ready that code in this article might need some modifications.</p><h4>Linux</h4><p>If you’re one of lucky Linux users, you won’t have such luxury as an installer, but it’s not harder then any other installation on this system. Luckily, great developers created cheatsheet on <a href="https://github.com/nodesource/distributions/blob/master/README.md">how to install any version of Node.js</a>. We gonna use the same 12 version.</p><pre>curl -sL <a href="https://deb.nodesource.com/setup_12.x">https://deb.nodesource.com/setup_12.x</a> | sudo -E bash - sudo apt-get install -y nodejs</pre><h4>create-react-app</h4><p>In our Vuejs article, we had to install additional global dependency to init the project. For react, we can use npx create-react-app to init the project.</p><h3>Init project</h3><p>We’re now ready to init our project. If you don’t have any Quarkus project to work with, use command below:</p><pre>mvn io.quarkus:quarkus-maven-plugin:1.4.1.Final:create \<br>     -DprojectGroupId=tech.donau.quarkify \<br>     -DprojectArtifactId=quarkus-react \<br>     -DclassName=&quot;tech.donau.quarkify.GreetingResource&quot; \<br>     -Dpath=&quot;/hello&quot;<br>cd quarkus-react</pre><p>Working example, as always, <a href="https://github.com/quarkifynet/quarkus-react">can be found on our github</a>.</p><h3>Init React app</h3><p>For location of our React app, we gonna use /src/main/webapp folder as a root folder. This is just helpful location to organize your sources neatly.</p><pre>mkdir src/main/webapp &amp;&amp; cd src/main/webapp/<br>npx create-react-app .</pre><p>This command will init the basic React project with initial structure and simple view.</p><p>Now you can run npm start and open <a href="http://localhost:3000/">http://localhost:3000</a>. You should see a familiar atom image. When finished, press Ctrl+C, because we&#39;re moving from atoms to quarks 🙂</p><h3>Serving from Quarkus</h3><p>Quarkus has dedicated folder that’s already prepared to serve static files, it’s src/main/resources/META-INF/resources. We only need to build or React project into this folder.</p><p>We can, of course, move them manually, but we have a good command that helps us put files automatically to the required folder.</p><p>Let’s open src/main/webapp/package.json and put one additional lines into scripts closure</p><pre>&quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;react-scripts start&quot;,<br>    &quot;build&quot;: &quot;react-scripts build&quot;,<br>    &quot;test&quot;: &quot;react-scripts test&quot;,<br>    &quot;eject&quot;: &quot;react-scripts eject&quot;,<strong><br>    &quot;prod&quot;: &quot;react-scripts build --dest &amp;&amp; mv build/* ../resources/META-INF/resources&quot;</strong><br>  },</pre><p>If you read <a href="https://quarkify.net/build-run-and-deploy-vuejs-app-with-quarkus/">our Vuejs guide</a>, you could notice that we don’t have a watch command. And that is because react-scripts doesn’t think that it’s a good way of doing it. In other words, either you serve or build a single time. If you really need it, have a look <a href="https://stackoverflow.com/a/42773333/4889035">at this answer</a>.</p><p>You can run npm run prod in a webapp folder and ./mvnw quarkus:dev afterwards, and you&#39;ll already see that Quarkus serves our static website.</p><h3>Install and build React project from maven</h3><p>Let’s use Maven to do all the node and npm installation boilerplate. Firstly, let’s make so when we checkout our project, maven will install NodeJs and build the project</p><pre>&lt;plugin&gt;<br>  &lt;groupId&gt;com.github.eirslett&lt;/groupId&gt;<br>  &lt;artifactId&gt;frontend-maven-plugin&lt;/artifactId&gt;<br>  &lt;version&gt;1.6&lt;/version&gt;<br>  &lt;configuration&gt;<br>    &lt;workingDirectory&gt;${project.basedir}/src/main/webapp&lt;/workingDirectory&gt;<br>    &lt;installDirectory&gt;target&lt;/installDirectory&gt;<br>  &lt;/configuration&gt;<br>  &lt;executions&gt;<br>    &lt;execution&gt;<br>      &lt;id&gt;install node and npm&lt;/id&gt;<br>      &lt;goals&gt;<br>        &lt;goal&gt;install-node-and-npm&lt;/goal&gt;<br>      &lt;/goals&gt;<br>      &lt;configuration&gt;<br>        &lt;nodeVersion&gt;v12.16.3&lt;/nodeVersion&gt;<br>        &lt;npmVersion&gt;6.14.4&lt;/npmVersion&gt;<br>      &lt;/configuration&gt;<br>    &lt;/execution&gt;<br>    &lt;execution&gt;<br>      &lt;id&gt;npm install&lt;/id&gt;<br>      &lt;goals&gt;<br>        &lt;goal&gt;npm&lt;/goal&gt;<br>      &lt;/goals&gt;<br>      &lt;configuration&gt;<br>        &lt;arguments&gt;install&lt;/arguments&gt;<br>      &lt;/configuration&gt;<br>    &lt;/execution&gt;<br>    &lt;execution&gt;<br>      &lt;id&gt;npm run build&lt;/id&gt;<br>      &lt;goals&gt;<br>        &lt;goal&gt;npm&lt;/goal&gt;<br>      &lt;/goals&gt;<br>      &lt;configuration&gt;<br>        &lt;arguments&gt;run prod&lt;/arguments&gt;<br>      &lt;/configuration&gt;<br>    &lt;/execution&gt;<br>  &lt;/executions&gt;<br>&lt;/plugin&gt;</pre><p>This plugin is not just a useless plugin that executes npm install and npm run build for you. It&#39;s not even close to this. As I&#39;ve said, it&#39;ll install the required version of Nodejs, run all the commands. This is executed on package time and anytime you package your app it will be there for you to ensure you have everything there up to date.</p><p>Here’s how bootstrap of a project looks on freshly new Ubuntu instance:</p><pre>sudo apt-get update<br>sudo apt-get install -y default-jre<br>git clone https://github.com/quarkifynet/quarkus-react.git<br>cd quarkus-react/<br>./mvnw clean package<br>java -jar ./target/quarkus-react-0.0.1-runner.jar</pre><h3>React development mode</h3><p>So what I do with React projects is that I run npm start in one terminal window, and ./mvnw quarkus:dev in second. <a href="https://quarkify.net/generate-quarkus-project-with-jhipster/">Jhipster with Quarkus</a> and React works the same way, so to speak.</p><p>Let’s modify our React page a little bit. Go to <a href="http://localhost:3000/">http://localhost:3000</a> and look at the initial page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HUcD4-jujpEaMkgs.png" /></figure><p>Open up webapp/src/App.js and replace bold text in your file to match next:</p><pre>import <em>React </em>from &#39;react&#39;;<br>import &#39;./App.css&#39;;<br><br>function <em>App</em>() {<br>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;header className=&quot;App-header&quot;&gt;<br>        <strong>&lt;img src=&quot;https://quarkify.net/wp-content/uploads/2020/05/quarkify_logo.png&quot; className=&quot;App-logo&quot; alt=&quot;logo&quot; /&gt;</strong><br>        &lt;p&gt;<br>          Edit &lt;code&gt;src/App.js&lt;/code&gt; and save to reload.<br>        &lt;/p&gt;<br>...</pre><p>Go back to browser, you’ll see instant change:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J6xxcd1eyK4UiphX.png" /></figure><p>In the next chapter of React with Quarkus, we’ll see how to communicate effectively with your frontend during the development phase, but if you decide to hack around the current setup, I suggest you add CORS property into application.properties file. This way your React app will be able to communicate from port 3000 to our Quarkus app on port 8080</p><pre>quarkus.http.cors=true</pre><h3>Serving React app from Quarkus</h3><p>Once you done development, just run ./mvnw clean package and you&#39;ll have ready jar with all the required static files.</p><pre>./mvnw clean package</pre><p>To check if it’s correct, you can execute next command and open <a href="http://localhost:8080/"><strong>http://localhost:8080</strong></a></p><pre>java -jar ./target/quarkus-react-0.0.1-runner.jar</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Sm-QtSolVfoePGmV.png" /></figure><p>And, as expected, you’ll see updated React page served from 8080 port.</p><h3>In conclusion</h3><p>You now know how easy it is to build the React app and serve it from the Quarkus application. There’s more to learn. The next step is to connect our React application with Quarkus API, without writing fetch logic for each of the requests. This is the topic for the next article 🙂</p><p><em>Originally published at </em><a href="https://quarkify.net/build-run-and-deploy-react-app-with-quarkus/"><em>https://quarkify.net</em></a><em> on May 26, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cc4f6074d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quarkify/build-run-and-deploy-react-app-with-quarkus-6cc4f6074d6">Build, run and deploy React app with Quarkus</a> was originally published in <a href="https://medium.com/quarkify">Quarkify</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generate Quarkus project with JHipster]]></title>
            <link>https://medium.com/quarkify/generate-quarkus-project-with-jhipster-bff4edecb815?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/bff4edecb815</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[jhipster]]></category>
            <category><![CDATA[quarkus]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Fri, 22 May 2020 16:23:28 GMT</pubDate>
            <atom:updated>2020-05-28T12:16:28.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BienaTsA5iOtEMqi.png" /></figure><p>For a long time, JHipster used Spring for all the backend logic, once I started to work with Quarkus I always thought how it could be great to have a way to generate Quarkus project with Jhipster. And we finally have it!</p><p>In this article, I’ll show you how to generate a new JHipster Quarkus project with angular frontend and complex entity logic with relationships, pagination, and security in just a few minutes. I’ll also guide you through the project structure.</p><blockquote>This article also available on <a href="https://quarkify.net/generate-quarkus-project-with-jhipster/">Quarkify website</a></blockquote><h3>Installing Quarkus blueprint</h3><p>First of all, we need to install Jhipster’s Quarkus blueprint, it can be done really easy with the next command</p><pre>npm install -g generator-jhipster-quarkus</pre><p>This will install required blueprint that we can use later, keep in mind that this project is in active development and you might need to update once the new version is out, you can do it by using the update command.</p><pre>npm update -g generator-jhipster-quarkus</pre><h4>In case you don’t have JHipster</h4><p>If you never used or installed jhipster itself, do it by next command:</p><pre>npm install -g generator-jhipster</pre><h3>Generate Jhipster project</h3><p>Everything else is super easy, as in any other Jhipster project</p><pre>jhipster --blueprints quarkus</pre><p>This will show you many info messages, like in a screen below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5706tYluSer9T6vW.png" /></figure><p>At the end of all those messages, you’ll be prompted to fill in some information(gray means default value):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lDLYFoL2ER3tclpM.png" /></figure><p>I’ll use quarkify_jhipster as a name of a project, next, you&#39;ll be prompted to fill in the package name, I use net.quarkify.jhipster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/0*ZWfnCD1Ivm8FEqtE.png" /></figure><p>After that, specify the <strong>production</strong> database type, as of now we have either SQL or none, let’s use SQL. For database type, let’s use PostgreSQL(Choose whatever you like)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PHgggejuemHpkFH4.png" /></figure><p>And for <strong>development</strong> database, which you should specify next, let’s use H2 with disk-based persistency. You can select in-memory one as well</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xFzQgckrU6FONBzE.png" /></figure><p>Next, the most interesting part, you need to choose the frontend framework, I’ll choose Angular.</p><p><strong>As of this article, I was having issues with React</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YHXt3uiRJPcEqSHF.png" /></figure><p>If you want to change your bootstrap theme, you can choose any of the next prompted themes, I chose darkly with primary navbar theme</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wnLy6QpSfuIkcDSc.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/0*E0LYzaK-MEhUHOVx.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/0*gEBlk5qwMdjZCOg8.png" /></figure><p>Next, select whether you want to have internationalization or not, put Y if you want or n if not. In this example, we won&#39;t use it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VGEaEazlfqNuRvH0.png" /></figure><p>That’s it, now Jhipster will generate and install all the required dependencies.</p><h3>Running the app</h3><p>You can verify if it’s running or not by executing ./mvnw command.</p><p>This will build frontend, and serve both frontend and backend, you can go to http://localhost:8080 and see result</p><h4>Frontend development environment</h4><p>If you plan to do any changes to frontend or will use JDL import(next section), you’ll need to either rebuild frontend or run development server.</p><p>To start development server, simply run npm start in a root folder. you can then go to http://localhost:9000, this will automaticall update and refresh page once you do any changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HfrIJx-QqDkBWtvM.png" /></figure><p>To build a static website, that will be later served from Quarkus, run ./mvnw clean compile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*bExf95kedo1gzzCm.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GXjfYCmMk3yBXsEH.png" /></figure><p>Go to account at the top, and put admin as a user and admin as a password, after that, you&#39;ll have all the features of an administrator. Keep in mind that some of the features might not work.</p><h3>Using JML to generate logic</h3><p>JHipster won’t be a JHipster, if you couldn’t use JDL.</p><p>JDL, or <a href="https://www.jhipster.tech/jdl/">JHipster Domain Language</a>, is a domain language with which you can describe entities and relationships between them. This will save hours of your development time if done correctly. Let’s create one JDL schema.</p><p>Firstly, go to <a href="https://gist.github.com/dmi3coder/a0cca9e0f7e276dbd29be8ad252b7e68">this gist</a> and copy schema from there. This is really great example for all the features JHipster provides.</p><p>Create schema.jh in root of your project and put copied data from the gist. Execute next command below and Jhipster will make everything else for you</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*hcYNmWhHOLLX9sLu.png" /></figure><pre>jhipster --blueprints quarkus import-jdl schema.jh</pre><p>If you’ll be prompted with conflict, just put a and hit enter. As we created a new empty application, we don&#39;t care about any conflicts. But you should keep in mind that you might need to check the difference in your later versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/0*swuAZIO2mdFh-ro0.png" /></figure><h4>Verify jdl-import result</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ppLSLBWHfdDa2_Ch.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YeRF6yuSrrTFbms3.png" /></figure><p>Execute ./mvnw clean compile and after that use ./mvnw to start the server. Once it&#39;s ready, you can open Entities and observe all of the new logic, select Job</p><p>You’ll see paginated list of entities. You can also click on Add new Job</p><p>As you can see, form already shows you available tasks because you have a relationship from job to task. same thing goes with Employee.</p><p>Not sure about you, but I see tons of saved hours. JHipster gives you ability to mix generated and custom code, this way you can generate simple logic at start and after that start working on really important logic that will require hours of work.</p><h3>Generated project structure</h3><p>I think it might be really helpful to know how JHipster project is sturctured. It might be good to generate some code, but it will be useless unless you won’t be able to modify it for your needs.</p><h3>pom.xml</h3><ul><li>/config - package contains constants, jsonb configuration, as well as properties for security and mail</li><li>/domain - this package contains all the (what a surprise) domain logic, mostly Entities to database and enums</li><li>/security - Here you can find everything related to security. If you read our article about <a href="https://quarkify.net/simple-jwt-token-authentication-with-quarkus/">jwt security</a>. You&#39;ll find it very familiar</li><li>/service - this package, as expected, holds all the service logic. Services are really nicely made as a interfaces, and implementation of them can be found in /service/impl. Besides that, you can find dto and mapper packages, they help to serialize and deserialize data from entity to transfer object.</li><li>/web/rest - contains all the resources.</li></ul><p>I won’t go in details for this file, but you have original quarkus pom.xml setup with large amount of plugins, that help to build frontend, test and more. From quarkus dependencies, you have undertow, resteasy with jsonb, mailer, hibernate with panache and validator, some jdbc dependencies, elytron-security and smallrye-jwt</p><h3>/java</h3><ol><li>/config/liquibase is a folder that contains all the migrations. Migrations are also managed by JHipster for any JDL changes, buy you can add your own migrations without any issue</li><li>/jwt/privateKey.pem and /META-INF/resources/publicKey.pem is, again, security keys that are used to generate and read JWT tokens, as I described in <a href="https://quarkify.net/simple-jwt-token-authentication-with-quarkus/">jwt auth article</a>.</li><li>/mail/templates contains email templates in case you&#39;ll use mailing</li></ol><p>This is probably the most interesting part. JHipster splits logic into such folders:</p><h3>/resources</h3><p>Here you can find two really interesting things:</p><p>Good word to say is that application.properties are also preconfigured for you.</p><h3>/webapp</h3><p>This is “root” folder four frontend application, either it’s React or Angular, they both use TypeScript. I won’t go into details here because we’re mostly interested in backend part</p><h3>/docker</h3><p>Here you can find more than just few dockerfiles. You have, additionaly, docker-compose files for different scenarios, such as just postgresql, for monitoring and even sonarqube</p><h3>In conclusion</h3><p>I used JHipster previously, and it’s such a pleasure to see the ability to generate Quarkus app. If you won’t use it you might just read the code because it contains many good patterns that can be used later in the development of any project.</p><p>Again, it’s not a complete solution but rather a good template that can help you bootstrap your project. You still need to do changes.</p><p><em>Originally published at </em><a href="https://quarkify.net/generate-quarkus-project-with-jhipster/"><em>https://quarkify.net</em></a><em> on May 22, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bff4edecb815" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quarkify/generate-quarkus-project-with-jhipster-bff4edecb815">Generate Quarkus project with JHipster</a> was originally published in <a href="https://medium.com/quarkify">Quarkify</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple JWT Token authentication with Quarkus]]></title>
            <link>https://medium.com/quarkify/simple-jwt-token-authentication-with-quarkus-893944f435cf?source=rss-60ac21763a01------2</link>
            <guid isPermaLink="false">https://medium.com/p/893944f435cf</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[quarkus]]></category>
            <dc:creator><![CDATA[Dmytro Chaban]]></dc:creator>
            <pubDate>Tue, 12 May 2020 14:51:12 GMT</pubDate>
            <atom:updated>2020-05-22T17:57:08.271Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*olhil4sLEVQm79_n.png" /></figure><p>Every significant app will have security. And you probably opened this article because you’re looking for some simple yet durable solution. What can be simpler yet good enough as JWT Token authorization? Official Quarkus website already <a href="https://quarkus.io/guides/security-jwt">covered this topic</a>, but I’ll show the most popular use-case for it, that is, generation of the token when the user logs in. I’ll show you a more abstract solution that you can plug-in to any app and generate a token with a single line of code in your /login method.</p><p>I also covered this topic at my <a href="https://www.udemy.com/course/quarkus-backend-development-java/?referralCode=0888EC1DEECC26F3234C">Quarkus course in Security section</a>. This articles basically repeats same lesson with additional simplicity</p><h3>User flow</h3><p>We’ll take the most usual use case: Users open your app, users register, then they do log in, receive the token, and after that use your app as they please.</p><h3>Initial setup</h3><p>You can init empty project from scratch by using next command:</p><pre>mvn io.quarkus:quarkus-maven-plugin:1.4.2.Final:create \<br>    -DprojectGroupId=tech.donau.quarkify \<br>    -DprojectArtifactId=jwt-auth \<br>    -DclassName=&quot;tech.donau.quarkify.ExampleResource&quot; \<br>    -Dpath=&quot;/hello&quot; \<br>    -Dextensions=&quot;resteasy-jsonb, jwt, jdbc-h2, hibernate-orm-panache&quot;</pre><p>Or, if you already have some project, you can add next dependencies into pom.xml</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;io.quarkus&lt;/groupId&gt;<br>  &lt;artifactId&gt;quarkus-resteasy-jsonb&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;io.quarkus&lt;/groupId&gt;<br>  &lt;artifactId&gt;quarkus-smallrye-jwt&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;io.quarkus&lt;/groupId&gt;<br>  &lt;artifactId&gt;quarkus-jdbc-h2&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;io.quarkus&lt;/groupId&gt;<br>  &lt;artifactId&gt;quarkus-hibernate-orm-panache&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>Complete working solution, as always, available at our <a href="https://github.com/quarkifynet/quarkus-jwt-auth">github</a>.</p><h3>Static classes</h3><p>Let’s start by adding TokenUtils class, it&#39;s independent so you can include it into any project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1bb1c6b7050af742373c9fabea4b5b8a/href">https://medium.com/media/1bb1c6b7050af742373c9fabea4b5b8a/href</a></iframe><p>You’re only interested in generateTokenString method. This method will be executed by our future TokenService. You can trace what it&#39;s doing, but basically, from an abstraction point of view, this method will encode our JwtClaims object, sign it with a private key that we will generate in next steps(one command line), and return to us it back as a string that we can pass to the user.</p><p>Other methods can be handy for some specific use-case, we won’t touch them in this article.</p><h3>Token service</h3><p>Now, once we have prepared class that will handle all underlying logic, we can create service that will be used by our services and resources.</p><p>JWT embeds idea that every user has role. You can, for example, have user, service and admin roles. Users are basic users of your app, they only have access to user endpoints. We can say that services are bots or applications that have access to limited amount of endpoints. One example can be that service can only upload data, it can’t read or delete it. And admin, of course, is god, he has access to such endpoints that are not available to simple users.</p><p>Let’s create a static class with constants for them. This will help you in future if you accidentally will put user instead of User for some endpoint and all the users won&#39;t have the ability to execute this endpoint.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cf53534ea94dc492ed3bf7e2e75fa9e/href">https://medium.com/media/7cf53534ea94dc492ed3bf7e2e75fa9e/href</a></iframe><p>And now, let’s create final class, which we’ll use to generate token</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a935bf65b9301af3fd4d3538940b1f9a/href">https://medium.com/media/a935bf65b9301af3fd4d3538940b1f9a/href</a></iframe><p>You can see that we have generateUserToken() method that calls generateToken(). The last method executes our TokenUtils.generateTokenString() method, which returns the token.</p><h3>Private and Public keys</h3><p>In order to JWT to work, we need to sign it with private key. Without this step anybody can just pass fake data to our Quarkus app, and it will think that it’s valid credentials. This way anybody can use admin endpoints, for example. Luckly get private and public key is super easy:</p><pre>openssl genrsa -out publicKey.pem<br>openssl pkcs8 -topk8 -inform PEM -in publicKey.pem -out privateKey.pem -nocrypt<br>openssl rsa -in publicKey.pem -pubout -outform PEM -out publicKey.pem</pre><p>This will create two files, which you can move into src/resources folder. Beware that if you loose this files, users that already generated tokens will be declined in authentication. I would suggest to keep them somewhere safe. Don&#39;t share them with anyone as well.</p><h3>Enable JWT Security</h3><p>When you moved publicKey.pem and privateKey.pem into src/resources, TokenService will be already usable, but we also need to pass some application properties in order for Quarkus to know where to look for our publicKey.pem. Put next data into application.properties</p><pre>quarkus.smallrye-jwt.enabled=true<br>mp.jwt.verify.publickey.location=publicKey.pem<br>mp.jwt.verify.issuer=DonauTech</pre><h3>Adding persistency</h3><p>Let’s add User object for our whole article to be usable. I&#39;ll use h2 database with Hibernate and Panache to make it as small as possible.</p><p>Firstly, let’s create User, as in next example. Keep in mind that it&#39;s super simple example, even without password encryption, this is not a production solution 🙂</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67e852f8b9f685d0082a6868c7642624/href">https://medium.com/media/67e852f8b9f685d0082a6868c7642624/href</a></iframe><p>Let’s also add some more parameters into application.properties</p><pre>quarkus.datasource.url=jdbc:h2:file:./test quarkus.datasource.driver=org.h2.Driver quarkus.datasource.username=test quarkus.datasource.password=test quarkus.hibernate-orm.database.generation=update quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect</pre><p>This is a super simple file database. It’ll be located at target/test.db. We use update, which will update schema without deletion of it on restart</p><h3>Registration and login</h3><p>We now ready to finally do registration and login. Ideally, we can have UserService, but for this example I just put everything into UserResource</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/662e8758999518e5b2bdb162ecc48159/href">https://medium.com/media/662e8758999518e5b2bdb162ecc48159/href</a></iframe><p>There’s nothing special here.</p><p>1. We have /register method that just persists the user itself into the database. <br>2. We have /login method that checks if data is correct, and after that generates a token back to user. Here&#39;s a homework for you: make it return a {&quot;token&quot;: data} structure so it&#39;s easy to use from javascript.</p><h3>Secure regular endpoints</h3><p>Security is not a security if it secures nothing. Let’s create few endpoints to test our token. We already have ExampleResource, let&#39;s expand it a little bit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9aa5842cd1aac36e9966088cfb037bb0/href">https://medium.com/media/9aa5842cd1aac36e9966088cfb037bb0/href</a></iframe><p>Let’s go one method at a time:</p><ol><li>String hello() method is just a default method with @PermitAll annotation. This annotation says that anyone can access this endpoint. Removing it won&#39;t change behavior in JWT case.</li><li>User me() can only be executed by either User or Service, as @RolesAllowed({Roles.USER, Roles.SERVICE}) says.</li><li>String adminTest() can only be executed by Admin. If you try to call it with a User you&#39;ll get 403 Unauthenticated response.</li><li>String nothing() won&#39;t be accessible by anyone.</li></ol><h3>Test time</h3><p>Now it’s time to do full test cycle and see how it’ll work. I’ll use curl commands with postman screenshots.</p><pre>curl --location --request POST &#39;http://localhost:8080/users/register&#39; \<br>--header &#39;Content-Type: application/json&#39; \<br>--data-raw &#39;{<br>	&quot;login&quot;: &quot;testuser&quot;,<br>	&quot;email&quot;: &quot;testuser@gmail.com&quot;,<br>	&quot;password&quot;: &quot;testtest&quot;<br>}&#39;</pre><p>This will return same result, but you’ll also have your id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*Ic4QRAdLbpcOhwDZ.png" /></figure><p>Now let’s log into our application by getting JWT token that we can later use in any other endpoint</p><pre>curl --location --request GET &#39;http://localhost:8080/users/login?login=testuser&amp;password=testtest&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*3zhLKDcBQ2Qa3zXG.png" /></figure><p>Let’s try to execute /hello without any token, it should work</p><pre>curl --location --request GET &#39;http://localhost:8080/hello/&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*eAAZrbJ1oeRnVQLM.png" /></figure><p>Now, put our token into header so that key is Authorization and value is Bearer $token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*m7amkmQfXlnwKuI9.png" /></figure><p>Now we can execute /hello/me endpoint, you should see user object in output</p><pre>curl --location --request GET &#39;http://localhost:8080/hello/me&#39; \<br>--header &#39;Authorization: Bearer $YOURTOKEN&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/0*cay94E7XAqRkEVVV.png" /></figure><p>You can see drawback of storing password as a plain text here. Ideally you shouldn’t return password at all.</p><p>Let’s try to execute /hello/admin endpoint</p><pre>curl --location --request GET &#39;http://localhost:8080/hello/admin&#39; \<br>--header &#39;Authorization: Bearer $YOURTOKEN&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*E8_CPpKaF2DC4d3Y.png" /></figure><p>As expected, simple user won’t be able to access admin endpoints. Try generating admin token yourself and executing this endpoint</p><p>And last endpoint, /hello/void, which won&#39;t work for anyone.</p><pre>curl --location --request GET &#39;http://localhost:8080/hello/void&#39; \<br>--header &#39;Authorization: Bearer $YOURTOKEN&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*40XYa-Py9kRopLZ4.png" /></figure><h3>In conclusion</h3><p>Now you know embeddable security solution that you can re-use in any project. Of course, there are many other options and this JWT auth doesn’t fit all. But for starters and simple projects, this solution can be really easy, without adding extra services just to handle the basic flow.</p><p><em>Originally published at </em><a href="https://quarkify.net/simple-jwt-token-authentication-with-quarkus/"><em>https://quarkify.net</em></a><em> on May 12, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=893944f435cf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quarkify/simple-jwt-token-authentication-with-quarkus-893944f435cf">Simple JWT Token authentication with Quarkus</a> was originally published in <a href="https://medium.com/quarkify">Quarkify</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>