Macrometa is a geo-distributed streaming database with built-in compute as a service to provide low latency reads and writes to users across the globe.

In this blog, let’s build a geo-distributed, low latency Address Book application in 10 mins using our new Macrometa CLI.

How to get started

1. Make sure you have Nodejs and nvm installed locally. For nvm, execute the following commands on your terminal.

2. Create Macrometa account and obtain an API key. Please see below video clip on how to sign up and create an API key.

Installing the Macrometa CLI

1. Install the Macrometa CLI by using the following command

2. Verify the installation by executing the version command of the CLI

3. Initialize the client with the init command to create the YAML file in the local directory.

Create backend for AddressBook

Using the Macrometa CLI, a developer can still do everything they did before from the GUI or REST APIs.

1. Let’s first create a global document collection called addresses and enable streams on that collection. We will be using this collection to store the address documents. The stream will enable us to receive the updates via push mechanism in the GUI of Address Book application. (Note: The @ prefix is used to decide variables that should be used as parameters to the query-worker REST API endpoint.)

2. Next, let’s create a Query Worker to add information for the user. Query workers enable us to package a query as a function, deploy it globally and make it available as a REST API endpoint. All of this happens transparently. The calls to this REST API endpoint from the browser will get geo-routed to the location closest to the user and get executed there. Typically the 95%tile request latencies are below 50ms from anywhere around the globe.

3. Similarly, create a query-worker to get information about the user.

4. Create a query-worker to update information about the user.

5. Finally create a query-worker to remove the user record.

We're done! You have now a geo-distributed backend for your application with required collection and query-workers aka functions deployed around the globe and available REST API endpoints.

You can verify if your API end points are working correctly or not by either using CURL or the CLI itself. Below is an example on how to use the CLI to verify the created API endpoints.

Create Frontend for Address Book App

The Address Book application uses React to build its interactive user interface where users can provide the GDN tenant details and fabric details and select a particular region to demonstrate the respective user information from the address book as per the input.

You can clone the source code for this GUI from https://github.com/Macrometacorp/tutorial-addressbook-streams

Deploy App on Github Pages

Once you build and run  the AddressBook application in local environment, you can deploy the app to Github pages by adding the following commands in your  scripts in package.json

Also add homepage in package.json


To deploy the app as a Github page, You need to install gh-pages as a dependency in your package.json i.e.,

Also you need to enable ghpages from settings in your Github repo

ghpages settings

Finally, run the following command to deploy the app on gh-pages

You should create an output similar to the one below.

ghpages deploy output


That’s it. Now you have a low latency geo-distributed AddressBook app available to serve your users globally. The running application will look like below as shown in the video.

Typically, developers spend most a lot of their time building and wiring together various products and services to provide a globally-distributed backend. The downside of this is that they spend less time on the actual application that moves the needle for their business.

With Macrometa, the developer can spend more time on where it matters to their business and let the platform take care all the other details. The Macrometa CLI provides a convenient way to create your backend in few simple calls and integrate it into your CI/CD pipelines.

Mar 31, 2022

More from 



View All

Join Our Newsletter and Get the Latest
Posts to Your Inbox