Skip to Main Content

Sep 18, 2020 | 8 minute read

How do you compose a commerce solution?

written by Anatoli IIakimets

In a previous article, we discussed what Composable Commerce is and why it is essential for businesses to adopt. In short, brands that prioritize infusing digital throughout their entire strategy need a commerce framework that empowers them to seamlessly build, deploy, and optimize experiences.  Composable Commerce is a new approach that gives digitally-driven brands back control so that they can keep up with customer needs and outpace competitors.

 

In this blog post, we will discuss the considerations to take when building and deploying a commerce solution and uncover the strengths and weaknesses involved when composing solutions with a rigid legacy system, a MACH-based architecture, and a true Composable Commerce framework. 

 

The use-case

To illustrate how composition works, we will use search integration as an example. For the business to increase conversion rates, it needs to ensure that customers can easily find what they are looking for. To deliver search capabilities, you can use one of the many search providers that match your business needs, including Algolia, Swiftype, Coveo, Elasticsearch, and many others. For illustration purposes, we will use Elasticsearch, a well-known player in the search engine market.

Below is the high-level outline of the use-case we will be discussing.
use-case

Composing a commerce solution

Now we will go in detail through all the steps required to compose a commerce solution and take a look at the questions which need to be asked at each step. After that we will discuss the composition process in the context of legacy commerce software, MACH commerce software and Elastic Path. And we will do this using real life examples and code.

 

Software deployment and configuration

This step includes the deployment of both commerce and search software, and there are several important considerations which need to be taken into account:

  • Can the software be consumed on-demand from the cloud, or do you need to deploy it on-premises/in a private cloud?
  • Does the software work out of the box, or does it require the configuration process? How long does it take to configure the software to start using it?
  • How long does it take to import enough of the data so that it can be tested?

 

Software integration

This step can take a lot of time and effort, depending on multiple factors:

  • What are the integration mechanisms available for each software application?
  • Is documentation readily available, and does it include everything necessary to develop the integration?
  • What are the detailed integration use-cases and what the integration architecture should look like?
  • How long does it take to implement the integration, including writing all the necessary code for scripts, lambda functions, etc.? Are there any assets available to accelerate the process?

Integration testing

This final step is critical because it ensures that the overall solution operates as intended and delivers business value.

  •  
  • What are the test use-cases, including fast tests, slow tests, performance tests? Do you need tests both for independent software applications as well as end-to-end tests?
  • How quickly can you deploy the integration, including the associated lambda functions, other custom code, and necessary test data?
  • How will you run all the necessary unit and end-to-end tests to make sure the composed solution works as intended? Can you do it automatically?
  • How will you deploy the integration into production?

The more interaction points between the two applications, the more complex the integration process will be.

Overall level of effort required to compose a commerce software depends on its capabilities, architecture, extensibility model and many other aspects.

 

Legacy Platforms

Composing a best-of-breed solution with a legacy platform can be a challenging task due to several factors:

  • Legacy platforms lack modularity because they were designed to be all in one solution and to be deployed and consumed as a whole.
  • Extensions are often developed as an afterthought and rely on proprietary extension models that are unique to a specific platform.

 

While the steps required to compose an end-to-end solution with a legacy commerce platform remain the same, they usually take a lot of time and effort:

  • When a specific commerce functionality is used in a legacy platform in multiple places, it needs to be changed in various places when extended. Due to this, things like a simple integration of a new payment method in the platform can take a significant amount of time.
  • Since the legacy platform is designed to be deployed as a whole, you either have to package multiple changes together to minimize downtime or to settle with numerous downtime windows if the functionality is deployed incrementally.
  • Testing also requires more effort since you are more likely to need to run end-to-end tests every time you make changes in multiple places across the codebase.

If you are integrating two or legacy software applications, the challenges listed above have a multiplicative effect.  On top of that, over time, custom integrations reduce the maintainability of the platform. Also, solution upgrades can become an issue requiring an implementation project.

MACH Solutions

There is a new approach to commerce software that relies on MACH architecture: Microservices, API-first, Cloud-native, and Headless. One example of MACH technology is commercetools. MACH architecture allows us to avoid many challenges associated with the legacy architecture to accelerate speed-to-market. For this blog post, we will take a look at what steps are required to do the use-case outlined above with commercetools.

 

Pre-requisites:

  1. Access to commercetools merchant center
  2. Instance of Elasticsearch

Setup

  1. Create a new project in the Merchant Center.
  2. Go to Settings > Developer Settings and click Create API Client
  3. Save details ( CTP_PROJECT_KEY , CTP_CLIENT_ID , CTP_CLIENT_SECRET , CTP_API_URL , CTP_AUTH_URL ) since they're only shown once.

Data Population

  1. Download the CT sample data project from Github.
  2. npm install
  3. In the root of the project create a file named .env containing your API client credentials:

CTP_PROJECT_KEY = myproject

CTP_CLIENT_ID = C0FFEEC0FFEEC0FFEEC0FFEE

CTP_CLIENT_SECRET = 133T133T133T133T133T

CTP_API_URL = https://api.{region}.{cloud}.commercetools.com

CTP_AUTH_URL = https://auth.{region}.{cloud}.commercetools.com

  1. npm run import:data

Infrastructure

Using AWS in this case:

  1. In AWS SQS, create a new standard queue.
  2. Create a Lambda function to process CT notifications.
  3.  Create an IAM role for your Lambda function that includes permissions to read from SQS.
  4. Configure the Lambda function to be triggered by messages coming from your SQS queue.

Business Logic

Your Lambda function should do the following:

  1. Process batched records coming from SQS.
  2. Authenticate against CT.
  3. Call the Product API to retrieve product data.
  4. Update the Elasticsearch index accordingly.

Configuration

Determine the public URL of your queue and configure CT to send product events to that queue.

 

Summary

You can integrate Commercetools with Elasticsearch without significant problems, but it will still require time to write all the necessary scripts and functions. More can be needed to execute this, depending on the integration complexity and the nature of integrated software.
 

Elastic Path

Now we will take a look at how you can implement the same use-case with Elastic Path using a Composable Commerce framework. 

 

Pre-requisites:

  1. Access to Elastic Path environment
  2. Instance of Elasticsearch
  3. NPM package manager
  4. Build script which can be found on GitHub.

Overview:
To create a composable solution, we will use Elastic Path webhooks, which are a part of the Extensions Hub. Webhooks allow applications to integrate with other systems by sending business events via the HTTP protocol.

overview

Whenever a new product is configured in a product catalog or a product is changed, Elastic Path creates a business event. This event is sent to the webhook, and the event is processed by the Lambda function, which then passes the product data to Elasticsearch so that the product can be searched in the future.

 

How to compose a solution:

The steps to compose a solution with Elastic Path and Elastic Search are straightforward and are executed using the following script:

  1. npm run test. Tests lambda function locally
  2. npm run build. Packages the lambda function and generates configuration needed for deployment.
  3. npm run deploy. Deploys the API gateway and lambda function and configures EPCC with the integration webhook
  4. npm run integration-test. Performs an end-to-end test to ensure that the integration is working:
    1. Searches for randomized test product using Elasticsearch and doesn't expect to find it.
    2. Creates test product in Elastic Path
    3. Searches for test product in Elasticsearch and expects to find it.
    4. Deletes test product from Elastic Path
    5. Searches for test product in Elasticsearch and doesn't expect to find it.
  5. npm run undeploy. Integration webhook is removed from Elastic Path, APIGW and Lambda function are undeployed

Summary

A truly Composable Commerce provider, like Elastic Path, provides you with all the benefits associated with MACH architecture and goes beyond it by bringing:

  • well-defined Packaged Business Capabilities, which can be easily combined with 3rd party or homegrown capabilities
  • Accelerator Packages which include all necessary artifacts including scripts, lambda functions, configuration settings, extensions, and integration code
  • Run-time composability that eliminates commerce platform downtime

pbc

Composability Comparison

While the overall integration process is similar for Elastic Path and commercetools there are specific differences in implementation of the use-case, which are highlighted in the table below. The most important difference comes from the fact that Elastic Path provides you with more than just microservices, that can be consumed via APIs like commercetools, but also bundles functionality into Packaged Business Capabilities and Accelerator Packages that contain all assets necessary for development.

 

This saves you valuable time by eliminating the need to "re-invent the wheel", simplifying development and accelerating deployment and future optimization for a composable solution.

 

You can check out the Accelerator Package for the search integration we walked through here.

 


Aspect

Elastic Path

commercetools
   
Events handling   
   
Webhooks   
   
Event queues   
   
Information sent through   event   
   
Record   
   
ID (requires additional   calls)   
   
Lambda processing   
   
One event at a time   
   
Needs to loop over a set   of records coming from SQS.   
   
Lambda function available
   
YES   
   
NO   
   
Script available
   
YES   
   
NO   

 

Learn more about how Elastic Path Commerce Cloud can help you to deliver a unique experience at speed.