<?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 Saritasa on Medium]]></title>
        <description><![CDATA[Stories by Saritasa on Medium]]></description>
        <link>https://medium.com/@saritasa?source=rss-20ff800a666f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Mi5z0BRUWM7LlKOroFxVqA.png</url>
            <title>Stories by Saritasa on Medium</title>
            <link>https://medium.com/@saritasa?source=rss-20ff800a666f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:42:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saritasa/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[I Was Right About OpenClaw (Testing AGENTS.md, Lobster, and Python for Workflows)]]></title>
            <link>https://medium.com/@saritasa/i-was-right-about-openclaw-testing-agents-md-lobster-and-python-for-workflows-4080b91379da?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4080b91379da</guid>
            <category><![CDATA[lobster]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[openclaw]]></category>
            <category><![CDATA[ai-orchestration]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 08 Oct 2026 17:48:36 GMT</pubDate>
            <atom:updated>2026-10-08T17:48:36.522Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*fIPxKHi-Zn5Obj-7oE01dA.png" /></figure><p>Written by <a href="https://www.linkedin.com/in/antonzimin-us/">Anton Zimin</a>, Development Manager at <a href="https://www.saritasa.com/artificial-intelligence-development">Saritasa</a></p><p>When <a href="https://openclaw.ai/">OpenClaw</a> exploded in popularity, I was skeptical. I viewed it as a toy designed to empower non-technical users to burn agentic API tokens at breakneck speed. As it turns out, I was right.</p><p>The project was originally named ClawdBot, then renamed to MoltBot, and finally settled on OpenClaw. It allows enthusiasts to set up local agents with memory, skills, and sub-agents.</p><p>OpenClaw uses a main agent to execute commands, communicate with the owner, find skills, and execute them. You can install a local LLM if your hardware is powerful enough. Alternatively, you’ll need to buy API tokens from third-party providers. It’s not possible to use a subscription plan (such as Claude Pro) due to licensing limitations. Some people overcame these limitations by cloning OAuth tokens, but they were later banned.</p><p>I believed that OpenClaw supported probabilistic AI orchestration, but Copilot convinced me that it can run workflow steps directly without using an LLM. Copilot stated that I can create an OpenClaw workflow “with zero LLM calls”. ChatGPT confirmed that and mentioned the “brilliant deterministic engine” that was recently introduced in OpenClaw — <a href="https://docs.openclaw.ai/tools/lobster">Lobster</a>. I decided to try it for a simple task.</p><h3>The Automation Experiment: Building a Gmail-to-Trello Workflow</h3><p>I wanted to create a “simple” workflow to download unread emails with the tag “OpenClaw” from Gmail. For every email, it should create a card on a Trello board and change the priority to high if the email contains certain keywords. I used three different approaches to solve this problem.</p><p>To get started, I installed OpenClaw, connected it to Anthropic Claude and Discord. Then I used Claude Code to generate the necessary code.</p><h3>Approach 1: Testing AGENTS.md for OpenClaw Workflow Execution</h3><p>I started with a simple prompt to create a cron job in OpenClaw:</p><blockquote>Implement an OpenClaw workflow:</blockquote><blockquote>Download fresh emails from Gmail with the tag OpenClaw</blockquote><blockquote>Create a new card in Trello for every email</blockquote><blockquote>If the email body contains words URGENT, IMPORTANT:<br> — Set the priority in Trello to High</blockquote><blockquote>Implement an OpenClaw automation:<br>Run the workflow every 5 minutes.</blockquote><p>The AGENTS.md file was updated manually using the <a href="https://github.com/AntonZiminSaritasa/openclaw-test/blob/main/agents/AGENTS.md">generated flow</a>.</p><p>OpenClaw tried to execute the workflow, but failed because I didn’t have the necessary skills configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*FZLiz5XsNPGgw7_Nd_qh7A.png" /></figure><p>Claude suggested installing the <strong>@mcinteerj/openclaw-gmail</strong> skill. It did not work because OpenClaw does not support TypeScript plugins as of 5/1/2026. A plugin that worked in January <a href="https://github.com/mcinteerj/openclaw-gmail/issues/7">does not work</a> in May. There is a built-in skill <strong>Himalaya</strong>, but I did not try it because it seems optimized for IMAP, and Google no longer supports personal access tokens (PAT). Instead, I installed the <a href="https://gogcli.sh/">gog CLI tool</a> (a command-line interface for Gmail and other Google services) and generated a token using OAuth.</p><p>I configured gog, Trello, and adjusted AGENTS.md several times. Finally, it worked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wMVPoYF-aDBofIUmboldjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*eb57cZIBYimxYU3gtd7dUg.png" /></figure><p>However, it does not handle gog output correctly. The workflow fails if I have zero unread emails:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*0kmyDbdmmr-ixNxsAIJxcg.png" /></figure><h4>OpenClaw Token Costs: How Expensive Is Agentic Execution?</h4><p>Large language models operate with tokens, aka digital representations of text. 100 English words is about 75 tokens. Big reasoning models are more expensive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*30ZburJLDiyg_R-c6k5gJQ.png" /></figure><p>One execution of a workflow without downloading any emails (37700 tokens) costs ~$0.13 with Opus 4.7 or $0.03 with Haiku 4.5. A workflow that downloads 6 emails and creates 6 Trello cards costs $0.25 with Opus or $0.04 with Haiku.</p><p>If I receive 6 emails per day but run the job every 5 minutes, it will cost over ~$1127 per month with Opus or $260 with Haiku.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*enrqLR2z7kqyEOfAmCJExw.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2F6uzi6%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2F6uzi6%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2F6uzi6%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="501" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0c26b95a5c09521ef408b34aface9de/href">https://medium.com/media/c0c26b95a5c09521ef408b34aface9de/href</a></iframe><p>The agent consumes tokens not only for your prompt and output, but also for system instructions, thinking, and skills. All active skills are concatenated and sent to the LLM. The installation of a new skill makes your agent more expensive. It also depends on the data. In my case, large emails are more expensive to process than small ones.</p><h4>Model Selection: Claude, GPT, Gemini, and Local Models</h4><p>For my agent, Opus 4.7 worked well, but it was very expensive. After spending $2 on several runs, I switched to Sonnet 4.7 and then to Haiku 4.5. It also worked, but OpenClaw discourages small models because they make the system less secure due to prompt injection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*PzkmpJN4W7xXe36aInwBWw.png" /></figure><p>I also tried local models, but my choice was limited. Because my VM did not support GPU passthrough, I had access only to CPU-bound models. I installed <a href="https://ollama.com/">Ollama</a> and tested “qwen2.5:3b” and “gemma4:e2b” models. For some reason, Qwen was not able to execute my workflow. Gemma tried, but failed to identify and execute any tool:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*BNAC16zaWFVVbmLnZAxy9g.png" /></figure><h4>Security &amp; Malware Risks in OpenClaw Skill Repositories</h4><p>AI agents use “skills” to execute actions. A skill is a Markdown text file with instructions, descriptions of console commands, and web requests. Users download skills from an online repository or find them on random websites. There are free skills available in the <a href="https://clawhub.ai/">ClawHub</a> repository, but many of them are <a href="https://thehackernews.com/2026/02/researchers-find-341-malicious-clawhub.html">malware</a>. An author of a skill can easily add malicious code and publish a new version. For example, the <a href="https://www.reddit.com/r/automation/comments/1r30pmp/that_spotify_skill_on_clawhub_yeah_it_was_trying/">Spotify Music Management</a> skill was used to steal personal information.</p><p>That’s why I installed OpenClaw inside a virtual machine without access to my data. I used some skills, but I’m not confident that they are completely safe.</p><p>The SkillDB project allows an agent to find and <a href="https://skilldb.dev/docs#how-agents-discover">download skills automatically</a>. I suppose this feature was created for people who love risk. Additionally, OpenClaw can create its own skills. You can describe an idea and let the agent go wild, generate, and execute random code on your PC.</p><p>Finally, your input data can contain prompt injections, which are regular text formatted in a way to hijack your AI agent. It means that somebody can send you an email that will order your agent to execute malicious code. Prompt injections can be included in <a href="https://www.ccn.com/news/crypto/ai-agent-drained-for-200k-with-this-one-tweet-hack-heres-how/">tweets on X</a> or published on websites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*mJIu3rweuDFuHtW52Dx6cQ.png" /></figure><h3>Approach 2: Testing Lobster for Deterministic AI Orchestration</h3><p>Originally, OpenClaw had only one orchestration engine. Later, the author implemented Lobster in an attempt to fight the probabilistic nature of LLMs. Lobster enforces the correct order of execution, preventing the model from hallucinating or generating arbitrary steps.</p><p>According to the OpenClaw docs, Lobster should be a first-class citizen plugin. I just need to turn it on in the config file. In my experience, it still requires the global <strong>lobster </strong>tool to be installed.</p><pre>npm install -g @clawdbot/lobster</pre><p>While debugging the tool, I installed the “lobster” skill from ClawHub. It did not work, but it was a dangerous operation because it’s a third-party skill, not affiliated with OpenClaw.</p><p>I decided to use the YAML workflow format and asked chatbots to generate it for me.</p><p>Copilot generated:</p><pre>- id: create_trello_card<br>    use: trello.create_card<br>    args:<br>      board_id: &quot;YOUR_TRELLO_BOARD_ID&quot;<br>      list_id: &quot;YOUR_TRELLO_LIST_ID&quot;<br>      name: &quot;{{ get_email.subject }}&quot;<br>      desc: &quot;{{ get_email.snippet }}&quot;</pre><p>Claude generated:</p><pre>- id: create_cards<br>    skill: trello<br>    prompt: |<br>      For each email in the input JSON, create a Trello card in list $trello_list_id<br>      with the email subject as the title and the email body as the description.<br>      Return JSON mapping each email message_id to the created card id.<br>    stdin: $search.json</pre><p>Neither of these versions is correct. This is because the LLMs did not have enough training data about the technology. I shared the documentation with Claude, but it did not help. Lobster’s documentation is pretty short and lacks examples for many features. The only way to learn how to create a correct workflow was to look in the <a href="https://github.com/openclaw/lobster">repository</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*LzdBYkV6Qc8pLQ6E6IVhyw.png" /></figure><p>I spent some time modifying the workflow and then decided to run it in OpenClaw. Suddenly, I realized that my YAML file was modified. Detecting an incorrect syntax layout, the LLM autonomously decided to “fix” it without authorization. The model was thinking:</p><blockquote>Actually, looking at this more carefully, I realize that the Lobster workflow syntax might not support complex node scripts like that. Let me check what the actual gog commands are and simplify this. Also, I should check if there’s already a proper workflow implementation somewhere or if this needs to be done differently.\n\nLet me try a simpler approach that uses the gog CLI directly and processes the output more carefully.</blockquote><p>The model wiped my custom workflow, entirely replaced it with its own generated code, and immediately executed it on my host environment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*sqZo4yfUME0O7TUXHEod0A.png" /></figure><p>I used the generated pipeline and fixed its bugs. It was hard to debug because the Lobster tool does not output stdout or stderr. The code looks bloated because it’s a shell script that generates a JavaScript file and executes it with Node.js. The env section did not inject environment variables correctly. I suppose it works only inside OpenClaw.</p><p>Final YAML: <a href="https://github.com/AntonZiminSaritasa/openclaw-test/blob/main/lobster/email-workflow.lobster">email-workflow.lobster</a></p><p>How to run it:</p><pre>set -a &amp;&amp; source ~/.openclaw/.env &amp;&amp; set +a<br><br>lobster run ~/.openclaw/workspace/workflows/email-workflow.lobster</pre><p>While the standalone Lobster CLI engine executes local files with zero LLM calls, invoking it through the OpenClaw agent ecosystem still consumes system prompt tokens to trigger the initial execution command. It was painful to create the script, and it looks redundant.</p><p>If you ask OpenClaw to run the workflow, your main agent will use some LLM tokens to run the command, but it will not control the steps.</p><h3>Approach 3: Building a Deterministic Baseline with Python</h3><p>It’s easy to use chatbots to automate routine tasks using Python or another scripting language.</p><p>This <a href="https://github.com/AntonZiminSaritasa/openclaw-test/blob/main/python/email_workflow.py">script</a> was generated by Claude Code on the first attempt. It’s not a perfectly isolated baseline because most of the code was derived from the JavaScript snippets in the Lobster workflow. However, it highlighted how easily traditional code generation can bypass complex agent architectures.</p><p>The code is clean, easy to extend, and easy to debug. It relies entirely on the Python standard library, with no external <strong>pip</strong> dependencies, and requires only a local installation of Python 3 and the <strong>gog CLI</strong> tool.</p><p>The reader might argue that the whole purpose of OpenClaw is to use an LLM agent to process text and execute skills, but you can call any LLM easily from Python.</p><h3>Comparison Summary: AGENTS.md vs Lobster vs Python Scripting</h3><p>For me, a simple script is the ultimate winner. Even if you don’t understand the code, it has one important advantage — it works the same way every time.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FJRsXC%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FJRsXC%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FJRsXC%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/32a74454393e8098ecdd1cbbe8b34649/href">https://medium.com/media/32a74454393e8098ecdd1cbbe8b34649/href</a></iframe><h3>Final Verdict: Do You Really Need an AI Agent Framework Like OpenClaw?</h3><p>Microsoft Copilot hallucinated. OpenClaw does not have zero-token orchestration.</p><p>If you orchestrate hundreds of agents using OpenClaw, you don’t need my advice. Keep tracking your token usage, optimize prompts, remove redundant text from output, and use smaller models if applicable.</p><p>If you are an AI enthusiast with development experience, look for a solution that doesn’t use LLMs yet delivers high reliability. A simple Python script could solve a problem. An LLM API call can easily be integrated there. Run OpenClaw in a secure Docker container or an isolated VM. Use local models or look for reliable resellers who will not steal your data.</p><p>If you are a non-technical person who wants to automate daily routines, you probably don’t need OpenClaw. It’s easier and cheaper to buy a subscription and use Claude Workspace, ChatGPT Workspace, n8n, Zapier, or another commercial solution.</p><p>There is a new trend among AI evangelists called tokenmaxxing. They brag about how many tokens they spent. It’s encouraged to burn thousands of dollars backed by enterprise budgets. Peter Steinberger, the creator of OpenClaw and an OpenAI employee, recently showed a dashboard showing <a href="https://www.businessinsider.com/openclaw-peter-steinberger-ai-token-bill-2026-5">$1.3 million in tokens</a> consumed in just 30 days. I’m sure the agents generated incredible code, <a href="https://github.com/openclaw/lobster/commit/bddb44c0bbd9f0ce92ed05a3c1c0dbdd5c1a6665">like this</a>. Top-tier AI providers are the only ones truly winning when developers deploy armies of agents to burn API tokens 24/7.</p><p>If you don’t have a goal to spend money on activities that can be free, maybe you don’t need OpenClaw. Many operations can be automated using a simple script or a no-code workflow. If necessary, add an atomic request to an LLM. If you really need an LLM to think, research, make decisions, call tools and skills, then it’s time to use an agent.</p><p>Repository: <a href="https://github.com/AntonZiminSaritasa/openclaw-test/">AntonZiminSaritasa/openclaw-test</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4080b91379da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI/CD for Unity Projects: Automated Versioning, Builds, and Deployment]]></title>
            <link>https://medium.com/@saritasa/ci-cd-for-unity-projects-automated-versioning-builds-and-deployment-2d75a5b3202a?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d75a5b3202a</guid>
            <category><![CDATA[cross-platform]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[semantic-versioning]]></category>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 17:29:10 GMT</pubDate>
            <atom:updated>2026-09-10T17:29:10.622Z</atom:updated>
            <content:encoded><![CDATA[<p>How we automated semantic versioning, multi-platform builds, and deployment in Unity using GitVersion, Unity Cloud Build, and custom scripts.</p><h3>The Challenge of Unity Cross-Platform Builds</h3><p>Unity is a cross-platform engine that is popular for building both 2D and 3D interactive experiences, including video games and simulations. To prepare a build for each platform, whether it’s web, mobile, VR, or something else, you need to change the project settings, calculate and specify the build version, build the build, and deploy it to the appropriate platform. This can be time-consuming for the developer and is also prone to human error.</p><p>Therefore, we’ve developed our own tools that allow you to build and deploy applications for different platforms with just one click.</p><h3>Automated Semantic Versioning for Unity with GitVersion</h3><p>Why do we need an application version?</p><p>1) To distinguish one build from another;</p><p>2) To write additional metadata to the build version;</p><p><strong>Furthermore, there are requirements for the application version:</strong></p><ul><li>The version must be unique and apply only to one build.</li><li>It must store metadata: which branch the version was built from and what commit it was in.</li><li>It must be readable and understandable.</li></ul><h3>Our Solution: Semantic Versioning and GitVersion Integration</h3><p>We decided to use <a href="https://semver.org/">semantic versioning</a> as a basis.</p><p>We use <strong>GitVersion</strong> to generate and calculate versions.</p><p><strong>GitVersion </strong>is an automatic version number calculation tool based on Git commit history. It calculates the version according to specific semantic versioning rules.</p><p>The application version depends on the current state of the repository — what branches and tags are present, as well as the active HEAD pointer.</p><p><strong>GitVersion </strong>produces the following <strong>JSON </strong>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*6c2RDG6CydFVbwlgA1uucg.png" /></figure><p>It contains lots of information about the current version of the project, such as the current branch, commit date, and, most importantly, the version number. We’re interested in <strong>FullSemVer</strong>, which contains a version string in a special format. Examples:</p><p>0.4.0-alpha.5</p><p>0.4.0.beta.1</p><p>0.4.0</p><p>The major number consists of <strong>MAJOR.MINOR.PATCH</strong>. According to standard rules, these values ​​change when:</p><ol><li>MAJOR, when a new project version is incompatible with the previous one.</li><li>MINOR, when new functionality is added that is backwards compatible with the previous version.</li><li>PATCH, when bug fixes and hotfixes are added. Used only in the main branch.</li></ol><p>A version may also contain pre-release and build metadata tags; these are added to the end of the version after MAJOR.MINOR.PATCH. For example, 0.1.1.alpha-3 or 1.0.0+20240331</p><p>The presence and meaning of the pre-release tag depends on the branch from which the current build is built.</p><p>Below is a diagram showing an example of the project repository structure and the corresponding build version for each commit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*49fl8hlMepjojjnrRLlrlw.png" /></figure><p><strong>develop </strong>— the main project branch where development is carried out through the creation of feature branches.</p><p><strong>feature </strong>— a branch for developing individual features; after merging into <strong>develop</strong>, it increments the <em>alpha </em>number by the number of commits in the merged branch.</p><p><strong>release </strong>— a branch for preparing for release. The first commit of the branch is always 0.1.0-beta.0. Each new release branch increments the minor version number.</p><p><strong>fix </strong>— a branch for fixes in preparation for release; after merging into release, it increments the beta number.</p><p><strong>main </strong>— this branch is used for the main build and publication of the application. When the project is ready for release, the release branch is merged into main, after which a tag is manually added, starting with 0.1.0.</p><p><strong>hotfix </strong>— a branch for urgent fixes to the release version of the project; it is merged into main. Each new hotfix branch increments the Patch version number.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FYE6q7%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FYE6q7%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FYE6q7%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="396" frameborder="0" scrolling="no"><a href="https://medium.com/media/a823a31818b26c05c17c991b1ea437aa/href">https://medium.com/media/a823a31818b26c05c17c991b1ea437aa/href</a></iframe><p>The development process looks like this: after creating and initializing the repository, the project is on its first commit with branches called “<strong>develop</strong>” and “<strong>main</strong>.” Next, developers complete project tasks and add new features, creating <strong>feature </strong>branches. After passing code review, these branches are merged into “<strong>develop</strong>.” When we need to create and ship a new release, a “<strong>release</strong>” branch is created from the current “<strong>develop</strong>” branch. This branch is used to prepare the release, creating “<strong>fix</strong>” branches and merging them into “<strong>release</strong>.” When the release is fully completed, the “<strong>release</strong>” branch is merged into “<strong>main</strong>” and back into “<strong>develop</strong>” to preserve all the fixes from that release in the project.</p><p><strong>GitVersion </strong>uses the <strong>GitVersion.yml</strong> configuration file, which is located in the root of the repository. We configured this file so that our version is calculated according to the scheme presented above. Below is the configured configuration file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*QxW3iPtcvx87x7y7RY_Zlg.png" /></figure><h3>Unity Editor Integration for Automated Versioning</h3><p>One of the key qualities of our internal tools is their usability.</p><p>To make <strong>GitVersion </strong>easy to use during development, we’ve created a set of tools that allow you to use it directly from the Unity Editor. These tools allow you to check the current project version at any time, directly from the engine window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*t5g3H6W8BDVFPFb21oB44Q.png" /></figure><p>Information received from <strong>GitVersion </strong>is saved in a special Unity file, a Scriptable Object. We can use it directly during application execution, for example, by displaying the current application version on the screen.</p><p>When preparing a build, our scripts activate <strong>GitVersion </strong>and use its output to populate build settings, such as <strong>BundleVersion</strong>, which is a string containing the current application version.</p><p>However, some platforms, such as iOS and MacOS, have specific features; they don’t accept the <strong>FullSemVer </strong>format string, such as 1.3.0-alpha.12 . Therefore, for these platforms, we only use the MajorMinorPatch format string, 1.3.0, from our file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*hh2yMrir9aPTpnyxZRDLCA.png" /></figure><h4>How to Generate Unique Build Numbers with Unix Timestamps</h4><p>The version isn’t all we need to calculate. To help the platform we’re uploading to understand which build is newer and which is older, we need to determine the build number, or <strong>BuildNumber</strong>. This is usually an integer with a limited size.</p><p>The first thing that comes to mind is to calculate the build number based on the <strong>MAJOR.MINOR.PATCH</strong> version.</p><p><strong>Problem</strong> — the following situation may arise: we’ve published version 0.1.0 from the main branch, then we continue development, and, for example, we want to upload version 0.2.0-beta.0 directly from the release branch to the platform so that our testers can test the upcoming release through internal testing channels. This version will then receive a higher <strong>BuildNumber</strong>. However, if something happens to the current stable version 0.1.0 and we urgently need to upload a hotfix, for example, 0.1.1, then its version number will be lower than 0.2.0-beta.0, and the platform will not be able to accept such a build for upload.</p><p><strong>Our solution</strong> is to use the current date and time to generate the <strong>BuildNumber</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*oDtCfzyZ_HKZ6T4Lr5Lqwg.png" /></figure><p>The idea is to use the number of minutes since the UnixEpoch. This ensures that at least one minute later, the new <strong>BuildNumber </strong>will be greater than the previous one.</p><p>We’ve also added <strong>BuildNumberOffset</strong>, which allows you to switch to the new <strong>BuildNumber </strong>calculation system on older projects where previous versions were already calculated using the old method.</p><h3>Building a One-Click Unity Build and Deployment System</h3><p>Building a project in Unity for different platforms requires switching the target platform for the project build, changing certain settings for the platform, specifying the correct <strong>BundleVersion</strong>, and so on. Doing this manually every time is not our approach.</p><p>That’s why we’ve created an <strong>Editor </strong>script for each platform that performs this routine every time before building the project. We can also run this entire logic directly from the Editor window, allowing us to build for the desired platform and test it on the device with a single click.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*fuEcY98TyNf27NX-K3JAZQ.png" /></figure><p>You might be wondering, “<em>What if I want to build a new release for multiple platforms at once? Do I have to click Build each time, wait, and then manually upload the builds to the platforms</em>?”</p><p>The answer is no. You don’t even need to run Unity with the project. For CI/CD on Unity projects, we use the <a href="https://cloud.unity.com/"><strong>Unity Cloud Build</strong></a> service, as well as special <strong>.sh</strong> scripts for deploying builds, which are located in the Unity project.</p><p>What does this process look like?</p><ol><li>We create a project page on <strong>UCB </strong>(Unity Cloud Build).</li><li>We connect <strong>UCB </strong>and our repository so that the service can build our build on remote servers.</li><li>We create the necessary configs for building on different platforms, such as iOS, Android, Meta, WebGL, and so on.</li><li>In these configs, we specify the location of the <strong>Post Build Script</strong> in the project — a script that should be run after the build is successfully built. This is our <strong>.sh</strong> script, which can upload the build to the platform.</li><li>Done! Now, on the project page on <strong>UCB</strong>, we can click and launch a simultaneous build on the required platforms. This will run on <strong>UCB </strong>servers and then be uploaded to the required platforms using our scripts.</li></ol><p>This way, both the project settings and the required version are calculated correctly for all platforms before the build using our logic.</p><p>There are also some special features here. For example, for <strong>WebGL </strong>builds, we can use <strong>GitHub Actions</strong>, which wait for the build to complete on <strong>UCB </strong>and then activate special scripts in the repository to deploy the build to the hosting.</p><h4>Release Channel Mapping: Alpha, Beta, and Production Pipelines</h4><p>Since most platforms allow the use of release channels, we developed a special channel naming system and mapping repository branches to these channels:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*19ShDD5VGGCkAKIXGhfISg.png" /></figure><ul><li><strong>ALPHA </strong>is a release channel for builds from the <strong>develop </strong>branch. Builds in this channel are distributed to the company’s test devices so that developers and testers can test the build.</li><li><strong>ALPHA-RC</strong> and <strong>BETA </strong>are release channels for builds from the <strong>release </strong>branch. Builds in this channel are available on internal devices, as well as on customer test devices, so that the release build can be verified and approved.</li><li><strong>RC </strong>and <strong>PRODUCTION </strong>are release channels for builds from the <strong>main </strong>branch. Before public release to the platform, the build is tested on test devices in the <strong>RC </strong>(<strong>Release Candidate</strong>) channel. When the build is ready for release, it can be promoted to the <strong>PRODUCTION </strong>channel, from which it is available to all users on the platform.</li></ul><h3>Results: Benefits of Automating Unity CI/CD Pipelines</h3><p>Developing internal tools for a team can often speed up and simplify further development.</p><p>Our system for versioning, building, and deploying builds, collectively known as <strong>Unity Build Tools</strong>, allows us to save countless developer hours and simplify and speed up the deployment process.</p><p>This is convenient:</p><ul><li>For clients, releases can be more stable and frequent.</li><li>For testers, the build of a new version appears on all devices almost simultaneously.</li><li>For developers, because they clearly understand how and why project versions are changing, and deployment takes just a couple of clicks.</li></ul><p>By automating versioning, builds, and deployment across platforms, Unity Build Tools helps us reduce manual work, minimize human error, and make releases faster and more consistent. For our clients, that means more reliable releases and a smoother path from development to testing and production, while our developers can spend less time managing builds and more time improving the product.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d75a5b3202a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building 3D Web Applications with Babylon.js and Angular: Lessons from a Golf AR Project]]></title>
            <link>https://medium.com/@saritasa/building-3d-web-applications-with-babylon-js-and-angular-lessons-from-a-golf-ar-project-20fbc5adc806?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/20fbc5adc806</guid>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[3d-web-development]]></category>
            <category><![CDATA[3d-web]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[babylonjs]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 13:52:53 GMT</pubDate>
            <atom:updated>2026-07-29T13:52:53.482Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Raise your hand if you knew you could use JavaScript to create full-fledged 3D apps, complete with AR and VR support, right in the browser.</p><p>Most beginners are surprised to learn how far the web has come in terms of 3D graphics and real-world game development.</p><p>In this article, you’ll learn:</p><ul><li>What <strong>tools and frameworks</strong> are needed to enter the world of Web-3D and AR applications?</li><li>How to <strong>connect an Angular interface to a 3D scene</strong> to make the app feel unified?</li><li>What challenges do developers face when creating a true 3D application?</li><li>What optimizations can dramatically increase performance?</li></ul><p>Our test project is <strong>Golf AR</strong>. It’s a small game where the user’s goal is simple: hit the ball into the hole. But for us, it wasn’t so much about the game itself as it was about exploring the real-world challenges a developer faces when creating an interactive 3D app in the browser: working with physics, camera control, lighting, event synchronization, and UI integration.</p><p>We won’t go into detail about how to build a 3D app in the browser from scratch, there are already dozens of good articles and courses on this topic. Here, we’ll share <strong>our practical development experience</strong>, discuss real-world challenges, and explore solutions using our project as an example.</p><p>Since the project covers several distinct areas, we’ve decided to split the material into two parts. In this first article, we’ll focus exclusively on the 3D portion of the project: architecture, performance, physics, and the integration of the 3D scene with the UI. In the second, we’ll detail some of the limitations associated with AR and the practical solutions we found during development.</p><h3>The Idea and Tech Stack</h3><h4>Why We Got Interested in Web 3D</h4><p>Web 3D is an emerging field that is developing rapidly due to WebGL and WebGPU. Today, the web already allows you to create:</p><ul><li>Visualizations of objects and mechanisms</li><li>Educational and scientific models</li><li>Architectural scenes</li><li>Medical and scientific models</li><li>AR and VR experiences</li><li>Interactive presentations and, of course, games</li></ul><p>The user <strong>doesn’t have to install an app</strong> — everything works right in the browser.</p><p>This was the primary reason for the interest: to evaluate how prepared the web is for developing realistic, interactive 3D applications.</p><h4>Selecting Tools</h4><p>When it comes to 3D in the browser, two engines are most often considered: <strong>Three.js and </strong><a href="http://babylon.js/"><strong>Babylon.js</strong></a>.</p><p>Both options are being actively developed and are suitable for serious projects; however, we decided to choose Babylon.js.</p><p><strong>The reasons</strong>:</p><ul><li>full TypeScript support</li><li>more beginner-friendly and simple API at launch</li><li>integrates well with Angular</li></ul><h4>Why Angular?</h4><p>At the time of development, Angular was the main framework used in our company.</p><p>Although Angular and 3D may not seem like the most obvious combination, in practice, it turned out to be convenient for development:</p><ul><li><strong>Angular </strong>handled the user interface, application state, and user scenario management</li><li><strong>Babylon.js</strong> handled the 3D scene: rendering, cameras, physics, animations, and object interactions</li><li>Communication between them was built through services and reactive streams. This allowed us to isolate the 3D logic from the UI and avoid tight coupling between layers</li></ul><p>The result was <strong>a clear and maintainable architecture</strong>.</p><h3>Advantages and Limitations of 3D on the Web</h3><p>Before diving into development, we evaluated the chosen technology and identified its strengths and weaknesses. Understanding these features is important for properly building the application architecture and anticipating potential challenges.</p><h4>Main Disadvantages</h4><p><strong>Performance is lower than native engines — </strong>The browser is a general-purpose environment that was not originally designed for high-load 3D scenarios. Because of this:</p><ul><li>code runs on top of the browser engine and JavaScript runtime;</li><li>access to the GPU and memory is limited;</li><li>performance is noticeably lower than that of native applications.</li></ul><p><strong>Hardware and system limitations</strong> — It’s more difficult to fully utilize the following features in a browser:</p><ul><li>the camera;</li><li>device sensors (gyroscope, GPS);</li><li>low-level access to the GPU.</li></ul><p>While access to such features is present in the browser, in practice, it is limited by security requirements, the permissions system, and implementation differences between browsers.</p><p><strong>Complex graphic effects require optimization</strong>, such as post-processing and realistic shadows.</p><p>If everything is done “like in an AAA game engine,” the browser simply won’t cope, you have to find a balance.</p><p><strong>It’s important to note: </strong>the bottleneck here isn’t JavaScript, but the browser environment itself. If the app is opened on a mobile device, the limitations of the device itself also play a role. A weaker processor, less available memory, and limited GPU performance will slow things down.</p><p>But the main advantage outweighs all this.</p><p>The user <strong>doesn’t have to install</strong> anything — just <strong>click on a link</strong> or <strong>open a website via a QR code</strong>, and within seconds, they’re <strong>enjoying a full 3D experience</strong>.</p><h3>A brief Introduction to 3D</h3><p>To make the rest of this article easier to read, let’s quickly go over the basic components of a 3D scene.</p><ul><li><strong>Scene </strong>is the entire scene, our virtual world, where objects, lights, cameras, and physics reside.</li><li><strong>Engine </strong>is responsible for rendering the scene and updating objects.</li><li><strong>Camera </strong>defines the user’s perspective on the scene.</li><li><strong>Light </strong>represents light sources<strong>. </strong>Without lighting, objects appear flat and dark. It is light and shadows that allow us to see the shape of objects, their volume, and create a sense of realism in the scene.</li><li><strong>Physics </strong>handles object behavior, including forces, collisions, friction, gravity, and everything that makes the world feel alive.</li><li><strong>Meshes </strong>are the 3D objects themselves in the scene. They can be anything from simple cubes to complex models.</li><li><strong>Material </strong>and <strong>Texture </strong>are the outer shell of objects. Material determines how an object reacts to light, while Texture defines its appearance: color, images, and video.</li><li><strong>Animation </strong>and <strong>Skeleton </strong>are responsible for the movement and skeletal animation of models.</li></ul><p>There are other components, but these are the main ones that developers encounter most often.</p><h3>Performance Issues and their solutions</h3><p>In 3D, and especially in the browser, performance is a major issue. Even on powerful devices, the browser imposes additional limitations, so a scene that performs well in a native engine may perform significantly worse on the web. <strong>This issue is even more pronounced on mobile devices</strong>. A phone’s resources (processor, memory, power consumption) are significantly inferior to those of a desktop computer.</p><p>As a result, a scene that might run smoothly in a native app or on a PC often requires significant optimization in a mobile browser; otherwise, FPS will drop, the device may overheat, and the battery will be rapidly drained.</p><h3>Light and Shadows</h3><p><strong>Light and shadows</strong> are among the most resource-intensive elements of a 3D scene. Each light source requires additional computations. Dynamic shadows create additional overhead, the engine must separately calculate which objects cast shadows and how the shadow should appear.</p><p>In small scenes, this is almost unnoticeable, but as more objects appear, the lighting begins to directly impact performance and FPS.</p><h4>Light baking</h4><p>One of the most effective methods for optimizing lighting and shadows is <strong>light baking</strong>, which is what we used.</p><p>The essence of this approach is that lighting is calculated in advance in a 3D editor (such as Blender or 3ds Max), and the result is saved directly in the object’s texture. For the engine, this is no longer dynamic lighting, but a material with pre-calculated lighting and shadows.</p><p>To use this approach in Babylon.js, you need to disable lighting computations for materials and set the texture as an emissive texture:</p><pre>const material = mesh.material;<br>material.emissiveColor = Color3.White();<br>material.emissiveTexture = material.albedoTexture;<br>material.disableLighting = true;</pre><p>After this, the engine displays the finished result, without any additional computations.</p><p>This method is suitable if your project:</p><ul><li>does not involve dynamic lighting changes (e.g., day/night cycles)</li><li>realistic shadows are not critical</li><li>the scene is mostly static</li></ul><p>Depending on the number of objects, light sources, and scene complexity, the performance gain can range from a few percent to multiple values.</p><p>In our case, this turned out to be one of the simplest and most effective optimization methods. The scene became noticeably more stable, and the FPS increased and stopped dropping when the camera and objects moved.</p><h3>Physics in the 3D World</h3><p>Physics adds significant computational overhead and quickly becomes a bottleneck as the scene complexity increases. It is responsible for collisions, object movement, friction, and overall scene behavior.</p><p>At the start of <strong>Golf AR</strong> development, the <strong>Cannon </strong>engine was chosen for physics. Initially, it was completely satisfactory, the scene was simple, there were few objects, and performance remained stable.</p><p>Problems arose after adding a new course with a large number of physics bodies. The scene began to lag and behave unstable. This behavior was unsatisfactory, and it became clear that we needed to find a solution to the emerging performance issues.</p><h4>Switching to Havok</h4><p>Around the same time, the Babylon.js team announced the integration of the <strong>Havok </strong>physics engine. Demos showed significant performance gains depending on the scene.</p><p>We studied the demo, looked at the API, and decided to replace <strong>Cannon </strong>with <strong>Havok</strong>.</p><p>The results were immediately noticeable:</p><ul><li>FPS increased severalfold,</li><li>jitters disappeared,</li><li>the scene became stable even with a large number of objects.</li></ul><h4>Optimizing Physics Shapes</h4><p>There’s a simple and very effective way to reduce the load on physics: <strong>using different types of physics shapes.</strong></p><p>If the physics body doesn’t have to exactly replicate the object’s shape, you can use simpler representations, such as <strong>PhysicsShapeType.CONVEX_HULL</strong>, which is a simplified “hull” of the object that replicates its general outline without fine details or indentations.</p><h4>Why is this necessary?</h4><p>The simpler the shape of the physics body, the fewer computations are required for collision detection. In 3D, all objects are composed of <strong>polygons</strong> — flat triangular faces. The fewer triangles used for physics computations, the lower the CPU load.</p><p>In the Golf AR project, we use two types of physics shapes:</p><ul><li><strong>PhysicsShapeType.MESH</strong> — a physics shape that completely replicates the object’s geometry.</li></ul><p>We use it for field surfaces where precision is important.</p><ul><li><strong>PhysicsShapeType.CONVEX_HULL</strong> is a simplified shape that only conveys the general outline of an object.</li></ul><p>It is used for trees, rocks, and other minor objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kC2FGoXsNJ4ONbXYeWGbQ.png" /></figure><p>Using PhysicsShapeType.MESH</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSjEo6VLGmy7lYDjnWkagQ.png" /></figure><p>Using PhysicsShapeType.CONVEX_HULL</p><p>Sample code:</p><pre>const physicsAggregate = new PhysicsAggregate(<br>  mesh,<br>  isFieldSurface ? PhysicsShapeType.MESH : PhysicsShapeType.CONVEX_HULL,<br>  { mass: 0, restitution: 0.25 },<br>);</pre><p>This provided a performance boost without complicating the logic or significantly impacting the user experience.</p><h3>Optimizing Loading and Models</h3><p>During development, we noticed that the website was taking too long to load.</p><p>On average, the initial load on mobile devices using a mobile data network took <strong>about 1 minute</strong>, which is unacceptable. Few people are willing to wait that long.</p><p>Opening <strong>DevTools → Network</strong>, we noticed two main issues:</p><ul><li>The Babylon.js bundles were large,</li><li>3D models were taking up a significant portion of the traffic.</li></ul><p>Reducing the size of Babylon.js bundles</p><p>The first step was optimizing the bundles themselves.</p><p>By default, Babylon.js can be imported “in its entirety,” which is convenient at the start, but it leads to unnecessary code in the build.</p><p>After a quick study of the documentation, we learned that using <strong>ES module imports</strong> can significantly reduce the bundle size by including only the modules that are actually used.</p><p>It used to be like this:</p><pre>import { Engine, Scene, Vector3, HavokPlugin, IDisposable } from &#39;@babylonjs/core&#39;;</pre><p>It became like this:</p><pre>import { Engine } from &#39;@babylonjs/core/Engines/engine&#39;;<br>import { Scene, type IDisposable } from &#39;@babylonjs/core/scene&#39;;<br>import { Vector3 } from &#39;@babylonjs/core/Maths/math.vector&#39;;<br>import { HavokPlugin } from &#39;@babylonjs/core/Physics/v2/Plugins/havokPlugin&#39;;</pre><p>This step significantly reduced the final bundle size by approximately <strong>30 MB</strong>, down to just 5 MB, while the application logic remained unchanged.</p><h3>Optimizing 3D Models</h3><p>The next challenge was the size of the models themselves.</p><p>We tried various optimization methods for the models and first consulted with a 3D designer. His edits had a modest effect, the models were already quite well optimized. Gradually, we realized that high detail isn’t always necessary. For example, we replaced the golf ball model with a simple sphere created using Babylon.js. The difference was virtually imperceptible to the human eye, but we managed to save <strong>about 1.3 MB</strong> by deleting the original model.</p><p>Loading Management via a User Flow</p><p>In parallel with optimizations, we decided to rethink the loading flow itself. The project was planned to include a tutorial, which allowed us to intelligently distribute resource loading. Ultimately, the user flow looked like this:</p><ol><li><strong>Loading the main bundles</strong> required for the site to function</li><li><strong>Welcome page</strong> — at this point, background loading of models begins</li><li><strong>Tutorial </strong>— the user learns the mechanics</li><li><strong>Game scene</strong> — by this point, all models are usually already loaded</li></ol><p>This approach allowed us to:</p><ul><li>hide the long loading process,</li><li>improve the first impression,</li><li>reduce the likelihood that users would simply leave the site.</li></ul><h3>Challenges We Encountered</h3><p>While developing the project, adding new mechanics, and refining the UX, we ran into plenty of hurdles. We had to figure things out on our own, sometimes relying on quick workarounds, but ultimately finding solutions that worked.</p><p>When the contact area is almost zero</p><p>At some point, we noticed the ball was behaving strangely. It was moving the same way in different parts of the field, even though the surface was visually different.</p><p>Intuitively, this didn’t seem right. In real life:</p><ul><li>a ball in sand is harder to move,</li><li>it rolls more slowly in tall grass,</li><li>and on a flat surface it rolls faster and further.</li></ul><p>To add realism, we decided to implement two mechanics:</p><ul><li><strong>Friction </strong>— to vary the speed of the ball’s roll in different parts of the field.</li><li><strong>Variable impact force</strong> — depending on the surface the ball is on at the moment of impact.</li></ul><p>When attempting to add friction, we encountered an unexpected problem. Due to the very small contact area between the ball and the surface, the standard friction coefficient did not produce a noticeable effect — even with higher values, the ball speed was unchanged. This prompted us to delve deeper into the physics properties of the ball.</p><p>Using Inertia and Damping</p><p>While studying the<strong> PhysicsBody API</strong>, we noticed two parameters: <strong>inertia </strong>and <strong>damping</strong>.</p><ul><li><strong>Inertia </strong>controls the resistance to rotation around the axes.</li></ul><p>By increasing this parameter, we reduced the ball’s ability to spin for long periods, causing it to lose rolling speed more quickly.</p><ul><li><strong>Damping </strong>controls the decay of motion, that is, how quickly an object loses energy over time.</li></ul><p>It’s important to note that <strong>damping affects not only the ball’s movement after impact but also impact force itself.</strong></p><p>Thanks to <strong>damping</strong>, we were able to naturally reduce the force of impact on highly resistant surfaces, (such as sand or tall grass) without introducing any additional logic. The ball simply received less energy and stopped faster, which looked realistic and predictable.</p><p>Results:</p><ul><li><strong>Inertia </strong>was used to control the speed of rotation and roll of the ball.</li><li><strong>Damping </strong>was used to simulate energy loss and impact attenuation on different surface types.</li></ul><p>This approach allowed us to achieve realistic ball behavior without complicating the mechanics or introducing unnecessary computations.</p><p>Data exchange and display issues</p><h3>Angular and Babylon.js Integration</h3><p>In this project, Babylon.js and Angular are integrated using services and a component-based approach. Angular is responsible for the UI, state, and lifecycle of the application, while Babylon.js is responsible for rendering and updating the 3D scene. It was important to structure their interactions so that they do not interfere with each other.</p><p>The basic idea of ​​the architecture was simple: <strong>Angular manages the application, Babylon manages the scene.</strong></p><h4>Scene Initialization</h4><p>The Angular component does not create the scene directly. Its job is to prepare the &lt;canvas&gt; and pass a reference to it to the service. All initialization occurs <strong>through SceneService</strong>, not within the component.</p><p>The component remains as lightweight as possible: it knows when the scene needs to be created or destroyed, but does not know how it is structured internally.</p><pre>@ViewChild(&#39;canvas&#39;)<br>public canvas: ElementRef&lt;HTMLCanvasElement&gt; | null = null;<br><br>private readonly sceneService = inject(SceneService);<br><br>ngAfterViewInit(): void {<br>  this.zone.runOutsideAngular(() =&gt; {<br>	  this.sceneService.initialize(this.canvas.nativeElement);<br>  });<br>}<br>public ngOnDestroy(): void {<br>	this.sceneService.disposeScene();<br>}</pre><h4><strong>Scene Service</strong></h4><p>All logic related to Babylon.js is encapsulated in SceneService. It is it that:</p><ul><li>creates a scene instance;</li><li>stores a reference to the current scene;</li><li>manages its state;</li><li>provides reactive state streams for the Angular application.</li></ul><p>The service acts as a link between the UI and the 3D world, keeping Angular and Babylon.js code separate.</p><pre>public initialize(element: HTMLCanvasElement): void {<br>  const scene = new BaseScene(element);<br>  this.scene$.next(scene);<br>}</pre><h4><strong>Scene Implementation</strong></h4><p>A separate scene class is responsible exclusively for 3D:</p><ul><li>creating the engine and scene;</li><li>setting up the camera, lighting, and objects;</li><li>running the render loop;</li><li>working with physics and animations;</li><li>etc.</li></ul><pre>export class BaseScene implements IDisposable {<br>  public constructor(private readonly canvas: HTMLCanvasElement) {<br>    this.engine = new Engine(this.canvas);<br>    this.scene = new Scene(this.engine);<br>		this.golfBall = new GolfBall(this.scene);<br><br>    // ... creating a camera, light, field objects, etc.<br>   <br>		this.gameManager = new GameManager(<br>			this.golfBall,<br>			this.scene,<br>			...<br>		);<br>    this.engine.runRenderLoop(() =&gt; this.scene.render());<br>  }<br>}</pre><p>Angular doesn’t interact directly with this class — all communication goes through the service.</p><h4><strong>UI Interaction</strong></h4><p>We used a reactive approach to communicate between the UI and 3D. The scene service provides state streams to which Angular components can subscribe. This allows, for example, to indicate scene loading or block the interface until the scene is fully initialized.</p><pre>public readonly isLoading$ = this.scene$.pipe(<br>  filterNull(),<br>  switchMap(scene =&gt; scene.gameManager.isLoading$),<br>);</pre><h4><strong>Conclusion</strong></h4><p>This approach allowed us to avoid code chaos and clearly separate responsibilities:</p><p><strong>Angular manages the app and UI, Babylon.js manages the 3D scene</strong>, and the service connects them. This simplified support, debugging, and further development of the project.</p><h3><strong>Second camera</strong></h3><p>We decided to add <strong>a second camera </strong>to track the ball. The golf course ended up being quite large, and the ball itself was very small in comparison. As a result, it was difficult for the player to quickly understand where the ball was, especially after hitting it.</p><p>To improve the user experience, we decided to add a ball-tracking camera. This made the on-screen action more dynamic and visual: the player could see not only the shot itself, but also the subsequent movement of the ball.</p><h4><strong>Initial Concept</strong></h4><p>We initially envisioned the following scenario. After the player hits the ball, a block appears at the top of the screen:</p><ol><li>first, it plays a short video of the golfer hitting the ball;</li><li>then the flight of the ball itself is shown, using a second camera;</li><li>after the ball comes to rest, the block disappears.</li></ol><p>It was important that the video and the image from the second camera be perceived as <strong>a single video sequence</strong>, without visual discontinuities.</p><h4><strong>Performance Issues</strong></h4><p>The camera image could only be rendered on the Babylon.js side, so the first solution was to use <strong>VideoTexture</strong>. The video and camera image were rendered within a single <strong>GUI.Rectangle</strong>, which visually solved the problem.</p><p>However, on mobile devices, performance issues arose almost immediately. FPS dropped noticeably, and stuttering appeared, significantly affecting the gameplay experience. The cause turned out to be that rendering the video in a 3D scene was too heavy for phones.</p><h4>Separating the implementation</h4><p>Our next step was to separate the tasks:</p><ul><li>the video played on the Angular side;</li><li>the image from the second camera played on the Babylon.js side.</li></ul><p>However, another challenge arose: synchronization and sizing. Essentially, we ended up with two independent blocks that were difficult to visually align perfectly, especially on different devices and resolutions.</p><h4>Final Solution</h4><p>In the end, we adopted a simpler and more reliable solution: <strong>replacing the video with animation</strong>. By that point, the golfer was already in the scene, showing an animation of his swing. Therefore, we immediately showed the image from the second camera, which showed both the swing animation and the subsequent flight of the ball.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ffast.wistia.net%2Fembed%2Fiframe%2Fcx9fxw6anl&amp;display_name=Wistia%2C+Inc.&amp;url=https%3A%2F%2Fsaritasa.wistia.com%2Fs%2Fwncahfbfmvwoi0b&amp;image=https%3A%2F%2Fembed-ssl.wistia.com%2Fdeliveries%2F09b463965ccf7e34f8fa8768d191d77c849b1d66.jpg%3Fimage_crop_resized%3D960x840&amp;type=text%2Fhtml&amp;schema=wistia" width="960" height="840" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e6354eea08e65c60fb4b9dd0608a404/href">https://medium.com/media/4e6354eea08e65c60fb4b9dd0608a404/href</a></iframe><p>This solution turned out to be:</p><ul><li>simpler to implement;</li><li>more stable on mobile devices;</li><li>and visually sufficient for the desired level of immersion.</li></ul><p>Sometimes foregoing a more “spectacular” solution in favor of stability and performance is the best choice, especially on the web and AR.</p><h3><strong>Results</strong></h3><p>The <strong>Golf AR</strong> project is still in development. We have many ideas: what could be improved in the architecture, where to optimize, and what functionality to add next. This was our first experience working with <strong>3D </strong>in <strong>JavaScript</strong>, and, as often happens, we didn’t consider many nuances at the outset.</p><p>Some issues were resolved during development, while others became apparent only later. The project evolved, its complexity grew, and the code required refactoring. This experience allowed us to better understand how to architect and optimize 3D web applications.</p><p>While working on the project, we encountered many challenges, encountered errors, and expended considerable time and effort. But it was all worth it. We gained valuable practical experience, thought through the interaction of Angular and Babylon.js within a single application, and learned how to work with 3D models and physics in the browser.</p><p>This article was written to introduce you to the relatively new but rapidly developing Web 3D technology, using the <strong>Golf AR</strong> project as an example. Yes, we mostly talked about the challenges we faced, but we wanted to use them to demonstrate how much can already be done on the web and how far this technology still has to go.</p><p>So, if you’re interested in 3D or just want to try something new, don’t be afraid to experiment. Jump on board this fast-moving train with us and dive into the world of <strong>Web 3D</strong>.</p><p>In the next article, we’ll delve deeper into <strong>AR</strong>, explore the pitfalls it faces, and share practical solutions that enabled us to create <strong>an interactive AR experience</strong>. You’ll learn how we addressed the limitations of browsers and mobile devices, and what approaches helped us create a smooth and realistic experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20fbc5adc806" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Built and Open-Sourced a Django Import-Export Extension]]></title>
            <link>https://medium.com/@saritasa/how-we-built-and-open-sourced-a-django-import-export-extension-92cc021f286f?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/92cc021f286f</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[open-source-development]]></category>
            <category><![CDATA[django-development]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 22:25:34 GMT</pubDate>
            <atom:updated>2026-02-05T22:25:34.357Z</atom:updated>
            <content:encoded><![CDATA[<p>In most long-lived software projects, code reuse becomes unavoidable over time. Sometimes that reuse stays internal. Other times, it makes sense to extract functionality into a standalone package that can be versioned, tested, and reused across projects with minimal friction.</p><p>And occasionally, that package solves a problem many teams face.</p><p>In this article, we’ll walk through our experience building and open-sourcing <strong>django-import-export-extensions</strong>, an extension to the popular django-import-export package that adds background processing, performance improvements, and better tooling for real-world Django applications. Along the way, we’ll cover <em>why</em> we built it and <em>how</em> we packaged it properly for open source: repository structure, documentation, CI, publishing, and long-term maintenance.</p><h3>Why We Needed a Custom Extension for django-import-export</h3><p>We originally adopted<a href="https://github.com/django-import-export/django-import-export"> django-import-export</a> in a client project to handle bulk data imports and exports. It worked well, right up until it didn’t.</p><p>As datasets grew, synchronous imports became slow. We needed:</p><ul><li>Background execution</li><li>Better performance for large imports</li><li>More flexibility when dealing with complex relationships and files</li></ul><p>We searched for existing solutions that layered this functionality on top of django-import-export, but nothing quite fit. So we built our own.</p><p>Rather than reinvent the wheel, we extended the package’s existing Resource abstraction (conceptually similar to serializers in DRF). By integrating Celery, we enabled import and export tasks to run asynchronously without rewriting core logic.</p><h3>When Internal Code Becomes an Open-Source Library</h3><p>Initially, this code lived directly inside a single project’s repository and was tightly coupled to business logic. The breaking point came when a second project needed the same background import/export behavior. Copying code felt wrong. Maintaining two versions felt worse. Plus we realized other teams could benefit from our solution.</p><p>So we extracted the logic into a standalone repository. This helped avoid code duplication, simplify maintenance, and ease future refactoring.</p><p>That refactor gave us room to do more than just reuse code. Over time, we:</p><ul><li>Optimized database queries</li><li>Added reusable widgets and fields</li><li>Improved handling of complex relationships</li><li>Added better file import support</li><li>Made the extension API-driven and easier to integrate</li></ul><p>At that point, this wasn’t just internal code anymore. It was a legitimate extension to an existing ecosystem. Open-sourcing the project made sense. It simplified internal usage, invited external feedback, and let us contribute back to the Django ecosystem.</p><p>That left one big question.</p><h3>How Do You Properly Structure an Open-Source Django Library?</h3><p>A solid open-source project is more than working code. It needs:</p><ul><li>Clear structure</li><li>Documentation</li><li>Testing</li><li>CI</li><li>Versioning</li><li>Publishing workflows</li></ul><p>Rather than assembling everything manually, we started with a Cookiecutter-based GitHub template.</p><p>Cookiecutter gave us what we needed:</p><ul><li>A clean, conventional repository structure</li><li>Standard configuration files</li><li>A solid starting point without long-term coupling</li></ul><p>This allowed us to focus on the package itself instead of boilerplate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*mFdBv5xX-Ucb33J18ISxCw.png" /></figure><h3>Repository Structure: Keep It Predictable</h3><p>The next step was to align the project with common conventions for Python/Django open-source libraries. One such convention: all library code lives in a dedicated package directory named after the project.</p><p>This prevents conflicts with other files (tests, setup.py, etc.) and makes the structure predictable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*cencybLQFho7G_5HPt__nQ.png" /><figcaption>Structure of the <strong>django-import-export</strong>-extensions application</figcaption></figure><h3>Documentation: Treat It as a First-Class Feature</h3><p>Documentation is often the difference between a package being adopted or ignored.</p><p>We use <strong>Sphinx</strong> to generate documentation from docstrings and Markdown files. While Makefile is a viable option, we use <strong>Invoke</strong> for task automation as it’s more Pythonic and easier to extend.</p><p>We also leveraged <a href="https://github.com/saritasa-nest/saritasa-invocations/"><strong>saritasa-invocations</strong></a>, an internal open-source package that provides reusable Invoke tasks.</p><pre>import pathlib<br><br>import invoke<br>import saritasa_invocations<br><br>LOCAL_DOCS_DIR = pathlib.Path(“docs/_build”)<br><br>@invoke.task<br>def build(context: invoke.Context):<br>  “””Build documentation.”””<br>  saritasa_invocations.print_success(“Start building of local documentation”)<br>  context.run(<br>    f”sphinx-build -E -a docs {LOCAL_DOCS_DIR} — exception-on-warning”,<br>  )<br>  saritasa_invocations.print_success(“Building completed”)</pre><p>Running inv docs.build is all it takes to generate docs locally.</p><h3>README, CHANGELOG, and CONTRIBUTING: Set Expectations Early</h3><p>The README.md is your project’s front door. It shouldn’t duplicate full documentation, but it <em>should</em> explain:</p><ul><li>What the package does</li><li>Why it exists</li><li>A basic usage example</li></ul><p>Beyond that, we consider two files essential:</p><ul><li><strong>HISTORY.md / CHANGELOG.md</strong> — easier than parsing commit history</li><li><strong>CONTRIBUTING.md</strong> — clear rules for PRs, tests, and code style. Good contribution guidelines reduce friction and improve code quality.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*K0DLi2SP_SCztP_bVMrw0Q.png" /><figcaption>Contents of HISTORY.md</figcaption></figure><h3>Testing Strategy: Treat It Like a Real Django App</h3><p>We use <strong>pytest</strong> and keep tests in a dedicated tests/ directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*QbZKLVzQn1c2_t-Xvd2LJQ.png" /><figcaption>Test Project Structure</figcaption></figure><p>Because this is a Django library, we also maintain a <strong>minimal test project</strong> that integrates:</p><ul><li>Models</li><li>Forms</li><li>Admin</li><li>Import/export flows</li></ul><p>This lets us test real framework interactions instead of isolated units.</p><h3>Dependency Management with Poetry</h3><p>We manage dependencies and publishing with <strong>Poetry</strong>, which works well for both internal and open-source projects.</p><p>However, <strong>uv</strong> (a Rust-based package manager) is currently being actively developed. It runs noticeably faster than Poetry, and we plan to migrate our projects to it in the near future.</p><h3>CI for Open Source: Automation Is Non-Negotiable</h3><p>One of the important aspects of <em>any</em> repository is a configured CI. In open-source, this becomes even more important because some code might be submitted by external developers, and manually checking everything would be too time-consuming.</p><p>First, we configured pre-commit, a tool that runs a series of checks before changes are pushed to the repository.</p><p>We configured <strong>pre-commit hooks</strong> for:</p><ul><li>ruff (linting, formatting, imports)</li><li>File-type linters</li><li>Migration checks</li><li>Tests</li><li>Documentation builds</li></ul><p>As well as <strong>GitHub Actions</strong> with a matrix strategy to test:</p><ul><li>Multiple Python versions</li><li>Multiple Django versions</li></ul><p>One of the main differences between open and internal libraries is the need to support multiple versions of Python and Django. To ensure compatibility, we configured GitHub Actions using a matrix strategy: this allows tests to run on different combinations of Python and Django versions automatically.</p><pre>name: Run tests and style checks<br>on:<br>  pull_request:<br>  push:<br>  branches: [main]<br>jobs:<br>  test:<br>    runs-on: ubuntu-latest<br>    strategy:<br>      fail-fast: false<br>      matrix:<br>        python-version:<br>          - “3.10”<br>          - “3.11”<br>          - “3.12”<br>          - “3.13”<br>          - “3.14”<br>        django-version:<br>          - “&gt;=4.2,&lt;4.3”<br>          - “&gt;=5.0,&lt;5.3”<br>      name: Python ${{ matrix.python-version }} — Django ${{ matrix.django-version }}<br>      steps:<br>        - name: Check out repository code<br>          uses: actions/checkout@v5<br>        - name: Set up Python ${{ matrix.python-version }}<br>          uses: actions/setup-python@v6<br>          with:<br>            python-version: ${{ matrix.python-version }}<br>        - name: Install Poetry<br>          uses: snok/install-poetry@v1<br>          with:<br>            version: latest<br>            virtualenvs-create: true<br>            virtualenvs-in-project: true<br>            installer-parallel: true<br>        - name: Cache poetry dependencies<br>          id: cached-poetry-dependencies<br>          uses: actions/cache@v4<br>          with:<br>            path: .venv<br>            key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles(‘**/poetry.lock’) }}<br>        - name: Cache pre-commit<br>          uses: actions/cache@v4<br>          with:<br>            path: ~/.cache/pre-commit<br>            key: ${{ runner.os }}-${{ matrix.python-version }}-pre-commit-${{ hashFiles(‘**/.pre-commit-config.yaml’) }}<br>        - name: Install local dependencies<br>          if: steps.cached-poetry-dependencies.outputs.cache-hit != ‘true’<br>          run: poetry install — no-interaction<br>        - name: Install Django<br>          run: |<br>            poetry run pip install ‘django${{ matrix.django-version }}’<br>        - name: Prepare env<br>          run: |  <br>            poetry run inv ci.prepare<br>        - name: Run checks ${{ matrix.python-version }}<br>          run: poetry run inv pre-commit.run-hooks<br>        - name: Coveralls Upload<br>          uses: coverallsapp/github-action@v2<br>          with:<br>            github-token: ${{ secrets.GITHUB_TOKEN }}<br>            flag-name: Python${{ matrix.python-version }} — Django${{ matrix.django-version }}<br>            parallel: true<br>    coveralls-finish:<br>      needs: test<br>      if: ${{ always() }}<br>      runs-on: ubuntu-latest<br>      steps:<br>        - name: Coveralls Finished<br>          uses: coverallsapp/github-action@v2<br>          with:<br>            github-token: ${{ secrets.GITHUB_TOKEN }}<br>            parallel-finished: true</pre><p><em>Example of running tests via GitHub Actions</em></p><p>This ensures compatibility across supported environments with every PR.</p><h3>Third-Party Integrations: Documentation Hosting, Coverage, and Publishing</h3><p>By this point, we already had solid documentation generated with <strong>Sphinx</strong>, but relying on locally built HTML files quickly became inconvenient. Local docs are fine during development, but they don’t scale well once other developers — especially external contributors — need consistent, always-available documentation.</p><p>To solve that, we set up <strong>automatic documentation publishing with Read the Docs</strong>.</p><p>After registering an account and connecting the repository, we configured two documentation versions:</p><ul><li><strong>latest</strong>: built automatically from the main branch</li><li><strong>stable</strong>: generated from the most recent release tag (for example, v1.0.0)</li></ul><p>This setup ensures that documentation is always accessible online and stays in sync with the codebase. Contributors can reference the latest changes, while users on released versions can rely on stable, versioned docs. In practice, this significantly reduced friction for both internal development and external adoption.</p><h3>Tracking Test Coverage with Coveralls</h3><p>Next, we wanted better visibility into how well the package was tested.</p><p>For that, we integrated <strong>Coveralls</strong>, which collects coverage reports after test runs and visualizes them at the file level. This makes it easy to see which parts of the codebase are well covered and which areas need additional tests, which becomes especially important as more contributors get involved.</p><p>The integration itself was straightforward. We added a coverage upload step to our existing GitHub Actions workflow, and from there, coverage data was automatically reported after every CI run.</p><h3>Publishing to PyPI</h3><p>With documentation and testing in place, the next step was distribution.</p><p>We published the library to <strong>PyPI</strong>, making it installable via any standard Python package manager. To do this, we created a dedicated PyPI account and generated an API token, which we then connected to <strong>Poetry</strong>.</p><p>Once configured, publishing new releases became trivial:</p><p><strong><em>poetry publish — build</em></strong></p><p>No manual builds, no extra configuration steps — just a clean, repeatable release process. New versions can now be published in a matter of minutes.</p><h3>README Badges for Project Visibility</h3><p>Finally, we tied all of these integrations together by adding informative badges to the README.md, including:</p><ul><li>Build status</li><li>Latest package version</li><li>Test coverage</li><li>Documentation status</li></ul><p>These badges provide an at-a-glance snapshot of the project’s health and maturity, helping users and contributors quickly assess its current state before diving in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*mZzGdBA3mhbsDQwaj7elLQ.png" /><figcaption>Badges for displaying current data</figcaption></figure><h3>Shipping the First Release</h3><p>Before publishing, we performed a deeper review and marked the project as <strong>Beta (4)</strong> on PyPI. Even though it was already in production internally, we wanted room to iterate.</p><p>After several months of usage and refinement, we shipped <strong>v1.0.0</strong>, updated the status to <strong>Production (5)</strong>, and <a href="https://github.com/django-import-export/django-import-export/pull/1994">opened a PR </a>in the original django-import-export repository linking to our extension.</p><p>We’ve since accepted contributions, including from maintainers of the original django-import-export project.</p><h3>Final Thoughts</h3><p>What started as internal code turned into a fully open-source Django extension with CI, documentation, tests, and a growing user base.</p><p>Open-sourcing a library isn’t just about publishing code. It’s about making deliberate choices around structure, tooling, automation, and long-term maintenance. When done right, it benefits both your team and the wider community.</p><p>We’re continuing to develop <a href="https://github.com/saritasa-nest/django-import-export-extensions"><strong>django-import-export-extensions</strong></a>, review issues and pull requests, and (hopefully) watch the star count grow.</p><p>If you have ideas for improvement or just want to contribute to the project, welcome!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92cc021f286f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Development Guide: Live Activities + Actionable Notifications with SwiftUI]]></title>
            <link>https://medium.com/@saritasa/ios-development-guide-live-activities-actionable-notifications-with-swiftui-2a3dc56bf63c?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a3dc56bf63c</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 18:49:03 GMT</pubDate>
            <atom:updated>2025-11-20T18:49:03.657Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by </em><a href="https://www.linkedin.com/in/nicol%C3%A1s-cobelo-39520228/"><em>Nicolas Cobelo</em></a><em>, </em><a href="https://www.saritasa.com/ios-development"><em>iOS Developer at Saritasa</em></a></p><p><strong>TL;DR: </strong>Apple’s <strong>ActivityKit</strong>, <strong>WidgetKit</strong>, and <strong>App Intents</strong> let you bring interactive, real-time updates directly to the Lock Screen and Home Screen. In this tutorial, we built a simple to-do app that lets users start, track, and complete tasks without ever opening the app. By combining Live Activities with custom intents and an <strong>ActivityManager</strong>, you can create smoother, faster workflows for any use case, from tasks and deliveries to fitness and events.</p><p>In recent years, Apple has dropped several powerful frameworks into developers’ laps:</p><ul><li><strong>WidgetKit</strong> for interactive widgets on the Home Screen</li><li><strong>ActivityKit</strong> for Live Activities on the Lock Screen and Dynamic Island</li><li><strong>UserNotifications</strong> for actionable reminders and updates</li><li><strong>SwiftData</strong> for clean local persistence</li></ul><p>Individually, they’re well documented. But together? Not so much. Resources explaining how these frameworks interact in real-world apps are scarce. That’s why we built a small demo project to connect the dots.</p><h3>The Test Case: A Smarter To-Do App</h3><p>To explore these frameworks in action, we built a simple <strong>To-Do app</strong>. The goal: let users create tasks and update their status without opening the app. Think of it as a way to:</p><ul><li>Mark tasks as complete directly from the <strong>Home Screen widget</strong></li><li>Start or finish tasks via <strong>Live Activities on the Lock Screen</strong></li><li>Get updates through <strong>UserNotifications</strong></li></ul><p>The result? A cleaner, faster user experience where managing tasks feels almost invisible.</p><h3>Updating Tasks from the Lock Screen with ActivityKit</h3><p><strong>ActivityKit</strong> powers <strong>Live Activities</strong>. These are interactive cards pinned to the Lock Screen and the Dynamic Island. They let users view and update real-time information without unlocking the phone.</p><p>For our To-Do app, this meant:</p><ul><li>Starting a Live Activity when a task begins</li><li>Updating its status directly from the Lock Screen</li><li>Completing tasks with a single tap</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*2Q_F7uRzt3RUb9mREcaG1A.gif" /></figure><p>To pull this off, we created a custom <strong>ActivityManager</strong> class in SwiftUI. This class handles the logic that connects Live Activities with our task data model.</p><h3>Building the Live Activity Widget</h3><p>To get started, we’ll create a new <strong>Widget Extension target</strong>:</p><p><strong>File → New → Target → Widget Extension<br></strong> Name it: <strong>LiveActivityWidget.</strong></p><p>After you create this Target, it is very important that you include it in the Target Membership section for any models, helpers, assets, or extensions that you might use in the Widget in order to avoid any potential errors.</p><p>This widget will display the task’s name, due date, and a button to mark it complete — all visible from the Lock Screen. The SwiftUI code looks like this:</p><pre><br>import AppIntents<br>import SwiftUI<br>import WidgetKit<br><br>struct LiveActivityWidget: Widget {<br>    var body: some WidgetConfiguration {<br>        ActivityConfiguration(for: TodoAttributes.self) { context in<br>            // Lock screen/banner UI goes here<br>            LiveActivityView(context: context)<br>        } dynamicIsland: { context in<br>            DynamicIsland {<br>                DynamicIslandExpandedRegion(.center) {<br>                    LiveActivityView(context: context)<br>                }<br>            } compactLeading: {<br>                Text(context.attributes.target.name)<br>            } compactTrailing: {<br>                Text(context.state.status.text)<br>            } minimal: {<br>                Text(&quot;&quot;)<br>            }<br>        }<br>    }<br>    <br>    @ViewBuilder<br>    func LiveActivityView(context: ActivityViewContext&lt;TodoAttributes&gt;) -&gt; some View {<br>        ZStack{<br>            VStack(alignment: .leading) {<br>                HStack(alignment: .center){<br>                    Image(&quot;appLogo&quot;)<br>                        .resizable()<br>                        .frame(width:38,height: 38)<br>                        .clipShape(.circle)<br><br>                    VStack(alignment: .leading){<br>                        HStack{<br>                            Text(context.attributes.target.name)<br>                                .font(.system(size: 18,weight: .bold))<br>                            Spacer()<br>                        }<br>                        Text(DateHelper.Formatter.longDate.string(from: context.attributes.target.startTime))<br>                            .font(.system(size: 16,weight: .medium))<br>                            .lineLimit(2)<br>                            .multilineTextAlignment(.leading)<br>                    }<br>                }<br><br>                ButtonView(context: context)<br>            }<br>            .padding(16)<br>            .activityBackgroundTint(Color.brandSecondary.opacity(0.5))<br>        }<br>    }<br>    <br>    @ViewBuilder<br>    func ButtonView(context: ActivityViewContext&lt;TodoAttributes&gt;) -&gt; some View {<br>        Group {<br>            switch context.state.status {<br>            case .pending:<br>                Text(&quot;Pending&quot;)<br>            case .inProgress:<br>                LiveActivityActionButtonsView(recordID: context.attributes.target.id)<br>            case .completed:<br>                RoundedRectangle(cornerRadius: 20, style: .circular)<br>                    .frame(width: .infinity,height: 40)<br>                    .foregroundStyle(Color.brandSecondary.opacity(0.5))<br>                    .overlay(content: {<br>                        Text(&quot;Completed!&quot;)<br>                            .font(Font.system(size: 16,weight: .bold))<br>                    })<br>            }<br>        }<br>    }<br>}<br><br>struct LiveActivityActionButtonsView: View {<br>    let recordID:String<br>    var body: some View {<br>        HStack{<br>            Button(intent: LiveActivityButtonIntent(id: recordID), label: {<br>                Text(&quot;Complete&quot;)<br>            })<br>            .buttonStyle(.plain)<br>            .frame(maxWidth: .infinity,minHeight:40,maxHeight:40)<br>            .background(Color.brandPrimary.gradient)<br>            .clipShape(Capsule())<br><br>        }<br>    }<br>}</pre><p>Inside <strong>LiveActivityView</strong>, we render the task details with SwiftUI, and use ButtonView to display a dynamic status button (pending, in-progress, or completed).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*nvLknSFH_jwLdmYss_ecLw.png" /></figure><h3>Defining Live Activity Attributes</h3><p>Next, we define a <strong>data model</strong> for Live Activities by conforming to the ActivityAttributes protocol. This struct describes both:</p><ul><li><strong>Static data</strong> (task name, start time, duration)</li><li><strong>Dynamic data</strong> (current status, last updated timestamp)</li></ul><pre><br>import ActivityKit<br>import WidgetKitstruct TodoAttributes: ActivityAttributes {<br>    <br>    enum Status: Codable, Hashable {<br>        case pending<br>        case inProgress<br>        case completed<br>        <br>        var text: String {<br>            switch self {<br>            case .pending: return &quot;Pending&quot;<br>            case .inProgress: return &quot;In Progress&quot;<br>            case .completed: return &quot;Completed&quot;<br>            }<br>        }<br>    }<br>    <br>    // Dynamic data<br>    public struct ContentState: Codable, Hashable {<br>        var status: Status<br>        var lastUpdated: Date<br>    }<br>    <br>    // Static data<br>    let target: Target<br>}<br><br>struct Target: Hashable, Codable, Identifiable {<br>    var id: String<br>    var name: String<br>    var startTime: Date<br>    var duration: Int?<br>}<br><br>extension Target {<br>    static var testTarget = Target(id: &quot;130&quot;, name: &quot;Review project&quot;, startTime: .now, duration: 60)<br>}<br><br>extension TodoAttributes {<br>    static var preview: TodoAttributes {<br>        TodoAttributes(target: Target.testTarget)<br>    }<br>}</pre><p>PD: When creating the TodoAttributes file, make sure to set the Target to both the WidgetToDo app and the LiveAcitivityWidgetExtension as both targets will need access to this struct</p><p>Then, in the Info.plist make sure to set Supports Live Activities to YES</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*vAEMlrrxVFcCc_Lajf_h_Q.png" /></figure><p>This gives ActivityKit everything it needs to render and update task information on the Lock Screen.</p><h3>Managing State with ActivityManager</h3><p>To keep the app logic organized, we created an <strong>ActivityManager</strong> class. Its job:</p><ul><li>Start Live Activities when tasks begin</li><li>Update them as task status changes</li><li>End them when tasks are completed</li></ul><p>The manager wraps ActivityKit calls into clean SwiftUI-friendly functions:</p><pre><br>import SwiftUI<br>import Combine<br>import ActivityKitclass ActivityManager: ObservableObject {<br>    struct ActivityStatus: Sendable, Hashable, Identifiable {<br>        var id: String<br>        var activityState: ActivityState<br>        var target: Target<br>        var contentState: TodoAttributes.ContentState<br>        <br>        init(id: String, activityState: ActivityState, target: Target, contentState: TodoAttributes.ContentState) {<br>            self.id = id<br>            self.activityState = activityState<br>            self.target = target<br>            self.contentState = contentState<br>        }<br>        <br>        init(activity: Activity&lt;TodoAttributes&gt;) {<br>            self.id = activity.id<br>            self.activityState = activity.activityState<br>            self.target = activity.attributes.target<br>            self.contentState = activity.content.state<br>        }<br>    }<br>    <br>    // current Activity<br>    @Published var activityStatus: ActivityStatus? = nil<br>        <br>    @Published var statusList: [ActivityStatus] = []<br>    <br>    private var activityList: [Activity&lt;TodoAttributes&gt;] = [] {<br>        didSet {<br>            DispatchQueue.main.async {<br>                self.statusList = self.activityList.map({ActivityStatus(activity: $0)})<br>            }<br>        }<br>    }<br>    <br>    func getLiveActivity(for recordID: String) -&gt; Activity&lt;TodoAttributes&gt;?{<br>        Activity&lt;TodoAttributes&gt;.activities.first(where: {$0.attributes.target.id == recordID})<br>    }<br>    <br>    /// Used for App Intent purposes<br>    func loadActivity(_ activityId: String?) {<br>        guard let activityId else {<br>            return<br>        }<br>        <br>        guard let activity = self.activityList.first(where: {$0.id == activityId}) else {<br>            print(&quot;No Activity Found for current Target!&quot;)<br>            return<br>        }<br>        if activity.activityState == .ended || activity.activityState == .dismissed {<br>            print(&quot;Activity ended! Please start a new one!&quot;)<br>            return<br>        }<br>        <br>    }<br>    <br>    func startActivity(for target: Target){<br>        let activityData: TodoAttributes = .init(target: target)<br>        let contentState: TodoAttributes.ContentState = .init(status: .inProgress, lastUpdated: .now)<br>                do {<br>                    let activity = try Activity&lt;TodoAttributes&gt;.request(attributes: activityData, content: .init(state: contentState, staleDate: Date(timeIntervalSinceNow: 10)))<br>                    print(&quot;Activity Added: \(activity)&quot;)<br>                } catch {<br>                    print(error.localizedDescription)<br>                }<br>    }<br>    <br>    func updateActivity(id: String, status: TodoAttributes.Status) async {<br>        guard let currentActivity = getLiveActivity(for: id) else {<br>            print(&quot;Start a New activity or load an existing one before update.&quot;)<br>            return<br>        }<br><br>        let contentState = TodoAttributes.ContentState(status: status, lastUpdated: .now)<br><br>        await currentActivity.update(<br>            ActivityContent&lt;TodoAttributes.ContentState&gt;(<br>                state: contentState,<br>                staleDate: nil<br>            )<br>        )<br>        if status == .completed {<br>            await self.endActivity(id: id, dismissalPolicy: .default)<br>        }<br>    }<br>    <br>    func endActivity(id: String, dismissalPolicy: ActivityUIDismissalPolicy) async {<br>        guard let currentActivity = getLiveActivity(for: id) else {<br>            print(&quot;Start a New activity or load an existing one before ending it.&quot;)<br>            return<br>        }<br><br>        await currentActivity.end(nil, dismissalPolicy: dismissalPolicy)<br>    }<br>}<br><br>// Helper functions for Intent actions<br>extension ActivityManager {<br>    <br>    func finishTask(id: String) async {<br>        await self.updateActivity(id: id, status: .completed)<br>       <br>    }<br>}</pre><p>This centralizes all Live Activity logic, making it easy to test, extend, or connect with other frameworks (like UserNotifications).</p><p>Again, make sure to set the Target to both the WidgetToDo app and the <strong>LiveAcitivityWidgetExtension</strong> as both targets will need access to this class.</p><h3>Connecting ActivityManager to the App</h3><p>With the <strong>ActivityManager</strong> ready, we integrate it into the app’s main struct so it’s available throughout SwiftUI views via <strong>@EnvironmentObject</strong>.</p><pre><br> @main<br>struct WidgetToDoStarterApp: App {<br>    @StateObject var activityManager: ActivityManager<br>    <br>    init() {<br>        let activityManager = ActivityManager()<br>        _activityManager = StateObject(wrappedValue: activityManager)<br>    }<br>    <br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>                .environmentObject(activityManager)<br>        }<br>        .modelContainer(for:Todo.self)<br>    }<br>}</pre><p>This makes Live Activity state reactive across the app, so tasks update seamlessly whether you’re inside the app or viewing from the Lock Screen.</p><h3>Hooking Live Activities into ContentView</h3><p>Now, we update <strong>TodoRowView</strong> to start Live Activities when a task begins:</p><pre><br>   private func startTask() {<br>        let target = Target(id: todo.id, name: todo.task, startTime: todo.startDate, duration: todo.durationInSeconds)<br>        manager.startActivity(for: target)<br>    }</pre><p>This connects your task model to <strong>ActivityKit</strong>. Any new task marked <em>in-progress</em> instantly spawns a Live Activity on the Lock Screen.</p><h3>Adding Button Actions with LiveActivityButtonIntent</h3><p>At this point, the Live Activity shows task info, but we want interactivity, such as a button that marks the task complete right from the Lock Screen. Enter <strong>LiveActivityButtonIntent</strong>.</p><pre><br>import AppIntents<br>import SwiftData<br>import ActivityKit<br><br>/// Button Intent which will update the todo status<br>struct LiveActivityButtonIntent: LiveActivityIntent {<br>    static var title: LocalizedStringResource = .init(stringLiteral: &quot;Toggles Todo State&quot;)<br>    static var openAppWhenRun: Bool = false<br>    static var isDiscoverable: Bool = false<br>    <br>    @Parameter(title: &quot;Todo ID&quot;) var id: String<br>    <br>    init() {<br>    }<br>    init(id: String) {<br>        self.id = id<br>    }<br>    <br>    func perform() async throws -&gt; some IntentResult{<br>        /// Updating todo status<br>        let context = try ModelContext(.init(for: Todo.self))<br>        /// Retrieving Respective Todo<br>        let descriptor = FetchDescriptor(predicate: #Predicate&lt;Todo&gt; {$0.id == id})<br>        if let todo = try context.fetch(descriptor).first {<br>            todo.isCompleted = true<br>            todo.lastUpdated = .now<br>            /// Saving Context<br>            try context.save()<br>            <br>            print(&quot;refreshing \(String(describing: id))&quot;)<br>            let manager = ActivityManager()<br>            manager.loadActivity(id)<br>            await manager.finishTask(id: id)<br>        }<br>        <br>        return .result()<br>    }<br>}</pre><p>This intent does three things:</p><ol><li><strong>Fetches the correct Todo</strong> by ID</li><li><strong>Updates its state</strong> (marking as completed)</li><li><strong>Signals ActivityManager</strong> to end the Live Activity</li></ol><p>With this in place, tapping the Lock Screen button not only updates the task visually but also persists the change in the app’s data model.</p><p><em>Tip: If, after building this code, you encounter errors like “Cannot find ‘class’ in scope” or “‘Class’ has no member ‘variable’”, then you probably forgot to add the new LiveActivityWidgetExtension target to the list of Target Membership in the files Identity and Type section</em></p><h3>Creating Actionable Notifications in iOS with UserNotifications + SwiftUI</h3><h4>Why Actionable Notifications Matter</h4><p>Push notifications are great for nudging users, but what if you could let them act directly from the notification itself? That’s where actionable notifications come in. Users can start, delay, or dismiss tasks without opening the app.</p><p>Apple’s <strong>UserNotifications</strong> framework makes this possible, but most of the documentation (and StackOverflow answers) lean heavily on UIKit and AppDelegate extensions. We wanted a clean SwiftUI-first solution, so we built one.</p><h4>Create a NotificationDelegate</h4><p>First, we set up a <strong>NotificationDelegate</strong> class that conforms to <strong>UNUserNotificationCenterDelegate</strong>. This lets us define how notifications behave and how users can interact with them.</p><pre><br>import Combine<br>import SwiftUI<br><br>class NotificationDelegate: NSObject, ObservableObject, UNUserNotificationCenterDelegate {<br><br>    private let notificationCenter = UNUserNotificationCenter.current()<br>    <br>    @Published var activityManager: ActivityManager<br>    <br>    init(activityManager: ActivityManager) {<br>        self.activityManager = activityManager<br>    }<br>    <br>    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -&gt; Void) {<br>        completionHandler([.badge, .banner, .sound])<br>    }<br>    <br>    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -&gt; Void) {<br>        let userInfo = response.notification.request.content.userInfo<br>        guard let taskId = userInfo[&quot;id&quot;] as? String ,<br>              let taskName = userInfo[&quot;task&quot;] as? String,<br>              let starTime = userInfo[&quot;startTime&quot;] as? Date,<br>              let duration = userInfo[&quot;duration&quot;] as? Int<br>        else {<br>            completionHandler()<br>            return<br>        }<br>        switch response.actionIdentifier {<br>        case Constants.startActionIdentifier:<br>            removeAllNotifications()<br>            let target = Target(id: taskId, name: taskName, startTime: starTime, duration: duration)<br>            start(task: target)<br>            break<br>        case Constants.rescheduleActionIdentifier:<br>            removeAllNotifications()<br>            rescheduleNotification()<br>            break<br>            <br>        case Constants.dismissActionIdentifier:<br>            removeAllNotifications()<br>            break<br>            <br>        case UNNotificationDefaultActionIdentifier,<br>        UNNotificationDismissActionIdentifier:<br>            break<br>            <br>        default:<br>            break<br>        }<br>        completionHandler()<br>    }<br><br>}<br><br>extension NotificationDelegate {<br>    <br>    /// Create notification for task<br>    func createNotification(for task: Todo) {<br>        <br>        // Remove any existing notifications for this task if there are any<br>        removePendingNotification(identifier: task.id)<br>        <br>        let content = UNMutableNotificationContent()<br>        content.title = task.task.capitalized<br>        content.subtitle =  &quot;It&#39;s time to complete your task!&quot;<br>        content.userInfo = [<br>            &quot;id&quot;: task.id,<br>            &quot;task&quot;: task.task,<br>            &quot;startTime&quot;: task.startDate,<br>            &quot;duration&quot;: task.durationInSeconds ?? 0<br>        ]<br>        content.categoryIdentifier = Constants.timerActionableIdentifier<br>        <br>        let components = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: task.startDate)<br>        let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false)<br><br>        registerNotificationRequest(identifier: task.id, content: content, trigger: trigger)<br>    }<br>    <br>    ///  Show the notification in 5 minutes<br>    private func rescheduleNotification() {<br>        let content = UNMutableNotificationContent()<br>        content.title = &quot;task.task.capitalized&quot;<br>        content.subtitle =  &quot;It&#39;s time to complete your task!&quot;<br>        content.categoryIdentifier = Constants.timerActionableIdentifier<br>        <br>        // reminder notification in 5 minutes<br>        let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5 * 60, repeats: false)<br>        registerNotificationRequest(identifier: &quot;task.id&quot;, content: content, trigger: trigger)<br>    }<br>    <br>    /// Registers the notification with its corresponding actions<br>    private func registerNotificationRequest(identifier: String, content: UNMutableNotificationContent, trigger: UNNotificationTrigger) {<br>        let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger)<br>        <br>        let startAction = UNNotificationAction(identifier: Constants.startActionIdentifier,<br>                                               title: &quot;Start task&quot;,<br>                                               options: .foreground)<br>        let rescheduleAction = UNNotificationAction(identifier: Constants.rescheduleActionIdentifier,<br>                                                    title: &quot;Remind me in 5 minutes&quot;,<br>                                                    options: .foreground)<br>        let dismissAction = UNNotificationAction(identifier: Constants.dismissActionIdentifier,<br>                                                 title: &quot;Dismiss&quot;,<br>                                                 options: .destructive)<br>        <br>        let category = UNNotificationCategory(identifier: Constants.timerActionableIdentifier, actions: [startAction, rescheduleAction, dismissAction], intentIdentifiers: [])<br>        <br>        UNUserNotificationCenter.current().setNotificationCategories([category])<br>        UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)<br>    }<br>    <br>    private func removeAllNotifications() {<br>        notificationCenter.removeAllDeliveredNotifications()<br>        notificationCenter.removeAllPendingNotificationRequests()<br>    }<br>    <br>    func removePendingNotification(identifier: String) {<br>        notificationCenter.removePendingNotificationRequests(withIdentifiers: [identifier])<br>    }<br>    <br>    /// Creates the Live Activity View for the corresponding task<br>    private func start(task: Target) {<br>        activityManager.startActivity(for: task)<br>    }<br>}<br><br>extension NotificationDelegate {<br>    private enum Constants {<br>        static let timerActionableIdentifier = &quot;TIMER_ACTION&quot;<br>        static let startActionIdentifier = &quot;START_ACTION&quot;<br>        static let rescheduleActionIdentifier = &quot;RESCHEDULE_ACTION&quot;<br>        static let dismissActionIdentifier = &quot;DISMISS_ACTION&quot;<br>    }<br>}</pre><p>This gives us hooks for two critical methods:</p><ul><li><strong>willPresent</strong> → controls how notifications appear when the app is in the foreground.</li><li><strong>didReceive</strong> → handles custom actions (start, reschedule, dismiss).</li></ul><p>This extension gives users three clear options when a notification fires:</p><ul><li>✅ <strong>Start the task</strong> (and trigger a Live Activity)</li><li>⏰ <strong>Reschedule for 5 minutes later</strong></li><li>❌ <strong>Dismiss the notification</strong></li></ul><p>To initialize it, we will update ContentView, like so:</p><pre><br>struct ContentView: View {<br>    @StateObject var activityManager: ActivityManager<br>    @StateObject var notificationDelegate: NotificationDelegate<br>    <br>    init() {<br>        let activityManager = ActivityManager()<br>        _activityManager = StateObject(wrappedValue: activityManager)<br>        _notificationDelegate = StateObject(wrappedValue: NotificationDelegate(activityManager: activityManager))<br>    }<br>    var body: some View {<br>        NavigationStack {<br>            HomeView()<br>                .navigationTitle(&quot;Todo List&quot;)<br>                .environmentObject(activityManager)<br>                .environmentObject(notificationDelegate)<br>        }<br>        .onAppear {<br>            UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in<br>            }<br>            UNUserNotificationCenter.current().delegate = notificationDelegate<br>        }<br>    }<br>}</pre><p>Example: when creating a new task, just call:</p><p><strong>delegate.createNotification(for: todo)</strong></p><p>That’s it! Your new task now comes with its own actionable notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*hw4kP3Rj9ecBEJTsqtSWqA.gif" /></figure><h3>Conclusion: Clean UX with Minimal Code</h3><p>By combining <strong>ActivityKit</strong>, <strong>WidgetKit</strong>, and <strong>App Intents</strong>, we’ve built a simple but powerful workflow:</p><ul><li>Users can start and track tasks directly from the Lock Screen</li><li>Tasks stay synced between app and Live Activity</li><li>Status updates are a single tap away. No app relaunch needed</li></ul><p>This pattern can extend beyond a to-do app. Think <strong>fitness tracking, deliveries, reservations, or live events</strong>, basically any scenario where users need quick interactions without deep-diving into your app.</p><p>Apple keeps shipping powerful frameworks like <strong>ActivityKit</strong>, <strong>WidgetKit</strong>, and <strong>UserNotifications</strong>. The challenge (and opportunity) for developers is figuring out how to stitch them together for smooth, modern user experiences. With a bit of <a href="https://www.saritasa.com/swift-development">SwiftUI-first architecture</a>, the results are both clean code and delightful UX.</p><p><strong>Happy coding!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a3dc56bf63c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Optimize Name Search in PostgreSQL with Trigram and BTree Indexes]]></title>
            <link>https://medium.com/@saritasa/how-to-optimize-name-search-in-postgresql-with-trigram-and-btree-indexes-02c57eb27687?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/02c57eb27687</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[query-optimization]]></category>
            <category><![CDATA[indexing]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 17:23:13 GMT</pubDate>
            <atom:updated>2025-09-04T17:23:13.256Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://medium.com/@saritasa/why-your-user-search-is-slow-and-how-to-fix-it-with-postgresql-6346a8d1d987">Part 1</a>, we explored why name search isn’t as simple as it looks. Now it’s time to take it further. In this article, we’ll dive into PostgreSQL’s advanced search capabilities: trigram matching, hybrid indexes, partial indexes, and how each strategy performs under pressure using the same name search example as our base.</p><h3>Smarter Matching with Trigram Search</h3><p>PostgreSQL’s <a href="https://www.postgresql.org/docs/current/pgtrgm.html">pg_trgm</a> extension enables similarity-based matching using trigrams (3-character sequences). With this, you can:</p><ul><li>Concatenate first_name and last_name into a single expression,</li><li>Create a trigram index on that expression,</li><li>Use the % (similarity) operator to match substrings and typos,</li><li>And sort by “distance” to prioritize the closest matches.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/0*V-Ot3K6ddGPQg352" /></figure><p><strong>Pros of the approach:</strong></p><ul><li>Case-insensitive matching</li><li>Works regardless of the complexity or order of names (e.g., it can handle something like “Titus von der Malsburg”)</li><li>Handles typos gracefully by ranking results by similarity</li><li>No need to normalize spaces or punctuation in the input</li></ul><p><strong>Cons of this approach:</strong></p><ul><li>The similarity filter can return too many loosely related matches. Without sorting, pagination (like showing only the first page of results) might exclude the most relevant names. That means <strong>sorting by similarity distance is practically required</strong> to get useful results.</li><li>But if the search term is too short or generic (like just one letter), it may match a large number of records. In that case, <strong>sorting by similarity becomes slow</strong>, since the database has to calculate and rank the distance for each matching record.</li></ul><h3>Combining Trigram Search with Filtering</h3><p>When searching by multiple fields (like full name <em>and</em> city) it’s best to use a <strong>combined index</strong>. But there’s a catch: PostgreSQL’s GIN (Generalized Inverted Index), used for full-text or trigram search, doesn’t naturally work with BTREE indexes used for filtering on fields like city or client ID.</p><h4>PostgreSQL’s <a href="https://www.postgresql.org/docs/current/btree-gin.html">btree_gin</a> extension bridges the gap with Mixed Indexing.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*0jP_o-uOFEH5ASuE" /></figure><p>It allows BTREE-style indexing within a GIN index, enabling efficient combined indexes like:</p><ul><li><strong>Full name</strong> (via trigram or full-text search)</li><li><strong>City</strong>, <strong>department</strong>, or <strong>client ID</strong> (as filters)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/0*FLIQun5K-1onPMiS" /></figure><p>Now, your queries can handle both<strong> name matching</strong> <em>and</em> <strong>exact filtering</strong>, all with one index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*TafDT46InIo1TU6P" /></figure><h3>Smart Filtering with Partial Indexes</h3><p>Partial indexes can shrink index size and improve performance by indexing only the rows you care about.</p><p>For example, two features are often used for user accounts: Soft Delete and Email Verification. Most times, you only need to search “verified” users who have already confirmed their email, but have not yet deleted their account. As a result, your queries always include conditions like:</p><ul><li>Only verified users</li><li>Only non-deleted accounts</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*ucF9ayGGkoCA7HnX" /></figure><p>Including these fields in a combined index can bloat the index size, especially if most users are verified and active. Instead, use a <a href="https://www.postgresql.org/docs/8.0/indexes-partial.html"><strong>partial index</strong></a>, one that only includes rows matching a specific condition. The number of records in the index will decrease, and the speed of query execution will increase slightly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*Bg75My948s4iZE7b" /></figure><p>This keeps your index lean and fast, focusing only on the relevant subset of users.</p><p>However, partial indexes only apply if your query <strong>exactly matches</strong> the WHERE clause in the index. So this works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/0*4fQJv9ATVMPMqGmD" /></figure><p>While this one doesn’t:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*nE4TNaFfTBhJhAWb" /></figure><h3>Scaling Multi-Tenant Performance with Per-Client Indexes</h3><p>In multi-tenant apps (e.g. SaaS platforms), users are often filtered by client_id. You almost never need to search across <em>all</em> users, just a specific client’s users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/0*HqN71totO_gVNB7t" /></figure><p>If one global index takes 1GB, splitting it into 100 client-specific indexes averages 10MB each. That’s faster to load, easier to maintain, and plays nicer with system memory.</p><ul><li>Smaller indexes = faster lookups</li><li>Less RAM usage during updates</li><li>Better performance under memory pressure</li><li>Inactive client data doesn’t affect performance</li></ul><h4>Tradeoffs to Consider:</h4><p>This approach comes with some downsides:</p><ul><li>Just like in the deleted_at example, if the SQL query does not have a condition that uniquely defines a suitable index (e.g. WHERE client_id=1), then the index will be ignored when creating a query plan (i.e. it is useless).</li><li>You’ll need to <strong>create a new index</strong> for every new client, requiring extra app logic</li><li>The PostgreSQL planner incurs overhead by scanning many indexes to choose the best one. Hundreds or thousands of indexes are fine, but <strong>millions</strong> can hurt performance.</li></ul><p><a href="https://www.postgresql.org/docs/12/ddl-partitioning.html">Table partitioning</a> is another option, but it has limitations (like no global primary key) making it less ideal for user tables. But it works well for tables containing <a href="https://en.wikipedia.org/wiki/Time_series">Time-Series Data</a>.</p><h3>Can You Use a BTree Index for Name Search?</h3><p>Yes, with some caveats.</p><h4>Prefix Matching Only</h4><p>In most cases, users begin typing names from the start — not the middle — so full substring search isn’t always necessary. This allows us to use LIKE ‘search%’ instead of LIKE ‘%search%’ for both first and last names, which <em>can</em> leverage a BTree index. Since LIKE is case-sensitive and ILIKE can’t use BTree, we can normalize both the indexed fields and the query input (e.g., by converting to lowercase) and create a BTree index on those expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*ODPNmAF20qYcW4uZ" /></figure><p>Be sure to specify the varchar_pattern_ops operator class when creating the index — this is what enables LIKE ‘search%’ to actually use the BTree index. Without it, the query planner might ignore the index entirely.</p><p>As a result, the SQL query becomes a bit more complex:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*7OCYJmcRVpyTHD7i" /></figure><p>You will also have to complicate the code a little to construct such a query:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*Y8dbAf3BwCqnbeBl" /></figure><p>Let’s break down what’s happening here:</p><ul><li>Normalize the user input (lowercase, trim, replace commas, etc.)</li><li>Break the input into <strong>up to 5 words</strong></li><li>Build dynamic conditions:</li><li>If 1 word → match against <em>either</em> first or last name</li><li>If 2+ words → match across both fields</li></ul><p>Why limit to 5 terms? More than that in a name is uncommon and can slow down queries.</p><p>The query execution plan will be as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/0*kp0ZFGOtniOm2vgp" /><figcaption><strong>Query execution plan using Like</strong></figcaption></figure><p>This approach causes the database to scan each index separatel<strong>y</strong> and merge the results.</p><p>You can improve performance further by indexing the concatenated names instead of handling them separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/0*LlLj8pNA4yKZu9QN" /></figure><p>And your query becomes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/0*Rm25ascE3D4_BGT7" /></figure><p>The difference from the original query with concatenation is that we search from the beginning of the string, not in the middle.</p><p>The query execution plan will be almost identical to the previous one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/0*rOE28Qcm5Mo8oRUu" /><figcaption><strong>Query execution plan using BTree index</strong></figcaption></figure><p>Keep in mind: this approach searches for a match in the <em>combined</em> first and last name string (not in each field separately) so the results may differ. Be sure to normalize the search string to maintain consistency.</p><p>Since this is a standard BTree index, you can also include additional fields (like city, department, or user type) and apply conditions for a partial index (e.g. to exclude deleted or unverified users).</p><h3>Which Query Is Fastest? A Performance Comparison</h3><p>Let’s break down the performance of different search approaches by assigning them shorthand names for easy comparison:</p><p><strong>non-indexed ILIKE:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*d0_V9WMyEOoQRBxG" /></figure><p><strong>indexed ILIKE:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/0*pXs4zT38sHDmXtyQ" /></figure><p>Uses a trigram index. While the logic remains the same, the query runs faster thanks to index support:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*PjBaffBK7ijOQ6Bx" /></figure><p>Similarity (with sort):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/0*ekih3LUSH5FMBeEb" /></figure><p>Uses pg_trgm extension to sort results by similarity score and uses sorting by the distance between rows so that the results closest to the query text are at the top:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*LyI_mn0vLNttrCKZ" /></figure><p><strong>BTree 1: Index on individual fields:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/0*slWhy0anU8NwS9oV" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*74lUaoYExr4jBiVk" /></figure><p><strong>BTree 2: Index on concatenated fields:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*jm3k-pMxJj-4hCSn" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/0*SlQRoLArHNEPvmOY" /></figure><p><strong>Important:</strong> These queries return <em>different</em> results. For example, similarity and <strong>BTree 1</strong> may find names like <em>Johnny Johns</em> or <em>Johnpaul Johnson</em> for a search like “John”, while <strong>ILIKE</strong> and <strong>BTree 2</strong> may not. You’ll need to balance speed against result quality depending on your needs.</p><h3>Benchmark Results</h3><p>The table contains average results for “hot” queries on different numbers of records (cold starts, when it was necessary to read the index or table into memory, are discarded).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*tghdNNnNAGsIENwnUanEuQ.png" /></figure><h3><strong>Conclusions</strong></h3><p>Firstly, the numbers above confirm:</p><ol><li><strong>It works… until it doesn’t.<br></strong> In early development, even unoptimized queries perform well. During testing or with low data volume, performance may dip slightly but won’t raise alarms.</li><li><strong>Once the data grows, indexing becomes critical.<br></strong> As soon as you hit production and your user base (or dataset) expands, performance degradation becomes noticeable unless you’ve implemented proper indexes. The right index can dramatically improve speed.</li><li><strong>GIN indexes offer flexibility, but at a cost.<br></strong> GIN (Generalized Inverted Index) is great for advanced text search, such as partial matches, typo tolerance, or sorting by relevance. But that power comes with overhead: they’re typically slower than BTree indexes or optimized ILIKE queries, especially on large datasets.</li><li><strong>BTree wins on raw speed.<br></strong> For fast, predictable performance (especially with millions of records) BTree indexes are hard to beat. You might sacrifice some search “fuzziness” or flexibility, but the speed gains are worth it.</li><li><strong>There’s no one-size-fits-all.<br></strong> Smaller datasets (under a few hundred thousand rows) can benefit from flexible GIN or trigram-based searches. For larger datasets, prioritize efficient use of BTree indexes, consider partial indexes, and optimize query structure to scale with your data.</li></ol><p>Bottom line: You can absolutely achieve fast, responsive search at scale as long as you understand your indexing options and apply them wisely.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02c57eb27687" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your User Search Is Slow (and How to Fix It with PostgreSQL)]]></title>
            <link>https://medium.com/@saritasa/why-your-user-search-is-slow-and-how-to-fix-it-with-postgresql-6346a8d1d987?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6346a8d1d987</guid>
            <category><![CDATA[database-design]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[database-performance]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 16:22:01 GMT</pubDate>
            <atom:updated>2025-08-21T16:22:01.269Z</atom:updated>
            <content:encoded><![CDATA[<p>User search seems simple, until it isn’t. Searching by first and last name is one of those deceptively common tasks that can quickly become a performance nightmare as your dataset grows. In this article, we’ll explore the most common challenges developers run into when implementing name search in PostgreSQL, and walk through practical ways to fix them.</p><p>Let’s say you have a typical registration form in your mobile application, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/0*gSQWwc7TJehT7Uk-" /><figcaption><strong>Image 1 — Sample registration screen</strong></figcaption></figure><p>And now you need a search field that allows you to find users (or any information related to them — for example, event participation), by entering their first and/or last name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/0*DVQGauP56X7EtlT9" /><figcaption><strong>Image 2 — Search form by name</strong></figcaption></figure><p>Sounds easy enough. But there’s a lot of complexity hidden behind a seemingly “simple” feature.</p><p>This search needs to be dynamic and happen in real-time. It is even more seamless if it updates as the user types. Performance (and therefore speed) matters. That means your backend API has to respond quickly, even with partial user input.</p><p>Also, for simplicity’s sake, suppose that users are stored in the following table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/0*kSOevl0ZFiJtbpZP" /><figcaption><strong>Image 3: Sample User Table</strong></figcaption></figure><h3>Challenge #1: Users Are Human (And Behave Unpredictably)</h3><p>Unfortunately, humans and users are often one and the same (at least until our AI overlords take over). And humans are, by nature, unpredictable.</p><p>Your search logic might be clean. But your users will test it in ways you can’t imagine.</p><p>People search for names in all manner of interesting ways: first-last, last-first, all-caps, all lowercase, extra spaces, commas, typos, strange characters… you name it, and we’ve likely encountered it.</p><p>Someone might write in “ John Doe”, while another may paste in “Doe,John“ and expect a match.</p><p>The simplest solution is to write an SQL query (or use an ORM, which will generate a similar SQL query “under the hood”):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/0*pnRLJyfQznBLXEZe" /></figure><p>But a naive SQL query like that won’t cut it unless you normalize the input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/0*aj4WtHF4vzDJ5Ym3" /></figure><p>This strips out extra spaces, replaces commas with spaces (without mashing names together), and gives you a clean, predictable input.</p><p><strong><em>Pro Tip: normalize names on user registration too!</em></strong></p><p>For example, remove accidental spaces at the beginning and end, otherwise the search for a user saved as first_name=’John ‘, last_name=’ Doe’ will not work correctly.</p><p>Now, you can find “John Doe” will all the following inputs:</p><ul><li>‘Joh’</li><li>‘John’</li><li>‘John D’</li><li>‘John Do’</li><li>‘ JoHn DoE ‘</li><li>‘DOE jo’</li><li>‘Doe, JOHN’</li><li>‘Doe,John’</li><li>‘, Doe, John, ‘</li></ul><p>So what’s the next problem here? Let’s take a look under the hood at the SQL query execution plan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/0*jwPtdlxEEpzrQspi" /><figcaption><strong>Image 4— Query execution plan</strong></figcaption></figure><p>A full table scan. Every time.</p><h3>Challenge #2: Performance (or Lack Thereof)</h3><p>Scanning every record is fine, up until it’s not. If you have under 10k users, you are unlikely to notice a huge difference with an optimally indexed query. The same holds true if the overall dataset is large, but searches are segmented to a single group. For example, if you only search employees in departments with no more than a few thousand people.</p><p>But as your dataset grows, things can get sluggish fast. You can read more about <a href="https://medium.com/@saritasa/an-intro-to-optimizing-database-performance-8255ef44a2c5">how to optimize your database for performance in one of our previous articles</a>.</p><p>For the purposes of this piece, we’ll simply emphasize the importance of testing with realistic data. Use real-world-sized datasets or generate diverse fake ones (not just user1, user2). Most modern frameworks have you covered (Laravel Factories, Faker, etc) here.</p><h3>Challenge #3: Identifying the Right Index</h3><p>Unfortunately, indexing the first name and last name separately won’t help much here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/0*4AFljjoRKgDMBcGW" /></figure><p>Why?</p><p>Because pattern-matching queries such as LIKE ‘%query%’ and especially ILIKE ‘%query%’ can’t take advantage of standard BTree indexes. The only scenario where BTree helps is LIKE ‘query%’ (case-sensitive, prefix search). But as soon as you need case-insensitive or mid-string matching, those indexes are useless.</p><p>When you’re working with a single text field and need substring matching, the usual answer is a full-text index. But in our case, we have two fields. So, to simplify the problem, we can combine them — say, by creating a TSVECTOR column that merges first_name and last_name, either via a trigger or a computed column, and then index that.</p><p>At first glance, that seems like a solid solution. But full-text search indexes are optimized for <em>words</em>, not substrings. They tokenize and stem text, meaning a search for “Jo” won’t match “John” because the token is “John”and the search term doesn’t match the full word. That makes full-text search poorly suited for autocomplete or partial name matching. It also tends to struggle with names in different languages from the one used for indexing.</p><p>So what’s the better solution?</p><p>Now it’s time to go beyond the basics.</p><p>In Part 2, we’ll dive into PostgreSQL’s advanced indexing options, like trigram search with pg_trgm, combining filters with btree_gin, optimizing for multi-tenant setups, and actual benchmark data to show what really performs best at scale.</p><h3><strong>TL;DR</strong></h3><ul><li>Name search seems simple — but unpredictable user input and growing datasets introduce surprising complexity.</li><li>Normalizing user input is essential to handle typos, weird spacing, and inconsistent formatting.</li><li>Basic indexing (e.g. on first_name and last_name separately) won’t help when using ILIKE or wildcard search.</li><li>Full-text search has limitations for name matching, especially for partial inputs.</li><li>The real solution lies in smarter indexing strategies.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6346a8d1d987" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Added Offline Sync to a Mobile App — Without Breaking Everything]]></title>
            <link>https://medium.com/@saritasa/how-we-added-offline-sync-to-a-mobile-app-without-breaking-everything-1b739c23a23b?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b739c23a23b</guid>
            <category><![CDATA[database-development]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[realm-database]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 29 May 2025 19:02:28 GMT</pubDate>
            <atom:updated>2025-05-29T19:02:28.250Z</atom:updated>
            <content:encoded><![CDATA[<h3>How We Added Offline Sync to a Mobile App — Without Breaking Everything</h3><p><em>Written by Anna Lazareva, Technical Project Manager at </em><a href="https://www.saritasa.com/?utm_source=medium&amp;utm_medium=dev_blog&amp;utm_campaign=offline_mode_article"><em>Saritasa</em></a></p><p>Users expect apps to “just work,” whether they are in a field in the middle of nowhere, on a plane, or somewhere in between.</p><p>One of our recent projects required just that: seamless operation both online and offline. The challenge in this particular case was adding offline support to an existing <a href="https://www.saritasa.com/mobile-app-development?utm_source=medium&amp;utm_medium=dev_blog&amp;utm_campaign=offline_mode_article">mobile app</a> that was originally built to assume a stable internet connection. So we approached from a different angle: we needed to remove the user’s dependence on the quality of the internet connection.</p><p>Here’s how we made that happen in an iOS app, starting from intercepting failed network calls to handling sync conflicts across devices.</p><h3>Step 1: Handling Connection Errors</h3><p>Originally, the app followed a straightforward flow:</p><ol><li>User triggers an action</li><li>Data is sent to the server</li><li>If successful, it’s saved locally and the user is notified</li></ol><p>But, if the internet connection dropped, nothing got saved and the user saw an error. Not exactly ideal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HYoGOHhMxv7fAoOf" /><figcaption>Image 1 — Server connection error handling scheme</figcaption></figure><p><strong>The fix:</strong> Catch connection errors in the API layer and route them to a special offline handler. Instead of showing an error, we save the request data locally. For the user, everything still feels smooth, even if the internet is out.</p><h3>Step 2: Storing Objects + Change Metadata Locally</h3><p>Sounds nice and simple.</p><p>Just save the data to the local database. But with Realm (the database for this project) and a Domain Driven Design (DDD) architecture (which allows us to fine-tune each object to our needs), things get… interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZbpNDIM3Kn8jc_eS" /><figcaption>Image 2 — Object mapping diagram</figcaption></figure><h3>Troubleshooting Realm</h3><p><a href="https://en.wikipedia.org/wiki/Realm_(database)">Realm</a> doesn’t let you update an object’s primary key. Originally, we used the server-provided ID as the primary key. But an offline-created object wouldn’t have that ID yet — we’d need to generate one locally.</p><p>There were a few options going forward:</p><ul><li><strong>Use a non-primary ID field</strong>. But then we lose Realm’s indexing and conflict resolution benefits. We wrote this off right away.</li><li><strong>Track two IDs (local and server)</strong>. At first glance it sounds fine, until you’re debugging mixed-up keys. So that was out.</li><li><strong>Create the object locally with a temporary localID.</strong> After syncing, delete it and replace it with the server version. This is what we went with.</li></ul><p>It took a little more work, but has much less risk of corruption or key collisions. And it leads to another question: how long does it take for all this to work? Remember, we don’t want the user to feel any impact.</p><h3>Step 3: Syncing with the Server (When Internet Returns)</h3><p>Our app deals with a lot of data, and checking every object to see what changed would be painfully slow.</p><h4>Enter: LocalUpdateModel</h4><p>To simplify this labor-intensive operation, we introduced a new object that is stored in the database and contains information about the changes made by the user.</p><p>This lightweight tracking model, <strong>LocalUpdateModel</strong>, has three parameters:</p><pre>LocalUpdateModel(<br>  id: note.Id,<br>  entityType: .note,<br>  changeType: .created // or .updated / .deleted<br>)</pre><p>Every local change creates or updates one of these models. That way, when connectivity returns, we know exactly what needs syncing.</p><h3>What About Syncing Multiple Devices in Offline Mode?</h3><p>Things get trickier when users are logged into multiple devices. Any of them could update or delete the same data.</p><p>So, we created a hierarchy of dependencies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*REHLIYER4uLDw3ga" /><figcaption>Image 3 — Object hierarchy diagram</figcaption></figure><p>When syncing, we go top-down:</p><ol><li>Sync account-level data</li><li>Sync each profile, unless deleted</li><li>Then sync the data within each profile (which can be parallelized across threads).</li></ol><p>We follow a strict order of operations:</p><p><strong><em>DELETE -&gt; CREATE -&gt; UPDATE</em></strong></p><h4>DELETE</h4><p>Once reconnected to Internet, we:</p><ul><li>Pull the full object list from the server.</li><li>Use <strong>LocalUpdateModel</strong> to identify objects deleted locally.</li><li>Confirm they still exist on the server</li><li>Send delete requests.</li></ul><p>Next, we check to see whether objects were deleted on other devices while we were offline. To do so, we:</p><ul><li>Compare the full local and server object lists.</li><li>Delete any local objects that are missing from the server because they were deleted from another device.</li></ul><h4>CREATE</h4><p>In this next stage, we:</p><ul><li>Find all locally created objects using <strong>LocalUpdateModel</strong></li><li>Sent them to the server</li><li>On, replace each one with a fresh server-synced version (with the new ID).</li><li>Pull in any new server-side objects to the local database that were added while offline.</li></ul><h4>UPDATE</h4><ul><li>Compare <strong>modifiedAt </strong>timestamps on each object</li><li>Whichever version is newer (local or server) “wins”</li><li>Use ID-keyed dictionaries for fast lookups during comparison</li></ul><p>At the end of this process, users see a notification that their sync was successful. And, most importantly, their data is safe and up to date.</p><h3>Handling Conflicts Between Multiple Offline Devices</h3><p>Let’s say two devices are offline.</p><p>Device A deletes a profile.</p><p>Device B updates data for that profile.</p><p>Device A reconnects to the internet first, so the profile is deleted on the server. When Device B reconnects later, it will receive information that the profile no longer exists, and the local changes won’t be transferred to the server.</p><p>However, if Device B reconnects first, then the changes to the data will be applied to the server, and then, when Device A connects, the profile will be deleted.</p><h4>Potential Resolutions:</h4><ol><li><strong>Manual conflict resolution:</strong> like GitHub merge conflicts, we could prompt the user to select between local and server data.</li><li><strong>Versioning system:</strong> Treat every change like a commit, with a full history and parent references. This is best if offline work is the primary use case, which is not the true for this application.</li><li><strong>Cloud sync proxy:</strong> Offload sync logic to a real-time service, like Firebase. This solves the data synchronization problem, but may involve additional cloud costs or limitations.</li></ol><p>These are all solid strategies, each with their own pros and cons. However, they add complexity and/or cost. The likelihood of this kind of conflict is fairly low in our client’s use case, so we stuck with the simplest solution: we notify the user of the conflict and let them choose.</p><h3>Lessons Learned: Consider Offline Functionality from the Beginning</h3><p>Designing an offline mode after the fact is not ideal. Many of these challenges could have been avoided if the application had been originally designed to work offline. Ideally, we would’ve had:</p><ul><li>An architecture prepared for intermittent connectivity.</li><li>A sync layer built into the app lifecycle</li><li>API endpoints design to support diffing, partial updates, and deleted by timestamp</li><li>A local DB schema that supports placeholder objects and merging.</li></ul><p>That said, our solution met all the client’s business goals, and delivered an offline mode that serves the users well. Thankfully, our team has plenty of experience <a href="https://www.saritasa.com/project-takeovers?utm_source=medium&amp;utm_medium=dev_blog&amp;utm_campaign=offline_mode_article">taking over projects</a> in all stages of development</p><p>Offline support should be considered from the beginning for most apps. It takes much more effort to add in later than if you build it in from day one.</p><p>Hopefully these lessons save you some pain in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b739c23a23b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our Recipe for Developing Good Automated Tests]]></title>
            <link>https://medium.com/@saritasa/our-recipe-for-developing-good-automated-tests-706f86b795ce?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/706f86b795ce</guid>
            <category><![CDATA[regression-testing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[qa-automation]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[qa-testing]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 08 May 2025 17:30:12 GMT</pubDate>
            <atom:updated>2025-05-14T20:38:37.660Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by Anton Oboleninov, Python Developer, &amp; Edited by </em><a href="https://www.linkedin.com/in/ron8mcr/"><em>Roman Gorbil</em></a><em>, Director of Python Department at </em><a href="https://www.saritasa.com/"><em>Saritasa</em></a></p><p>Testing a new version of an application prior to release is non-negotiable. With every release, there is the possibility of introducing bugs. New features must be tested, but existing functionality (regression testing) should be tested as well to be sure that issues were not introduced when new features were added. With each new release, new test cases (unit/functional) are added to your test suite. The bigger the test suite, the more time-consuming regression testing becomes. Eventually, your QA team becomes swamped with hundreds of manual tests. This delays releases and slows down product development.</p><p>One option is to reduce the number of tests run prior to release. Often a “Smoke Test” or Selective Test will be run just to ensure there are no obvious issues with core functionality. Obviously this has a serious downside in that if all tests are not run, a problem could slip by into the production release. Over time it becomes very difficult to run E2E testing prior to every release, simply because the testing process will take too long.</p><p>The answer of course, is Automated Testing. With automated testing, a large number of tests can be completed in a short period of time. This allows for the completion of a full E2E system test prior to the release of each new version of the application. But automation isn’t magic, it requires engineering. Building a reliable, maintainable automated test suite takes effort, planning, and the right tools. Here’s how we built ours.</p><h3>Choosing Which Tests to Automate</h3><p>Our QA goal is simple: make sure the app works as expected and meets client requirements. To do that, we need reliable, repeatable test cases for the entire system.</p><p>We chose Integration Regression Testing as the starting point for our automated tests. This process of manually testing the integration between client and server components was incredibly time-consuming and had a high risk of regressions, which made it the perfect testing ground to save time.</p><h3>Our Stack: PyTest, Selenium, and Qase.io</h3><h4>Why Pytest?</h4><p>Because Python is one of the most popular languages ​​for automated testing and we have an experienced team of <a href="https://www.saritasa.com/python-development">Python developers</a>. <a href="https://docs.pytest.org/en/8.0.x/index.html"><strong>Pytest</strong></a> has a simple and clear syntax and many plugins that facilitate testing, making it a perfect fit for our team.</p><h4>Why Selenium?</h4><p>We chose the Selenium<strong> </strong>framework for interacting with a browser. Selenium provides APIs in various programming languages, including Python which fit into our process nicely.</p><p>As an alternative to Selenium, we considered the increasingly popular <a href="https://playwright.dev/python/">Playwright</a>, but ultimately decided it wasn’t the best fit for our process. We found Playwright is great for getting started quickly with automated tests or automating a small amount of tests. However, when using Playwright for more complex interfaces, you need to develop additional interaction classes; these add another layer between the tests and the browser. Additionally, Playwright auto-generates Python code, which complicates debugging. Also one of our future goals is to set up test automation for mobile apps, and Playwright is only starting to support it.</p><h4>Other Tools</h4><p>We already had a well-established process for documenting testing using <a href="http://qase.io/">Qase.io</a> and had a decent pool of test cases that only needed to be automated.</p><h3>Page Object Model: The Foundation</h3><p>The modern standard for designing automated testing systems is to use<a href="https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/"> Page Object </a>Models. In a nutshell, Page Object Models involve separating application interaction logic from test logic. All operations with pages are concentrated in the classes for these pages. Tests only use the methods for the pages affected by the tests.</p><p>The first project we chose to develop automated tests included a number of complex components (logically related web elements). To make these easier to work with, we decomposed the page into a number of smaller classes. The page contains elements<strong> (</strong>simple HTML tags) and components <strong>(</strong>groups of HTML tags — dropdown, filter panel, etc.). Components can contain smaller sub-components and can be reused on several pages, which makes it easier to refactor the code in the future, and simplifies the page’s code.</p><p>We recently moved our basic implementation of the Page Object Model to the Open Source project — <a href="https://github.com/saritasa-nest/pomcorn"><strong>pomcorn</strong></a>. It can be used for automated tests, parsing, or any other automated work with the browser.</p><p><strong>Pomcorn </strong>class diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/0*XjI3ae3QwSWYKP--" /></figure><h3>Locators: Making XPath Less Painful</h3><p>To identify elements on the page, we developed a wrapper class named <strong>Locator </strong>for the <a href="https://www.selenium.dev/documentation/webdriver/elements/locators/#xpath">locators provided by the Selenium XPath</a>. We created the Locator wrapper class to avoid having to specify <a href="https://www.selenium.dev/documentation/webdriver/elements/locators/">the locator strategy</a> used each time and to reduce the amount of raw XPath used. Some autotest guides recommend avoiding XPath (ie: <a href="https://playwright.dev/docs/locators#locate-by-css-or-xpath">Playwright</a>). However, we found it is more flexible since it allows us to easily create nested locators (for this, we implemented the “/” and “//” operators). This is especially useful when the page contains a component with a list of complex subcomponents.</p><p>For example, the posts panel on our website <a href="http://saritasa.com/">saritasa.com</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e40dbc4QbuXlhN2-" /></figure><p>However, it consists of many child elements — posts. And to find a specific post item, we can extend the path:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xTdYiEXN_MGnjbtL" /></figure><p>This is how <a href="https://pomcorn.readthedocs.io/en/latest/locators.html">the Locator classes</a> we developed work. The element described above can be obtained using the following code:</p><pre>from pomcorn import locators<br>from selenium import webdriver<br><br>chrome = webdriver.Chrome()<br>chrome.get(&quot;https://www.saritasa.com/work/type-code-takeover&quot;)<br><br>posts_list_locator = locators.ClassLocator(class_name=&quot;posts&quot;, exact=True)<br>post_locator = posts_list_locator / locators.ClassLocator(”post-work-item”)<br><br>chrome.find_element(*post_locator)</pre><p>Component and element classes use locators to locate the parts of the interface they represent. So, a “posts list” component might look like this:</p><pre>from pomcorn import ListComponent, locators, Page<br><br>class Post(Component[Page]):…<br><br>  @property<br>  def title(self) -&gt; str: …<br><br>  def open(self) -&gt; PostDetailsPage: …<br><br>class PostsList(ListComponent[Post, Page]):<br><br>  base_locator = locators.ClassLocator(class_name=”posts”, exact=True)<br>  relative_item_locator = locators.ClassLocator(”post-work-item”)</pre><p><em>PostsList</em> is a component that allows us to work with a number of smaller components — Posts. This approach allows us to represent what we see on the site as locator-based python classes.</p><h3>SDK and Preparing Data</h3><p>When writing tests, we try to follow the <a href="https://automationpanda.com/2020/07/07/arrange-act-assert-a-pattern-for-writing-good-tests/">Arrange Act Assert </a>pattern. Often, the Assert step involves preparing data on the backend using the API. To abstract work with low-level http requests and their results, it is best to use a wrapper to convert data structures into higher-level objects. We decided to automatically generate the SDK based on the Swagger specification we had so as not to waste time on template code.</p><p>We settled on <a href="https://github.com/openapi-generators/openapi-python-client/">openapi-python-client</a> for an SDK generator since, unlike <a href="https://github.com/swagger-api/swagger-codegen">Swagger Generator</a> and other similar generators, it is tailored for Python and supports typing in auto-generated code.</p><p>To avoid copy-pasting the same code over and over again, we placed calls to SDK methods for creating and deleting objects in function-based factories. We saw a number of advantages in this approach, and based on this, we would not recommend even looking at a regular <a href="https://factoryboy.readthedocs.io/en/stable/">factory boy</a>:</p><ul><li>Auto-suggestions for mandatory arguments;</li><li>Type hints;</li><li>Explicit tear downs — we return the created object via yield, and after the test is completed, a request is made to delete this object.</li></ul><p>The final key component of data pre-preparation is <a href="https://docs.pytest.org/en/6.2.x/fixture.html">fixtures</a>. We use fixtures for all data pre-preparation:</p><ul><li>Creating/deleting unnecessary/editing objects</li><li>Pre-configuring the system via API</li><li>Opening the required page</li><li>Obtaining environment variables</li></ul><p>We also often use <a href="https://docs.pytest.org/en/7.3.x/how-to/parametrize.html">the parameterization feature</a> built into pytest, which allows us to avoid duplicating code for similar tests by defining groups of parameters for which the test will be executed.</p><h3>Test creation process</h3><p>Let us take a look at our workflow for writing autotests using an example. You can find a detailed tutorial on starting autotests in <a href="https://pomcorn.readthedocs.io/en/latest/demo.html">the documentation</a> for our <a href="https://github.com/saritasa-nest/pomcorn"><strong>pomcorn</strong></a><strong> </strong>library.</p><p><strong>Webdriver</strong></p><p>Before you start writing tests, you need to choose and configure browsers/webdrivers. You can read about webdriver settings <a href="https://www.selenium.dev/documentation/webdriver/drivers/options/">here</a>. In our projects, we use an approach similar to <a href="https://github.com/pytest-dev/pytest-splinter/blob/1b0aa1efaec40919d79d424bb6d5c418925f2ad6/pytest_splinter/plugin.py#L499">the browser instance getter</a> from pytest-splinter. In this article, we will use the Chrome() webdriver provided by Selenium as our example.</p><p>To create a webdriver fixture that will open a browser, navigate to the web application we are testing, and log in to it:</p><pre>from selenium import webdriver as selenium_webdrver<br>from selenium.webdriver.remote.webdriver import WebDriver<br>from openapi_sdk import models<br><br>import pytest<br><br>from api_factories import utils<br>from pages.auth.sign_in_page import SignInPage<br><br>@pytest.fixture(scope=”session”)<br>def admin_webdriver(session_admin: models.User) -&gt; WebDriver:<br>  &quot;&quot;&quot;Initialize webdriver for logged-in admin session.”””<br>  webdriver = selenium_webdrver.Chrome()<br>  email = session_admin.email<br>  password = utils.get_user_password(email)<br>  sign_in_page = SignInPage.open(webdriver)<br>  sign_in_page.sign_in(email=email, password=password)<br><br>  return webdriver</pre><p>We should point out that we made this fixture session-based (scope=”session”), i.e. the browser can be opened only once during the entire test session. Some guides strictly insist that tests should be maximally isolated and a new browser should be used for each test. This approach avoids the influence of one test on another. However, this approach offers poor performance because each test has to wait for a new browser to open and to log in to the site. We decided that a session browser is a simple and safe way to speed up the tests. The issue of one test affecting another can be resolved by building the correct architecture of tests and teardowns in fixtures that pre-prepare data, change application or browser settings.</p><h3><strong>Page: Interacting with the Browser</strong></h3><p>After defining the webdriver, we create a page class that defines all the methods, components, and properties needed for the test. For example, let’s look at the authorization page class of one of our projects:</p><pre>from __future__ import annotations<br><br>from pomcorn import locators<br><br>from pages.base_page import Page<br>from pages.auth.forms.login_form import LoginForm<br><br>class LoginPage(Page):<br><br>def check_page_is_loaded(self) -&gt; bool:<br>  return self.init_element(<br>    locator=locators.ElementWithTextLocator(“Sign In”),<br>  ).is_displayed<br><br>@property<br>def login_form(self) -&gt; LoginForm:<br>  return LoginForm(<br>    page=self,<br>    base_locator=locators.ClassLocator(“auth-form”),<br>  )<br><br>def login(self, email: str, password: str):<br>  return self.login_form.login(email=email, password=password)</pre><p>Let’s see what’s defined here: The <strong>check_page_is_loaded</strong> method is responsible for checking whether the page is fully loaded. Here we define the condition by which we will consider the page fully loaded. In this case, it is displaying an element with the text “Sign In”.</p><p>This method is used in the base <a href="https://pomcorn.readthedocs.io/en/latest/demo.html#base-page"><strong>Page</strong></a><strong> </strong>class from our <a href="https://github.com/saritasa-nest/pomcorn"><strong>pomcorn</strong></a><strong> </strong>package, in the <strong>wait_until_loaded method</strong> called during object initialization, which, as the name suggests, waits for the page to fully load. You have to be sure that when accessing the page object, it will definitely be loaded. This eliminates errors that could occur due to the fact that some part of the page has not had time to load.</p><p>The base <a href="https://pomcorn.readthedocs.io/en/latest/demo.html#base-page"><strong>Page</strong></a><strong> </strong>class also implements other methods that are inherent in all pages. For example, <a href="https://pomcorn.readthedocs.io/en/latest/developer_interface.html#pomcorn.page.Page.open"><strong>open</strong></a><strong> </strong>and <a href="https://pomcorn.readthedocs.io/en/latest/developer_interface.html#pomcorn.page.Page.refresh"><strong>refresh</strong></a>.</p><p>The <strong>login_form</strong> property returns the <strong>LoginForm </strong>component to us, representing a group of elements that make up the login form (<strong>email</strong> and <strong>password </strong>fields, <strong>login </strong>button), and also implementing methods for interacting with them. You can read more about the components <a href="https://pomcorn.readthedocs.io/en/latest/objects_hierarchy.html#component-classes">here</a>.</p><p>The <strong>login </strong>method is a shortcut for the authorization form, calling the <strong>login </strong>method, which fills in the <strong>email </strong>and <strong>password </strong>fields, and then clicks the <strong>login </strong>button.</p><p>We recommend using fixtures to open pages. This approach allows you to reduce the test body, reuse the fixture in the future, and determine when listing fixtures at what point in the data preparation this page should be opened. Example below:</p><pre>import pytest<br>from selenium.webdriver.remote.webdriver import WebDriver<br><br>from pages.auth.login_page import LoginPage<br><br>@pytest.fixture<br>def login_page(admin_webdriver: WebDriver) -&gt; LoginPage:<br>  &quot;&quot;&quot;Open login page and return instance of it.”””<br>  return LoginPage.open(admin_webdriver)</pre><h3><strong>Writing the Test</strong></h3><p>With all the preparations done, we can take a final look at the test case…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/0*9cKGpCx-7Lcii__6" /></figure><p>… and write a concise and readable test:</p><pre>def test_sign_in_inactive_user(<br>  inactive_user: sdk_models.User,<br>  login_page: LoginPage,<br> ):<br>  login_page.login(<br>    email=inactive_user.email,<br>    password=utils.get_user_password(inactive_user.email),<br>  )<br>  login_page.unable_to_log_in_msg.wait_until_visible()</pre><p>The final step is to mark the test with a link to the test case in <a href="https://app.qase.io/">Qase.io</a>. For this, we use the <a href="https://github.com/saritasa-nest/pytest-qaseio"><strong>pytest-qaseio</strong></a> plugin we developed.</p><pre>@pytest.mark.qase(“https://app.qase.io/case/DEMO-11&quot;)<br>def test_sign_in_inactive_user(<br>  inactive_user: sdk_models.User,<br>  login_page: LoginPage,<br>):<br><br>  login_page.login(<br>    email=inactive_user.email,<br>    password=utils.get_user_password(inactive_user.email),<br>  )<br>  login_page.unable_to_log_in_msg.wait_until_visible()</pre><p>Using the plugin, we can save the results of running automated test cases in <a href="http://qase.io/">Qase.io</a> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ocOy4n-n9wOI5yXQ" /></figure><h3>Conclusion</h3><p>We hope that you have found this article interesting and useful. For the sake of brevity, we omitted a lot of nuances associated with developing automated tests, such as:</p><ul><li>Optimization</li><li>Caching</li><li>Fighting flaky tests</li><li>Organizing CI/CD</li><li>Pre-preparing related objects</li><li>And other fun stuff</li></ul><p>We plan to post more in the future to share some ways we deal with these issues. Hopefully, we have helped you by sharing our process and empowered you to learn more from our process and experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=706f86b795ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vibe Coding Is a Vibe… Until It Isn’t]]></title>
            <link>https://medium.com/@saritasa/vibe-coding-is-a-vibe-until-it-isnt-956d386acddc?source=rss-20ff800a666f------2</link>
            <guid isPermaLink="false">https://medium.com/p/956d386acddc</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[Saritasa]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 16:14:23 GMT</pubDate>
            <atom:updated>2025-04-24T16:15:58.360Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by </em><a href="https://www.linkedin.com/in/antzimin/"><em>Anton Zimin</em></a><em>, Development Manager at </em><a href="https://www.saritasa.com/?utm_source=medium&amp;utm_medium=dev_blog&amp;utm_campaign=vibe_coding"><em>Saritasa</em></a></p><p>TLDR: I tried “vibe coding” using Cursor and Microsoft Copilot. In five hours, I created a semi-functional file search app… and then watched it slowly collapse under its own weight. AI was helpful, frustrating, surprising, and occasionally catastrophic. If you’re building something throwaway or exploratory, vibe coding is fun. If you want something stable, maintainable, or efficient, bring a developer.</p><figure><img alt="Illustration generated by Microsoft Copilot" src="https://cdn-images-1.medium.com/max/512/1*C25EvXdf5sMi1kFbidDumQ.png" /><figcaption>Illustration generated by Microsoft Copilot</figcaption></figure><p>Recently, I stumbled across the term <strong>“vibe coding”</strong>, where people prompt an AI to build an application through conversational back-and-forth. I was skeptical. But curiosity got the better of me, so I decided to give it a try.</p><h3>Hour 1: Establishing the Vibe</h3><p>I installed the Cursor editor. I was pleasantly surprised because sometimes hyped-up programming tools do not support Windows. The editor suggested opening a folder or cloning a repository from GitHub. Since there was no New Project menu item, I created an empty repository. I authenticated Cursor in GitHub, giving it access to my public and private repositories.</p><p>I asked Cursor to clone my repository, but it did not work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*206EHW5r4QCBxL7n2sc_xA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*I77ljCndAXjNXsjglQ9g6A.png" /></figure><p>After several attempts, I switched to another tool to clone the repository. I opened the folder in Cursor and entered my first prompt in the chat:</p><blockquote>Create desktop app for Windows. It should have 1 window. The window has a search text box and a list of items. The search text box allows me to enter a search term. The list will show a list of files under D:\Work\Cursor\cursor-test that have the word. The search must be instant.</blockquote><p>Cursor decided to use <a href="https://www.saritasa.com/python-development">Python</a> with the Tk GUI toolkit. The app did not support Python 2, so I installed Python 3 and started the program:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtPN1exQr0XxKwESTK_8KA.png" /></figure><p>It worked from the first attempt and took me only 14 minutes to create.</p><p>I submitted the next request:</p><blockquote>When I select a file on the list, show its content on a text area on the right.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KP3O7N_rnAoBFQj4" /></figure><p>However, I noticed that sometimes the app freezes. I used several prompts to resolve the issue.</p><blockquote>It worked 1 time but then I selected another file and the window got frozen.</blockquote><blockquote>It’s still freezing sometimes. I did not change the dir, I just edited search term many times. It’s completely frozen. I don’t think it’s reading any file.</blockquote><blockquote>Sometimes the window becomes unresponsive while I’m typing. Then it unfreezes after several seconds.</blockquote><blockquote>The window is freezing when I select files while the search is still running in a large dir.</blockquote><p>Eventually, I gave up and moved on.</p><p>I asked Cursor to add more UI elements:</p><ul><li>a directory selector</li><li>“Reveal in File Explorer” context menu item.</li></ul><p>Cursor introduced a file to store the app settings.</p><p>I played with the app for some time and noticed serious performance issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RUmwwXDPYF3qXYvB" /></figure><blockquote>The app consumes 14 GiB of RAM. Is it normal?</blockquote><p>Cursor pleasantly surprised me by making some really smart changes to skip large files and limit the number of results. It improved the performance and memory usage. The app was pretty stable. It took 35 minutes to build it.</p><p>Impressed, I decided to test the limits of my new application. I spent 7 minutes adding line numbers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U-exntYip2X33Ycv" /></figure><p>That’s when I noticed a relatively minor issue — the list on the left lost selection when the text area was focused. I asked Cursor to fix it. The editor gave me the correct solution after 8 tries:</p><blockquote>When I select text on the text area on the right, selection disappears from the left list.</blockquote><blockquote>I can’t select anything in the text area anymore</blockquote><blockquote>No, it does not work.</blockquote><blockquote>The list on the left loses selection again.</blockquote><blockquote>No, it does not work.</blockquote><blockquote>It sort of works by blocking the first attempt to select text. However, on the second attempt I can select text but the list loses selection.</blockquote><blockquote>The list still loses selection.</blockquote><blockquote>It does not work</blockquote><blockquote>Yes, it works.</blockquote><p>I wanted to push further. I asked for file icons like those in Windows Explorer. Cursor understood the assignment and used the WinAPI and <a href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shgetfileinfoa">SHGetFileInfo</a>. Unfortunately, the icons didn’t display, and file preview broke.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y2pojm8m2PbeTFmB" /></figure><h3>Second Hour: Bugs, Bugs Everywhere</h3><p>One problem spawned another. The chatbot threw fix after fix at the wall. Most didn’t stick.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HL9t2GIqjD2pfbt4" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/0*OrLgl9CBVKqEG9bs" /></figure><p>After 28 minutes and 17 prompts, file preview returned. Line numbers? Gone again.</p><p>I started working on the line numbers again — a feature that I had 50 minutes ago. Cursor suddenly deleted the requirements.txt file but tried to convince me that it did not do it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/0*xnJfmIxDIcQvoKqR" /></figure><p>Obviously, the restored version was incorrect. The AI created it from scratch.</p><p>Sometimes the app was showing runtime errors, sometimes features were silently broken. Cursor regularly generates programs that can’t even start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*anOv4m3bPXhU-UJT" /></figure><h3>Hour 3: Much Worse than a Junior Dev</h3><p>Cursor began to behave like an overwhelmed intern. It suggested irrelevant APIs, broke existing features, and confidently issued incorrect commands like: <em>git show 4ecdd19d6d97ffe40af9ec974f68edae43cda081 | cat</em> (which doesn’t work on Windows).</p><p>Eventually, I restored a working version myself and asked the editor to compare the changes. Eventually, Cursor generated a version that added floating line numbers in the <em>center</em> of the text area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gl7wopuL9zRWcgEN" /></figure><p>The editor fixed the issue. I lost 1 hour 20 minutes. The icons feature did not work, but at least I was able to restore the previous state.</p><p>I started a new chat and explained the requirements again.</p><blockquote>The app should display file content in the text area when I select a file from the list.</blockquote><p>Cursor had a bright idea to use <a href="https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shfileinfoa">SHFILEINFO</a> structure.</p><p>It did not work though. Icons were still not shown.</p><p>I realized that the AI chatbot would never be able to fix the issue. It was trained on LeetCode, typical web applications, and useless pet projects. Normally people generate a Flappy Bird, Snake, 2048, or a similar simple game. However, the chatbot can’t generate working WinAPI code for Python.</p><p>I can’t blame it. Python is not the most efficient instrument for this task. Its dynamically typed nature makes it extremely difficult to develop and debug applications using the low-level SDK. A strongly typed language like Rust, C++, C#, or Java would be a better choice.</p><p>I don’t expect Claude, ChatGPT, or anything else to improve their WinAPI skills anytime soon. The tools are designed to generate quick and dirty HTML, TypeScript, Python, and Swift.</p><p>I asked Cursor to delete everything related to icons. I lost faith in it. Should I mention that the editor broke my app again?</p><p>I wrote 55 requests, spent 1 hour 40 minutes and achieved nothing. Every response was taking ~20 seconds. It was like a 90’s PC when you needed to wait for the computer to think after every click.</p><p>My vibe coding session was not vibing, so I wanted to relax a bit. I asked Cursor to generate a search animation for Gen Z based on Subway Surfers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*OH94PmN-xhudnOh8" /></figure><p>Cursor generated a bunch of statements to animate shapes on a canvas. It’s impressive but completely worthless.</p><h3>Hour 4: Continuing to Debug</h3><p>I spent a significant amount of time restoring features broken during the “vibe coding” sessions. Various UI components randomly stopped working. I believe the chatbot writes a new version code every time and some lines can be easily lost or replaced.</p><p>The Select Directory dialog was suddenly replaced with a menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/0*PBvr0YSuQ0K1vvUB" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HqfwKKMxBAI_AuG-" /></figure><p>I did not ask for these changes.</p><h3>Hour 5: Pay to Play</h3><p>Cursor removed or corrupted my LICENSE and README.md files many times. I know that I can open every file and accept or reject changes, but it violates the vibe coding approach.</p><p>Every time I asked to restore a damaged file, the chatbot created brand-new content.</p><p>I was begging Cursor to restore my files when it notified me that it was time to pay:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/0*V7veuIDQ7cx344Fl" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DUJzlYzRVoX_-7b-" /></figure><p>It took me less than 1 workday to exceed the limits of the free plan. I paid $20 for the subscription, reviewed my list of models (Claude 3.7 Sonnet, ChatGPT 4o), and continued working on small changes.</p><p>Cursor Pro uses the same models as the free plan. I did not notice any speed or quality improvements.</p><p>It uses regular LLM models that can flop on a simple question:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*OU1WGcMGmw1zLj4R" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/0*juxubRfxJ2zgCS8V" /></figure><p>Soon my vibe was finally killed — Cursor’s backend died.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*SohW9Z1CLd4-F9UP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SlnuENYFzf-mXr2Q" /></figure><h3>Hour ?: Thinking Mode</h3><p>I asked Cursor to generate a file structure to build a Debian package. As usual, it tried but failed miserably.</p><p>You can specify which model to use in Cursor. I have been using Auto mode until now, but I decided to try Claude 3 Opus — the ultimate thinking machine. It was so expensive that Cursor used to provide only 3 requests per day back in April 2024.</p><p><em>“Claude 3 Opus is our most intelligent model, with best-in-market performance on highly complex tasks”</em> — Antrophic.</p><p>I turned on the claude-3-opus switch and asked it to fix the mess created by its fellow peers. It started to think, showing me the whole process. It was painful to watch — the bot was dropping one word every second. After over a minute of thinking Opus deleted my copyright and changelog files, and corrupted setup.py.</p><p>I tried the o1-mini model as well. It took over 2 minutes to respond.</p><p>It generated a long list of changes but Cursor was unable to apply them.</p><p>I shared the explanation by o1-mini with the regular bot:</p><blockquote>Can you use entry_points in setup.py and erevert debian/rules to its standard configuration? Also, remove tkinter from setup.py because it can’t be installed via pip.</blockquote><p>However, it did not help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p6WTYaP7Wqh3GdGW" /></figure><h3>Hour: Too Many, I Cheated</h3><p>My package build ran into a snag. The last resort was to start reading the <a href="https://wiki.debian.org/Python/Pybuild">Pybuild </a>documentation. I experimented for a while and gave instructions to Cursor:</p><blockquote>dpkg-buildpackage does not work with the shebang.</blockquote><p>It helped. After several iterations I was able to build a deb package (non-working of course).</p><p>The further editing was painful as always. Sometimes Cursor acted modest and asked for permission to remove a file, but most of the time it silently removed necessary files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/0*1JZCkeKN5x6M9ARG" /></figure><p>At some point Cursor confessed that it’s too difficult for it to create a file without a trailing space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/0*1UhXlJKs0aPJlpy5" /></figure><p>Finally I was able to publish the package to Launchpad. It took about 3 hours and over 30 prompts. One serial entrepreneur claims that an AI agent created a complex multi-player videogame for him for a comparable amount of time.</p><p>You can try to install the program on Ubuntu or Debian:</p><blockquote># Download the public key and register the PPA.</blockquote><blockquote>gpg — recv-keys — keyserver keyserver.ubuntu.com 69D3D10EFBE95AFB</blockquote><blockquote>gpg — export 69D3D10EFBE95AFB | sudo tee /etc/apt/keyrings/antonziminsaritasa2025.gpg</blockquote><blockquote>echo “deb [signed-by=/etc/apt/keyrings/antonziminsaritasa2025.gpg] <a href="https://ppa.launchpadcontent.net/antonziminsaritasa/cursor/ubuntu">https://ppa.launchpadcontent.net/antonziminsaritasa/cursor/ubuntu</a> noble main” | sudo tee /etc/apt/sources.list.d/antonziminsaritasa-ubuntu-cursor-noble.list</blockquote><blockquote>sudo apt update</blockquote><blockquote>sudo apt install buzzkill-search</blockquote><blockquote>buzzkill-search</blockquote><p>You can also follow the <a href="https://github.com/AntonZiminSaritasa/buzzkill-search/tree/master?tab=readme-ov-file#installation">instructions</a> to run the <a href="https://github.com/AntonZiminSaritasa/buzzkill-search/blob/master/buzzkill_search/buzzkill_search.py">script</a> using Python 3 on Windows or Linux.</p><blockquote>python3 buzzkill_search.py</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sDwK5f7rgAYQBeST" /></figure><p>The program searches files by name and content and displays them in the preview area.</p><p>Unfortunately, I can’t edit anything anymore. A minor change in one file causes <a href="https://github.com/AntonZiminSaritasa/buzzkill-search/pull/3">total regeneration of others</a>. The quality of the code is questionable. If I ask a programmer to support it, he would politely suggest <a href="https://www.saritasa.com/project-takeovers">rewriting everything</a>. The chatbot put everything into a single file and did not create any tests.</p><p>You can find all generated source code and <a href="https://github.com/AntonZiminSaritasa/buzzkill-search/blob/master/prompts.md">195 prompts</a> in the <a href="https://github.com/AntonZiminSaritasa/buzzkill-search">GitHub repository</a>.</p><h3>Final Thoughts</h3><p>Cursor, Copilot, and other AI are useful helpers at work, school, and home. They help us to search information faster, study new languages, and solve programming problems. Cursor is a wonderful editor that can help build things faster if you know what you’re doing.</p><p>However, we need to understand the limitations of the tools. I submitted over 200 “fast requests” to the LLMs within 2 workdays.</p><p>That’s 40% of Cursor Pro’s monthly limit. Every LLM has a context window. It’s 128k for GPT-4 and 200k for Claude 3.7 — pretty small numbers.</p><p>My tiny single file project requires over 40,000 tokens just for the file content. That means a chatbot can’t work with any commercial-grade project without quality compromises. Gemini 1.5 Pro can hold up to 1 million tokens but I did not get a chance to work with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*LG1i4rEP-sGx38pE" /></figure><p>All this to say, I don’t believe that vibe coding is viable at this moment. A chatbot needs a small context to work in. Otherwise, it recreates all files every time and breaks the entire program.</p><p>Some experts say vibe coding is designed for “weekend projects” and bored hobbyists. I would recommend you stay away from this approach if you want to keep your weekends pleasant.</p><p>I’ll continue testing the rapidly evolving AI instruments and I’m looking forward to writing an updated article in 2026.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=956d386acddc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>