Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Software Architecture

Eric Andrews edited this page Aug 8, 2019 · 5 revisions

Layered

The software consist of three layers, which are listed below from the lowest to the highest.

Diagram of layers of architecture

  • Connection layer deals with network-level concerns such as forming connections and sending text/binary messages over sockets or as datagrams. It wraps around a network library (currently ws) and provides a library-independent interface for the higher levels.
  • Protocol layer is responsible for encoding messages before they are given to the connection layer to be sent out to the network. It also decodes messages received from the connection layer and re-interprets them in terms of higher-level concerns.
  • Logic layer is concerned with application-level concerns such as message propagation, stream management, duplicate and gap detection, resend requests, and in the case of the tracker, forming overlay topologies. The logic layer reacts to high-level events emitted from the protocol layer and pushes new data to the Streamr network via the same layer.
  • Broker layer is not a part of this repository but acts the main executable for running a node. A separate section below is dedicated to broker.

Layered architecture allows changing certain implementation details without having to make sweeping re-writes across the entirety of the code base. For example, if we wanted to switch up our network to work on UDP instead of WebSockets most of the code changes would be contained to the connection layer.

Another benefit of layered architecture is the ability to separate and address concerns at their approriate levels. E.g., while IP addresses and ports may be crucial on the connection layer for establishing connections, a more abstract notion of identity (say an Ethereum address) is appropriate on the logic layer.

Broker

Broker layer resides in a separate repository. In practice, it is the main executable for running a network node, or a broker node. The broker node is built on top of the network node (the broker includes network as a library dependency) and provides storage implementations and compatibility adapters.

The network defines a Storage interface for storing received messages as well as fetching messages for resend requests. However, the network does not in itself provide implementations for different storage solutions. The broker, as a user of the network library, provides storage implementations, one of such that operates on Apache Cassandra.

Compatibility adapters allow users of foreign protocols (e.g, MQTT or HTTP) to interact with the Streamr network. These interactions are facilitated by the broker and its adapters by taking care of connection management and the translation of messages from the foreign protocol to Streamr network protocol and visa versa. As illustrated below, clients of adapters do not become peers in the network. Instead, the broker acts as a middleman and is itself a peer.

Diagram of broker adapters and network

Clone this wiki locally