<?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 Nikita Lapin on Medium]]></title>
        <description><![CDATA[Stories by Nikita Lapin on Medium]]></description>
        <link>https://medium.com/@nikilapi?source=rss-fb32efec57b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Zf7YLnDkjq-aYFSbHCztow.jpeg</url>
            <title>Stories by Nikita Lapin on Medium</title>
            <link>https://medium.com/@nikilapi?source=rss-fb32efec57b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:31:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikilapi/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[That’s why you should read “RESTful Web Services Cookbook”. Book review]]></title>
            <link>https://medium.com/@nikilapi/thats-why-you-should-read-restful-web-services-cookbook-book-review-4d05fa4e133c?source=rss-fb32efec57b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d05fa4e133c</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Nikita Lapin]]></dc:creator>
            <pubDate>Sat, 10 Sep 2022 15:01:23 GMT</pubDate>
            <atom:updated>2022-09-10T15:01:23.191Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3mMYttbRPqFGa7s0.jpg" /></figure><p>I’ve seen so many bad-designed APIs. Moreover, I did that too. So I’ve tried to find a good theory article or book on how to design and maintain REST in the right way, so people don’t get hurt using it.</p><h3>What did this book give me?</h3><p>I read a lot of articles about API design, but still, something fundamental was missing. Some kind of basic knowledge. Whenever I read any literature, I try to immediately think about whether I make my projects according to this theory. Thanks to this, I can understand if the advice is really good or if it is very situational, and in our case, we have done well to take a step to the side for sake of the user experience. It’s always some kind of trade-off.</p><p>Several years ago, at work, I had to do a thing in which, at that time, I was not very good at — writing backend. Writing a backend includes writing some kind of API to work with your server. I know some things about API versioning, and HTTP methods, but it was all at a basic level. I still lacked knowledge about how to properly design URLs, and how to define resources, caching, and security. In order to gain that knowledge, I read articles, watched videos, and it really helped. This book also became one of the bricks and concrete to pour all that knowledge and consolidate them together. The book has its flaws, of course, but it was useful for me.</p><h3>What is this book?</h3><p>REST is all around us. We ask and are asked about that in interviews. When we want to get any data, that server will most likely use the REST API.</p><p><strong>Who is this book for:</strong></p><ul><li>For those who have never worked with REST before and want to understand how to do it correctly.</li><li>For those who want to close the blind spots in the REST topic.</li><li>For those who like practically oriented books.</li></ul><p><strong>Who does not need this book:</strong></p><ul><li>For those who have been making REST APIs for years and know the basics thoroughly. You are unlikely to find anything interesting in this book</li><li>For those interested in the low-level theory of HTTP.</li></ul><h3>Why should you or shouldn’t you read it?</h3><p>The book was published in 2010. A lot of new things have appeared since that time, but still, the basic concepts have not gone anywhere. If you already have the fundamentals, you can safely skip this book.</p><h3><strong>P.S.</strong></h3><p>Thank you all for reading. If you liked this review <strong>do not forget to clap</strong> 👏 and add this to your list or share it with your colleagues. Some useful links are listed below:</p><p><strong>Telegram channel</strong>, where I write and repost some useful articles and express my own opinion on some Mobile/Backend technologies.</p><p><a href="https://t.me/nikilapi_public">nikilapi</a></p><p><strong>GitHub:</strong></p><p><a href="https://github.com/lapin7771n">lapin7771n - Overview</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d05fa4e133c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Hexagonal Architecture. Part 2. Authentication.]]></title>
            <link>https://medium.com/@nikilapi/flutter-hexagonal-architecture-part-2-authentication-17a1464c0eaa?source=rss-fb32efec57b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/17a1464c0eaa</guid>
            <category><![CDATA[programming-paradigms]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Nikita Lapin]]></dc:creator>
            <pubDate>Fri, 10 Jun 2022 14:48:50 GMT</pubDate>
            <atom:updated>2022-06-10T14:48:50.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Article title as image" src="https://cdn-images-1.medium.com/max/1024/1*8MY7t30pkUcJ1aCc1zHQGw.jpeg" /></figure><p>In the previous part, we talked about the basic concepts of Hexagonal Clean Architecture.</p><figure><img alt="Hexagonal Architecture overview" src="https://cdn-images-1.medium.com/max/956/0*EIjk7Nw0PwYJM5ct.png" /><figcaption>Architecture overview (Main modules)</figcaption></figure><p>Enough of theory, let’s do some practice.</p><p>We will try to implement Authentication using <a href="https://firebase.google.com/">Firebase</a> with an email and password provider. Our goal is to see <a href="https://github.com/lapin7771n/flutter-hexagonal-architecture">how to apply Hexagonal Architecture to the enterprise case</a>. Here are our <strong>use cases</strong>:</p><ul><li>As a user, I’d like to have the ability to log in with email and password.</li><li>As a user, I’d like to have the ability to log out from a previously logged-in profile.</li><li>As a user, I’d like to be logged in every time I open the app if I logged in before.</li></ul><p><a href="https://medium.com/@nikilapi/i-found-the-perfect-architecture-for-flutter-apps-59fc2dc8f00f">Part 1. Introduction.</a></p><p>Part 2. Authentication. <strong>You are here.</strong></p><p>Part 3. Fetching data. <em>Coming soon…</em></p><p>Part 4. Conclusion. <em>Coming soon…</em></p><p><strong>DISCLAIMER</strong>: In this case, we are coding a simple application, but Hexagonal Architecture may be a perfect fit for large enterprise applications. If your application has simple CRUD commands, maybe it’s overhead for you. So be skeptical about applying this while reading further.</p><p>Ok, let’s start from the heart of the app — <strong>Entity</strong>.</p><h3>Entity</h3><blockquote>Entities encapsulate <strong>Enterprise wide</strong> business rules. An entity can be an object with methods, or it can be a set of data structures and functions. It doesn’t matter so long as the entities could be used by many different applications in the enterprise.</blockquote><blockquote>If you don’t have an enterprise, and are just writing a single application, then these entities are the business objects of the application. They encapsulate the most general and high-level rules. They are the least likely to change when something external changes. For example, you would not expect these objects to be affected by a change to page navigation, or security. No operational change to any particular application should affect the entity layer.</blockquote><blockquote><strong>The Clean Code Blog by Robert C. Martin (Uncle Bob)</strong></blockquote><p>In the authentication use case, there are no specific domain rules that will be implemented in the current sample. You can update passwords and email, and apply other business rules here. The extended domain model will be implemented in the following articles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*W6i5d0ToxJLtFYd0MGJSaQ.png" /><figcaption>user.dart</figcaption></figure><h3>Use Case</h3><p>Why do we need UseCase?</p><p>According to the <em>Robert C. Martin (Uncle Bob)</em> <strong><em>Use Case</em></strong> is:</p><blockquote>The software in this layer contains <strong>application specific</strong> business rules. It encapsulates and implements all of the use cases of the system. These use cases orchestrate the flow of data to and from the entities, and direct those entities to use their <strong>enterprise wide</strong> business rules to achieve the goals of the use case.</blockquote><blockquote>We do not expect changes in this layer to affect the entities. We also do not expect this layer to be affected by changes to externalities such as the database, the UI, or any of the common frameworks. This layer is isolated from such concerns.</blockquote><blockquote>We <strong>do</strong>, however, expect that changes to the operation of the application <strong>will</strong> affect the use-cases and therefore the software in this layer. If the details of a use-case change, then some code in this layer will certainly be affected.</blockquote><p><strong><em>Use Cases</em></strong> usually do such things:</p><ol><li>Take input</li><li>Validate business rules</li><li>Manipulate model state</li><li>Return output</li></ol><p>Don’t confuse input and business validation. According to the book <em>“Get Your Hands Dirty on Clean Architecture” by Tom Hombergs</em></p><blockquote>Validating a business rule requires access to the current state of the domain model while validating input does not.</blockquote><p>Input validation is not part of business rules, but it should be done inside the application core. There are several reasons to do so: we shouldn’t trust adapters to validate their input and it will reduce the amount of repeated code in case several adapters call the same <strong>Use Case</strong>.</p><figure><img alt="Login Command Dart class" src="https://cdn-images-1.medium.com/max/1024/1*b-YzdPIdWKqqQe7cN89EgQ.png" /><figcaption>login_command.dart</figcaption></figure><p>There are several use-cases that we will implement. The first one is <strong>Log in</strong> use-case.</p><figure><img alt="Login Use Case class" src="https://cdn-images-1.medium.com/max/1024/1*rOhMIVi4mYvjbp0fuKqK1Q.png" /><figcaption>login_use_case.dart</figcaption></figure><p><strong>UseCase interface (abstract class in the case of Dart) is the input port in terms of Hexagonal Architecture. The service that implements abstract classes is UseCase itself.</strong></p><p>If you can Log in to the system there should be functionality to<strong> log out</strong> from the session:</p><figure><img alt="Log out Use Case class" src="https://cdn-images-1.medium.com/max/1024/1*lhwWWDHQuURAVG_1R-EgyQ.png" /><figcaption>logout_use_case.dart</figcaption></figure><p>If you open the app with the cold boot (the app is not loaded from the RAM but loads to the memory) you should check if the user is logged in. To do so let’s create a separate UseCase:</p><figure><img alt="Load User use case class" src="https://cdn-images-1.medium.com/max/1024/1*g1k5eF9495d1qdK4YpJOHw.png" /><figcaption>load_user_use_case.dart</figcaption></figure><p>We are using <strong>Stream&lt;User?&gt;</strong> to be notified if the user logged out from the app or changed.</p><p>Let’s see in which way to implement such use-cases:</p><figure><img alt="Auth Service that implements several use cases. Login, logout, load user use cases" src="https://cdn-images-1.medium.com/max/1024/1*_yvVzH5WHVLLiDB7ABAp6Q.png" /><figcaption>auth_service.dart</figcaption></figure><p>As we saw in the picture of the Hexagonal Architecture UseCases communicate with the outer world through the ports.</p><p>In Flutter world UI triggers communication with UseCase through the BLoC library (you can use the state management tool you like).</p><h3><strong>UI Adapter</strong></h3><blockquote>The outermost layer is generally composed of frameworks and tools such as the Database, the Web Framework, <strong>Flutter Framework</strong> etc. Generally you don’t write much code in this layer other than glue code that communicates to the next circle inwards.</blockquote><blockquote>This layer is where all the details go. The <strong>Flutter</strong> is a detail. The database is a detail. We keep these things on the outside where they can do little harm.</blockquote><p>👆 I’ve selected text bold I changed to have an understanding of how to apply Clean Architecture to the Flutter.</p><p>We will discuss BLoC implementation, not widgets. My suggestion is to have one BLoC for each screen that should interact with application business logic. We have very primitive BLoC classes that describe interaction with User Interface. Let’s discuss each element separately:</p><p>The authentication event describes how the user interacts with the app. If the user clicks on the Login button UI fires an event to the Authentication BLoC. The same for the log-out functionality.</p><figure><img alt="BLoC events" src="https://cdn-images-1.medium.com/max/1024/1*R3WUzDp3fxGdqA6VBdniAg.png" /><figcaption>auth_event.dart</figcaption></figure><p>States express the current situation inside the app.</p><ul><li>An <strong>Initial State</strong> is needed to show the splash screen and to indicate that we need to clarify the login status.</li><li><strong>AuthLoggedInState </strong>shows us that the user is logged in and we can show the Profile Details page.</li><li><strong>UnauthState</strong> is needed to indicate that we have to redirect the user to the login page.</li></ul><figure><img alt="BLoC states" src="https://cdn-images-1.medium.com/max/1024/1*y7sa3dG1qmdJsqpB4dHA3Q.png" /><figcaption>auth_state.dart</figcaption></figure><p>The presentation layer (BLoC) is placed outside of the application core so it interacts with the application through input ports (use case interfaces).</p><figure><img alt="Authentication bloc class" src="https://cdn-images-1.medium.com/max/1024/1*XoaDl4wrRbaMx1t6XMKy_w.png" /><figcaption>auth_bloc.dart</figcaption></figure><h3>Folder structure (packages structure)</h3><p>Last but not least. We have so many elements, such as use cases, input and output ports, and incoming (<em>BLoC</em>) and outgoing (<em>Network repositories, Firebase Auth package</em>) adapters in our Hexagonal Architecture. So we should find a way to structure them into our project:</p><figure><img alt="folder structure with lob as root folder" src="https://cdn-images-1.medium.com/max/1024/1*i1LXiM0w0n3g-GmB21A1bA.png" /></figure><h3>P.S.</h3><p>Thank you all for reading. That was the second article in a series of Hexagonal Architecture usage for the Flutter enterprise project. If you liked this article <strong>do not forget to clap</strong> 👏 and add this to your list or share it with your colleagues. Some useful links are listed below:</p><p><strong>Telegram channel</strong>, where I write and repost some useful articles and express my own opinion on some Mobile/Backend technologies.</p><p><a href="https://t.me/nikilapi_public">nikilapi</a></p><p><strong>GitHub</strong> project:</p><p><a href="https://github.com/lapin7771n/flutter-hexagonal-architecture">GitHub - lapin7771n/flutter-hexagonal-architecture: Hexagonal Clean Architecture adapted to the Flutter app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17a1464c0eaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I found the perfect Architecture for Flutter apps.]]></title>
            <link>https://medium.com/@nikilapi/i-found-the-perfect-architecture-for-flutter-apps-59fc2dc8f00f?source=rss-fb32efec57b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/59fc2dc8f00f</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Nikita Lapin]]></dc:creator>
            <pubDate>Fri, 27 May 2022 21:04:31 GMT</pubDate>
            <atom:updated>2022-07-22T09:46:19.438Z</atom:updated>
            <content:encoded><![CDATA[<p>As professional engineers, we all want to write maintainable and easy-to-understand code. But how can we succeed if we build on the wrong foundation? That’s where good architecture comes into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KcA3ptDox2uP1ZAN" /><figcaption>Photo by <a href="https://unsplash.com/@danist07?utm_source=medium&amp;utm_medium=referral">Danist Soh</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Each architecture serves its needs. So if you have a simple CRUD application, that will be an overhead for you. But in case you seek an enterprise solution, take a seat and read this article.</p><p>Part 1. Introduction. <strong>You are here.</strong></p><p><a href="https://medium.com/@nikilapi/flutter-hexagonal-architecture-part-2-authentication-17a1464c0eaa">Part 2. Authentication.</a></p><p>Part 3. Fetching data. <em>Coming soon…</em></p><p>Part 4. Conclusion. <em>Coming soon…</em></p><p>As a reference, I’ve taken <a href="https://reflectoring.io/spring-hexagonal/">Hexagonal Architecture</a> by <a href="https://reflectoring.io/authors/tom">Tom Hombergs</a>. I really advise you to read his book. There are a lot of hidden depths.</p><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*qLuUKv-rySm1ulwxsYM-bw.png" /><figcaption>Architecture overview (Main modules)</figcaption></figure><h3>Entity</h3><ul><li>Domain rules</li><li>Has no dependency on outwards components</li><li>Pure Dart classes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nrlrYnNaz057O4Can7SPIA.png" /></figure><h3>UseCase</h3><blockquote>The software in this layer contains <em>application specific</em> business rules. It encapsulates and implements all of the use cases of the system. These use cases orchestrate the flow of data to and from the entities, and direct those entities to use their <em>enterprise wide</em> business rules to achieve the goals of the use case.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Xy38yPMVPIwfFPPGPB4Cg.png" /><figcaption>Use Case implementation</figcaption></figure><h3>Input and Output ports</h3><ul><li>Interfaces</li><li>Every communication to and from the outside happens through dedicated “ports”.</li><li><strong>Input port</strong>: i.e. (<em>UseCase</em>)</li><li><strong>Output port</strong>: e.g. (<em>Port</em>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G0BsNAbMCoso8d0spsgVFA.png" /><figcaption>Input Port. Send Money Use Case</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9-ABJ73aYAXSNB-CCO0yRA.png" /><figcaption>Output Ports. Load and Update Account Port</figcaption></figure><p>Why do we need to slice persistence adapter instead of creating a general one? As Robert C. Martin said:</p><blockquote><em>“Depending on something that carries baggage that you don’t need can cause you troubles that you didn’t expect.”</em></blockquote><p>The Interface Segregation Principle provides an answer to this problem. It states that broad interfaces should be split into specific ones so that clients only know the methods they need. So when we work on some Service we just plug in the ports we need.</p><h3>Adapters</h3><ul><li>Form of an outer layer of the hexagonal architecture</li><li>Not part of the core but interact with it</li><li><strong>Input adapters</strong>: Call the input ports to get something done. (<em>Flutter UI/BLoC</em>)</li><li><strong>Output adapters</strong>: Called by <em>UseCase</em>. Implementation of the output ports (e.g. <em>Data Repositories, Cloud Repositories</em>)</li></ul><p><strong>Input adapter</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hfZZVRyE_asou6IV6vxQbw.png" /><figcaption>Input Adapter. Send Money BLoC</figcaption></figure><p><strong>Output adapter</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKCQpZFXzUj7j55BPj7ZlA.png" /><figcaption>Output adapter. Data Adapter.</figcaption></figure><h3>Organizing code</h3><p>I think that organizing the packages has the same importance as writing clean code and making clean architecture. In my perfect world packaging structure represent and express your architecture. Just one look at the packages should say to you what architecture you are using.</p><p>My favorite is to create <strong>layer-driven packages</strong> (i.e. domain, inner, outer) with features-related code inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nslQ_RNqUHyk1gDF52Dm4A.png" /></figure><p>Thank you for reading till the end. I have <a href="https://t.me/nikilapi_public">a Telegram channel</a> with useful articles that I try to post every day. Take care. See you in the next one.</p><p>Glory to Ukraine 🇺🇦</p><p><a href="https://t.me/nikilapi_public">nikilapi</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59fc2dc8f00f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>