|
2 | 2 | title: Designing Features
|
3 | 3 | description: A set of tips for designing atomic and transferable features
|
4 | 4 | ---
|
| 5 | + |
| 6 | +import { Aside } from '@astrojs/starlight/components' |
| 7 | + |
| 8 | +Designing a feature in the Vyuh framework requires putting together a bunch of |
| 9 | +elements. This includes the following: |
| 10 | + |
| 11 | +- **APIs** to talk to the backend to fetch data |
| 12 | +- **Experience layer** that renders the widgets on the screen and provides User |
| 13 | + Interactivity |
| 14 | + - Distilling the **Content Blocks** that make up the feature |
| 15 | + - **Journeys** which allow the user to navigate from screen to screen in |
| 16 | + exploring the content and interacting with it in different ways |
| 17 | + - **Design system** components for a consistent experience |
| 18 | + - Client side **State management** to keep track of User interactions |
| 19 | + - **Analytics** to track user interactions and understand user behavior |
| 20 | + |
| 21 | +<Aside title={'Universal Truth about Applications'}> |
| 22 | + |
| 23 | +Although we talk about the **Vyuh Framework** in this article, the set of things |
| 24 | +that you have to do for building a feature for an application is _universally |
| 25 | +true_ and applicable across all applications. |
| 26 | + |
| 27 | +Whether you use a low-code tool or a no-code tool, the set of things you have to |
| 28 | +do pretty much remains the same. The Vyuh Framework however makes it easier to |
| 29 | +manage both functional and non-functional aspects of building a feature. This |
| 30 | +allows you to grow from an MVP to the scale of a Super App! |
| 31 | + |
| 32 | +</Aside> |
| 33 | + |
| 34 | +## Core Ideas |
| 35 | + |
| 36 | +Some of the core ideas of building a feature are already discussed in a separate |
| 37 | +article on [Features and Plugins](/concepts/features-and-plugins). Make sure to |
| 38 | +take a look at that before reading further. |
| 39 | + |
| 40 | +In this article, we'll focus more on applying the Vyuh Framework to build a |
| 41 | +feature. This is all about distilling the feature in terms of its schemas, APIs, |
| 42 | +and experience widgets. |
| 43 | + |
| 44 | +## Distilling a Feature |
| 45 | + |
| 46 | +As we've already seen in the article that was referenced before, a feature is |
| 47 | +essentially a collection of screens stitched together to form a journey. The |
| 48 | +content of each screen comes from a set of content blocks that you would design |
| 49 | +and configure from a CMS. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +Now, it's possible that these content blocks may not have a CMS counterpart, and |
| 54 | +could be driven entirely from code. But for now, let's assume for a moment that |
| 55 | +we are designing features that are CMS connected, which allows dynamic |
| 56 | +configuration and flexibility for the business teams. |
| 57 | + |
| 58 | +Thus, the three core building blocks of any feature include the **APIs**, the |
| 59 | +**Content Blocks**, and **Journeys**. Let's see each of these in detail. |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +### APIs |
| 64 | + |
| 65 | +APIs are the primary source of data for the feature. They could be REST APIs, |
| 66 | +GraphQL APIs, or even Websockets. The APIs are responsible for fetching the data |
| 67 | +that is required to render the content blocks on the screen. |
| 68 | + |
| 69 | +The APIs are also responsible for sending the user interactions back to the |
| 70 | +server for processing. This could be a simple form submission or a complex |
| 71 | +interaction that requires a series of steps to be completed. |
| 72 | + |
| 73 | +The Vyuh framework has a built-in component for working with APIs, called the |
| 74 | +`APIContent`. This can be configured from the CMS, making it easier for the |
| 75 | +business teams to change the type of data source that should be used to drive |
| 76 | +the content on the screen. The API content-block simplifies the configuration |
| 77 | +needed to show content on the screen, without burdening the business teams with |
| 78 | +the implementation details of the request headers, API keys or other security |
| 79 | +parameters that are required to fetch data from the endpoint. |
| 80 | + |
| 81 | +> Although we talk about APIs as the driving source of content for the content |
| 82 | +> block, it's possible that the content blocks come directly from the CMS. In |
| 83 | +> this case, they are configured on the CMS itself and rendered on the screen. |
| 84 | +
|
| 85 | +#### API SDKs |
| 86 | + |
| 87 | +As you start working with more complex APIs and a large number of APIs, you will |
| 88 | +soon see a need to wrap all these APIs into an API SDK. The API SDK can expose a |
| 89 | +HTTP client that is used to fetch data from the server using semantic operations |
| 90 | +instead of talking directly to the endpoint URLs. |
| 91 | + |
| 92 | +The use of the API SDK also hides the details of deserializing the response |
| 93 | +payloads and creating Dart objects out of them. Additionally, these API SDKs can |
| 94 | +be tested independently and made sure that they are robust enough to work under |
| 95 | +various conditions and request parameters. |
| 96 | + |
| 97 | +When these APIs are commonly used across multiple features, the API SDK becomes |
| 98 | +the common package through which these features make those calls. |
| 99 | + |
| 100 | +In short, think of wrapping your APIs inside an API SDK and exposing it as a |
| 101 | +common package that can be used by multiple features when needed. |
| 102 | + |
| 103 | +### Content Blocks |
| 104 | + |
| 105 | +While the APIs focus on fetching data from a remote endpoint, the content blocks |
| 106 | +are the key elements that allow you to render this data inside a screen. These |
| 107 | +content blocks have two counterparts: |
| 108 | + |
| 109 | +- On the CMS where it exists as a schema, allowing business teams to configure |
| 110 | + it. |
| 111 | +- On the Flutter side where it exists as a widget and possibly with the |
| 112 | + combination of other elements like state management, dependency injection, |
| 113 | + analytics, etc., which will all wrap together to provide the implementation |
| 114 | + for the content block. Here is where you would also apply the **Design |
| 115 | + System** to make the widgets visually consistent. |
| 116 | + |
| 117 | +<Aside title={'Design System as an SDK'}> |
| 118 | + |
| 119 | +The Design System, just like the API-SDK, can be extracted into a separate |
| 120 | +package. This could be used across multiple features and even across apps if |
| 121 | +they are maintaining a similar visual identity. |
| 122 | + |
| 123 | +It's probably a good idea to start building your design system (themes, colors, |
| 124 | +typography, icons, spacings, and of course the UI components) into a separate |
| 125 | +package so it becomes more reusable across features & apps. |
| 126 | + |
| 127 | +</Aside> |
| 128 | + |
| 129 | +### Journeys |
| 130 | + |
| 131 | +Now we have included journeys as part of a feature which is purely from a |
| 132 | +customer's perspective. |
| 133 | + |
| 134 | +However, when we work with the Vyuh Framework, we think of the journeys as not |
| 135 | +being hardcoded into the feature itself. Instead, they are defined and |
| 136 | +configured from the CMS. This gives the business the ability to change the |
| 137 | +journeys on the fly depending on the type of customer, |
| 138 | + |
| 139 | +Externalizing the journeys is one of the key elements of the Vyuh Framework. |
| 140 | +With that, the features themselves only have to expose a set of content blocks, |
| 141 | +which are configured from the CMS. The business teams will use the content |
| 142 | +blocks to assemble pages and then stitch them together through a navigation |
| 143 | +journey. |
| 144 | + |
| 145 | +<Aside title={'Fixed Journeys'}> |
| 146 | + |
| 147 | +However, there are cases where a journey is so fixed in nature that it doesn't |
| 148 | +require a special type of configuration from the CMS. The payment journey is one |
| 149 | +such example. |
| 150 | + |
| 151 | +Once you check out from your cart, the payment journey begins and accepts your |
| 152 | +payment method, then takes you additional screens for more details, and finally |
| 153 | +completes the secure transaction. It then takes you back to the confirmation |
| 154 | +page. This journey can be hard-coded into the feature itself. |
| 155 | + |
| 156 | +</Aside> |
| 157 | + |
| 158 | +## Summary |
| 159 | + |
| 160 | +This guide has provided a set of tips for designing your features by identifying |
| 161 | +its core components. By applying these ideas you can even make features that |
| 162 | +work across a family of Vyuh Apps. |
0 commit comments