Architecture#
Components#
Mainflux IoT platform is comprised of the following services:
| Service | Description |
|---|---|
| auth | Manages platform's orgs and auth concerns |
| users | Manages platform's users and auth concerns |
| things | Manages platform's things, profiles, groups and group members |
| certs | Issues and manages X.509 certificates for mTLS device authentication |
| http-adapter | Provides an HTTP interface for sending messages |
| mqtt-adapter | Provides an MQTT and MQTT over WS interface for sending messages |
| coap-adapter | Provides a CoAP interface for sending messages |
| ws-adapter | Provides a WebSocket interface for sending commands |
| modbus | Polls Modbus TCP devices on a schedule and publishes readings as messages |
| rules | Evaluates threshold rules and Lua scripts against incoming device messages |
| alarms | Persists alarms triggered by rule actions to PostgreSQL |
| downlinks | Manages scheduled outbound HTTP requests (downlinks) for things and groups |
| shadows | Maintains a persisted desired/reported state record (shadow) for each thing |
| webhooks | Forwards device messages to external HTTP endpoints |
| smtp-notifier | Sends email notifications to contacts defined on notifier records |
| smpp-notifier | Sends SMS notifications to contacts defined on notifier records |
| converters | Accepts CSV and JSON uploads and publishes them as messages for bulk ingestion |
| filestore | Provides file storage for things and groups |
| uiconfigs | Persists and manages UI configuration settings scoped per org, group and thing |
| postgres-writer | Persists messages to PostgreSQL |
| postgres-reader | Provides an HTTP API for querying messages from PostgreSQL |
| timescale-writer | Persists messages to TimescaleDB |
| timescale-reader | Provides an HTTP API for querying messages from TimescaleDB |
| audit | Persists platform events and exposes them through an HTTP API |
| cli | Command line interface |

Domain Model#
The platform is built around 5 main entities: users, organizations, groups, profiles and things.
User represents the real (human) user of the system. A user is identified by an
e-mail and password, which serve as platform access credentials for obtaining
an access token. Once logged into the system, a user can manage their resources (groups,
things and profiles) in CRUD fashion and define access control.
Org represents the highest entity in the system hierarchy consisting of its members and groups. It unites all the elements into a whole.
Group within an organization represents a set of Things, Profiles, Notifiers, Webhooks, Downlinks. Access to these entities requires appropriate rights, which are obtained when assigning a user to a group.
Profile defines the message format and processing rules for all things assigned to it. Things within the same profile share the same communication contract (content type, data transformation, filtering, and routing settings).
Thing represents devices (or applications) connected to Mainflux that uses the
platform for message exchange with other "things".
Messaging#
Mainflux uses NATS as its messaging backbone, due to its
lightweight and performant nature. NATS subjects are derived from the message
content type and optional subtopic, following the format
<format>.messages.<optional_subtopic> (e.g. senml.messages.bedroom.temperature).
In general, there is no constraint on the content exchanged between things. However, in order to be post-processed and normalized, messages should be formatted using SenML.
Unified IoT Platform#
Running Mainflux on a gateway moves computation from the cloud towards the edge, thus decentralizing the IoT system. Since the same Mainflux code can be deployed on a gateway and in the cloud, there are many benefits, the biggest one being easy deployment and adoption: once engineers understand how to deploy and maintain the platform, the same knowledge applies across the whole edge-fog-cloud continuum. The same set of tools can be used, and the 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.