<?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 Tech at ZET on Medium]]></title>
        <description><![CDATA[Stories by Tech at ZET on Medium]]></description>
        <link>https://medium.com/@zetapp?source=rss-59343c71543e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-sUwqALsevwSLPqb3Bfc9Q.jpeg</url>
            <title>Stories by Tech at ZET on Medium</title>
            <link>https://medium.com/@zetapp?source=rss-59343c71543e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:41:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zetapp/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[State Machines: Unleashing the Power of Backend-Driven Systems]]></title>
            <link>https://zetapp.medium.com/state-machines-unleashing-the-power-of-backend-driven-systems-1438ea048dd7?source=rss-59343c71543e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1438ea048dd7</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[state-machine]]></category>
            <category><![CDATA[backend-driven-ui]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Tech at ZET]]></dc:creator>
            <pubDate>Thu, 13 Jul 2023 09:24:16 GMT</pubDate>
            <atom:updated>2023-07-13T09:24:16.635Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TPNPleI5U1PEFsiOMsZR-A.jpeg" /></figure><blockquote>Increased top of the funnel for adding customer onto our platform by <strong>10%</strong>, leveraging State Machine.</blockquote><h3>Introduction</h3><p>In the world of software engineering, state machines have emerged as indispensable tools for solving complex problems and creating efficient, backend-driven systems. By organizing and automating processes, state machines provide a structured approach to managing system behavior and also a way such that developers can effectively manage UI behavior, handle complex workflows, and ensure a seamless user experience. In this article, we will explore why state machines are crucial, the problems they can solve, their technical explanation, and the benefits they offer.</p><h3>Need of the State Machines</h3><p>State machines are crucial because they allow us to control and coordinate the behavior of complex systems. As applications and processes become more intricate, it becomes increasingly challenging to manage and track their various states and transitions. State machines excel at solving problems that involve managing workflows, concurrent processes, and tracking the state of a system. They are handy in scenarios with multiple possible states and transitions, and the system behavior depends on specific conditions or events. State machines help in ensuring that processes follow a defined sequence and react appropriately to different inputs or situations. By incorporating state machines, developers can ensure consistent UI behavior, handle various edge cases, and simplify the implementation and maintenance of the UI logic.</p><h3>Understanding State Machines</h3><p>A state machine comprises the following components taking an example of backend-driven frontend design:</p><p><strong>State</strong>: It is a situation during the execution of a program. A state can be represented by a variable or an object.</p><p><strong>Event Data</strong>: This is the input from the front end, like user input and other parameters.</p><p><strong>Action Data: </strong>This is the output we are getting from the machine and returning to the front end.</p><p><strong>Transition</strong>: It is a change of state that occurs when an event occurs. An event can be a user input, a timer, or a system message. A transition is a list that you can store in memory or in a database. Transition consists of</p><ul><li><strong>Source</strong>: This is the start state of a transition.</li><li><strong>Conditions</strong>: It is a list of conditions that we’ll evaluate before moving to any other state, like satisfying all the conditions or requirements to move to that state.</li><li><strong>Before Trigger</strong>: This is an action we do before moving to a state like SNS subscriptions sending the message to any asynchronous task also.</li><li><strong>Trigger</strong>: This is an action we perform for moving the user into that state, like saving user input or processing other things.</li><li><strong>AfterTrigger</strong>: Generally we are using it to do some post-processing and returning to the next state. You can configure it accordingly.</li></ul><pre>class Transition{<br><br> String source;<br>  <br> List&lt;String&gt; allConditions;<br> <br> String beforeTrigger;<br> <br> String trigger;<br> <br> String afterTrigger;<br><br>}</pre><p><strong>GetNextAction Service:</strong> It’ll match the current state with the user state and then perform all the validation over all the conditions if it’s valid for the user then perform before trigger, trigger, and after trigger.</p><pre>getNextAction{<br>for (Transition transition : transitions) {<br>  if (condition) {<br>    // condition: userSoruce matches with current state of transitions and all conditions are true for this transition<br>    performBeforeTrigger(transition.getBeforeTrigger(), eventdata);<br>    performTrigger(transition.getTrigger(), user, eventdata);<br>    performAfterTrigger(transition.getAfterTrigger(), user, eventdata);<br>      }<br>    }<br>}</pre><p>We are using reflections to execute methods and the machine code somewhat looks like this</p><pre>class SignupMachine{<br>    transitions = new ArrayList&lt;&gt;();<br>    transitions.add(new Transition(source, ListofConditions, Before trigger, trigger,<br>        After trigger));<br>}</pre><p>For example how ATM state machine will work</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*1jlBZaV3sMlFIIKG.png" /></figure><h3>Benefits of State Machines</h3><p><strong>Modularity and Maintainability</strong>: State machines enable modular design, dividing complex systems into manageable states and transitions. This modular structure facilitates ease of maintenance, testing, and debugging, as changes made to a specific state or transition do not affect the entire system.</p><p><strong>Consistent Behavior</strong>: State machines ensure that UI components behave consistently and predictably across different states and interactions. By explicitly defining state transitions and event triggers, developers can eliminate unexpected UI behavior and create a smoother user experience.</p><p><strong>Flexibility and Extensibility</strong>: State machines offer flexibility in accommodating changes or additions to the system’s behavior. By simply adding or modifying states and transitions, new features or requirements can be integrated without requiring significant modifications to the existing codebase.</p><p><strong>Error Handling and Validation</strong>: State machines facilitate robust error handling by defining how the system should react in exceptional scenarios. By including error states and transitions, it becomes easier to detect and handle errors, ensuring the system behaves predictably even under unexpected circumstances.</p><p><strong>Efficiency and Performance</strong>: State machines provide an efficient and optimized approach to managing system behavior. By explicitly defining all possible states and transitions, unnecessary computations or checks can be avoided, leading to improved performance and responsiveness.</p><p><strong>Backend-Driven Systems</strong>: State machines play a crucial role in making systems backend-driven. By defining the behavior and rules in a state machine, the logic resides on the server side, reducing the complexity on the client side. This ensures consistent behavior across different platforms and provides better control over the system.</p><p><strong>Scalability and Maintenance</strong>: State machines promote modularity and maintainability in UI development. By breaking down the UI logic into states and transitions, developers can make changes or add new features without disrupting the entire system. This modular structure enhances scalability and facilitates efficient maintenance.</p><h3>Conclusion</h3><p>State machines provide a structured and efficient approach to modeling complex systems, enabling backend-driven behavior and simplifying the design and implementation of processes. By defining states, transitions, and events, state machines ensure that systems respond predictably and appropriately to different inputs and conditions. By leveraging the benefits of modularity, readability, flexibility, error handling, and efficiency, state machines enable us to build robust and reliable software systems in a scalable and manageable manner.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1438ea048dd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Infrastructure migration from AWS Elastic Beanstalk to EKS]]></title>
            <link>https://zetapp.medium.com/infra-migration-from-aws-elastic-beanstalk-to-eks-23072f96e340?source=rss-59343c71543e------2</link>
            <guid isPermaLink="false">https://medium.com/p/23072f96e340</guid>
            <category><![CDATA[containerization]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[ek]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Tech at ZET]]></dc:creator>
            <pubDate>Tue, 27 Jun 2023 08:38:25 GMT</pubDate>
            <atom:updated>2023-06-27T09:35:04.072Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jya93-vZEGERCHov-g-eAQ.jpeg" /></figure><p>In today’s dynamic and rapidly evolving technology landscape, businesses constantly seek ways to optimize their infrastructure for better scalability, flexibility, and efficiency. One such transition is that many organizations considered a migration from Elastic Beanstalk to the AWS Kubernetes platform. In this short blog post, we’ll explore the reasons behind this shift, the challenges we face, and the benefits we gained from revamping our infrastructure.</p><p><strong>Understanding Elastic Beanstalk and AWS Kubernetes Platform:</strong></p><ul><li><strong>Elastic Beanstalk: </strong>This AWS managed service provides a platform that abstracts away the infrastructure-related complexity so the developers can focus on applications code &amp; functionality. Here the developers can just deploy their code by uploading the code. It is easy to use and integrates with other AWS services for improvement on top of it.</li><li><strong>AWS Kubernetes Platform (EKS): </strong>EKS is a container orchestrating managed service provided by AWS which simplifies the management of Kubernetes clusters and automates many of the tasks associated with running and scaling containerized applications. Many benefits &amp; challenges come with it that we will discuss in further sections.</li></ul><p><strong>The Motivation to Migrate:</strong></p><ul><li><strong>Scalability and Flexibility:</strong> When the organization starts the main concerns lie with functionality &amp; quality. However, as it grew along with the code, the infrastructure should be able to adapt to the needs of business &amp; scale requirements. Elastic Beanstalk is primarily for rapid development and the generic infrastructure pattern that is hard to customize &amp; control. As the application becomes more complex, we need to handle those complexities by finer tuning and control over networking, configuration &amp; deployment strategies. Elastic Beanstalk provides containerized deployment, however, it doesn’t provide sophistication at the Kubernetes level yet. Also, Elastic Beanstalk is AWS specific vendor service that inherited creates the dependency that is not adaptive in cloud providers. As the application package size increases there is a hard package limitation of 500 MBs from ELB that hinders deployment.</li><li><strong>Containerization Benefits:</strong> Containerization makes the application encapsulation &amp; portable. So testing in different environments is not an issue for the same application on platforms. The isolation level increases from VM to the process level for the container which guards the application. Also, multiple processes can save us the compute &amp; utilize it efficiently. The declarative way of deployment help us makes it easily manageable. The Kubernetes scheduler and fault tolerance help immensely.</li><li><strong>Ecosystem and Community Support: </strong>On top of all the points mentioned above, the Kubernetes community is evolving every day, and more &amp; more adoption and integration with tools are being created.</li></ul><p><strong>Planning the Migration &amp; Overcoming the Challenges:</strong></p><ul><li><strong>Assessing existing application(s) Architecture: </strong>We started with identifying and jotting down all the dependencies, database configurations, resource requirements &amp; integrations for existing applications. Identifying whether the application(s) is monolithic or microservice in nature it helps you in the longer run. We have multiple services as microservices so it was straightforward however, we also have one giant monolithic application. So we took this opportunity to break it into potential microservices. Most of the services are stateless which came in handy however, we planned the storage persistence (AWS EBS, EFS, or a third-party solution) where they are needed. These conditions were needed to be also kept in mind with the scale of the application for the future ahead. That’s where Kubernetes shines as it is also evolving in nature. We have dissected the existing application configuration to Kubernetes components &amp; designed the template.</li><li><strong>Containerization and Image Building: </strong>As the containerized application needs dependency in check we followed best practices to create images where it considers specific versions, a well-known dependency provider which remediates security vulnerability &amp; loopholes.</li><li><strong>Kubernetes Cluster Design: </strong>Based on the research and experience, we have designed the resource requirement and reliability parameters in the form of computing, network, scalability, and availability of infrastructure.</li></ul><p><strong>Benefits of Adopting AWS Kubernetes Platform:</strong></p><ul><li><strong>Improved Scalability and Resource Utilization: </strong>Kubernetes etcd component keeps tabs on resources of the existing cluster so allocation made by it are reliable. However, for the second round of safety, we have also integrated the third-party tool for scaling by provisioning additional resources. However, when it comes to Elastic Beanstalk they were hard to customize where here we can customize it on the application level &amp; over the infrastructure level so we can make more optimized decisions.</li><li><strong>Service Resilience and High Availability: </strong>We have kept the replica set for all of our applications, so Kubernetes takes care of it natively. Also from the infrastructure standpoint, we have added 3 availability zone and node arrangements making it more resilient to failures.</li><li><strong>Enhanced Development and Deployment Workflow: </strong>We have integrated GitHub workflows for different environments which is very is with templating which comes in handy with AWS Kubernetes. Most of our services are somehow part of the eco-system so it is easy to integrate and experiment with additional services using AWS managed EKS platform.</li></ul><p><strong>Lessons Learned and Best Practices:</strong></p><ul><li><strong>Monitoring and Observability: </strong>As the infrastructure becomes more complex, you also need to put more guards and monitoring to find the origin of problems in terms of monitoring &amp; alerting. We have integrated native tools like Prometheus &amp; grafana for it. Also, the Prometheus alert manager specifically helped us a lot. Integrating third-party tools like Karpenter helped us with scaling with sudden traffic. For the logging of the application, we started to use AWS-managed OpenSearch which is used for centralized logging.</li><li><strong>Security Considerations: </strong>RBAC setup has been a cornerstone for this requirement whereas with Kubernetes we are experimenting with new things. Where this can be a separate blog post so let’s talk about it in a separate blog.</li><li><strong>Continuous Learning and Adaptation: </strong>As we have the microservice environment and more environments to play around with more cost-efficient &amp; secure way, it makes it easy to integrate with new services and adopt the new changes quickly.</li></ul><p><strong>Conclusion:</strong></p><p>Revamping our infrastructure from Elastic Beanstalk to the AWS Kubernetes platform has been a transformative journey for our organization. By adopting Kubernetes, we have gained scalability, flexibility, and improved operational efficiency. While the migration process presented its challenges, the benefits we now enjoy outweigh the initial complexities. As technology continues to evolve, businesses need to evaluate and adapt their infrastructure to stay ahead.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23072f96e340" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building universal apps in react native ( Part 1 — Design System )]]></title>
            <link>https://zetapp.medium.com/building-universal-apps-in-react-native-part-1-design-system-243749fbab72?source=rss-59343c71543e------2</link>
            <guid isPermaLink="false">https://medium.com/p/243749fbab72</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[universal-app]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Tech at ZET]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 06:03:38 GMT</pubDate>
            <atom:updated>2023-06-14T11:06:19.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Universal Apps in React Native ( Part 1 — Design System )</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GFZmf856-VVYKxqHT5XWww.jpeg" /></figure><p>At Zet, our mission is to make our fintech solutions accessible across all platforms. To accomplish this ambitious goal, we have invested significantly in building universal applications. And when it comes to building cross-platform apps, there’s no technology that outperforms React Native.</p><p>As we embarked on this journey, we quickly realized the importance of choosing the right set of libraries to lay the foundation for our applications. In this article, we will delve into the decision-making process behind selecting the libraries that power our design system and state management solution.</p><p><strong>Design System</strong></p><p>Our design team has put in significant effort to develop a comprehensive design system. To bring this design system to life in a React Native environment, we conducted thorough research and shortlisted several libraries. Our goal was to create a universal design system that would seamlessly function across mobile, web, and desktop platforms. In this section, we will discuss the libraries we considered and outline their key features and advantages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdZ0nzrq5MCF0qvCKSuF9w.png" /><figcaption>Button usage guidelines from our universal design system — <a href="https://medium.com/u/557724753cfd">Ashish Negi</a></figcaption></figure><p><strong>1. Nativewind:</strong></p><p><a href="https://www.nativewind.dev/">Nativewind</a> brings tailwind support to React Native, offering a robust set of features and enhancements. We were particularly drawn to the recently announced version 3, which introduced exciting new features, including support for variants, compound variants, and defaultProps. These additions greatly improved the developer experience (DX) and allowed us to iterate faster. Moreover, Nativewind provides excellent TypeScript support, ensuring type safety throughout the development process.</p><p>Example usage of Nativewind:</p><pre>import { styled } from ‘nativewind’;<br>import {Text} from ‘react-native’<br>const Typography = styled(‘Text’, ‘font-normal’<br> variants: {<br> heading: ‘text-2xl font-bold’,<br> subheading: ‘text-lg font-semibold’,<br> body: ‘text-base’,<br> },<br>});<br>// Usage<br>&lt;Typography variant=&quot;heading&quot;&gt;Welcome to Zet&lt;/Typography&gt;</pre><p><strong>2. Tamagui:</strong></p><p><a href="https://tamagui.dev/">Tamagui</a> is a popular library that inherently offers tools for building a fully typed design system. However, when we started our project, it was still in its alpha phase and had several bugs. Considering the stability and reliability of our chosen library were crucial factors, we decided not to proceed with Tamagui.</p><pre>import { createFont, createTamagui, createTokens } from &#39;tamagui&#39; <br><br>const interFont = createFont({<br>  family: &#39;Inter, Helvetica, Arial, sans-serif&#39;,<br>  size: {<br>    1: 12,<br>    2: 14,<br>    3: 15,<br>  },<br>  lineHeight: {<br>    2: 22,<br>  },<br>  weight: {<br>    1: &#39;300&#39;,<br>    3: &#39;600&#39;,<br>  },<br>  letterSpacing: {<br>    1: 0,<br>    2: -1,<br>  },<br>  face: {<br>    300: { normal: &#39;InterLight&#39;, italic: &#39;InterItalic&#39; },<br>    600: { normal: &#39;InterBold&#39; },<br>  },<br>})</pre><p><strong>3. Shopify Restyle:</strong></p><p><a href="https://shopify.github.io/restyle/">Shopify Restyle</a> emerged as another strong contender, meeting all the requirements we had for our design system. However, after careful evaluation, we concluded that Nativewind had an advantage in terms of developer experience (DX) and the ability to iterate quickly.</p><pre>import { Text, createText } from &#39;@shopify/restyle&#39;;<br>import { ThemeProvider } from &#39;shopify-restyle&#39;;<br><br>const theme = {<br>  typography: {<br>    heading: {<br>      fontSize: 24,<br>      fontWeight: &#39;bold&#39;,<br>      color: &#39;#333&#39;,<br>    },<br>    subheading: {<br>      fontSize: 18,<br>      fontWeight: &#39;600&#39;,<br>      color: &#39;#555&#39;,<br>    },<br>    body: {<br>      fontSize: 16,<br>      color: &#39;#888&#39;,<br>    },<br>  },<br>};<br><br>const Typography = createText(theme);<br><br>// Usage<br>&lt;ThemeProvider theme={theme}&gt;<br>  &lt;Typography variant=&quot;heading&quot;&gt;Welcome to Zet&lt;/Typography&gt;<br>&lt;/ThemeProvider&gt;</pre><p><strong>4. Stylesheet (React Native):</strong></p><p>While it is possible to use the built-in <a href="https://reactnative.dev/docs/stylesheet">Stylesheet</a> in React Native to build a design system from scratch, we encountered challenges with the developer experience (DX). The lack of advanced features and additional tooling made it less ideal for our specific needs.</p><pre>import { StyleSheet, Text, View } from &#39;react-native&#39;;<br><br>const styles = StyleSheet.create({<br>  heading: {<br>    fontSize: 24,<br>    fontWeight: &#39;bold&#39;,<br>    color: &#39;#333&#39;,<br>  },<br>  subheading: {<br>    fontSize: 18,<br>    fontWeight: &#39;600&#39;,<br>    color: &#39;#555&#39;,<br>  },<br>  body: {<br>    fontSize: 16,<br>    color: &#39;#888&#39;,<br>  },<br>});<br><br>const Typography = ({ variant, children }) =&gt; {<br>  const textStyle = styles[variant] || styles.body;<br>  return &lt;Text style={textStyle}&gt;{children}&lt;/Text&gt;;<br>};<br><br>// Usage<br>&lt;Typography variant=&quot;heading&quot;&gt;Welcome to Zet&lt;/Typography&gt;</pre><p>After considering various factors, we decided to utilize Nativewind for building our universal design system in React Native. Its tailwind support, recent feature enhancements, and excellent TypeScript integration made it the most suitable choice for building universal apps.</p><p><strong>Documenting and Testing — Storybook</strong></p><p>Since, all the components in the design system are built in isolation.Hence, <a href="https://storybook.js.org/">Storybook</a> was the go to tool to document and test our components.</p><pre>import { ComponentMeta } from &#39;@storybook/react&#39;<br>import { Button } from &#39;./Button&#39;<br><br>export default {<br> title: &#39;Design/Button&#39;,<br> component: Button,<br> argTypes: {<br>   intent: {<br>     options: [&#39;primary&#39;, &#39;error&#39;, &#39;warning&#39;, &#39;success&#39;],<br>     control: {<br>       type: &#39;select&#39;,<br>     },<br>   },<br>   size: {<br>     options: [&#39;sm&#39;, &#39;md&#39;, &#39;lg&#39;],<br>     control: {<br>       type: &#39;select&#39;,<br>     },<br>   },<br>   disabled: {<br>     control: { type: &#39;radio&#39; },<br>     options: [true, false],<br>   },<br> },<br>} as ComponentMeta&lt;typeof Button&gt;</pre><p>A simplified version of the Button component story.</p><p>By leveraging <a href="https://www.nativewind.dev/">Nativewind</a>, we aimed to create an efficient design system that could be seamlessly applied across mobile, web, and desktop platforms. Further, Storybook served as an essential companion for design system development, offering a comprehensive platform for documenting, testing, and showcasing components in isolation.</p><p>Stay tuned for part 2!</p><p>Author — <a href="https://medium.com/u/591dd69925b9">Anurag Alla</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=243749fbab72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How did we implement A/B (Experiment) service?]]></title>
            <link>https://zetapp.medium.com/how-did-we-implement-a-b-experiment-service-c81cd0d63ef1?source=rss-59343c71543e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c81cd0d63ef1</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[spring-boot-2]]></category>
            <dc:creator><![CDATA[Tech at ZET]]></dc:creator>
            <pubDate>Thu, 01 Jun 2023 05:32:34 GMT</pubDate>
            <atom:updated>2023-06-01T05:32:34.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFTja3deg-1pFE_-HY0lKA.jpeg" /></figure><p>In business, sometimes we might have multiple solutions/features (flow in an app, colour, design) by our hypothesis and we may not be sure which one will work for the customers. So we decide to test them all out by releasing those features to a certain set of customers. We then analyse the data and make a calculated decision of which feature is serving best to our customers and decide to make it a permanent part of our app showing it to all users while discarding the other feature. This practice is commonly known as A/B Testing.</p><p><strong>What is A/B testing?</strong></p><p>A/B testing, also known as split testing, is a marketing experiment wherein you split your audience to test a number of variations of a campaign and determine which performs better. In other words, you can show version A of a content/feature/behaviour to one half of your audience, and version B to another.</p><p><strong>Why not use 3rd party services?</strong></p><p>We did use 3rd party X for A/B. With X, we observed the following problems:</p><ul><li>High latency because of server side tagging</li><li>Feature complexity</li><li>Tracking and impact measurement of split sections.</li><li>High cost</li></ul><p><strong>What our service offers?</strong></p><p>This service (implemented as a micro-service) will enable clients to do A/B testing. We can do any number of experiments with multiple features(return values). This is designed keeping in mind about scalability and further enhancements.</p><p><strong>Common functionality includes:</strong></p><ol><li>Ability to control a feature go-live on a restricted basis (specific users)</li><li>Enabling any feature for random(%) users</li><li>Evaluating the feature on the basis of user profile/specific parameters with complex logic</li><li>Ability to control a front-end feature (UI element) on a restricted basis</li><li>Adding/Editing the features in any experiment</li><li>Capability to make segments mutually exclusive</li><li>Ability to find out which user fall under a particular segment</li><li>All other analyses that could stem from such experiment</li></ol><p><strong>Tech Stack:</strong></p><p>Springboot, Java 8, Maven, Mysql, Groovy</p><p><strong>Schema Design:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EKIQgUhP0WOe577sEmpUcQ.png" /></figure><p>Here is a short description of what the above entities save. All entities extend BasEntity to get the common columns across all entities.</p><ol><li><strong>Experiment:</strong> All experiments will get saved here with a unique name and optional description.</li><li><strong>Feature:</strong> An experiment can have multiple features which will be saved in this table with unique name, optional description and experiment_id as foreign key to the experiment table.<br>Value is what that feature will return to the client in json format.<br>Whitelisted_users will contain a list of user_id as a comma separated list which will tell what users are assigned to this feature.</li><li><strong>Logic:</strong> Since each experiment can have certain criteria to divide the user segment on some condition, this condition will be saved in the condition column of the logic table. (We will come to implementation later)</li><li><strong>User_Feature_Mapping:</strong> Since we might want that once a user is assigned to a certain feature, it will remain in the same feature for future API calls. In other words, we might want to maintain consistency instead of evaluating logic(condition) every time.</li></ol><p><strong>Flow Design:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*az_UJe17wjvQg6FraUuavA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*XHmCrOFnRB_878pF5ngL_g.png" /></figure><p>Now we will see what the above 2 flows means:</p><p>The <strong>usePreCalculated</strong> flag is important here as it means whether we want to reuse the value contained in the User_Feature_Mapping table or evaluate the condition from the logic table again.</p><ol><li>If it is false, we will check in the whitelisted_list of each feature of the experiment. If it exists, then return value, else we will evaluate the logic and then accordingly return the feature value;</li><li>If it is true, we will first check in user_feature_mapping table if that user_id and experiment_id is present. If yes then we return the value. If not, then we will follow above step (step 1)</li></ol><p><em>Note: Every time we evaluate the logic, we will save the result in user_feature_mapping table.</em></p><p><strong>How do we evaluate conditions?</strong></p><p>We are storing groovy code in the condition column of the logic table. Below is just one sample example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*PAJWm3fVGDDDF-TnByt2rw.png" /></figure><p>We chose a groovy shell for its sheer amount of flexibility. We can execute complex functions and even call external methods and apis with the code stored as a text. This is beneficial when our use case is complex such as we want to assign user segments on the basis of certain user properties or parameters which can only be fulfilled by 3rd party APIs.</p><p>For example, if we want to divide the A/B as 90:10, we can do a modulo 10 operation on user_id and assign result 0 to segment B and remaining to segment A. We can change the ratio or even logic any number of times without the need of redeploying.</p><p><strong>List of APIs:</strong></p><ol><li>To create an experiment</li><li>To edit the experiment</li><li>To get the details of an experiment</li><li>To add a feature to an experiment</li><li>To edit a feature</li><li>To edit whitelisted users list for certain feature</li><li>To Evaluate an experiment and return response in json (Major Api)</li></ol><p><strong>Data Tracking:</strong></p><p>In order to analyse our features’ performance, we need to store events in one place, be it DB or 3rd party like Mixpanel that will help us to create funnels and compare our features’ performance in any given timeframe to get insights and make a decision regarding which feature to be final.</p><p><strong>Way ahead:</strong></p><p>We can aim for introducing caching for optimisation of latency. Also using GroovyShell introduces a high waiting time in the queue if the number of requests per unit time is high. This can be avoided by writing a general function in the code itself which will split the users according to the percentage given in the feature table while GroovyShell still can be kept for the high flexibility it offers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c81cd0d63ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When to use Global State?]]></title>
            <link>https://zetapp.medium.com/when-to-use-global-state-4d65abd915c5?source=rss-59343c71543e------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d65abd915c5</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Tech at ZET]]></dc:creator>
            <pubDate>Thu, 11 May 2023 09:18:31 GMT</pubDate>
            <atom:updated>2023-05-11T12:38:03.910Z</atom:updated>
            <content:encoded><![CDATA[<p>When you’re building React Native apps, you gotta think about state management, right? There are a few ways to do it, but one of the most popular is global state. In this blog post, we’ll talk about what global state is, whether it’s the best option for your app, and how to use it.</p><h3>What is Global State?</h3><p>So, global state is just a single state object that you can access and change from any component in your app. This means that you can keep track of everything in one place and make sure that everyone is on the same page.</p><p>It’s super easy to create global state in React Native using the Context API. Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*1u9ed7XsJ1YwSahesdKV0w.png" /></figure><p>In this code, we’re making a GlobalProvider component that wraps everything in our app. We create a GlobalContext object with createContext, set an empty object as the initial state with useState, and then make that state available to all of our components with GlobalContext.Provider.</p><h3>Pros and Cons of Global State</h3><p>So, there are some pretty sweet things about global state:</p><ul><li><strong>Easy to Use:</strong> Global state is super simple to use — you can access it from anywhere in your app!</li><li><strong>Saves Time:</strong> Using global state can save you time by avoiding having to pass state down through multiple components.</li></ul><p>But, there are some downsides, too:</p><ul><li><strong>Easy to Misuse:</strong> It’s really easy to use global state too much, which can make your code hard to keep track of.</li><li><strong>Performance Issues:</strong> If your state object gets too big or too many components are using it at once, your app might slow down.</li></ul><h3>When to Use Global State</h3><p>So, when should you use global state? Here are a few examples:</p><ul><li><strong>User Authentication:</strong> If you need to keep track of whether someone is logged in across your whole app, global state is a good way to do it.</li><li><strong>Theme Settings:</strong> If you want to let your users switch between light and dark mode, global state can make it easy.</li><li><strong>API Responses:</strong> If you want to cache responses from your server and use them in multiple parts of your app, global state is a good choice.</li></ul><h3>Managing Global State</h3><p>When you’re using global state, it’s important to keep everything organised. You can use the useContext hook to access the global state from any component in your app.</p><p>Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*F_5O_aX_fLIoKI5MbuPxMw.png" /></figure><p>In this code, we’re importing the GlobalContext object and using useContext to get the state and setState values. Then, we just use those values like we would any other state.</p><h3>Final Words</h3><p>So, there you have it — global state can be a pretty sweet way to manage state in your React Native app. It’s easy to use, can save you time, and can be really helpful in certain situations. But, you gotta be careful — using it too much can cause performance issues and make your code hard to manage. So, make sure you’re weighing the pros and cons before you decide whether to use it or not!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d65abd915c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>