mainflux

package module
v0.36.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

README

MainfluxLabs logo

Mainflux

Open-Source IoT Platform

Go Report Card License

Documentation | Contributing | Releases

Introduction

Mainflux is an open-source IoT platform written in Go. It handles device connectivity over HTTP, MQTT, WebSocket, and CoAP, and provides a full pipeline from data ingestion to storage, rules evaluation, alarms, and notifications — without requiring external tooling for each step.

Data normalization is built into the platform through Profiles, which define per-group transformation and routing rules at ingestion time. Security goes beyond standard mTLS: certificate lifecycle management includes TPM and secure element support for hardware-backed key storage. The platform runs entirely on your own infrastructure with no cloud dependency.

Features

  • Multi-Protocol Support: HTTP, MQTT, WebSocket, and CoAP protocol adapters.
  • Device Management: Thing and group management with flexible metadata.
  • Profiles: Per-profile data transformation and routing configuration, including content type, field mapping, and time normalization.
  • User Management: Organizations, groups, platform and org invites, and role-based access control (RBAC).
  • Rules Engine: Condition and threshold-based rules with configurable alarm, email, and SMS actions.
  • Alarms: Real-time alarm generation and lifecycle management triggered by sensor data.
  • Scheduled Actions: Cron-based task scheduler for automated platform operations.
  • Certificates: X.509 certificate issuance, renewal, and revocation with full mTLS support.
  • Hardware Keys: TPM and secure element support for external key management.
  • Notifications: Email (SMTP) and SMS (SMPP) notifier services.
  • Data Storage: Pluggable writers and readers for PostgreSQL, TimescaleDB, and MongoDB.
  • Backup and Restore: Full platform backup and restore capability.
  • Observability: Prometheus metrics, Jaeger distributed tracing, and structured logging.
  • Event Sourcing: Redis-based event streaming across services for real-time IoT event processing.
  • CLI: Command-line interface for platform management and development workflows.
  • Container Deployment: Docker and Docker Compose support out of the box.

Prerequisites

The following are needed to run Mainflux:

Developing Mainflux will also require:

Installation

Clone the repository:

git clone https://github.com/MainfluxLabs/mainflux.git
cd mainflux

Run with Docker Compose:

docker compose -f docker/docker-compose.yml up -d

Or build and run from source:

make run

Usage

Build the CLI:

make cli
./build/mainfluxlabs-cli version

Check service health:

curl -X GET http://localhost:8080/health

For full API documentation and usage examples, visit mainfluxlabs.github.io/docs.

Documentation

Complete documentation is available at mainfluxlabs.github.io/docs.

Community and Contributing

Contributions are welcome and encouraged:

Authors

This project is a fork of mainflux/mainflux, which has since been archived. It is maintained independently by MainfluxLabs, continuing the original work with new features and long-term support. See MAINTAINERS for the current team.

License

Mainflux is open-source software licensed under the Apache-2.0 license. Contributions are welcome and encouraged!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version represents the last service git tag in git history.
	// It's meant to be set using go build ldflags:
	// -ldflags "-X 'github.com/MainfluxLabs/mainflux.Version=0.0.0'"
	Version = "0.0.0"
	// Commit represents the service git commit hash.
	// It's meant to be set using go build ldflags:
	// -ldflags "-X 'github.com/MainfluxLabs/mainflux.Commit=ffffffff'"
	Commit = "ffffffff"
	// BuildTime represetns the service build time.
	// It's meant to be set using go build ldflags:
	// -ldflags "-X 'github.com/MainfluxLabs/mainflux.BuildTime=1970-01-01_00:00:00'"
	BuildTime = "1970-01-01_00:00:00"
)

Functions

func Env

func Env(key, fallback string) string

Env reads specified environment variable. If no value has been found, fallback is returned.

func Health

func Health(service string) http.HandlerFunc

Health exposes an HTTP handler for retrieving service health.

func LoadEnvFile

func LoadEnvFile(envfilepath string) error

LoadEnvFile loads environment variables defined in an .env formatted file.

Types

type HealthInfo

type HealthInfo struct {
	// Status contains service status.
	Status string `json:"status"`

	// Version contains current service version.
	Version string `json:"version"`

	// Commit represents the git hash commit.
	Commit string `json:"commit"`

	// Description contains service description.
	Description string `json:"description"`

	// BuildTime contains service build time.
	BuildTime string `json:"build_time"`
}

HealthInfo contains version endpoint response.

Directories

Path Synopsis
api
Package api contains implementation of Auth service HTTP API.
Package api contains implementation of Auth service HTTP API.
api/grpc
Package grpc contains implementation of Auth service gRPC API.
Package grpc contains implementation of Auth service gRPC API.
jwt
postgres
Package postgres contains Key repository implementations using PostgreSQL as the underlying database.
Package postgres contains Key repository implementations using PostgreSQL as the underlying database.
redis
Package redis contains cache implementations using Redis as the underlying database.
Package redis contains cache implementations using Redis as the underlying database.
tracing
Package tracing contains middlewares that will add spans to existing traces.
Package tracing contains middlewares that will add spans to existing traces.
Package certs contains the domain concept definitions needed to support Mainflux certs service functionality.
Package certs contains the domain concept definitions needed to support Mainflux certs service functionality.
api
Package api contains implementation of certs service HTTP API.
Package api contains implementation of certs service HTTP API.
pki
postgres
Package postgres contains repository implementations using PostgreSQL as the underlying database.
Package postgres contains repository implementations using PostgreSQL as the underlying database.
tracing
Package tracing contains middlewares that will add spans to existing traces.
Package tracing contains middlewares that will add spans to existing traces.
cmd
alarms command
auth command
certs command
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
cli command
coap command
converters command
downlinks command
filestore command
http command
modbus command
mongodb-reader command
mongodb-writer command
mqtt command
postgres-reader command
postgres-writer command
rules command
smpp-notifier command
smtp-notifier command
things command
uiconfigs command
users command
webhooks command
ws command
Package coap contains the domain concept definitions needed to support Mainflux CoAP adapter service functionality.
Package coap contains the domain concept definitions needed to support Mainflux CoAP adapter service functionality.
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package consumers contain the domain concept definitions needed to support Mainflux consumer services functionality.
Package consumers contain the domain concept definitions needed to support Mainflux consumer services functionality.
notifiers
Package notifiers contain the domain concept definitions needed to support Mainflux notifications functionality.
Package notifiers contain the domain concept definitions needed to support Mainflux notifications functionality.
notifiers/smpp
Package smpp contains the domain concept definitions needed to support Mainflux SMS notifications.
Package smpp contains the domain concept definitions needed to support Mainflux SMS notifications.
notifiers/smtp
Package smtp contains the domain concept definitions needed to support Mainflux SMTP notifications.
Package smtp contains the domain concept definitions needed to support Mainflux SMTP notifications.
writers
Package writers contain the domain concept definitions needed to support Mainflux writer services functionality.
Package writers contain the domain concept definitions needed to support Mainflux writer services functionality.
writers/mongodb
Package mongodb contains the domain concept definitions needed to support Mainflux MondoDB writer service functionality.
Package mongodb contains the domain concept definitions needed to support Mainflux MondoDB writer service functionality.
writers/postgres
Package postgres contains repository implementations using Postgres as the underlying database.
Package postgres contains repository implementations using Postgres as the underlying database.
writers/timescale
Package timescale contains repository implementations using Timescale as the underlying database.
Package timescale contains repository implementations using Timescale as the underlying database.
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
api
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
api/http
Package http contains implementation of kit service HTTP API.
Package http contains implementation of kit service HTTP API.
Package http contains the domain concept definitions needed to support Mainflux http adapter service functionality.
Package http contains the domain concept definitions needed to support Mainflux http adapter service functionality.
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package logger contains logger API definition, wrapper that can be used around any other logger.
Package logger contains logger API definition, wrapper that can be used around any other logger.
api
api
api/http
Package http contains implementation of kit service HTTP API.
Package http contains implementation of kit service HTTP API.
redis
Package redis contains cache implementations using Redis as the underlying database.
Package redis contains cache implementations using Redis as the underlying database.
pkg
Package pkg contains library packages used by Mainflux services and external services that integrate with Mainflux.
Package pkg contains library packages used by Mainflux services and external services that integrate with Mainflux.
messaging/mqtt
Package mqtt hold the implementation of the Publisher and PubSub interfaces for the MQTT messaging system, the internal messaging broker of the Mainflux IoT platform.
Package mqtt hold the implementation of the Publisher and PubSub interfaces for the MQTT messaging system, the internal messaging broker of the Mainflux IoT platform.
messaging/nats
Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Mainflux IoT platform.
Package nats hold the implementation of the Publisher and PubSub interfaces for the NATS messaging system, the internal messaging broker of the Mainflux IoT platform.
messaging/rabbitmq
Package rabbitmq holds the implementation of the Publisher and PubSub interfaces for the RabbitMQ messaging system, the internal messaging broker of the Mainflux IoT platform.
Package rabbitmq holds the implementation of the Publisher and PubSub interfaces for the RabbitMQ messaging system, the internal messaging broker of the Mainflux IoT platform.
transformers
Package transformers contains the domain concept definitions needed to support Mainflux transformer services functionality.
Package transformers contains the domain concept definitions needed to support Mainflux transformer services functionality.
ulid
Package ulid provides a ULID identity provider.
Package ulid provides a ULID identity provider.
uuid
Package uuid provides a UUID identity provider.
Package uuid provides a UUID identity provider.
api
mongodb
Package mongodb contains the domain concept definitions needed to support Mainflux MondoDB reader service functionality.
Package mongodb contains the domain concept definitions needed to support Mainflux MondoDB reader service functionality.
postgres
Package postgres contains repository implementations using Postgres as the underlying database.
Package postgres contains repository implementations using Postgres as the underlying database.
timescale
Package timescale contains repository implementations using Timescale as the underlying database.
Package timescale contains repository implementations using Timescale as the underlying database.
tracing
Package tracing contains middlewares that will add spans to existing traces.
Package tracing contains middlewares that will add spans to existing traces.
api
Package things contains the domain concept definitions needed to support Mainflux things service functionality.
Package things contains the domain concept definitions needed to support Mainflux things service functionality.
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
api/grpc
Package grpc contains implementation of things service gRPC API.
Package grpc contains implementation of things service gRPC API.
api/http
Package http contains implementation of things service HTTP API.
Package http contains implementation of things service HTTP API.
postgres
Package postgres contains repository implementations using PostgreSQL as the underlying database.
Package postgres contains repository implementations using PostgreSQL as the underlying database.
redis
Package redis contains cache implementations using Redis as the underlying database.
Package redis contains cache implementations using Redis as the underlying database.
standalone
Package standalone contains implementation for auth service in single-user scenario.
Package standalone contains implementation for auth service in single-user scenario.
tracing
Package tracing contains middlewares that will add spans to existing traces.
Package tracing contains middlewares that will add spans to existing traces.
tools
mqtt-bench/cmd command
provision/cmd command
api
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
api/grpc
Package grpc contains implementation of users service gRPC API.
Package grpc contains implementation of users service gRPC API.
api/http
Package http contains implementation of users service HTTP API.
Package http contains implementation of users service HTTP API.
bcrypt
Package bcrypt provides a hasher implementation utilizing bcrypt.
Package bcrypt provides a hasher implementation utilizing bcrypt.
postgres
Package postgres contains repository implementations using PostgreSQL as the underlying database.
Package postgres contains repository implementations using PostgreSQL as the underlying database.
tracing
Package tracing contains middlewares that will add spans to existing traces.
Package tracing contains middlewares that will add spans to existing traces.
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
api/http
Package http contains implementation of kit service HTTP API.
Package http contains implementation of kit service HTTP API.
ws
api
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL