<?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 Sidelnykov Valery on Medium]]></title>
        <description><![CDATA[Stories by Sidelnykov Valery on Medium]]></description>
        <link>https://medium.com/@sidelnykovvalery?source=rss-f423ff184e50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VBMXGk1CfnXxN4Hj3UdAZA.jpeg</url>
            <title>Stories by Sidelnykov Valery on Medium</title>
            <link>https://medium.com/@sidelnykovvalery?source=rss-f423ff184e50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 06:18:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sidelnykovvalery/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 Couldn’t Review AI at This Speed. So I Changed How I Engineer.]]></title>
            <link>https://medium.com/@sidelnykovvalery/i-couldnt-review-ai-at-this-speed-so-i-changed-how-i-engineer-45a448f3b04a?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/45a448f3b04a</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai-governance]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 17:41:00 GMT</pubDate>
            <atom:updated>2026-11-15T17:41:00.763Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*SHSD_88dV4jDHAMJhXMLdg.png" /></figure><p><em>How AI is changing the role of a Staff Engineer — from reviewing every implementation to building systems that scale engineering judgment.</em></p><p>There is a particular kind of engineering fatigue that comes from opening your tenth pull request of the day, seeing another 1,200 lines of generated code, and realizing that you are still expected to understand all of it.</p><p>Now imagine that five developers are working with AI agents, each producing code at a speed that would have seemed ridiculous just a year ago.</p><p>Welcome to my recent experience as a Staff Engineer.</p><p>And no, the solution wasn’t to drink more coffee.</p><p>It was to rethink how I approach engineering.</p><h3>1. My job was never just about writing code</h3><p>As a Staff Engineer working across frontend engineering, my responsibilities are quite different from those of someone delivering features within a single application.</p><p>I’m usually introducing new libraries, frameworks, SDKs and platforms that become foundations for multiple products and engineering teams.</p><p>I build the initial implementations, establish architectural patterns, introduce governance, create contribution guidelines and demonstrate paved roads that help other engineers adopt these technologies.</p><p>For example, last year my team spent around six months building a data visualization platform. More than ten engineers contributed to three core libraries, which now power fifteen applications.</p><p>This kind of work comes with a particular responsibility.</p><p>When you introduce a new library, you’re not just delivering a collection of components. You’re introducing decisions that other developers will inherit.</p><p>A questionable abstraction can become technical debt across fifteen applications. An inconsistent API can become fifteen different interpretations of how something should work.</p><p>And that’s why I’ve traditionally been quite hands-on.</p><p>I like understanding the architecture, challenging abstractions, reviewing implementations and making sure that what we’re introducing is maintainable, modular and genuinely useful.</p><p>I tend to trust proven patterns over inventing something new just because we can. If MUI already solves a problem elegantly, perhaps we don’t need another abstraction with three additional layers of configuration.</p><p>This approach worked reasonably well in the pre-AI world.</p><p>Then the volume of engineering output changed.</p><h3>2. AI made implementation faster. Reviewing it became my full-time job.</h3><p>Let’s look at what we were actually building.</p><p>The first generation of our visualization platform was a major engineering initiative. We introduced three new libraries and used them to transform a large legacy application into fifteen separate applications. This gave multiple feature teams the independence to develop and evolve their products without being blocked by one huge application.</p><p>It was a substantial architectural step forward, and the three libraries became the foundation for those applications.</p><p>Now we’re working on the next generation of the platform. And this isn’t simply a new version with a few improvements.</p><p>We’re introducing a new design system and fundamentally changing how our UI components are built.</p><p>A significant part of the existing component library is being deeply refactored. We’re moving towards a more abstract, modular and reusable approach, with the ambition of making the design system useful across the organisation rather than tightly coupled to one particular implementation.</p><p>At the same time, we have to preserve backward compatibility, keep our SDK flexible for existing consumers, address technical debt accumulated over previous releases, and incorporate requirements coming from feature teams already using the platform.</p><p>We’re also introducing three new libraries and CLI tooling to make adoption and development easier.</p><p>In other words, we’re not just polishing the existing platform. We’re changing its foundations while keeping the existing ecosystem working.</p><p>This comes with significant engineering requirements. And the overall scope is comparable to the previous platform delivery, even though the technical challenges are different.</p><p>The interesting part?</p><p>We’re targeting approximately one month of delivery with five developers.</p><p>Of course, this isn’t a controlled experiment where AI is the only variable. We have existing platform knowledge, established architecture, and lessons learned from the first generation. But the amount of implementation work we’re able to delegate to AI has changed dramatically.</p><p>AI is now involved in technical design, implementation planning, architectural exploration, building complete libraries, testing, and reviewing substantial changes.</p><p>And that’s where I encountered an unexpected problem.</p><p>I was still trying to maintain my previous engineering habits.</p><p>Five developers working with agents can generate an extraordinary amount of code. Multiple large MRs, sometimes exceeding 1,000 lines, arriving for review every day.</p><p>I was switching between architectural contexts, inspecting implementations, tracing dependencies, challenging design decisions and trying to understand every detail before approving anything.</p><p>At some point, I realised that I was spending close to 80% of my working time reviewing AI-assisted implementations.</p><p>That’s not exactly what I imagined doing as a Staff Engineer.</p><p>I wasn’t introducing new technologies, improving developer experience or thinking about the next architectural evolution.</p><p>I was becoming a very expensive code reviewer.</p><p>And the uncomfortable part was that I couldn’t simply stop reviewing. I was still accountable for the engineering quality of the foundations we were building.</p><p><strong>AI had increased our implementation capacity much faster than our ability to verify the results.</strong></p><p>I needed a different approach.</p><h3>3. Stop reviewing faster. Start paving the road.</h3><p>The first thing I changed was where I invested my engineering attention.</p><p>Instead of trying to inspect every implementation, I started investing more heavily in establishing the engineering environment in which those implementations happen.</p><p>I call this paving the road.</p><p>The idea is simple: before asking developers or AI agents to build something, make sure there is an established, documented and preferably reusable way to build it.</p><p>For me, this involves several layers.</p><h4>Layer 1: Organisation-wide engineering principles</h4><p>At the highest level, we establish principles that apply across products and libraries.</p><p>For example:</p><ul><li>Prefer simplicity over unnecessary abstraction.</li><li>Follow proven patterns from established libraries where appropriate.</li><li>Build modular and reusable solutions.</li><li>Keep design-system principles framework-agnostic wherever possible.</li><li>Avoid introducing complexity that doesn’t solve a real problem.</li></ul><p>These principles provide architectural direction without prescribing every implementation detail.</p><p>If we’re building a design system, for example, we want the underlying concepts to remain useful even if the consuming framework changes.</p><p>We don’t want our design decisions to become prisoners of a particular implementation technology.</p><h4>Layer 2: Library-specific contribution governance</h4><p>Every library has its own contribution guide.</p><p>It describes how to extend the library, which patterns to follow, how to organise code and what quality expectations contributors should meet.</p><p>We also invest in initial components and working examples.</p><p>This is important: governance shouldn’t just tell developers what not to do. It should demonstrate the preferred way of doing things.</p><p>A good paved road makes the correct approach easier than inventing an alternative.</p><h4>Layer 3: A central AI context hub</h4><p>We maintain a central collection of product-specific AI skills.</p><p>These include:</p><ul><li>Contribution skills.</li><li>Architectural audit skills.</li><li>Migration skills.</li><li>Other reusable engineering workflows.</li></ul><p>The idea is to make established engineering knowledge accessible to agents instead of rediscovering conventions in every new task.</p><h4>Layer 4: Repository and feature-specific skills</h4><p>Some instructions are too specific to belong in global governance.</p><p>For example:</p><ul><li>How to build an atom or molecular component.</li><li>How to synchronise design tokens from Figma.</li><li>How to onboard a new third-party library.</li><li>How to implement a particular feature using established patterns.</li></ul><p>These focused skills provide the right instructions at the right level.</p><h3>Documentation still matters</h3><p>We also maintain an internal documentation portal. Our repositories publish their documentation through automated pipelines, making technical knowledge available across the engineering organisation.</p><p>One small convention I particularly like is maintaining TL;DR sections in our documentation.</p><p>Let’s be honest: developers already have an enormous amount of information to process. If we expect everyone to read a 40-page document before changing a component, we’re creating friction.</p><p>Documentation needs to be useful for humans and accessible to AI agents.</p><p>They don’t necessarily need to consume it in the same way.</p><h3>4. A practical example: turning a UI component into an AI-auditable paved road</h3><p>Let’s take something familiar: building a complex UI component for a shared library.</p><p>Imagine we’re introducing a new component that will be consumed by several applications.</p><p>It sounds like a frontend implementation task.</p><p>It isn’t.</p><p>Before we can consider it ready, we need agreement across three different perspectives:</p><ol><li>Product owners — what problem should the component solve?</li><li>Design leads — how should it behave and look?</li><li>Engineering — how should it be implemented and integrated?</li></ol><p>As the engineering lead, I need to make sure all three perspectives become one coherent implementation.</p><p>For every component, I want to establish several things:</p><p><strong>Product and design alignment</strong></p><ul><li>Are all expected features documented?</li><li>Are behavioural decisions and edge cases captured?</li><li>Have design decisions been agreed upon?</li><li>Are interaction states and accessibility expectations clear?</li></ul><p><strong>API and architecture</strong></p><ul><li>Is the public contract intuitive?</li><li>Are we following established patterns rather than reinventing the wheel?</li><li>Is the API modular and flexible?</li><li>Are we introducing unnecessary configuration or abstractions?</li></ul><p><strong>Implementation quality</strong></p><ul><li>Is the code readable?</li><li>Is cognitive complexity reasonable?</li><li>Are responsibilities separated properly?</li><li>Are there unnecessary dependencies?</li></ul><p><strong>Quality and developer experience</strong></p><ul><li>Are unit and integration tests in place?</li><li>Are important scenarios covered?</li><li>Is documentation available?</li><li>Can another developer understand how to use the component without reading its implementation?</li></ul><p>You can probably see where this is going.</p><p>After building and reviewing several components, we start recognising recurring patterns.</p><p>We know what good looks like.</p><p>We know which mistakes tend to happen.</p><p>We know what questions need to be asked before considering a component complete.</p><p>And this is where the interesting transformation happens.</p><p>Instead of repeating the same manual review process for every new component, we turn the accumulated knowledge into an audit skill.</p><p>The skill receives the component implementation, its specification and the relevant engineering context.</p><p>It can then evaluate the implementation against our established expectations and produce findings.</p><p>Suddenly, something that previously required me to repeat the same checklist manually becomes a reusable engineering capability.</p><p>The important detail is that I personally reviewed the initial implementations and helped establish the standards.</p><p>We’re not asking AI to invent our engineering principles.</p><p>We’re asking it to consistently apply principles that we’ve already established and validated.</p><p><strong>That’s the difference between using AI to generate code and using AI to scale engineering practices.</strong></p><h3>5. From reading every line to evaluating red flags</h3><p>This is probably the biggest change in my personal workflow.</p><p>I increasingly use Claude Code as my primary engineering interface.</p><p>I started my AI journey with Cursor, where the IDE was still the centre of my development workflow and AI was helping me work with the code.</p><p>Today, I spend much more time in conversation mode.</p><p>I discuss architecture, provide specifications, delegate implementation, challenge decisions and evaluate results.</p><p>I still use the IDE, but increasingly to inspect interfaces, types, schemas and architectural boundaries rather than manually navigating every implementation detail.</p><p>The same transformation applies to code reviews.</p><p>My current workflow looks something like this:</p><p><strong>Step 1. Provide the context</strong></p><p>I give the review process access to the relevant architectural principles, contribution guidelines, specifications, audit skills and additional review instructions.</p><p><strong>Step 2. Ask AI to evaluate the implementation</strong></p><p>Rather than asking for a generic code review, I ask it to evaluate the implementation against our established engineering governance.</p><p>I want it to identify things such as:</p><ul><li>Architectural violations.</li><li>Inconsistent public APIs.</li><li>Unnecessary abstractions.</li><li>Unexpected complexity.</li><li>Missing test coverage.</li><li>Integration risks.</li><li>Deviations from the specification.</li><li>Potential problems for downstream consumers.</li></ul><p><strong>Step 3. Focus on red flags</strong></p><p>The output is a structured review with findings and explanations.</p><p>My job is no longer to reconstruct every implementation detail from a 1,200-line MR.</p><p>Instead, I evaluate the findings.</p><p>Is this actually a problem? Is it a genuine architectural concern? Is the model misunderstanding an intentional design decision? Does this reflect something I would have noticed if I had reviewed the entire MR manually?</p><p>In other words, I’m using AI to mirror and scale my engineering intuition.</p><p><strong>Step 4. Let developers and their agents resolve the findings</strong></p><p>The review produces comprehensive comments that developers can take directly into their own agent-assisted workflows.</p><p>They can investigate the findings, challenge them where appropriate and implement corrections.</p><p>The cycle becomes much more efficient.</p><p>Importantly, this isn’t a claim that AI review guarantees correctness. Models can miss problems, misunderstand context and generate false positives. Automated tests, static analysis, integration checks and human review of critical decisions remain essential.</p><p>But I no longer need to spend the majority of my day manually inspecting every line to identify where my attention is needed.</p><p>My responsibility shifts towards evaluating the quality of the findings and making the decisions that actually require engineering judgment.</p><h3>6. The cognitive overload nobody talks about</h3><p>There’s an interesting paradox in my experience.</p><p>Initially, AI increased my cognitive overload.</p><p>I was switching between agents, different libraries, architectural contexts and enormous pull requests.</p><p>The agents were producing more code, but I didn’t fully trust them.</p><p>So I tried to control everything.</p><p>I wanted to understand every implementation, verify every decision and maintain the same level of visibility I had before AI.</p><p>It was exhausting.</p><p>What eventually helped wasn’t a better model or a more sophisticated prompt.</p><p>It was changing the way I structured the work.</p><p>Once I started establishing governance, reusable skills, specifications and automated audits, I could stop carrying every implementation detail in my head.</p><p>I could focus on the architecture and the decisions that mattered.</p><p>The interesting thing is that the engineering problems haven’t become simpler. Our ambitions have increased.</p><p>But I can now handle a broader range of engineering responsibilities without constantly switching into implementation-level thinking.</p><p>I think this is an underrated benefit of AI.</p><p>We talk a lot about generating code faster. We talk less about reducing the cognitive overhead of coordinating, understanding and validating increasingly complex engineering work.</p><p>For me, this has become one of the most valuable changes.</p><h3>7. What I think comes next: governance as an organizational capability</h3><p>I also think this approach can evolve beyond individual engineering teams.</p><p>Imagine having a centralized engineering governance system across an organization.</p><p>Architectural principles, contribution guidelines, approved patterns, audit skills and documentation could be maintained as reusable organizational assets.</p><p>Repositories could consume the relevant context automatically.</p><p>A GitLab-integrated agent could review incoming MRs against the organization&#39;s engineering standards, identify violations and provide actionable feedback.</p><p>Developers could communicate directly with that agent, investigate findings and resolve issues with their own coding agents.</p><p>By the time a change reaches the Staff Engineer or architecture reviewer, the routine governance checks have already happened.</p><p>The human reviewer can focus on the things that genuinely require human judgment: architectural trade-offs, cross-product implications, significant design decisions and long-term maintainability.</p><p>This is an evolution I’m interested in exploring further.</p><p>Not because humans should disappear from code reviews, but because their attention is too valuable to spend repeatedly checking the same established conventions.</p><h3>8. So, what does a Staff Engineer do in the AI era?</h3><p>I don’t think the answer is simply writing more code with AI.</p><p>For someone working across libraries, frameworks, platforms and multiple engineering teams, I see the role evolving in a different direction.</p><p>Less time personally producing and inspecting every implementation.</p><p>More time establishing architectural principles, creating paved roads, codifying engineering knowledge and building systems that allow developers and agents to work consistently.</p><p>There are a few practical lessons I’d take from this experience:</p><ol><li><strong>Review the foundations, not just the output.</strong> Personally validate initial implementations and establish good patterns before trying to automate their enforcement.</li><li><strong>Turn repeated review comments into governance.</strong> If you keep explaining the same architectural decision, it’s probably time to document it and make it reusable.</li><li><strong>Build paved roads before building audit skills.</strong> AI should have a proven example of what good looks like, not just a list of things to avoid.</li><li><strong>Make specifications first-class engineering artefacts.</strong> Clear intent and acceptance criteria make both implementation and evaluation more predictable.</li><li><strong>Automate repetitive verification, not engineering accountability.</strong> Let AI identify potential problems, but retain human judgment over significant decisions.</li><li><strong>Protect your cognitive bandwidth.</strong> Your job isn’t to understand every generated line. It’s to understand the system, its constraints and the decisions that matter.</li></ol><p>Last year, we spent six months building a platform with more than ten engineers.</p><p>Today, we’re attempting its next major evolution with five engineers and a one-month target.</p><p>I don’t know whether we’ll hit every target, and I wouldn’t attribute the difference to AI alone.</p><p>But I do know that I wouldn’t approach this delivery using the engineering practices I had a year ago.</p><p>I started using AI to write code faster.</p><p>I ended up changing how I define, communicate, review and govern engineering quality.</p><p><strong>Perhaps the biggest transformation isn’t that AI can write code faster than we can. It’s that we need to stop making ourselves the bottleneck through which every line of code must pass.</strong></p><p>And for me, that’s what being a Staff Engineer in the AI era is increasingly about.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45a448f3b04a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Staff Engineering in the Age of AI: Turning Infinite Possibilities into Clear Direction]]></title>
            <link>https://medium.com/@sidelnykovvalery/staff-engineering-in-the-age-of-ai-turning-infinite-possibilities-into-clear-direction-cb75ca533e94?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb75ca533e94</guid>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[engineering-management]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[leadership]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 14:52:58 GMT</pubDate>
            <atom:updated>2026-08-02T14:52:58.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*imSoJpLE4LJ9qrP8cYit1A.png" /></figure><blockquote>“AI gave every engineer a faster keyboard.</blockquote><blockquote>The Staff Engineer’s job is to decide what is worth typing.”</blockquote><p>Around 18 months ago, I got access to my first AI coding assistant. At the beginning, it felt like a very fast junior engineer. It could fix bugs, write functions, and generate components in seconds. But it also made surprisingly simple mistakes and sometimes created a very “creative” solution for a very simple problem. 🙂</p><p>So I spent a lot of time reviewing, correcting, and explaining. But during the following months, something changed.</p><p>AI models evolved, and my way of working with them evolved too.</p><p>The junior engineer gradually became a much stronger partner. With the right context, clear goals, architecture constraints, and understanding of the problem, AI moved from completing small tasks to helping design solutions, analyze multiple repositories, and deliver large parts of complex features from a high-level specification.</p><p><strong>It was almost like growing an engineer.</strong></p><p>Not by teaching syntax, but by providing context: our architecture, patterns, constraints, and the reasons behind our decisions. And this became my biggest lesson.</p><p><strong>AI does not replace engineering thinking. It amplifies it.</strong></p><p>The better the context, the better the outcome. The clearer the intention, the more valuable the possibilities AI can generate.</p><p>And this changed where I spend my time.</p><p><strong>The biggest challenge is no longer producing code. The biggest challenge is creating clarity.</strong></p><h3>From Producing Code to Managing Possibilities</h3><p>The first surprise was not that AI could write code. The surprise was how quickly the amount of generated code exceeded my ability to process it.</p><p>At the beginning, I tried to keep the old workflow:</p><p>Generate → Review → Fix → Merge.</p><p>But this approach stopped scaling very quickly. The problem was not the quality of individual lines of code. The problem was that every generated solution created more decisions:</p><p>Is this the right approach? Does it fit our architecture? Will it scale? Are we solving the right problem?</p><p><strong>I realized that I could not spend my attention reviewing every possible implementation.</strong></p><p>My role had to move one level higher.</p><p>Instead of asking: “Is this code correct?”</p><p>I started asking: <strong>“Is this the right direction?”</strong></p><p>This was the moment when my relationship with AI changed.</p><p>I stopped treating AI as a faster developer.</p><p>I started treating it as a system that <strong>can amplify my thinking </strong>— if I provide the <strong>right context, constraints, and direction</strong>.</p><h3>Architecture: Reducing Uncertainty About Direction</h3><p>When the implementation cost goes down, choosing the right direction becomes even more important.</p><p>Recently, I worked on a problem where the solution touched multiple repositories, multiple teams, and different parts of our platform. The interesting part was not writing the code. The difficult part was creating a shared understanding.</p><p>Before implementation started, I needed to answer simple but important questions:</p><ul><li>What are we building?</li><li>Why are we building it this way?</li><li>Which parts should be common?</li><li>Which parts should stay flexible?</li><li>Where should responsibilities live?</li></ul><p>I spent a lot of time exploring ideas, discussing options, and using AI as a brainstorming partner. But the final step was always the same: <strong>distill everything into a simple model</strong> that other people could understand.</p><p>Engineers needed enough detail to implement their pieces. Leadership needed enough clarity to understand the direction and trade-offs.</p><p><strong>A good architecture document is not valuable because it contains a lot of information. It is valuable because it removes unnecessary complexity and helps everyone build the same mental model.</strong></p><p>In the AI era, creating architecture is less about designing every component yourself. It is about reducing uncertainty before hundreds of possible implementations start competing with each other.</p><h3>Platform: Reducing Uncertainty About Implementation</h3><p>Architecture gives direction. But direction alone is not enough.</p><p>When multiple teams build products, another question appears: How do we avoid solving the same problem again and again?</p><p>This is where platforms become important.</p><p><strong>A good platform is not just a collection of reusable components or libraries. It is a collection of reusable decisions.</strong></p><p>Over the years, I have seen the same pattern many times. A team needs to solve a problem. They make a reasonable local decision. Another team faces a similar problem and makes another reasonable local decision.</p><p>Individually, every decision looks fine. But over time, the organization accumulates different approaches, different patterns, and different ways of solving the same problem. This is where complexity starts growing.</p><p>The role of a platform team is not to own everything. It is to identify what should become a shared capability and hide unnecessary complexity behind simple, easy-to-use tools.</p><blockquote>For example, a UI platform is not only about providing components. It is about creating a common language between designers and engineers. When designers can build prototypes using the same components that engineers use in production, we remove a whole layer of translation. The engineer can focus on business logic and integration instead of rebuilding visual decisions.</blockquote><p>The same principle applies to AI. If every AI-generated application starts from zero, we are just creating new versions of the same problems faster. The goal is not to generate more code. The goal is to make the right decisions reusable.</p><p><strong>A strong platform allows teams to move faster because they don’t need to rethink everything every time.</strong></p><h3>Governance: Reducing Uncertainty About Quality</h3><p>When development becomes faster, quality becomes a different kind of challenge.</p><p>In the past, experienced engineers could often protect quality through direct involvement: reviewing pull requests, discussing approaches, and sharing knowledge during implementation.</p><p><strong>But this approach does not scale when everyone can generate significantly more code.</strong></p><p><strong>The answer is not to review more. The answer is to create systems that make good decisions easier and bad decisions harder.</strong></p><p>Good governance starts with culture: Do we write tests? Do we follow common patterns? Do we document important decisions? Do we understand the trade-offs behind our tools?</p><p>Then it continues with automation:</p><ul><li>Static analysis.</li><li>Linters.</li><li>Code quality checks.</li><li>Automated tests.</li><li>Architecture rules.</li><li>And now, AI-based assistance.</li></ul><p>The goal is not to replace engineering judgment with more automation.</p><p><strong>The goal is to protect engineering attention for the decisions that actually require human experience.</strong></p><blockquote>One example from my experience was defining how teams should use our UI library. The biggest challenge was not creating the components. The challenge was making sure everyone understood how to use them correctly. We extended this knowledge beyond engineers and included designers who created early prototypes. By providing the right guidance at the beginning, we reduced the amount of rework later.</blockquote><p>This is what good governance should do.It should not slow teams down.</p><p><strong>It should remove uncertainty, prevent repeated mistakes, and allow teams to move faster with confidence. In the AI era, governance becomes less about controlling every change. It becomes about creating an environment where the right changes happen naturally.</strong></p><h3>The New Staff Engineer: Protecting Attention</h3><p>The biggest change for me was not learning how to use AI.</p><p><strong>It was learning where to spend my attention.</strong></p><p>At the beginning, I tried to keep control over everything. I wanted to understand every generated change, review every solution, and verify every detail.</p><p>But this approach does not work anymore. The speed of generating possibilities is now higher than the speed at which one person can analyze them. I had to change my mindset.</p><p>My value is not in being the person who knows every line of code. My value is in knowing which questions to ask.</p><ul><li>Which direction is correct?</li><li>Which trade-offs matter?</li><li>Which complexity should we accept?</li><li>Which complexity should we eliminate?</li></ul><p>This is the part where experience becomes more important, not less. AI can explore thousands of possible solutions. A Staff Engineer helps decide which one is worth building.</p><p>The role has shifted from producing more code to creating more clarity. From writing every solution to designing systems where many people can build the right solutions.</p><p>From being the person who has all the answers to being the person who helps the organization ask better questions.</p><p><strong>I don’t know exactly how AI will change engineering in the next few years. But I know one thing from my own experience: The more possibilities AI creates, the more valuable clarity becomes.</strong></p><h3>Final Thoughts</h3><p>I used to think that the biggest advantage of experienced engineers was knowing more. Knowing more technologies. Knowing more patterns. Knowing more details about the systems we build.</p><p>Today, I think the advantage is something different.</p><p><strong>It is knowing what deserves attention.</strong></p><p>In a world where AI can quickly generate many possible solutions, the ability to choose the right one becomes more valuable than ever.</p><p>The future is not about humans competing with AI on the amount of code we can produce. It is about humans and AI working together to create better products faster — with the right direction, the right constraints, and the right understanding.</p><p>AI gave every engineer a faster keyboard.</p><p>The Staff Engineer’s job is to decide what is worth typing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb75ca533e94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Future of Frontend Isn’t Components. It’s Domain Translation.]]></title>
            <link>https://medium.com/@sidelnykovvalery/the-future-of-frontend-isnt-components-it-s-domain-translation-753109248305?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/753109248305</guid>
            <category><![CDATA[frontend-architecture]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[skills]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Mon, 11 May 2026 17:44:10 GMT</pubDate>
            <atom:updated>2026-05-11T17:44:10.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CMrH3M0bT1jt97dUxthcbw.png" /></figure><blockquote>Imagine giving a Ferrari to a 2 teams and telling everyone to drive “roughly in the same direction.”</blockquote><p>For the first few minutes, it looks impressive.</p><p>Designers generate complete systems overnight. Frontend engineers scaffold applications before standup ends. AI agents continuously produce components, specifications, contracts, diagrams, and architecture proposals like caffeinated interns that never sleep.</p><p><strong><em>Everybody moves incredibly fast.</em></strong></p><blockquote>The problem is that if a Ferrari goes slightly in the wrong direction at 300 km/h, you do not get lost slowly. You disappear from the map almost immediately.</blockquote><p>Design moves one way. Engineering moves another. AI interprets both in its own statistically confident direction. Product joins later with “just one small clarification.”</p><p><strong><em>Individually, everybody looks extremely productive. </em>Collectively, the system slowly turns into semantic spaghetti. <em>At AI-assisted speed, divergence scales much faster than alignment.</em></strong></p><p>And suddenly, organizations discover they are producing enormous amounts of output while somehow becoming less coherent every sprint.</p><h3>I realized this while building a design system</h3><p>Recently, I worked on a frontend platform initiative to build a new design system architecture.</p><p>The original idea sounded clean. We wanted a token-driven foundation, typed contracts in code, reusable atomic components, and a structured bridge between design and implementation.</p><p>The architecture itself was relatively straightforward. We introduced layered abstractions: design tokens as a foundation, typed representations in code, specification-driven component definitions, and implementation wrappers atop existing UI primitives.</p><p>The goal was simple: create a shared language between design and engineering.</p><p>At least, that was the theory…</p><h3>Two domains, two different realities</h3><p>Reading design directly from Figma using MCP within modern agentic flow is no longer the hard part.</p><p>Generating tokens, extracting specifications, converting designs into text, or scaffolding implementation artifacts — AI already does this surprisingly well.</p><p>The more interesting problem starts one layer deeper. Because design language is not only about tokens.</p><p>A designer may think about balance, rhythm, visual weight, or something close to the golden ratio. They look at a component and instinctively feel that spacing, proportions, and hierarchy create harmony.</p><p>Frontend engineering does not understand “harmony,” but it understands CSS, HTML, APIs, and well-structured governance.</p><p>And suddenly the question becomes much harder:</p><blockquote><em>How do you translate a feeling of visual balance into CSS rules and component APIs?</em></blockquote><p>How do you convert “this card feels too heavy” into deterministic implementation logic?</p><p>How do you encode visual hierarchy into reusable abstractions without leaking implementation complexity everywhere?</p><p>This is where the real bottleneck appears.</p><p>Not in generating artifacts.</p><p>But in translating between two domains that often describe the same interface, using completely different mental models.</p><h3><strong>Building a translation layer.</strong></h3><p>We introduced a specification-driven workflow where design definitions became structured frontend contracts. Tokens, variants, slots, states — everything moved through a pipeline that transformed design artifacts into typed APIs and implementation rules.</p><p>At some point, the system started looking less like a design system and more like a compiler driven by Agentic flow and scripts.</p><p>The real challenge started later.</p><p>Because the difficult part was never transforming data; it was <strong>aligning meaning.</strong></p><p>Design and the frontend used the same vocabulary to describe completely different realities. <em>Variants, states, slots, recipes, and semantic colors</em> — these terms existed in both domains, but they weren’t synonyms. Design operated through <strong>visual semantics</strong> and patterns of harmony. Frontend operated through <strong>logic gates</strong>, props, accessibility constraints, and framework-specific lifecycles.</p><p>This is where the silent drift happened. Technically, everything was “correct”: the specifications generated, the contracts compiled, and the pipelines passed. But somewhere in the middle, the <strong>intent</strong> evaporated. A visual state in Figma became a messy combination of props in React; a reusable recipe became a labyrinth of branching logic.</p><p>The systems looked aligned on the surface while internally speaking different languages. That was our “lightbulb” moment: <strong>Translation is not the same thing as transformation.</strong></p><p>Transforming a Figma variable into a TypeScript token is a solved engineering problem. Preserving the <em>intent</em> of a layout across two different semantic models is the new frontier. To bridge this, we had to stop treating the handoff as a data export and start treating it as a <strong>negotiated contract.</strong></p><h3>The Path to Alignment: 3 Steps to Domain Translation</h3><p>To solve this, we moved beyond simple “syncing” and built a workflow centered on <strong>uSpec</strong> (Universal Specification) and Agentic governance.</p><h3>1. The Figma-Native uSpec Page</h3><p>Instead of leaving engineers to interpret canvas layers, we introduced a <strong>uSpec (Universal Specification)</strong> page directly within Figma.</p><ul><li><strong>The Goal:</strong> Force the designer to speak “Frontend” without leaving their creative environment.</li><li><strong>How it works:</strong> This isn’t just a mock-up; it’s a structured documentation frame that defines slots, specific prop-mappings, and behavioral logic (e.g., “how this component grows when text overflows”).</li><li><strong>Result:</strong> It aligns the naming conventions <em>at the source</em>. If it’s a “Ghost” variant in Figma, it is explicitly mapped to a variant=&quot;ghost&quot; API in the uSpec before a single line of code is written.</li></ul><h3>2. The Internal Governance Model &amp; Quality Pyramid</h3><p>We encoded our engineering “soul” into a set of machine-readable rules. This governance model includes:</p><ul><li><strong>The Quality Pyramid:</strong> Automated checks from code quality to integration tests and a11y.</li><li><strong>Implementation Requirements:</strong> Strict rules on how components must be structured with clear architecture patterns.</li><li><strong>The Bridge:</strong> By feeding these requirements into our AI Agents, the “caffeinated intern” now has a boss who cares about long-term maintenance, not just speed.</li></ul><h3>3. The Agentic “Audit &amp; Ship” Workflow</h3><p>Finally, we replaced the manual handoff with an Agentic pipeline that treats the uSpec as the “Source of Truth.”</p><ul><li><strong>The Translation Phase:</strong> The Agent reads the uSpec and the governance model simultaneously. It identifies “Semantic Friction” — points where the design intent conflicts with engineering constraints.</li><li><strong>The Audit Phase:</strong> Before shipping, the Agent performs a multi-domain audit. It verifies that the rendered code matches the visual intent <em>and</em> the technical contract.</li><li><strong>The Result:</strong> A component that doesn’t just look like the design, but <strong>behaves</strong> like the design, while adhering to the rigor of a production-grade codebase.</li></ul><h3>Why this matters</h3><p>We shifted the bottleneck. We are no longer stuck on “How do we get this color into the code?” We are now focusing on “Does this component represent the same concept in Figma as it does in React?”</p><p>When the <strong>Domain Translation</strong> is solved, the Ferrari finally starts driving in one direction.</p><p>How does this framing feel for the conclusion of your article? Should we lean harder into the “Agent as a Mediator” role?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=753109248305" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Boxes to Context: Architecture in the Age of Agentic Engineering]]></title>
            <link>https://medium.com/@sidelnykovvalery/from-boxes-to-context-architecture-in-the-age-of-agentic-engineering-b07c28b6294c?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/b07c28b6294c</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[developer-experience]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[engineering-leadership]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 16:00:34 GMT</pubDate>
            <atom:updated>2026-03-28T16:00:34.763Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5yEjbHHouoqeH5crLXHrUg.png" /></figure><p>There was a time when being an Architect meant opening a diagram tool, drawing a lot of boxes representing “Microfrontends,” connecting them with arrows to a “Shell,” and feeling productive.</p><p>(<strong>You weren’t.</strong>)</p><p>You’d spend hours aligning rectangles for your Module Federation strategy. Blue for the Auth MFE. Green for the Design System. Red for “the legacy monolith no one should touch.” Then you’d export it to PDF, upload it to a wiki, and send it to Slack.</p><p><strong>That was the last time anyone looked at it.</strong></p><h3>The Breaking Point: Microfrontend Chaos</h3><p>In a modern frontend platform, architecture isn’t a single repo. It’s 20+ teams, 50+ microfrontends, a shared component library, and a complex web of deployment pipelines.</p><p>The diagrams couldn’t keep up. Not because diagrams are bad – but because the speed of a git push outpaces the speed of a mouse click. And now, <strong>Agentic Engineering</strong> has entered the chat.</p><h3>What “Agentic” Actually Means: The Control Panel</h3><p>By “agentic,” I don’t just mean a chatbot. I mean an <strong>Orchestrator</strong> – like <strong>Cursor</strong> or <strong>Claude</strong> – connected to your company’s entire nervous system.</p><p>Imagine a control panel where your AI agent has:</p><ul><li><strong>Company Context</strong>: Access to Confluence, internal docs, and Slack history via company mcp.</li><li><strong>Codebase Awareness</strong>: Not just one repo, but the entire “Frontend Galaxy” (Shell + MFEs + Shared Utils).</li><li><strong>Execution Power</strong>: Deep integration with Jira and Git via mcp.</li></ul><p><strong>Architecture is no longer a diagram. It is a Knowledge Base that answers back.</strong></p><h3>My Current Workflow: From Research to Reusable Skill</h3><p>This is how I architect a frontend platform today. I don’t start with a canvas; I start with an orchestrator.</p><h4>1. The Research Phase (External + Internal)</h4><p>Instead of guessing, I start with a prompt:</p><blockquote>How do FAANG companies handle cross-MFE state synchronization? Compare that to our current implementation in the ‘Checkout’ and ‘Account’ repos. Check the Slack channels with the storage related complains and previous ADRs about it.</blockquote><p>The agent scans external best practices and cross-references them with our <strong>internal Slack history</strong> and <strong>Confluence</strong> to find why we made certain trade-offs two years ago.</p><h4>2. The Planning Mode: ADRs</h4><p>Once the direction is clear, I move to planning. I don’t write a 10-page doc. I ask the agent to draft an <strong>ADR (Architecture Decision Record)</strong> in Markdown based on our research. Thanks agents — now building diagrams is a easy journey and mermaid format perfectly aligns with the git markdown representation.</p><p>It captures the why, the trade-offs, and the impacted MFEs. This ADR lives in the platform’s root repo. <strong>If it’s not in Git, it didn’t happen.</strong></p><h4>3. Technical Design (a.k.a. “Let’s Make It Real”)</h4><p>Once the ADR is merged, it’s time to go deeper. This is the part where architecture stops being “nice ideas” and starts becoming something real enough that engineers can’t escape it. I don’t open 12 tabs and start guessing. I just ask:</p><blockquote><em>“Based on this ADR, create a Technical Design for the new Shared State Utility. Look at existing schemas, interfaces, and how our current flows actually work.”</em></blockquote><p>The agent goes through the codebase like a very fast and very patient engineer:</p><ul><li>checks existing interfaces</li><li>looks at how data actually flows (not how we <em>think</em> it flows)</li><li>spots inconsistencies we’ve been ignoring for months</li></ul><p>And then produces a design that is:</p><ul><li>aligned with reality</li><li>consistent with existing patterns</li><li>not based on wishful thinking</li></ul><p><em>The best part? It reads the code. Not our assumptions.</em></p><p>So instead of inventing architecture…</p><p>…I’m refining something that already fits.</p><h4>4. Task Breakdown (Goodbye Manual Jira Suffering)</h4><p>Now comes the part everyone secretly hates: breaking everything into Jira tickets.</p><p>Previously, this looked like:</p><ul><li>create epic</li><li>create 12 tickets</li><li>forget 3 important ones</li><li>discover missing pieces mid-sprint</li><li>repeat</li></ul><p>Now it’s more like:</p><blockquote><em>“Generate a Jira Epic based on this design. Split tasks between the Shell team and the Payment MFE team. Add proper acceptance criteria.”</em></blockquote><p>And it just… does it.</p><p>You get:</p><ul><li>clear epics</li><li>properly scoped tasks</li><li>acceptance criteria that actually make sense</li><li>separation between teams without awkward overlap</li></ul><p>And somehow:</p><ul><li>it doesn’t forget edge cases</li><li>it doesn’t create useless tickets like “Investigate stuff”</li></ul><p><strong><em>Writing Jira tickets manually is officially the new box-drawing.</em></strong></p><p>I still review, of course. But instead of creating structure from scratch…</p><p>…I’m editing something that’s already 80% right.</p><p>Which, honestly, feels illegal.</p><h4>5. Designing the “AI Skill”</h4><p>This is the final, most important step. Once the feature is implemented, I don’t just write a README. I design an <strong>AI Skill</strong>.</p><p>I feed the patterns, the constraints, and the “how-to” back into our company’s skill base. Now, when any developer in the company wants to use that new platform feature, they don’t read documentation — they ask their agent: <em>“How do I implement the new cross-MFE event bus?”</em> and the agent applies the skill I designed.</p><p><strong>The best documentation is the one your agent already knows.</strong></p><h3>The Shift: From Artifacts to Context</h3><p>It’s not just tooling. It’s a shift in how we think:</p><ul><li>From <strong>Artifacts</strong> (PDFs) → to <strong>Interactions</strong> (Conversations).</li><li>From <strong>Documentation</strong> → to <strong>Live Context</strong>.</li><li>From <strong>Repetition</strong> → to <strong>Encoding Knowledge</strong>.</li></ul><p>As a Platform Architect, I don’t try to describe the system upfront. I build a system that is <strong>explainable on demand.</strong></p><h3>The Test</h3><p>Next time you open a diagram tool to map out a new Microfrontend, pause. Ask yourself: <strong>“What question am I actually trying to answer?”</strong></p><p>Start there. We didn’t become architects to align rectangles. We became architects to make complexity navigable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b07c28b6294c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The AI Productivity Paradox: Why We’ll Need More Seniors, Not Fewer]]></title>
            <link>https://medium.com/@sidelnykovvalery/the-ai-productivity-paradox-why-well-need-more-seniors-not-fewer-34a1c4a7d8f4?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/34a1c4a7d8f4</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[delivery]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sun, 05 Oct 2025 21:11:31 GMT</pubDate>
            <atom:updated>2025-10-05T21:11:31.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3mQ4Syv3TBdOl_p-RkYbw.png" /></figure><p>A few months ago, my team and I built a framework with a visual component library. We decided to let AI handle part of the workload -drafting technical design docs, generating mid-sized components, filling in test coverage, even fixing bugs. The results were staggering: in some cases, productivity jumped by 50%, and nearly 60-80% of the code came from AI.</p><p>But there was a catch. Reviewing that code became the real bottleneck. Some days we faced up to 10 massive merge requests waiting for senior eyes. Instead of typing code, I was spending hours validating architecture, catching hidden complexities, and ensuring long-term maintainability.</p><p>This is the paradox of the AI era: the faster code ships, the heavier the burden of control. AI accelerates delivery, but the responsibility for correctness, scalability, and sound architecture rests squarely on senior developers.</p><h3>The Paradox of Productivity</h3><p>AI is not just a tool that helps you type faster-it’s a force multiplier. It can generate entire components in minutes, spin up design docs that would take hours, and auto-fill boilerplate tests with uncanny accuracy. For teams under delivery pressure, this feels like magic.</p><p>But the illusion fades quickly. More output means more code to understand, review, and maintain. The volume grows faster than human attention can keep up. Suddenly, senior developers aren’t just writing less code — they’re firefighting complexity. Instead of moving the system forward, they spend their days making sure the AI didn’t move it backward.</p><p>This is where productivity flips into a paradox: speed without governance creates fragility. Left unchecked, the flood of “working code” can bury teams under mounting technical debt.</p><h3>The Governance Model: Layers of Control</h3><p>The only way to survive the flood of AI-written code is with layered governance. Think of it as building guardrails at different scales:</p><p><strong>Platform Level — Global Patterns</strong><br> Shared rules that apply everywhere: design principles, security standards, logging practices, performance budgets. These are the non-negotiables that keep the system coherent across teams and projects.</p><p><strong>Application Level — Local Patterns</strong><br> Each app has its own architectural style: how modules are split, how domains are enforced, how state is managed. Here, consistency is key. Without it, AI will happily generate dozens of “valid” but conflicting approaches.</p><p><strong>Component Level — Tactical Patterns</strong><br> Small design decisions: hooks vs. utilities, naming conventions, code structure. This is where AI often shines, but it still needs guardrails to avoid creating cognitive spaghetti.</p><p>By enforcing governance at these three layers, teams can let AI accelerate development without letting chaos take over. It’s less about slowing down the machine, and more about teaching it to run inside the right track.</p><h3>Automated Quality Gates</h3><p>Governance works best when it’s backed by automation. Seniors can’t manually catch every hidden dependency or unreadable function in the flood of AI code — the scale is just too big. That’s where automated quality gates come in.</p><p><strong>Cognitive Complexity Checks</strong>: Tools that highlight overly complicated methods or sprawling conditionals before they ever reach review.</p><p><strong>Test Coverage Reports</strong>: Automated thresholds that flag untested paths, forcing AI (and humans) to back up speed with safety nets.</p><p><strong>Static Analysis &amp; Security Scans</strong>: Linters, vulnerability scanners, and dependency checkers that run continuously in the background.</p><p>The goal isn’t to replace senior judgment, but to filter noise. With automated gates catching structural issues, seniors can focus on what only humans can do: validating architecture, reasoning about trade-offs, and anticipating long-term costs.</p><p>“Trust, but verify” becomes the mantra. Let AI ship code fast — but let machines and humans together keep it safe.</p><h3>Educating the Next Generation</h3><p>One of the most debated questions in the AI era is: <em>should juniors even use AI tools?</em><br> Some teams lock them out entirely, fearing they’ll become “prompt typists” instead of real engineers. Others let juniors generate freely, but risk creating developers who can’t debug without a chatbot.</p><p>A healthier middle ground is emerging: <strong>semi-automatic education</strong>.</p><ul><li>Juniors use AI to generate solutions.</li><li>Seniors review, refine, and point out gaps.</li><li>AI then explains the corrections and patterns behind the changes.</li></ul><p>In this model, AI acts as a <strong>co-mentor</strong>, reinforcing feedback loops while seniors ensure the learning sticks. The result? Juniors still practice problem-solving, but with a safety net that scales better than one-to-one tutoring.</p><p><strong><em>The irony is clear: AI may produce more code than any junior ever could, but its real long-term value is in helping juniors learn why good code matters.</em></strong></p><h3>What “Good Code” Means in the AI Era</h3><p>AI can generate thousands of lines of functional code in a fraction of the time it takes a human. But <em>functional</em> isn’t the same as <em>good</em>. In fact, the AI era makes the definition of good code sharper than ever:</p><ul><li><strong>Readable -</strong>because humans will maintain it long after the AI has moved on.</li><li><strong>Scalable - </strong>because today’s “quick win” feature can become tomorrow’s bottleneck.</li><li><strong>Secure - </strong>because AI will happily copy insecure patterns unless told otherwise.</li><li><strong>Tested</strong> <strong>-</strong> because velocity without safety nets leads to brittle systems.</li><li><strong>Consistent with governance layers</strong> <strong>-</strong>because fragmented styles across apps kill long-term productivity.</li></ul><p>Good code today isn’t measured by <em>how fast it runs</em>, but by <em>how safely it evolves</em>. AI may accelerate delivery, but it cannot judge trade-offs, foresee architectural consequences, or balance short-term wins with long-term health. That responsibility remains human so far …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34a1c4a7d8f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Avoiding Technical Debt in the Age of AI-Generated Code]]></title>
            <link>https://medium.com/@sidelnykovvalery/avoiding-technical-debt-in-the-age-of-ai-generated-code-ce6db76eea65?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce6db76eea65</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sat, 19 Jul 2025 17:57:51 GMT</pubDate>
            <atom:updated>2025-07-19T17:57:51.567Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2LdwArbMNRW8THVtLjwbxA.png" /></figure><blockquote>AI can write code — but only you can make it maintainable.</blockquote><h3>Introduction: AI Isn’t Lazy, It’s Just Literal</h3><p>Ask AI to “build me a React app,” and you’ll get one. Ask it again tomorrow? You’ll get a totally different one — with a different file structure, different naming conventions, maybe even a different architecture.</p><p>The problem? <strong>AI generates code that works, but often not code that lasts.</strong></p><p>As engineers, we’ve spent years learning to reduce technical debt. But now we face a new challenge: <strong>AI isn’t creating legacy code after five years of growth — it’s doing it in five minutes.</strong></p><p>And here’s the catch: The quality of AI-generated code depends entirely on how you prompt it. Your architecture, your constraints, your design rules — <strong>that’s the new seniority</strong>.</p><p>Let’s talk about how to guide AI to avoid technical debt, not invite it in.</p><h3>1. Architecture Requirements: <em>Don’t Let AI Freestyle Your Foundation</em></h3><blockquote>AI is like a junior dev with infinite energy and zero context. If you don’t tell it what your architecture should look like, it will guess — or worse, make it up.</blockquote><h4>✅ Give it structure:</h4><p><strong>Define a file layout and Layers:</strong></p><pre>/components<br>/hooks<br>/services<br>/types<br>/tests</pre><p><strong>Enforce concept separation:</strong></p><ul><li>Keep UI rendering in components</li><li>Move logic into hooks</li><li>Abstract data access into services</li><li>Create helper functions</li></ul><p><strong>Design around interfaces:</strong><br>Use TypeScript or JSDoc to describe expected shapes. Don’t let AI assume your intent.</p><p><strong>Encourage SOLID principles:</strong><br>Tell AI to build for <em>single responsibility</em>, <em>open/closed</em>, and <em>interface segregation</em>.</p><h3>2. Implementation Control: <em>Slow the AI Down with Rules</em></h3><p>The worst kind of technical debt isn’t messy — it’s invisible. And AI is great at producing invisible complexity unless you set limits.</p><h4>✅ Control the details:</h4><p><strong>Use strict typing:</strong><br> Enable strictNullChecks, noImplicitAny, and exactOptionalPropertyTypes. AI will follow the rules if you give them.</p><p><strong>Enforce clean code rules:</strong></p><ul><li>No inline styles</li><li>No any</li><li>No magic strings</li><li>No logic in render functions</li></ul><p><strong>Apply coding standards in the prompt:</strong></p><p>“Follow Airbnb style guide. Keep components under 100 lines. Each function must have a semantic name and clear purpose.”</p><p><strong>Force clean separation in logic:</strong></p><p>“Separate form state and submission logic into a useFormHandler hook. Don’t mix async operations with rendering logic.”</p><p><strong>Prevent overengineering:</strong><br> AI sometimes tries to impress with factories, singletons, or patterns you don’t need. Keep it focused.</p><h3>3. Code Quality: <em>If It’s Not Testable, It’s Not Trustworthy</em></h3><p>AI can generate tests — but they’re only as meaningful as your test requirements.</p><h4>✅ Build for testability:</h4><p><strong>Specify test tools and patterns:</strong></p><p>“Use React Testing Library. Write unit tests for every hook and component. Organize mock data under /__mocks__.”</p><p><strong>Require edge case coverage:</strong></p><p>“Include one test where the API fails, one where input is invalid, and one where the user submits twice.”</p><p><strong>Set test quality benchmarks:</strong></p><ul><li>100% TypeScript coverage</li><li>Minimum 80% unit test coverage</li><li>No console.log in production code</li><li>No unhandled promises</li></ul><p><strong>Detect fake coverage:</strong><br> AI may write tests that pass but do nothing. Validate the assertions and input variation.</p><p><strong>Use checklists during generation:</strong><br> Prompt AI to follow these as part of output generation.</p><h3>Conclusion: Technical Debt Starts at the Prompt</h3><p>AI isn’t careless — it’s just obedient. If your prompt is vague, the result will be too. If your structure is missing, AI will improvise. And if you don’t enforce rules, AI will break them — quietly.</p><p>Here’s the twist: <strong>governing AI isn’t all that different from mentoring junior developers</strong>.</p><p>You wouldn’t just throw a task at a junior and hope it magically comes out clean. You’d provide structure, explain the architecture, define the boundaries, and review the results. You’d teach them SOLID principles. You’d remind them why code readability matters. And you’d explain why just because something “works,” doesn’t mean it’s ready.</p><blockquote><strong><em>Personally, I’ve spent hours mentoring teammates — explaining why separating concerns matters, what makes a good interface, and how testable code saves time.</em></strong></blockquote><p>When working with AI, <strong>the same rules apply</strong>. The difference is that you’re mentoring a model instead of a person — and your feedback happens through the prompt, not a code review.</p><blockquote><strong><em>“Don’t delegate architecture to AI. Architect your AI.”</em></strong><em><br> That’s how you avoid machine-generated messes — and how you scale your expertise, not just your codebase.</em></blockquote><p>In the age of AI, your role as a senior engineer is more critical than ever — not because you write more code, but because <strong>you define how good code gets written</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce6db76eea65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Callbacks and Dependency Injection: Your Escape Plan from Interface Hell]]></title>
            <link>https://medium.com/@sidelnykovvalery/callbacks-and-dependency-injection-your-escape-plan-from-interface-hell-6d6952193670?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d6952193670</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 19:03:31 GMT</pubDate>
            <atom:updated>2025-06-08T19:03:31.771Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2KPxk1AnMGEdEWIgqQZcGw.png" /></figure><blockquote>Dependency injection: the polite way to say ‘not my problem.</blockquote><p>You’ve done it. You’ve built a clean library — or maybe even a shiny new internal framework. It works. It scales. Your interfaces are solid. You sleep well at night.</p><p>Then it happens.</p><p>A product owner walks in with a feature request that makes absolutely no sense… until it’s suddenly a top priority. Or worse — an upstream data provider changes their authentication model overnight, breaking your elegant fetchData() abstraction.</p><p>Even at the component level, things can go sideways. You’ve got a stable, well-behaved React component with neatly defined props. Suddenly, someone needs to inject a bizarre UI block into the middle of your layout — complete with its own props, handlers, and business logic. Goodbye clean boundaries.</p><p>Now you’re faced with a choice:<br> 🚨 Break existing consumers with interface changes,<br> 🔀 Introduce alternative APIs that confuse everyone,<br> 🧩 Or cram in conditionals and edge-case logic that only 5% of users need — welcoming chaos and fragility into your codebase.</p><p>But what if there was a better way?</p><p>This is where the real power of <strong>callbacks</strong>, <strong>middleware</strong>, and <strong>dependency injection</strong> comes into play. These aren’t just patterns — they’re your architecture’s pressure valves. They let you design systems that bend without breaking, flex under shifting requirements, and scale without spiraling into technical debt.</p><p>In this article, we’ll explore how these concepts help tame complexity, reduce coupling, and unlock real flexibility in modern frontend systems. Whether you’re crafting hooks, components, or full-scale UI platforms — mastering these patterns pays off, one clean interface at a time.</p><h3>Callbacks — Micro-Level Flexibility</h3><blockquote>Callbacks: Because sometimes the only thing you know is <em>what</em> needs to happen — not <em>how</em> or <em>when</em>.</blockquote><p>In small-scale code — components, utilities, helpers — <strong>callbacks are your escape hatch</strong>. Instead of hardcoding behavior, you delegate decisions to the consumer. It keeps your code generic, composable, and surprisingly future-proof.</p><p><strong>Example 1: React Component Customization (Render Props)</strong></p><p>Imagine a UI library where your component does all the boring stuff (loading, fetching), and lets <em>you</em> control how the data is rendered.</p><pre>function DataLoader({ fetchData, children }) {<br>  const [data, setData] = useState(null);<br><br>  useEffect(() =&gt; {<br>    fetchData().then(setData);<br>  }, [fetchData]);<br><br>  return data ? children(data) : &lt;LoadingSpinner /&gt;;<br>}<br><br>// Usage:<br>&lt;DataLoader fetchData={getUsers}&gt;<br>  {(data) =&gt; &lt;UserList users={data} /&gt;}<br>&lt;/DataLoader&gt;</pre><p>📌 <em>Why this works</em>:<br> You can swap in any data source, and any rendering logic. The component doesn’t know or care — it just loads and hands off control. This is perfect for internal UI libraries, where flexibility is key.</p><p><strong>Example 2: Flexible Sorting Utility (Functional Strategy)</strong></p><p>Rather than write one utility for each business case (sortByAge, sortByRevenue, sortByStatusThenAgeThen…), you delegate sorting logic via a comparator callback:</p><pre>function sortWithStrategy&lt;T&gt;(items: T[], comparator: (a: T, b: T) =&gt; number): T[] {<br>  return [...items].sort(comparator);<br>}<br><br>// Usage:<br>sortWithStrategy(users, (a, b) =&gt; a.age - b.age);</pre><p>📌 <em>Why this works</em>:<br> This keeps your utility function dumb and reusable, and pushes business logic to the caller. It also makes testing much easier — you test the sort function <em>once</em>, then test the comparator functions separately.</p><p><strong>Example 3: Highcharts — The Callback Powerhouse</strong></p><p><a href="https://www.highcharts.com/">Highcharts</a> is one of the most widely used charting libraries — and it’s built on a philosophy of <strong>callbacks everywhere</strong> to offer extreme customization without bloating the core.</p><pre>lotOptions: {<br>  series: {<br>    point: {<br>      events: {<br>        click: function () {<br>          alert(`You clicked on ${this.category}`);<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>Highcharts exposes customization hooks in the form of callbacks for nearly every aspect of the chart: tooltips, click events, labels, even animation steps. This lets devs extend it deeply <em>without ever touching the internals</em>.</p><h3>Middleware — Medium-Level Composability</h3><p>Middleware is like having a helpful assistant who handles all the messy, specialized tasks outside your main flow — so your core logic stays consistent and easy to maintain.</p><p>Now imagine you’ve become a platform supporting multiple APIs. One day, a brand-new API shows up with a completely different authentication scheme and a wildly different data contract. Your visualization components, however, still expect the same clean, consistent data format they’ve always relied on.</p><p>How do you avoid breaking everything?</p><p>This is exactly where middleware comes into play.</p><p>It lets you <strong>delegate those wild variations</strong> — token injection, auth changes, data reshaping — to isolated layers inside your request and response pipeline. Your core fetch logic and your visualization components stay blissfully unaware of the chaos behind the scenes.</p><p>In this section, we’ll see how Axios middleware makes this elegant by injecting tokens on requests and transforming diverse API responses into a single, consistent format — protecting your platform from regressions and keeping your UI humming smoothly.</p><pre>import axios, { AxiosRequestConfig, AxiosResponse } from &quot;axios&quot;;<br><br>// Type definitions for middleware callbacks<br>type RequestMiddleware = (config: AxiosRequestConfig) =&gt; Promise&lt;AxiosRequestConfig&gt; | AxiosRequestConfig;<br>type ResponseMiddleware&lt;T = any&gt; = (response: AxiosResponse&lt;T&gt;) =&gt; Promise&lt;T&gt; | T;<br><br>class DataService {<br>  private api = axios.create({ baseURL: &quot;https://api.example.com&quot; });<br><br>  // Public init method to inject middleware callbacks<br>  public init(requestMiddleware: RequestMiddleware, responseMiddleware: ResponseMiddleware) {<br>    this.api.interceptors.request.use(async (config) =&gt; {<br>      // Delegate request config transformation<br>      return await requestMiddleware(config);<br>    });<br><br>    this.api.interceptors.response.use(async (response) =&gt; {<br>      // Delegate response transformation<br>      return await responseMiddleware(response);<br>    });<br>  }<br><br>  // Generic GET method for example<br>  public async get&lt;T = any&gt;(url: string): Promise&lt;T&gt; {<br>    const response = await this.api.get&lt;T&gt;(url);<br>    return response as any; // Already transformed by responseMiddleware<br>  }<br>}<br><br>// Fake external token injection middleware example<br>async function injectAuthToken(config: AxiosRequestConfig): Promise&lt;AxiosRequestConfig&gt; {<br>  const token = await getExternalAuthToken(); // Pretend async token fetch<br>  config.headers = config.headers || {};<br>  config.headers.Authorization = `Bearer ${token}`;<br>  return config;<br>}<br><br>// Fake external response transformer middleware example<br>function transformResponse(response: AxiosResponse) {<br>  return snakeToCamelDeep(response.data);<br>}<br><br>// Usage<br>const dataService = new DataService();<br><br>dataService.init(injectAuthToken, transformResponse);<br><br>// Then you can simply use<br>(async () =&gt; {<br>  const users = await dataService.get(&quot;/users&quot;);<br>  console.log(users);<br>})();</pre><h3>Dependency Injection: Plugging in Black Boxes Without Breaking a Sweat</h3><p>Imagine you’re building a big ecommerce app with tons of features owned by different teams. Your main app handles product browsing, cart, checkout — but delivery tracking? That’s another team’s baby, living in its own app, with its own deployment schedule, tech stack, and release cycles.</p><p>Now, you want to show delivery tracking <strong>right inside your app</strong>, on a dedicated route — but here’s the catch: you don’t want to rewrite their code, duplicate logic, or get tangled up in their deployment headaches. You just want to say:</p><p>“Hey, here’s an orderID. Show me the tracking info.”</p><p>Enter <strong>Dependency Injection</strong>, powered by <strong>Webpack Module Federation</strong> — your secret weapon for plugging in black boxes with minimal fuss.</p><p>Instead of tightly coupling your app to their internals, you <strong>inject</strong> that delivery tracking component like a puzzle piece, treating it as a standalone module with a simple, stable contract (e.g., the orderID input). Your app doesn’t care how it works inside — it just renders the piece and lets the other team own all the complexity.</p><p>And no, you’re not thinking about the old-school iframe trick — this is way cooler and way cleaner.</p><p>This approach lets teams move fast, deploy independently, and keep their codebases clean — all while delivering a seamless user experience in the main app.</p><p><strong>Host App (Main Ecommerce App) — webpack.config.js</strong></p><pre><br>module.exports = {<br>  // ... other webpack config<br>  plugins: [<br>    new ModuleFederationPlugin({<br>      name: &quot;host_app&quot;,<br>      remotes: {<br>        deliveryTracking: &quot;deliveryTracking@http://localhost:3001/remoteEntry.js&quot;,<br>      },<br>      shared: {<br>        react: { singleton: true, eager: true, requiredVersion: &quot;^18.0.0&quot; },<br>        &quot;react-dom&quot;: { singleton: true, eager: true, requiredVersion: &quot;^18.0.0&quot; },<br>      },<br>    }),<br>  ],<br>};</pre><p><strong>Remote App (Delivery Tracking Microfrontend) — webpack.config.js</strong></p><pre>module.exports = {<br>  // ... other webpack config<br>  plugins: [<br>    new ModuleFederationPlugin({<br>      name: &quot;deliveryTracking&quot;,<br>      filename: &quot;remoteEntry.js&quot;,<br>      exposes: {<br>        &quot;./DeliveryTracker&quot;: &quot;./src/DeliveryTracker&quot;, // Expose this component<br>      },<br>      shared: {<br>        react: { singleton: true, eager: true, requiredVersion: &quot;^18.0.0&quot; },<br>        &quot;react-dom&quot;: { singleton: true, eager: true, requiredVersion: &quot;^18.0.0&quot; },<br>      },<br>    }),<br>  ],<br>};</pre><p><strong>How the Host Loads the Remote Component</strong></p><pre>import React, { Suspense, lazy } from &quot;react&quot;;<br><br>const DeliveryTracker = lazy(() =&gt; import(&quot;deliveryTracking/DeliveryTracker&quot;));<br><br>function OrderRoute({ orderId }) {<br>  return (<br>    &lt;Suspense fallback={&lt;div&gt;Loading delivery info...&lt;/div&gt;}&gt;<br>      &lt;DeliveryTracker orderId={orderId} /&gt;<br>    &lt;/Suspense&gt;<br>  );<br>}<br><br>export default OrderRoute;</pre><h3>Wrapping It Up: Callbacks, Middleware, and Dependency Injection — Your Triple Threat</h3><p>Remember, callbacks let you hand off custom behavior without messing with the core flow. Middleware acts as your adaptable gatekeeper, transforming requests and responses on the fly. And dependency injection plugs in entire black-box components — like microfrontends — without breaking a sweat.</p><p>Want to take it further? Inject capabilities like user auth, logging, or feature flags into those remote components using callbacks — keeping your platform flexible and future-proof.</p><p>Together, these patterns give you the power to <strong>build systems that bend without breaking, adapt without chaos, and scale without headaches.</strong> Interface hell? Not on your watch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d6952193670" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Headless, But Not Brainless: Designing Smart CMS Abstractions]]></title>
            <link>https://medium.com/@sidelnykovvalery/headless-but-not-brainless-designing-smart-cms-abstractions-a0ee61ba4140?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0ee61ba4140</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[architectural-design]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[cms]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sat, 03 May 2025 20:07:28 GMT</pubDate>
            <atom:updated>2025-05-03T20:07:28.630Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UmAhiXxfkTTT1FZvF_Iseg.png" /></figure><p>Let’s be honest — when picking a CMS, we rarely think about <strong>switching</strong> later. We find a fancy headless CMS, love its UI, get everything up and running, and move on with our lives. But then… things change.</p><p>Maybe the <strong>pricing suddenly skyrockets</strong>, and now every API request feels like burning cash. Maybe the <strong>performance tanks</strong>, and simple content updates take ages to reflect on the site. Or maybe the CMS admin UI gets a major “redesign” that nobody asked for, and your content team starts questioning their life choices.</p><p>There are <strong>many reasons</strong> why a company might decide to switch CMS providers:</p><ul><li><strong>Cost:</strong> Some CMS platforms charge per API call, per user, or per content item. As your site grows, these costs <strong>explode</strong>.</li><li><strong>Performance:</strong> API response times can be slow, and rate limits might throttle your app when traffic spikes.</li><li><strong>Feature limitations:</strong> You need a <strong>custom workflow</strong>, <strong>advanced content permissions</strong>, or <strong>AI-generated content</strong>, but your CMS doesn’t support it.</li><li><strong>Editorial experience:</strong> The CMS admin panel is either too complex or too limited, frustrating content managers.</li><li><strong>Vendor lock-in:</strong> Some CMS solutions make <strong>migrating data out</strong> a nightmare — so you’re stuck unless you rewrite half your backend.</li></ul><p><strong>But what about developers?</strong></p><p>The real problem isn’t just <strong>switching</strong> CMS platforms — it’s how much <strong>technical debt</strong> we create along the way. Many projects start with the frontend <strong>tightly coupled</strong> to a specific CMS. Direct API calls scatter across the codebase, content models mimic the CMS structure 1:1, and before we know it, our app is <strong>married</strong> to a single provider.</p><p>Then one day, the business says, “We need to migrate to a new CMS.” And suddenly, every page, component, and API layer needs a rewrite.</p><p>But what if we <strong>designed it right</strong> from the start?</p><p>An <strong>ideal CMS integration</strong> wouldn’t care <strong>which CMS</strong> we use — it would just fetch and deliver content in a predictable way. Instead of hardcoding API calls, we’d have a <strong>CMS service layer</strong> that acts as a translator between our app and any CMS provider. Whether it’s REST, GraphQL, or something entirely custom, the CMS logic would live <strong>in one place</strong>, keeping our app <strong>clean and adaptable</strong>.</p><p>Content wouldn’t be fetched <strong>directly</strong> from a CMS — it would flow through <strong>structured abstractions</strong>. A <strong>Page Model</strong> would define layouts, independent of where the data comes from. <strong>Content Slots and Containers</strong> would allow flexible placement of CMS-managed elements, ensuring reusability. Components wouldn’t fetch data themselves but instead rely on <strong>a well-defined content contract</strong>, making them CMS-agnostic.</p><p>This isn’t just about <strong>swapping CMS platforms</strong> when needed — it’s about <strong>future-proofing</strong> our architecture. By designing a <strong>decoupled, flexible CMS layer</strong>, we don’t just avoid migration headaches; we make our entire content pipeline <strong>more scalable, maintainable, and resilient</strong>.</p><p>​​Let’s explore how to build it.</p><h3>Designing an Abstract CMS Layer</h3><p>At the core of a well — architected CMS integration is <strong>a single, unified service </strong>— the <strong>CMS Service</strong>. This is the layer that <strong>hides the complexity</strong> of dealing with different CMS providers and provides a <strong>consistent interface</strong> for the rest of the application.</p><p><strong>Why do we need an abstraction?</strong></p><p>Imagine a frontend project that directly interacts with a CMS API. Every component, every page, and every service reaches out to the CMS with its own API call. Now, let’s say we need to switch to a new CMS. Suddenly, we’re looking at <strong>hundreds of breaking changes</strong>, touching everything from API requests to data models.</p><p>A well-designed <strong>CMS Service</strong> prevents this disaster by acting as a <strong>single point of interaction</strong> with the CMS. Instead of scattering CMS-specific logic across the app, all communication flows through a structured interface, following two key design patterns:</p><h4>Singleton: A Single Source of Truth</h4><p>The <strong>CMS Service</strong> is a classic case for the <strong>Singleton pattern</strong>. Since CMS integration is a global concern — affecting every part of the app — it makes sense to have <strong>one shared instance</strong> managing it.</p><p>With a singleton, we ensure:<br> — There’s <strong>only one instance</strong> managing CMS interactions.<br> — All API requests flow through a <strong>centralized</strong> pipeline.<br> — We can <strong>efficiently handle caching, authorization, and retries</strong> in one place.</p><p>A basic implementation might look like this:</p><pre>class CMSService {<br>  private static instance: CMSService;<br>  private adapter: CMSAdapter;<br><br>  private constructor(adapter: CMSAdapter) {<br>    this.adapter = adapter;<br>  }<br><br>  static getInstance(adapter?: CMSAdapter): CMSService {<br>    if (!CMSService.instance) {<br>      if (!adapter) throw new Error(&quot;Adapter is required for initialization&quot;);<br>      CMSService.instance = new CMSService(adapter);<br>    }<br>    return CMSService.instance;<br>  }<br><br>  async getPage(slug: string) {<br>    return this.adapter.fetchPage(slug);<br>  }<br>}</pre><p>This guarantees that wherever we call CMSService.getInstance(), we get the <strong>same instance</strong> managing CMS interactions.</p><h4>Adapter Pattern: Decoupling CMS Implementations</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUOmf36s-WWk_gtbCT_xcQ.png" /></figure><p>Since different CMS platforms have <strong>different APIs</strong>, we don’t want our app to be tied to any <strong>one</strong> implementation. Instead, the <strong>CMS Service</strong> relies on an <strong>adapter </strong>— a wrapper that translates requests into a <strong>standard format</strong>.</p><p>For example, let’s say we have two CMS providers:</p><ul><li><strong>CMS A</strong> provides a GraphQL API.</li><li><strong>CMS B</strong> offers only REST endpoints.</li></ul><p>By using the <strong>Adapter pattern</strong>, we create a common interface that both must implement</p><pre>interface CMSAdapter {<br>  fetchPage(slug: string): Promise&lt;PageModel&gt;;<br>  fetchBanner(id: string): Promise&lt;CMSBanner&gt;;<br>}<br><br>// Each CMS then has its own implementation:<br><br>class CMSAGraphQLAdapter implements CMSAdapter {<br>  async fetchPage(slug: string): Promise&lt;PageModel&gt; {<br>    return graphqlQuery(`{ page(slug: &quot;${slug}&quot;) { title, content } }`);<br>  }<br>  <br>  async fetchBanner(id: string): Promise&lt;CMSBanner&gt; {<br>    return graphqlQuery(`{ banner(id: &quot;${id}&quot;) { image, link } }`);<br>  }<br>}<br><br>class CMSBRestAdapter implements CMSAdapter {<br>  async fetchPage(slug: string): Promise&lt;PageModel&gt; {<br>    return fetch(`/cms-b/pages/${slug}`).then((res) =&gt; res.json());<br>  }<br><br>  async fetchBanner(id: string): Promise&lt;CMSBanner&gt; {<br>    return fetch(`/cms-b/banners/${id}`).then((res) =&gt; res.json());<br>  }<br>}<br><br>// Now, our CMS Service can work with any CMS, simply by swapping adapters:<br>const cms = CMSService.getInstance(new CMSAGraphQLAdapter());<br>cms.getPage(&quot;home&quot;).then((page) =&gt; console.log(page));</pre><p><strong>Bringing It All Together</strong></p><p>With a <strong>Singleton CMS Service</strong>, an <strong>Adapter-based CMS integration</strong>, and <strong>internal caching</strong>, we get a <strong>future-proof CMS architecture</strong> that:</p><ul><li><strong>Supports any CMS provider</strong> by swapping adapters.</li><li><strong>Keeps the app decoupled</strong> from CMS-specific APIs.</li><li><strong>Optimizes performance</strong> with caching.</li><li><strong>Reduces migration pain</strong> when switching providers.</li></ul><p>This is just the foundation. Next, we’ll explore how to structure <strong>CMS page models</strong> and <strong>content containers</strong> to create a fully flexible system.</p><h3>CMS Page Model &amp; Slots/Containers for CMS Content</h3><p>When designing a CMS integration, the best model is often <strong>the real-life model of a frontend application </strong>— a <strong>Page Model</strong>. Instead of treating CMS content as a random collection of entries, we should think of it in terms of <strong>structured pages, slots, and components</strong> that naturally map to our UI.</p><p>At its core, a <strong>Page Model</strong> is a structured representation of a webpage, containing:</p><ul><li><strong>SEO Metadata</strong> — Title, description, canonical URL, and other search-related details</li><li><strong>Header &amp; Footer</strong> — Common elements shared across multiple pages.</li><li><strong>Slots (Containers)</strong> — Designated areas where CMS-driven content appears.</li><li><strong>Components (Banners, Images, Blocks, etc.)</strong> — The actual CMS-managed content.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ViH7MmdsK7g7PMg6lMDfVA.png" /></figure><p>This approach allows us to <strong>cleanly separate layout concerns from content</strong>, making CMS integration easier and reducing unnecessary complexity.</p><p>Instead of embedding CMS components directly in the layout, we introduce the concept of <strong>Slots (or Containers)</strong>. A slot is essentially a <strong>placeholder in the frontend layout</strong> that dynamically pulls in CMS-driven content.</p><p>Why use slots?</p><ul><li><strong>Flexibility</strong> — Allows non-developers (e.g., content managers) to manage what appears where</li><li><strong>Decoupling</strong> — Keeps the frontend layout stable while changing CMS content dynamically.</li><li><strong>Performance</strong> — Enables targeted caching strategies based on slots instead of full pages.</li></ul><p>For example, consider a <strong>landing page with multiple content sections</strong>:</p><pre>{<br>  &quot;page&quot;: {<br>    &quot;slug&quot;: &quot;homepage&quot;,<br>    &quot;title&quot;: &quot;Welcome to Our Store&quot;,<br>    &quot;seo&quot;: {<br>      &quot;title&quot;: &quot;Best Deals Online | Our Store&quot;,<br>      &quot;description&quot;: &quot;Find the best products at the best prices.&quot;<br>    },<br>    &quot;slots&quot;: {<br>      &quot;hero-banner&quot;: {<br>        &quot;type&quot;: &quot;banner&quot;,<br>        &quot;id&quot;: &quot;banner123&quot;<br>      },<br>      &quot;featured-products&quot;: {<br>        &quot;type&quot;: &quot;product-carousel&quot;,<br>        &quot;id&quot;: &quot;carousel456&quot;<br>      },<br>      &quot;footer-content&quot;: {<br>        &quot;type&quot;: &quot;text-block&quot;,<br>        &quot;id&quot;: &quot;text789&quot;<br>      }<br>    }<br>  }<br>}</pre><p>Each <strong>slot</strong> corresponds to a specific area on the page (e.g., “hero-banner” or “featured-products”) and is filled with CMS-driven content.</p><h4>Components: The Building Blocks of CMS-Managed Content</h4><p>At the lowest level, we have <strong>CMS Components </strong>— these could be banners, images, promotional blocks, or any other reusable content pieces.</p><p>A key principle is that <strong>UI components should remain independent of the CMS structure</strong>. Instead of coupling CMS data directly to components, we define <strong>internal stable interfaces</strong> for component props.</p><p><strong>Why define internal interfaces?</strong></p><ul><li>Ensures <strong>stability</strong> — The UI does not break when switching CMS providers.</li><li>Provides <strong>clear boundaries</strong> — CMS-specific logic stays within an abstraction layer.</li><li>Supports <strong>reusability</strong> — Components can be used across different pages and projects.</li></ul><p>The CMS Service Layer should be responsible for <strong>mapping raw CMS data to internal component interfaces</strong>, ensuring that UI components always receive data in a predictable format.</p><p><strong>Bringing It All Together</strong></p><p>By structuring our CMS integration around a <strong>Page Model, Slots, and Components</strong>, we achieve:</p><ul><li><strong>A scalable content architecture</strong> that mirrors real-life UI.</li><li><strong>A flexible way to manage content dynamically</strong> without touching frontend code.</li></ul><p><strong>A future-proof solution</strong> that works with any CMS provider.</p><h3><strong>Tools &amp; Processes to Support a Robust CMS Integration</strong></h3><p>Designing a great CMS abstraction layer is just part of the story. To truly simplify the developer experience and keep the system stable and scalable, we need the right <strong>supporting tools and processes</strong>. These tools aren’t just “nice-to-haves”-they’re essential for maintaining sanity when working with ever-changing content and evolving schemas.</p><h4>GraphQL Schema Generator: Let the Types Do the Heavy Lifting</h4><p>If your CMS supports GraphQL (and many modern headless ones do), one of the biggest wins you can get is by introducing a <strong>GraphQL schema generator</strong>. This tool can:</p><ul><li>Generate <strong>TypeScript types</strong> automatically from your CMS queries.</li><li>Help with <strong>autocomplete, type safety</strong>, and fewer bugs in adapters.</li><li>Keep your <strong>CMS data contracts explicit and versionable</strong>.</li></ul><p>This dramatically simplifies building and maintaining CMS adapters. You no longer need to guess the shape of the data-your IDE tells you. And when the schema changes, you’ll know exactly what broke (and where). It’s like having a map when navigating a jungle of content.</p><h4>Fallbacks: CMS Shouldn’t Be a Single Point of Failure</h4><p>Let’s be real-no system is perfect, and <strong>CMS outages do happen</strong>. But your site shouldn’t go down just because someone at the CMS provider accidentally kicked a cable.</p><p>That’s why it’s important to build <strong>fallback strategies</strong> into your architecture. Here’s what that could mean:</p><ul><li><strong>Static fallbacks</strong> for critical content (think: 404 page messages, navigation links, etc.).</li><li><strong>Cached versions</strong> of content in local storage, edge caches, or your own backend.</li><li><strong>Fail-safe logic</strong> in components that can gracefully render “empty states” if CMS content is unavailable.</li></ul><p>Most importantly: <strong>CMS should never be responsible for critical system configurations</strong>. If a wrong update to a banner layout can break your whole app, something’s wrong.</p><h4>Schema Change Culture: Process, Not Chaos</h4><p>One of the most overlooked parts of CMS integration is the <strong>process around evolving the schema</strong>.</p><p>Without some discipline, it’s easy to fall into a trap where every team adds their own version of a banner, button, or promo block-leading to <strong>duplication, inconsistencies</strong>, and higher CMS costs.</p><p>Here’s what a healthy schema evolution process could include:</p><ul><li><strong>Schema change approvals</strong> — Every new component or model should go through a lightweight review.</li><li><strong>Data normalization mindset</strong> — Favor reusing and extending existing models over creating new ones.</li><li><strong>Audits and cleanup</strong> — Occasionally review and refactor stale or redundant types.</li></ul><p>This doesn’t have to be heavy bureaucracy — but a little structure can go a long way in keeping your CMS clean, cost-effective, and easy to work with.</p><h3><strong>Conclusion</strong></h3><p>When it comes to integrating a CMS into your frontend application, the biggest mindset shift you can make is this:</p><p>👉 <strong>Don’t build for <em>a</em> CMS — build for <em>any</em> CMS.</strong></p><p>It’s tempting to dive straight into whatever APIs your chosen CMS offers, plug in a few queries, and ship fast. But what happens when pricing changes? Or the UI becomes too clunky for content editors? Or your team decides to switch platforms entirely?</p><p>That’s when the pain of <strong>tight coupling</strong> starts to show. And trust us-it hurts.</p><p>Instead, think in <strong>abstractions from day one</strong>. Wrap your CMS logic in a single, well-designed service. Use adapters to isolate specific implementations. Design your content models around real frontend structures like <strong>pages, slots, and components</strong>, not scattered content blobs. Create strong internal contracts and let your components rely on stable, predictable data.</p><p>Support your architecture with helpful tools like <strong>GraphQL schema generators</strong>, caching layers, and fallbacks. And don’t forget the <strong>human side</strong>-build a lightweight process around schema changes to keep things clean and normalized as your project grows.</p><p>At the end of the day, your CMS should feel like just another plugin behind a solid interface — not the core of your business logic.</p><p>Build with flexibility in mind, and you’ll thank yourself later-whether you stick with your current CMS for years or swap it out next quarter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0ee61ba4140" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frontend Code Quality: Automate Everything, Review Only What Matters]]></title>
            <link>https://medium.com/@sidelnykovvalery/frontend-code-quality-automate-everything-review-only-what-matters-2e9aa29f4bbe?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e9aa29f4bbe</guid>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Sat, 22 Mar 2025 22:46:48 GMT</pubDate>
            <atom:updated>2025-03-22T22:46:48.433Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VI7m9i3uzgCqtzsTgyJuuQ.jpeg" /></figure><h3><strong>Introduction</strong></h3><blockquote>A well-reviewed MR is like a good novel — thoughtful, detailed, and not rushed between calls.</blockquote><p>Every frontend team faces the same problem: big Merge Requests (MRs) piling up, waiting for review. You ask your Senior Engineers for help, but they’re too busy. When your Principal Engineer finally has time, the feedback is mostly about small issues — like missing semicolons or spacing — while bigger problems go unnoticed. The result? Features are delayed, developers are frustrated, and code quality doesn’t really improve.</p><p>Engineering management sets strict approval rules to maintain high standards, ensuring that only experienced engineers can give the final approval. But there’s a problem — there are only a few of them, and their schedules are packed with meetings and other high-priority tasks. This makes the review process slow and unpredictable.</p><p>Now you understand the challenge: maintaining high code quality without slowing down development. Peer reviews are essential, but they take a lot of time. Every hour a Senior or Principal Engineer spends on small fixes is an hour they can’t use for architecture, mentoring, or solving big technical challenges.</p><p>So, how do we fix this?</p><ul><li><strong>Reduce the time spent on peer reviews</strong> without sacrificing quality.</li><li><strong>Automate trivial checks</strong> so human reviews focus on actual logic and architecture.</li><li><strong>Ensure high code quality from the start</strong>, making the review process smoother.</li></ul><p>In this article, I’ll break down <strong>how to organize the entire process</strong> — from pre-commit checks to CI/CD automation — to <strong>minimize peer review iteration, increase efficiency, and make everyone happier.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xZweJ2Px5sWgA5QUkyHq8w.png" /></figure><h3>Linters &amp; Formatters</h3><p>Nobody should waste time in code reviews arguing over semicolons, indentation, or quote styles. <strong>ESLint and Prettier</strong> exist for a reason — let them handle it.</p><p>The key is <strong>consistency across the organization</strong>. Every team should share a <strong>common ESLint and Prettier config</strong> to ensure a unified coding style. At the same time, allow flexibility — specific applications might need to tweak some rules, but the core guidelines should remain the same.</p><p>💡 <strong>Make it enforceable:</strong></p><ul><li>Apply linting &amp; formatting <strong>before commits</strong> using Husky + lint-staged.</li><li>Run checks in <strong>CI/CD pipelines</strong> to prevent inconsistent code from merging</li></ul><p>With this in place, code reviews can focus on <strong>logic, not formatting.</strong></p><h3><strong>GitLab repository structure and Merge Request Templates</strong></h3><p>A well-structured repository and a clear review process can significantly <strong>reduce friction in code reviews</strong>. By setting <strong>folder structure standards</strong> and enforcing <strong>GitLab Merge Request (MR) templates</strong>, we ensure that every change follows best practices <strong>before</strong> it even reaches peer review.</p><h4>Repository Structure: Predictability Over Chaos</h4><p>Developers shouldn’t have to guess where to place a new service or component. A <strong>consistent folder structure</strong> improves maintainability and speeds up onboarding.</p><p>Instead of letting structure evolve chaotically, teams should define a <strong>clear set of guidelines</strong> for organizing code. This should include:</p><ul><li><strong>Project-wide conventions</strong> for structuring components, services, and utilities.</li><li><strong>Patterns for common use cases</strong>, such as handling API services, UI components, or state management.</li><li><strong>Code recipes</strong> that provide real-world examples of how to structure different features.</li></ul><p>For an in-depth look at <strong>applying the GRASP pattern to frontend architecture</strong>, check out my previous article:<br> <a href="https://medium.com/p/f6ba3dd39e9e"><strong>Design Patterns for Frontend Platforms</strong></a></p><p>💡 <strong>Best practice:</strong> Keep the <strong>folder structure guide</strong> documented in README close to code.</p><h4>Merge Request Templates: A Built-in Quality Checklist</h4><p>To avoid <strong>incomplete or poorly described MRs</strong>, use <strong>GitLab MR templates</strong> with a clear checklist. This ensures that every change meets the project’s <strong>Definition of Done (DoD)</strong> before peer review.</p><p>GitLab allows teams to create <strong>multiple MR templates</strong> for different types of changes:</p><ul><li><strong>Feature development</strong></li><li><strong>Bug fixes</strong></li><li><strong>Refactoring &amp; tech debt</strong></li><li><strong>Hotfixes</strong></li></ul><p><strong>Example: Feature MR Template</strong></p><pre>## Summary  <br>_What does this MR introduce?_<br><br>## Screenshots and videos clearly demonstrates introduced feature and business cases  <br>  <br>## Checklist  <br>- [ ] Code follows project structure guidelines   <br>- [ ] Unit tests added/updated if needed (coverage percentage not reduced)<br>- [ ] AAT tests added and covered all business case of the feature  <br>- [ ] No console logs/debuggers left  <br>- [ ] All interfaces properly documented  <br>- [ ] SonarQube quality gate passed (no new issues)  <br><br>## Related Tickets  <br>_Link to Jira/Trello/etc._<br><br>## Affected area for regression tests</pre><p><strong>Example: Bug Fix MR Template</strong></p><pre>## Issue  <br>_Describe the bug and link to the relevant issue._  <br><br>## Fix Summary  <br>_How was this bug fixed?_  <br><br>## Checklist  <br>- [ ] Unit tests added to cover the issue  <br>- [ ] Verified across different environments<br>- [ ] No console logs/debuggers left<br>- [ ] SonarQube quality gate passed (no new issues)</pre><p><strong>Useful GitLab Documentation:</strong></p><ul><li><a href="https://docs.gitlab.com/ee/user/project/merge_requests/templates.html">Customizing Merge Request Templates</a></li><li><a href="https://docs.gitlab.com/ee/user/project/merge_requests/#using-merge-request-templates">Using Multiple MR Templates</a></li></ul><p>💡 <strong>By standardizing folder structure and MR templates,</strong> we reduce review time, enforce consistency, and <strong>allow developers to focus on writing great code instead of process overhead.</strong></p><h3><strong>CI/CD Automation: The Ultimate Quality Gate</strong></h3><p>Automating code quality checks in the CI/CD pipeline <strong>eliminates human bottlenecks</strong> and ensures that only well-structured, maintainable, and secure code reaches production.</p><h4>AAT with Playwright: A Frontend-Friendly Testing Approach</h4><p>Automated Acceptance Testing (AAT) is crucial for validating <strong>end-to-end user flows</strong>.<a href="https://playwright.dev/"> <strong>Playwright</strong></a> is a great choice because:</p><ul><li>It <strong>supports TypeScript</strong>, making it easy for frontend developers to maintain.</li><li>It handles <strong>cross-browser testing</strong> out of the box.</li><li>It integrates smoothly into <strong>CI/CD workflows</strong>.</li></ul><p>💡 <strong>While Playwright deserves a dedicated discussion, this section focuses on static code analysis as the core of automation.</strong></p><h4>Static Code Analysis with SonarQube: The Automated Code Reviewer</h4><p>SonarQube acts as a <strong>comprehensive quality gate</strong> that analyzes code <strong>before</strong> peer review. It provides immediate feedback directly in the <strong>Merge Request (MR)</strong>, reducing unnecessary review cycles.</p><p><strong>How SonarQube Automates Code Quality Checks</strong></p><ul><li><strong>Code Coverage by Unit Tests</strong> — Ensures that changes are backed by tests.</li><li><strong>Security Scans</strong> — Detects <strong>dangerous expressions</strong>, unsafe dependencies, and potential vulnerabilities.</li><li><strong>Code Duplication Analysis</strong> — Helps enforce <strong>DRY principles</strong> across the codebase.</li><li><strong>Cognitive Complexity Score</strong> — Flags overly complex functions, making code easier to maintain.</li><li><strong>Failing CI/CD on Critical Issues</strong> — Prevents merging code that violates quality standards.</li></ul><blockquote><strong>Cognitive Complexity</strong> — My personal favorite! If the code is too complex for the author today, imagine how painful it will be for another developer fixing a bug in it a month later. Keeping complexity low means fewer headaches down the road.</blockquote><p>💡 <strong>SonarQube comments directly in the MR</strong>, allowing developers to fix issues before peer review, and <strong>blocks pipeline</strong>.</p><p>Example <strong>GitLab CI/CD Pipeline Snippet</strong>:</p><pre>stages:<br>  - test<br>  - quality<br><br>sonarqube:<br>  stage: quality<br>  script:<br>    - sonar-scanner -Dsonar.projectKey=my_project -Dsonar.host.url=https://sonarqube.example.com<br>  allow_failure: false</pre><p><strong>Helicopter View for Technical Directors</strong></p><p>Beyond just reviewing individual pull requests, SonarQube helps engineering teams see the bigger picture of code quality across the entire organization. It provides:</p><ul><li><strong>Test Coverage Insights</strong> — Shows how well the application is tested, helping teams identify gaps before issues reach production.</li><li><strong>Maintainability Reports</strong> — Highlights areas of technical debt, making it easier to prioritize refactoring and long-term improvements.</li><li><strong>Code Quality Trends</strong> — Tracks how code quality evolves over time, helping leadership enforce best practices and spot potential risks early.</li></ul><p>By integrating SonarQube into the CI/CD pipeline, teams automate code quality checks, reduce manual review effort, and ensure a more scalable and maintainable frontend codebase.</p><h3><strong>Peer Review: The Last but Lightest Step</strong></h3><p>By enforcing best practices through automation, peer review shifts from hunting for code style issues and minor mistakes to focusing on business logic, architecture, and feature implementation. This significantly reduces review time and cost, making the process more efficient and enjoyable for everyone involved.</p><p>With linters, formatters, structured guidelines, GitLab templates, and SonarQube scans in place, reviewers no longer have to spend hours pointing out inconsistent indentation, missing tests, or security risks — these are already caught before the MR reaches them. Instead, they can concentrate on what really matters: feature correctness, performance optimizations, and overall system impact.</p><h4>Automating Code Quality = Scaling Knowledge Sharing</h4><p>Another major benefit of automated quality gates is that they act as built-in mentors for new developers. Instead of relying on senior engineers to repeatedly explain best practices, static analysis tools, pre-configured templates, and well-documented guidelines highlight areas that need improvement, allowing newcomers to self-learn and adapt faster.</p><h4>Long-Term Impact: Maintainability &amp; Clean Code</h4><p>Organizing code delivery in this way creates a sustainable development workflow where:</p><ul><li>Code remains clean and consistent across teams.</li><li>Technical debt is reduced by proactively addressing issues.</li><li>New hires onboard faster with fewer knowledge gaps.</li><li>Peer review becomes an accelerator rather than a bottleneck.</li></ul><p>By shifting <strong>code quality enforcement</strong> from <strong>manual review to automation</strong>, frontend teams unlock <strong>higher efficiency, better collaboration, and a scalable engineering culture</strong> — delivering <strong>high-quality products faster and with fewer headaches</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e9aa29f4bbe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frontend Architecture Patterns: Part 2 — The Hidden Power of Indirection and Observer]]></title>
            <link>https://medium.com/@sidelnykovvalery/frontend-architecture-patterns-part-2-the-hidden-power-of-indirection-and-observer-d34f7a8ec9ba?source=rss-f423ff184e50------2</link>
            <guid isPermaLink="false">https://medium.com/p/d34f7a8ec9ba</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Sidelnykov Valery]]></dc:creator>
            <pubDate>Mon, 17 Mar 2025 12:38:48 GMT</pubDate>
            <atom:updated>2025-03-17T12:38:48.445Z</atom:updated>
            <content:encoded><![CDATA[<h3>Frontend Architecture Patterns: Part 2 — The Hidden Power of Indirection and Observer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Vxi5TA2DobGjFWFuwO_FVw.jpeg" /></figure><p>While building a stable frontend system you want it to be solid, simple, and not collapse when you least expect it. The best architectures are clear and robust, avoiding unnecessary complexity. But what if adding an extra, slightly unrelated piece makes everything work even better?</p><blockquote><strong>“All problems in computer science can be solved by another level of indirection, except for the problem of too many layers of indirection.”</strong> — David Wheeler</blockquote><p>That’s where Indirection and Observer come in. They’re like those behind-the-scenes crew members in a magic show — barely noticeable, but without them, everything falls apart. Instead of tight, fragile dependencies that tangle up your codebase like last year’s Christmas lights, these patterns introduce a layer of flexibility. They help keep things modular, maintainable, and — most importantly — less of a nightmare when requirements inevitably change.</p><p>Let’s take a closer look at how these silent operators can keep your frontend smooth, scalable, and free from unnecessary chaos.</p><h3>Indirection: The Art of Adding a Middleman (For Good Reasons)</h3><p>Indirection is all about adding an intermediary to keep things loosely connected. Instead of components talking to each other directly, you introduce a layer in between to handle the communication. This keeps things flexible, reduces dependencies, and makes future changes a whole lot easier.</p><p>At the macro level, indirection often comes into play when handling communication between the frontend and backend — or even between different backend services. A great example of this is using a GraphQL Federated API Gateway.</p><p>Modern applications rarely rely on a single backend service. Instead, they pull data from a diverse ecosystem of microservices — each with its own API, authentication rules, and response formats. One might expose REST endpoints, another uses GraphQL, and yet another follows its own custom protocol. For a frontend application, handling this chaos feels like translating between creatures in a zoo, each speaking a different language. Every new feature often requires weaving together data from multiple sources, resulting in a maze of API calls, redundant requests, and brittle dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qG-IVB6a4td8mpAW3P-qoQ.png" /></figure><p>This is where a GraphQL Federated Gateway comes in, acting as a smart intermediary that consolidates all these backend services into a single, unified GraphQL API. Instead of making multiple calls to different services and figuring out how to merge responses on the client side, the frontend only needs to query one GraphQL endpoint. The gateway takes care of resolving which backend service owns the data, fetching it efficiently, and presenting it in a consistent format.</p><p>By introducing this layer of indirection, the frontend gains a simple, predictable interface while backend services remain loosely coupled. Teams can evolve their microservices independently — adding new data sources, modifying schemas, or even replacing entire services — without breaking the frontend. The result is a more scalable, maintainable system that reduces complexity where it matters most.</p><p>However, this centralized approach isn’t without its drawbacks. Since every request passes through the GraphQL Gateway, it becomes a critical bottleneck — if it’s slow or overloaded, the entire system suffers. <strong>High traffic</strong> can put immense pressure on the gateway, so it must be optimized to remain thin and efficient, delegating work to backend services instead of doing heavy processing itself. Another challenge is <strong>release coordination </strong>— any change to the gateway’s schema or resolver logic can potentially impact multiple applications at once, requiring careful versioning and rollout strategies. While the gateway simplifies frontend interactions, it introduces a new point of failure that must be carefully managed.</p><p><strong>From Global to Local: Indirection at the Micro Level</strong></p><p>If a <strong>GraphQL Federated Gateway</strong> introduces a layer of indirection at the macro level — helping frontend applications deal with a chaotic mix of backend services — then the same principle can be applied at a <strong>micro level</strong> within the application itself. Just as the gateway provides a unified API for the frontend, we can introduce <strong>micro-level indirection</strong> to enhance flexibility, maintainability, and performance when dealing with data.</p><p>A practical example is creating an <strong>abstract API hook</strong> to manage requests to the GraphQL Gateway. Instead of having each component directly query the API, we centralize the logic in a dedicated hook that not only handles requests but also adds application-specific optimizations such as <strong>caching, pagination, and error handling</strong>.</p><p>But what if backend responses aren’t always in the format we need? In many cases, especially when supporting multiple API versions behind feature flags, we may encounter different response structures for the same data. This is where the <strong>Adapter pattern</strong> becomes invaluable. It adds an additional layer of abstraction, allowing us to transform data into a consistent shape before it reaches the UI.</p><p>Imagine we have two versions of an API, each returning data in a different format. We need to support both API versions simultaneously, without complicating our UI logic or introducing unnecessary duplication. The Adapter pattern provides a clean, testable way to handle this: we can create separate adapters for each API version that normalize the data into a unified structure, allowing the same UI to consume both versions seamlessly.</p><p>First of all let’s create <strong>usePaginatedQuery</strong> hook:</p><pre>import { useQuery, DocumentNode } from &quot;@apollo/client&quot;;<br>import { useState } from &quot;react&quot;;<br><br><br>type PaginatedQueryResult&lt;T&gt; = {<br>  data: {<br>    edges: {<br>      node: T;<br>    }[];<br>    pageInfo: {<br>      hasNextPage: boolean;<br>      endCursor: string | null;<br>    };<br>  };<br>};<br><br><br>type AdapterFunction&lt;T&gt; = (response: any) =&gt; T[];<br><br>type PageInfo = {<br>  hasNextPage: boolean;<br>  endCursor: string | null;<br>};<br><br>type PaginatedQueryResponse&lt;T&gt; = {<br>  data: T[];<br>  loading: boolean;<br>  error?: Error;<br>  loadMore: () =&gt; void;<br>  hasNextPage: boolean;<br>};<br><br>// The generic usePaginatedQuery hook<br>export function usePaginatedQuery&lt;T&gt;(<br>  query: DocumentNode,<br>  initialVariables?: Record&lt;string, any&gt;,<br>  adapter: AdapterFunction&lt;T&gt;, // Adapter function to normalize data<br>): PaginatedQueryResponse&lt;T&gt; {<br>  const [cursor, setCursor] = useState&lt;string | null&gt;(null);<br><br>  // Use Apollo stack to get graphQL query api from hook based wraper<br>  const { data, loading, error, fetchMore } = useQuery&lt;PaginatedQueryResult&lt;T&gt;&gt;(query, {<br>    variables: { ...initialVariables, after: cursor },<br>  });<br><br>  // Extract pagination data<br>  const pageInfo = data?.data?.pageInfo || { hasNextPage: false, endCursor: null };<br>  <br>  // Transform data to generic format<br>  const items = adapter(data);<br><br>  const loadMore = () =&gt; {<br>    if (pageInfo.hasNextPage) {<br>      fetchMore({<br>        variables: { ...initialVariables, after: pageInfo.endCursor },<br>        updateQuery: (prevResult, { fetchMoreResult }) =&gt; {<br>          if (!fetchMoreResult) return prevResult;<br>          return {<br>            ...fetchMoreResult,<br>            data: {<br>              edges: [...prevResult.data.edges, ...fetchMoreResult.data.edges],<br>              pageInfo: fetchMoreResult.data.pageInfo,<br>            },<br>          };<br>        },<br>      });<br>      setCursor(pageInfo.endCursor);<br>    }<br>  };<br><br>  return { data: items, loading, error, loadMore, hasNextPage: pageInfo.hasNextPage };<br>}</pre><p>And here the example how to use it in React component</p><pre>import { gql } from &quot;@apollo/client&quot;;<br>import { usePaginatedQuery } from &quot;./usePaginatedQuery&quot;;<br>import { adaptAPIv1Response } from &quot;./adapters/APIv1Adapter&quot;;<br>import { adaptAPIv2Response } from &quot;./adapters/APIv2Adapter&quot;;<br><br>// Abstract query for any type of data<br>const GET_DATA_V1 = gql`<br>  query GetData($after: String) {<br>    data(first: 5, after: $after) {<br>      edges {<br>        node {<br>          id<br>          name<br>          value<br>        }<br>      }<br>      pageInfo {<br>        hasNextPage<br>        endCursor<br>      }<br>    }<br>  }<br>`;<br><br>const GET_DATA_V2 = gql`<br>  query GetData($after: String) {<br>    data(first: 5, after: $after) {<br>      edges {<br>        node {<br>          identifier<br>          title<br>          description<br>        }<br>      }<br>      pageInfo {<br>        hasNextPage<br>        endCursor<br>      }<br>    }<br>  }<br>`;<br><br>export function GenericList() {<br>  // Assume featureFlag determines which API version to use<br>  const featureFlag = &quot;v2&quot;; // This could be dynamically set based on environment, config, or user preference<br>  const adapter = featureFlag === &quot;v2&quot; ? adaptAPIv2Response : adaptAPIv1Response;<br>  <br>  const { data, loading, error, loadMore, hasNextPage } = usePaginatedQuery(<br>    featureFlag === &quot;v2&quot; ? GET_DATA_V2 : GET_DATA_V1,<br>    {},<br>    adapter // Pass the adapter function based on feature flag<br>  );<br><br>  if (loading &amp;&amp; !data.length) return &lt;p&gt;Loading...&lt;/p&gt;;<br>  if (error) return &lt;p&gt;Error: {error.message}&lt;/p&gt;;<br><br>  return (<br>    &lt;div&gt;<br>      {data.map((item) =&gt; (<br>        &lt;div key={item.id}&gt;<br>          &lt;p&gt;{item.name} - {item.value}&lt;/p&gt;<br>        &lt;/div&gt;<br>      ))}<br>      {hasNextPage &amp;&amp; (<br>        &lt;button onClick={loadMore} disabled={loading}&gt;<br>          {loading ? &quot;Loading...&quot; : &quot;Load More&quot;}<br>        &lt;/button&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}</pre><p>By introducing the Adapter pattern to the usePaginatedQuery hook, we can seamlessly support multiple API versions without duplicating UI logic. Since the hook is generic, the adapter can be implemented for any type of request, normalizing data from different APIs into a consistent format. Adapters are pure functions, making them easy to test independently. This approach keeps the code clean, flexible, and maintainable, allowing the same UI to handle different response structures effortlessly, while ensuring that each part can be tested in isolation.</p><h3><strong>From Indirection to Complete Decoupling: The Observer Pattern</strong></h3><p>So far, we’ve explored how indirection adds an intermediary to keep things loosely connected. But what if we want to take it a step further — what if we want to completely eliminate the need for components to know anything about each other? This is where the Observer Pattern shines. Rather than simply redirecting interactions, the Observer Pattern allows components to communicate without being directly connected at all. Instead of one component calling another, components simply emit events, and anyone interested can listen and react accordingly. It’s like an announcement system: one entity shouts a message into the void, and whoever is interested can pick it up and act on it — no one needs to know who else is listening.</p><p>This complete decoupling makes our components even more independent, reducing dependencies and giving us a more flexible architecture. Let’s dive into how this works by creating an Event Emitter for tracking user actions on an e-commerce platform. Instead of embedding tracking logic directly into each component — say, for analytics, logging, or third-party integrations — we’ll use the Observer Pattern to broadcast events that any interested party can listen to. This way, we keep our components clean, modular, and agnostic of their dependencies, while still capturing all the necessary interactions.</p><p><strong>Step 1: Create a Global Event Emitter</strong></p><p>We will use <strong>Node.js </strong>EventEmitter to build a centralized event bus.</p><pre>import { EventEmitter } from &#39;events&#39;;<br><br>// Create a singleton event emitter instance<br>const eventBus = new EventEmitter();<br><br>export default eventBus;</pre><p><strong>Step 2: Emit Events from User Actions</strong></p><p>In an e-commerce store, different UI components should be able to <strong>emit user events</strong> when interactions happen.</p><p>Example: <strong>Emitting an “add to cart” event from a button click</strong></p><pre>import eventBus from &#39;../services/eventBus&#39;;<br><br>const ProductPage = ({ product }) =&gt; {<br>  const handleAddToCart = () =&gt; {<br>    eventBus.emit(&#39;add_to_cart&#39;, { <br>      productId: product.id, <br>      name: product.name, <br>      price: product.price, <br>      timestamp: Date.now()<br>    });<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h2&gt;{product.name}&lt;/h2&gt;<br>      &lt;button onClick={handleAddToCart}&gt;Add to Cart&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default ProductPage;</pre><p><strong>Step 3: Subscribe to Events (Analytics &amp; Third-party Integration)</strong></p><p>Now, let’s <strong>listen</strong> for these events and send the data to <strong>Google Analytics, Facebook Pixel, or a custom service</strong>.</p><p>Example: <strong>Centralized Analytics Listener</strong></p><pre>import eventBus from &#39;../services/eventBus&#39;;<br><br>// Google Analytics integration<br>eventBus.on(&#39;add_to_cart&#39;, (data) =&gt; {<br>  console.log(&#39;[Analytics] Add to Cart:&#39;, data);<br>  window.gtag(&#39;event&#39;, &#39;add_to_cart&#39;, {<br>    items: [{ id: data.productId, name: data.name, price: data.price }],<br>    event_time: data.timestamp<br>  });<br>});<br><br>// Custom logging service<br>eventBus.on(&#39;add_to_cart&#39;, (data) =&gt; {<br>  console.log(&#39;[Logging Service] User added product to cart:&#39;, data);<br>  fetch(&#39;/api/log-event&#39;, {<br>    method: &#39;POST&#39;,<br>    body: JSON.stringify(data),<br>    headers: { &#39;Content-Type&#39;: &#39;application/json&#39; }<br>  });<br>});</pre><p>Using an event emitter for e-commerce tracking offers several key benefits. First, it promotes<strong> loose coupling</strong>, meaning you don’t have to modify individual components when integrating new analytics services. This flexibility ensures that changes are easier to manage. Secondly, it <strong>enhances scalability</strong> by allowing multiple services to subscribe to the same event without interfering with each other, making it simple to add or modify tracking capabilities as the system grows. Finally, it provides <strong>centralized control</strong>, consolidating all event tracking logic in one place, which simplifies debugging and ensures that tracking is consistent across the application.</p><h3>Summary</h3><p>Indirection and Observer patterns are key to creating clean, maintainable code in large-scale applications. Indirection acts as an intermediary, enabling decoupled interactions between components, often through techniques like proxy or service layers, making your code more flexible and testable. For instance, using a mock API service layer for development or testing can speed up iteration without affecting core business logic. Meanwhile, the Observer pattern allows components to communicate through events, reducing tight coupling. It’s like having a global event system where components can publish and subscribe to changes without needing to know who’s listening, enhancing scalability. Together, these patterns improve flexibility, ease of maintenance, and modularity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d34f7a8ec9ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>