All Maps courtesy © Mapbox, © OpenStreetMap

After introducing the Crypto Spatial Coordinate (CSC) standard and the Proof of Location protocol, we are happy to introduce the third element of FOAM: The Spatial Index — a general purpose visual blockchain explorer. The Spatial Index can serve as the front-end for any decentralized application that needs to visualize smart contracts on a map. The purpose of this post is to introduce the architecture and technology stack behind the Index and demonstrate its current capabilities.

Crypto-Spatial Coordinates enable the blockchain to act as an index of spatial contracts and, by extension, allow spatial contracts to be queried and displayed on the Spatial Index. As an open-source web-app, the Spatial Index is a visual UX interface that will be used to a) allow users to interact with, understand, engage with, and act on CSC contracts and to b) serve as the foundation of the large variety of decentralized applications that can be built on top of our protocols.

Architecture and Technology Stack

The spatial index is an explorer for geospatial assets on the blockchain. The full architecture of the application consists of:

Frontend app a visual explorer written in purescript, backed by our 1.a visual explorer written in purescript, backed by our purescript-web3 library 2. Interactive deck.gl and D3 visualization components for visualizing network activity utilizing the FOAM protocol. 3. Metamask/Uport for secure transaction signing and authentication. REST API written in haskell, complete with swagger documentation and a haskell client library provided by the 4.written in haskell, complete with swagger documentation and a haskell client library provided by the servant framework. 5. Ethereum logs indexer for indexing logs produced by spatial index contracts, making them available for performant queries.

The diagram above illustrates the five major components that have been developed for the Spatial Index. Their relationships can be simplified as follows:

The indexer and database component capture all relevant data emitted by FOAM contracts via the Ethereum logs — e.g. deploying CSCs, performing localizations, token transfers, etc — and indexes it for high performance queries and consumption over websockets. The only other thing required to run this component is an Ethereum client with the web3 API enabled. While we run a custom kubernetes cluster of geth and parity nodes scaled accord to user demands, this indexer is available as a standalone docker service for other developers who want access to the underlying data in Postgres and ElasticSearch.

The REST API utilizes this data store for our applications, and also acts as an open API for other applications seeking access to data generated by FOAM. It is written in haskell using the servant framework, meaning that up-to-date API documentation and client libraries can be generated from the type system on demand.

Our visual frontend explorer displays the data from the REST API in meaningful ways using D3.js and deck.gl. In addition, the visualizer allows the user interact with FOAM contracts in the browser via Metamask or Uport. The visualizer is written in purescript, a strongly typed functional programming language targeting the browser, and is backed by our purescript-web3 library. (See our previous post on why we believe this is important.)

The main achievement and contribution of this design is allowing users to interact with the blockchain and deploy smart contracts with geospatial parameters from within a web browser. The architecture of the Spatial Index forms a smooth loop of events, from web-app, to blockchain, to indexer, and back to the app. We use some of the most advanced software available for the task, including the languages, the data processing units, and the kubernetes cluster that supports all of it.

Walkthrough of Current Skin:

1: Navigate Crypto-Spatial Coordinates

Spatially-specific smart contracts, also known as Crypto-Spatial Coordinates (CSCs) are displayed directly in the application. Users can apply filters to display CSCs according to each use-case. In our first version of the Spatial Index, the CSCs represent the Zone-anchors and their Zones as described in our previous blog post on the Proof of Location Protocol