<?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 RapiPay Engineering on Medium]]></title>
        <description><![CDATA[Stories by RapiPay Engineering on Medium]]></description>
        <link>https://medium.com/@tech.rapipay?source=rss-5ec6ef2b1e66------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*__trEUtPhlRFCedbVf6Unw.jpeg</url>
            <title>Stories by RapiPay Engineering on Medium</title>
            <link>https://medium.com/@tech.rapipay?source=rss-5ec6ef2b1e66------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 01:53:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tech.rapipay/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[Server Driven UI]]></title>
            <link>https://medium.com/@tech.rapipay/server-driven-ui-80ae85603747?source=rss-5ec6ef2b1e66------2</link>
            <guid isPermaLink="false">https://medium.com/p/80ae85603747</guid>
            <category><![CDATA[frontend-framework]]></category>
            <category><![CDATA[server-driven-ui]]></category>
            <category><![CDATA[ui-framework]]></category>
            <dc:creator><![CDATA[RapiPay Engineering]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 14:07:20 GMT</pubDate>
            <atom:updated>2024-01-18T07:03:34.882Z</atom:updated>
            <content:encoded><![CDATA[<p>Server-driven UI, often referred to as “SDUI” is a dynamic approach to user interface design and development that relies on server-side logic and data to control the appearance and behaviour of an application’s user interface. Unlike traditional client-side UI frameworks, which build and manage the UI on the user’s device, SDUI shifts this responsibility to the server.</p><p>Server-driven UI is gaining popularity in various domains, including web and mobile applications, as it allows for more flexibility and efficiency in creating user interfaces that can adapt to changing requirements and user interactions. This introduction sets the stage for a deeper exploration of the concepts, benefits, and practical implementations of server-driven UI.</p><p>The ServerDrivenUI (SDUI) is an approach that enables the dynamic management of the entire User Interface by utilising the Meta JSON. This Meta JSON is generated by a node JS server and is universally applicable across all platforms. The framework responsible for handling the Meta across various platforms such as web, iOS, and Android is known as the ServerDrivenUI SDK.</p><h3>Problem Statement</h3><p>For our fintech super-app, nye.money we were involved in integrating multiple banking and financial service providers, which involved provider specific onboarding journey for different financial products. The onboarding process for each provider is unique and consists of several steps and screens. <strong>For example</strong>, if bank A has 12 steps and bank B has 10 steps, we would need to create a total of 22 screens. These screens are necessary for all three platforms as we support: Android, iOS, and Web.</p><p>Currently, we are working on multiple providers and we foresee the integrations to increase in our app in future. As the number of providers will increase, we will be creating more screens to handle the onboarding flow for each. This approach would be creating few problems —</p><ol><li>Application size will keep on increasing with increasing number of providers.</li><li>Managing and maintaining would be tough due to large number of screens and multiple platforms.</li><li>Any change in any of the bank journey’s screen would require a fresh build &amp; app release.</li><li>Challenging to maintain a cohesive onboarding experience across web, iOS, and Android platforms by adhering to a unified design system, consistent navigation structure, and platform-specific guidelines.</li></ol><h3>Solution</h3><p>In order to address the problem mentioned above, we need a system that allows us to generate screens dynamically from the server as needed. The server needs to send information to the client (SDKs) and based on the information, client knows how to render UI and attach behaviour to it.<br>We have divided our solution into 2 parts —</p><ol><li>Configurations (Meta JSONs)</li><li>Platform SDK</li></ol><p><strong>SDUI Workflow</strong></p><p>The SDUI architecture consists of the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*jCb8EjkM80T0NJYZZ2vWYQ.png" /><figcaption>SDUI Workflow</figcaption></figure><h4>Controller</h4><ol><li>Controller controls the flow and execution of SDUI.</li><li>It requests pageId from applications UI.</li><li>Based on the page Id, it calls GraphQL to fetch the meta jsons for the page.</li><li>Fetched json is passed to Renderer which renders the jsons and adds functionality.</li><li>Apart from this, controller also calls callback method passed by application UI, to get commonData (like productId, accessToken etc.), which can be used during the execution of screen.</li><li>Controller also interacts with Store to update &amp; get screen state.</li></ol><h4>Renderer</h4><ol><li>Renderer is responsible for recursive rendering of components, attaching styles &amp; adding behaviours to the screen.</li><li>It interacts with Store to get the latest component level data, and update when required.</li></ol><h4><strong>SDK Architecture</strong></h4><p>The SDUI SDK architecture consists of the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*L4qbZzXISkQ9vgADk2002w.jpeg" /><figcaption>SDUI Architecture</figcaption></figure><h3>SDUI Building Blocks</h3><p>These two are core building blocks for SDUI — configuration (Meta JSONs) and Platorm SDK.</p><p><strong>Configurations (Meta JSONs)</strong></p><p>Configurations or meta JSONs are basically those information which server can send to the client SDKs, so that client know what to render on the screen and what behaviour to attach.</p><p>Meta JSONs are largely divided in 4 parts —</p><ol><li>Layout</li><li>Styles</li><li>Observers</li><li>Actions</li></ol><p><strong>Sample:</strong></p><p>We will be developing a small screen using SDUI approach.</p><p><strong>Layout — </strong>Layout meta JSONs are used to represent Layout needs to be rendered in screen. It can be related to HTML which is basically a building block on any web page. Similar to HTML, layouts are building block on SDUI screens. Here is the a sample layout object from layout JSON file —</p><pre>const mobileLayout: ILayout | null = {<br>  root: {<br>    id: &#39;root&#39;,<br>    name: &#39;root&#39;,<br>    style: &#39;root&#39;,<br>    element: {<br>      type: &#39;layout&#39;,<br>      name: &#39;column&#39;, // It will be treated as VStack<br>    },<br>    children: [<br>      // These UI Components will be rendered recursively<br>      &#39;spacer&#39;,<br>      &#39;screenHeading&#39;,<br>      &#39;panTextField&#39;,<br>      &#39;spacer&#39;,<br>      &#39;footer&#39;,<br>    ],<br>  },<br>  spacer: {<br>    // This is equivalent of SwiftUI component Spacer()<br>    id: &#39;spacer&#39;,<br>    name: &#39;spacer&#39;,<br>    element: {<br>      type: &#39;layout&#39;,<br>      name: &#39;spacer&#39;,<br>    },<br>    platforms: [&#39;ios&#39;], // Only used for iOS platform.<br>  },<br>  screenHeading: {<br>    id: &#39;screenHeading&#39;,<br>    name: &#39;screenHeading&#39;,<br>    style: &#39;screenHeading&#39;, // This style will be picked from styles json.<br>    element: {<br>      type: &#39;widget&#39;,<br>      name: &#39;text&#39;,<br>    },<br>    data: {<br>      label: &#39;A demo screen&#39;, // This will be displayed in Text component<br>    },<br>  },<br>  panTextField: {<br>    id: &#39;panTextField&#39;,<br>    name: &#39;state.panTextField&#39;, // This name will be used to access this component properties in store.<br>    events: [&#39;onChange&#39;],<br>    element: {<br>      type: &#39;widget&#39;,<br>      name: &#39;textbox&#39;, // This is normal input field.<br>    },<br>    data: {<br>      placeholder: &#39;panNumber_placeholder_text&#39;, // Placeholder to show<br>      type: &#39;Text&#39;,<br>    },<br>    isValid: &#39;check-pan-validity&#39;, // Observer that checks if the value entered is valid.<br>  },<br>  footer: {<br>    id: &#39;footer&#39;,<br>    name: &#39;footer&#39;,<br>    style: &#39;footer&#39;,<br>    element: {<br>      type: &#39;layout&#39;,<br>      name: &#39;row&#39;, // This is equivalent to HStack<br>    },<br>    children: [&#39;proceedBtn&#39;],<br>  },<br>  proceedBtn: {<br>    id: &#39;proceedBtn&#39;,<br>    name: &#39;proceedBtn&#39;,<br>    style: &#39;proceedBtn&#39;,<br>    element: {<br>      // This is default button<br>      type: &#39;widget&#39;,<br>      name: &#39;button&#39;,<br>    },<br>    data: {<br>      label: &#39;global_proceedBtn_text&#39;, // Localised label of button.<br>    },<br>    actions: {<br>      onClick: &#39;show-toast-action&#39;, // OnClick action to perform which is defined in action json<br>    },<br>    disabled: &#39;check-proceed-disabled&#39;, // Observer to check disable property which is defined in observer json<br>  },<br>};<br> <br>export default mobileLayout;</pre><p>The code above shows the structure of the layout JSON. The rendering process begins with the root object and creates the element on the screen based on its properties. Once the current element is created, the rendering process moves on to its children and repeats the same process to render the entire layout on the screen.</p><p><strong>Observers — </strong>Observers are commonly used to provide dynamic validation for form elements. Additionally, elements can have their own observers. These observers can perform various tasks such as validation and computation. Below is an example of an observer object for a layout JSON file. —</p><pre>const observers: IObservers = {<br>  &#39;check-pan-validity&#39;: {<br>    operation: &#39;and&#39;,<br>    cases: [<br>      {<br>        observees: [], // This component is independent<br>        checks: {<br>          type: &#39;isValid&#39;,<br>          value:<br>            &#39;([A-Za-z]){3}([PCAFHTpcafht]){1}([A-Za-z]){1}([0-9]){4}([A-Za-z]){1}$&#39;, // Regex to compare<br>          errorMessage: &#39;Invalid PAN&#39;, // Error message to show if regex failed.<br>        },<br>      },<br>    ],<br>  },<br>  &#39;check-proceed-disabled&#39;: {<br>    operation: &#39;and&#39;,<br>    cases: [<br>      {<br>        observees: [&#39;state.panTextField&#39;], // Dependency of this observer is on its observees.<br>        checks: {<br>          type: &#39;isValid&#39;, // Checks isValid property of all the observees.<br>        },<br>      },<br>    ],<br>  }<br>};<br><br>export default observers;</pre><p>The above code represents structure of observer JSON. observers can be assigned to any element in layout. In above example ‘check-pan-validity’ is being used to add regex validation on ‘panTextField’ in layout and ‘check-proceed-disabled’ observer is used for enabling and disabling ‘proceedBtn’ in layout.</p><p><em>P.S. pan (PAN) is a tax identification number in India that we used in the example here. It could be any other field depending upon your requirements.</em></p><p><strong>Actions — </strong>You can use actions for various operations such as calling an API, navigating, performing computations, encrypting data, or displaying messages to the user through toasts or pop-up windows. Below is an example of an observer object for a layout JSON file. —</p><pre>const actions: IActions = {<br>  &#39;show-toast-action&#39;: {<br>    default: &#39;build-message&#39;, // Default action to pick first.<br>    actionHandler: {<br>      &#39;build-message&#39;: { // It concatenates two string using compute.<br>        type: &#39;compute&#39;,<br>        map: {<br>          &#39;temp.toastMessage&#39;: {<br>            lhs: &#39;text-inline:Your PAN number is &#39;,<br>            rhs: &#39;text:state.panTextField&#39;,<br>            operation: &#39;+&#39;<br>          }<br>        },<br>        onExit: [&#39;show-toast&#39;] // Performing other action after performing this action.<br>      },<br>      &#39;show-toast&#39;: { // Showing error toast message based on store value.<br>        type: &#39;toast&#39;,<br>        message: &#39;text:temp.toastMessage&#39;<br>      }<br>    }<br>  }<br>};<br><br>export default actions;</pre><p>Here ‘show-toast-action’ action is defined for showing toast message which consist multiple action handler in chain like first action handler which will execute is ‘<strong>build-message’</strong> on it’s completion ‘<strong>show-toast’</strong> action handler will execute.</p><p><strong>Styles — </strong>JSON styles are utilized to style the displayed layout. They serve as CSS for the page layout. We generate three types of JSON style files, one for each platform (Android, iOS, and Web). Below is an example of the JSON style used for web —</p><pre>const webStyles: IStyles | null = {<br>  root: {<br>    jusitfyContent: &#39;space-between&#39;,<br>    height: &#39;90vh&#39;,<br>    width: &#39;100%&#39;,<br>    padding: &#39;8px 16px&#39;,<br>  },<br>  footer: {<br>    justifyContent: &#39;space-between&#39;,<br>    flex: 1,<br>    alignItems: &#39;flex-end&#39;,<br>  },<br>  proceedBtn: {<br>    width: &#39;100%&#39;,<br>    textTransform: &#39;none&#39;,<br>    padding: 16,<br>  }<br>};<br> <br>export default webStyles;</pre><p>Style JSON used for iOS —</p><pre>const iosStyles: IStyles = {<br>  root: { // Adding padding 16 to all the side at topmost UI component.<br>    id: &#39;root&#39;,<br>    padding: 16<br>  },<br>  screenHeading: { // Increasing font size as per requirement<br>    id: &#39;screenHeading&#39;,<br>    fontSize: 24,<br>    paddingBottom: 24<br>  }<br>};<br><br>export default iosStyles;</pre><p>Style JSON used for android —</p><pre>const androidStyles: IStyles | null = {<br>  root: {<br>    id: &#39;root&#39;,<br>    justifyContent: &#39;center&#39;,<br>    height: &#39;match_parent&#39;,<br>    paddingLeft: 16,<br>    paddingRight: 16,<br>    paddingTop: 16,<br>    paddingBottom: 16,<br>    backgroundColor: &#39;theme:background&#39;,<br>  },<br>  screenHeading: {<br>    id: &#39;screenHeading&#39;,<br>    width: &#39;match_parent&#39;,<br>    marginLeft: 8,<br>    fontSize: 24,<br>    fontWeight: &#39;semiBold&#39;,<br>    lineHeight: 24,<br>    alignment: &#39;center&#39;,<br>  },<br>  proceedBtn: {<br>    id: &#39;proceedBtn&#39;,<br>    width: &#39;match_parent&#39;,<br>    marginRight: 16,<br>    marginLeft: 16,<br>    marginBottom: 16,<br>  },<br>};<br><br>export default androidStyles;</pre><p>Android Demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*EWhjFTpiQ1bpBTFbRvQNmA.gif" /></figure><p>iOS Demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iuAtzZmW-8l4QAQj4SVLAg.gif" /><figcaption>SDUI iOS demo</figcaption></figure><p>Web Demo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YcjIAmeXtNXVAh-AgqfEyg.gif" /><figcaption>SDUI Web demo</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*okyuE5S3_kFAgMHI3snASA.gif" /><figcaption>SDUI Web (reponsive) demo</figcaption></figure><h3>Platform SDKs</h3><p>SDK is required so that the Meta JSONs (layout and styles) get converted into a user interface (UI). This is platform specific for each of Android, IOS, and Web.</p><p>Our SDK is built using a component-based approach. Instead of sending the client a full UI screen, the server sends a list of components to display. Each component has a specific structure and behavior, allowing for reusable UI elements and consistent application design.</p><p>The SDUI SDK library has all the UI components and helpers needed for the Meta JSON.</p><h3>Pros</h3><p><strong>Future-Proofing UI — </strong>SDUI enables developers to future-proof the user interface by facilitating updates or changes without requiring new app releases. This ensures an adaptable, scalable, and sustainable approach.</p><p><strong>No New Code or Testing — </strong>With SDUI, there’s no need to write new code for UI changes, eliminating the necessity for extensive testing. This streamlines the development process and reduces the potential for introducing new bugs.</p><p><strong>No App Version Updates — </strong>Changes to the user interface do not necessitate submitting new versions of the app. As a result, there’s no waiting for approval from app stores such as Apple or Google, expediting the deployment of UI updates.</p><p><strong>Immediate User Impact — </strong>Since updates are implemented server-side, all users immediately experience the changes without the delay associated with app store approvals. This enhances the agility of the development and update process.</p><p><strong>Rapid Deployment — </strong>SDUI significantly reduces the time required for UI updates, allowing changes that once took weeks or months to be implemented in a matter of days or even hours. This accelerated deployment enhances responsiveness to user needs and market dynamics.</p><h3>Improvement scope &amp; future work</h3><p>SDUI will speed up feature release time in the future, but the initial adoption requires some overhead.</p><p><strong>Performance Optimization — </strong>Explore ways to optimize the performance of server-driven UI to reduce latency and improve responsiveness. This could involve techniques such as smart caching, data compression, and minimising the payload size.</p><p><strong>Real-time Updates — </strong>Investigate ways to enable real-time updates for server-driven UI. This could involve integrating technologies like Web Sockets or Server-Sent Events to push updates from the server to the client in real-time.</p><p><strong>Granular Component Updates — </strong>Refine the granularity of updates to individual UI components. This can help in reducing the amount of data that needs to be transferred between the server and the client when updates occur.</p><p><strong>Developer learning curve — </strong>It is easy to learn the setup of meta changes but Grasping the client-side rendering logic and how UI components are dynamically generated based on data received from the server could take longer time.</p><p><strong>Debugging within the SDK — </strong>Debugging the user interface (UI) can be challenging because it’s created using recursive methods, making it a bit complicated and time-consuming. However, using UI logging can help us identify and understand the issues more effectively.</p><p><strong>Mobile Battery consumption — </strong>In the context of server-driven UI, if the UI structure (Meta) is complex, it can lead to higher energy usage by the device, potentially causing quicker depletion of the battery. This is because rendering intricate UI elements demands more processing power and resources, which, in turn, can contribute to increased energy consumption.</p><h3>Conclusion</h3><p>This way the new features become easier to roll out. The existing feature modification becomes quicker than the conventional method, and the total effort needed to take a feature from the drawing board to the customer reduces to a great extent. In conclusion, server-driven UI is a powerful paradigm that, when implemented thoughtfully, can provide a dynamic, efficient, and consistent user experience. The success of this approach hinges on addressing its challenges and leveraging its strengths to create responsive, adaptable, and maintain consistency of logic across different frontends.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80ae85603747" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>