An extremely performant, horizontally scalable, and fully managed implementation of WooCommerce's Store API and more. It can be used to create extremely performant eCommerce stores at any scale, while using the vast ecosystem of WooCommerce plugins and extensions.
The service is implemented as a thin distributed layer serving almost all frontend requests on behalf of a large number of WooCommerce stores. Serverless Woo has few moving parts and relies on popular, battle-tested, and horizontally scalable technologies. The service should be fully managed and actively monitored by the provider (including the underlying WooCommerce installations).
To stay performant at any scale, the service is built with the following components:
-
ElasticSearch for search and filtering of products, customers, coupons and other similar models with a large number of records.
-
A key-value database for storing general purpose data, such as tax rates, site settings, and other data that is not generally represented by a model. We have implementations for Redis and MySQL to support this.
-
HotStore - another key-value store intended to be used as described in the DynamoDB whitepaper. This service will allow us to efficiently scale out to multiple datacenters while maintaining guarantees required for a high-performance eCommerce store. We use MySQL/Redis locally for development, which can be replaced by services such as Netflix's Dynomite or AWS's DynamoDB in production.
Each of these services is managed and can be scaled out independently as needed.
This project is currently in development and is not ready for production use. We are following these milestones for the first production-ready release:
- Basic functionality for simple product endpoints.
- Cart endpoints without tax calculations.
- Payment gateway support - WooPay and Cash on delivery.
- Checkout block based payment gateway support.
- [.] Tax calculations and support for WooCommerce tax plugin.
- Shipping price calculations and support for WooCommerce shipping plugin.
- Monitoring and fault tolerance.
- Rate limiting and basic fraud prevention.
- Coupons and discount codes.
- Account management and sign up for customers.
Future milestones (open for discussion):
- Support for WooCommerce Subscriptions.
- Advanced fraud prevention and monitoring.
- Support for popular WooCommerce plugins.
- AI powered product recommendations, upsells and agents.
You would need a running WordPress/WooCommerce instance to run this service. There are many ways to do this from running each component natively to using a Docker, so your preferred way is up to you.
We use docker-compose to manage the service, and use colima in turn to run the docker service. Any other ways of running docker are also fine, and service can be run without docker too, but this guide for assumes you are using docker.
Note: Since the service is under development, the process to setup the site is very manual at the moment.
-
Create a new site in the WordPress admin and add the WooCommerce plugin.
-
Clone the repository and run docker-compose up to start the service.
-
Modify the
/etc/hosts
to add docker services name to your local machine:
127.0.0.1 wb.test
127.0.0.1 wb.valkey.test
127.0.0.1 wb.search.test
127.0.0.1 wb.db.test
- You would need to register the site in the service, you can do so by sending a POST request to the
/sites
endpoint with the site name. Assuming your site is running onlocalhost:10004
, you can send the following request:
POST http://wb.test:81/sites?token=test
Content-Type: application/json
{
"id": "my-test-site",
"name": "My Test Site",
"url": "localhost:10004",
"tax_settings": {
"tax_enabled": false
},
"currency_info": {
"currency_code": "USD",
"currency_symbol": "$",
"currency_minor_unit": 2,
"currency_decimal_separator": ".",
"currency_thousand_separator": ",",
"currency_prefix": "$",
"currency_suffix": ""
},
"tax_rates": [],
"shop_backend_url": "http://localhost:10004",
"cors_allowed_origins": []
}
You should receive a 201 response with the site information. Note the wh_key
field which will act as token for webhooks to update the site.
- At this point, your site is ready to be used and is available at
http://my-test-site.wb.test:81
. You can either add another entry to/etc/hosts
or use theX-WB-Client-Site
header instead to send requests to the site.
GET http://wb.test:81/store/v1/products
X-WB-Client-Site: my-test-site
Or (after adding the entry to /etc/hosts
):
GET http://my-test-site.wb.test:81/store/v1/products
- As you would notice, the list of products is empty. This is because we have not yet added any products to the site. Since the service is under development, the process to add webhooks is manual. Go the the WooCommerce site in WooCommerce > Settings > Advanced > Webhooks, and add a new webhook with the following details:
- Name:
Serverless Woo Products
- Delivery URL:
http://wb.test:81/webhooks/products?key={wh_token}
- Secret:
test
- Topic:
product.updated
- Status:
active
- API Version: WP REST API Integration V3
- Secret: (leave blank)
- Since the service is local, we need to tell WordPress to allow it explicitly. Add the following filters to your theme's
functions.php
file:
add_filter( 'http_allowed_safe_ports', function( $ports ) {
return array_merge( $ports, array( 81 ) );
}, 10, 1 );
add_filter( 'http_request_host_is_external', function( $external, $host, $url ) {
return $external || ( 'wb.test' === $host );
}, 10, 3 );
-
Import products into the site, and wait for webhooks action to populate the products. You can now send requests to the service and have it act on behalf of the site.
-
Install the WooServerlessConnector plugin into the WooCommerce site, to allow checkout and tax rate calculations. Eventually the goal is to move all manual configuration to the connector plugin.