Customization in Saas using Plug and Play (PnP) architecture
Join the DZone community and get the full member experience.Join For Free
there are a lot of design patterns, architectures and design concepts that can be applied to technical aspects of implementing a product. for exapmle, we have mvc architecture that isolates the view, controller and model of the application. we have a factory pattern that defines how to create objects and so on. yet, these all limit themselves to the technical aspects of the product, while there exists no definite pre-defined architecture or patterns to design and build "business functions". the plug and play architecture i want to describe in this article is a "functional architecture", that defines a pattern to design the business functionality to get the most out of it.
modular architecture is a design technique where functionality of a program is separated into independent, interchangeable modules, such that each module contains everything necessary to execute one aspect of the desired functionality. typically, in modular architecture, separation is done based on technical aspects. for eg., a module is created for database interaction, another is created for logging and so on. the advantage of a modular architecture is that you can easily replace or add components without affecting the rest of the application. the modules clearly define the interfaces that are used to interact with the module and these are tied at compile time to other modules.
what if we could extend this architecture to "business functionality" rather than just limiting it to technical aspects of a product. we already design "business functionality" in a modular manner. but, we do not consciously look at it as modules with clear-cut interfaces for inputs and outputs.
defining the plug and play architecture
the plug and play architecture extends the techniques of modular architecture to business functions. for eg., a module can be created to encompass all functions related to order, while another can be created to encompass all functions related to quote. i will call these independent modules implementing business functions as flows.
an application, in this architecture, is defined as a "collection of flows working together". the same advantage of modular architecture applies here, i.e., you can replace, add or remove flows without affecting the rest of the application. an added advantage to extending modules to business functions, is that the flows can be combined in different paths to get different business functionality.
further, extending this definition to be able to add, remove or replace modules at "runtime" rather than tying them together at compile time gives us the flexibility to customize the application at runtime without "in-built flags and if clauses". the beauty of this extension of the architecture is that "it gives us the flexibility to create a set of loosely coupled flows that can be bound together at runtime as opposed to coding one tightly integrated application that is rigid and not malleable".
to further see how this architecture works, let us consider a set of loosely coupled flows coded as per the diagram:
there are 5 flows coded and deployed. each flow exposes an output and accepts a set of inputs.
for eg., the "product listing" flow encapsulates the following business functions
- create products manually by admin
- import products by admin
- provide services to view, search and list products
- expose an output, "product" data that can be linked to other flows
another eg., is the cart flow. this encapsulates the following business functions
- create a new cart
- add items to the cart
- check out the cart
- expose an output, "cart" data that can be linked to other flows
- accept an input, "cart item" that can be linked to the output from other flows
we can connect the output "product" data from "product listing" flow to the "cart item" input of the cart flow. this is not tightly coupled at compile time and is left as an open gate or an input for the cart flow. at runtime the gate is closed or left open as required by the customer.
from the diagram we see that we have 5 gates that can be closed. leading us to create different applications at runtime by closing the correct gates. for eg., we can just enable "product listing" for a customer which provides just the basic features of product listing. gates 4 and 6 can be closed to create an application with the features
- create, list products
- add products to a cart
- send an enquiry for the products added to the cart
in another variation instead of gates 4 and 6, gate 7 can be closed. the application now has the features
- create, list products
- send an enquiry for single products
by plugging the "inputs" of flows with different "outputs" from other flows, varied applications can be created. this is called a plug and play architecture. smart is implemented in this architecture to provide a highly flexible container to build saas products.
need for plug and play architecture
when a product is exposed as a multi-tenanted saas product, it cannot be created with "one size fits all" tenet. to break this tenet we need a flexible, customizable runtime environment where features can be varied based on a customer requirement without affecting other customers serviced by the same application. the plug and play architecture provides this flexibility to the saas.
Opinions expressed by DZone contributors are their own.
Tactics and Strategies on Software Development: How To Reach Successful Software [Video]
Cypress Tutorial: A Comprehensive Guide With Examples and Best Practices
Building a Robust Data Engineering Pipeline in the Streaming Media Industry: An Insider’s Perspective
Microservices With Apache Camel and Quarkus (Part 2)