Architecture
Discover the architecture behind Magistrala – an open-source, scalable IoT platform. Learn about its core components, domain model, messaging, and edge capabilities.
Components
Magistrala IoT platform is comprised of core services (auth, users, groups, clients, channels, domains, protocol adapters) together with additional services such as bootstrap, provision, consumers, readers, and the rules engine. For the full component reference, see the Architecture page in the Dev Guide.
Domain Model
The platform consists of the following core entities: user, client, channel, group, and domain.
User represents the real (human) user of the system. Users are represented via their email address, first and last names, a unique username, and password used as their credentials in order to obtain an access token. Once logged into the system, a user can manage their resources (i.e. domains, groups, clients and channels) in CRUD fashion and define access control policies through roles.
Group represents a logical grouping of clients, channels or other groups. It simplifies access control management by allowing entities to be grouped together. A user becomes a member of a group through a role, which determines what actions they can perform on the group and its associated entities. Groups support a parent–child hierarchy.
Client represents a device or application connected to Magistrala that uses the platform for message exchange. Clients have roles to which users are members, determining which actions the role member can perform on them.
Channel represents a communication channel — a message topic consumed by all clients connected to it. It also serves as a grouping mechanism for clients. A client connected to a channel forms a connection that can be Publish-only, Subscribe-only, or Publish-and-Subscribe.
Domain represents a top-level organizational unit that encompasses groups, channels, and clients. All these entities must belong to a domain. A user's role on a domain determines what actions they can perform on the domain and the entities within it.
Messaging
Magistrala uses NATS as its default messaging backbone, due to its lightweight and performant nature. You can treat its subjects as physical representation of Magistrala channels, where subject name is constructed using channel unique identifier. Magistrala also provides the ability to change your default message broker to RabbitMQ, VerneMQ or Kafka.
In general, there is no constraint put on content that is being exchanged through channels. However, in order to be post-processed and normalized, messages should be formatted using SenML.
Edge
Magistrala platform can be run on the edge as well. Deploying Magistrala on a gateway makes it able to collect, store and analyze data, organize and authenticate devices. To connect Magistrala instances running on a gateway with Magistrala in a cloud we can use two gateway services developed for that purpose:
Unified IoT Platform
Running Magistrala on gateway moves computation from cloud towards the edge thus decentralizing IoT system. Since we can deploy same Magistrala code on gateway and in the cloud there are many benefits but the biggest one is easy deployment and adoption - once engineers understand how to deploy and maintain the platform, they will be able to apply those same skills to any part of the edge-fog-cloud continuum. This is because the platform is designed to be consistent, making it easy for engineers to move between them. This consistency will save engineers time and effort, and it will also help to improve the reliability and security of the platform. Same set of tools can be used, same patches and bug fixes can be applied. The whole system is much easier to reason about, and the maintenance is much easier and less costly.