de.iotb - IoT Backend Platform
Multi-tenant IoT platform for device connectivity, data streaming, and container orchestration.
Service Overview
de.iotb is a scalable IoT backend platform that handles device management, real-time telemetry streaming, command and control, and container orchestration for multi-tenant deployments.
Base URL: https://iot.dedot.io
Key Features
MQTT Broker
Industry-standard protocol for reliable device communication
Device Management
Registration, provisioning, and lifecycle management
Real-time Telemetry
High-throughput data streaming and processing
Container Orchestration
Dynamic scaling with shared and standalone containers
Active Rules Engine
Event-driven automation and alerts
Multi-tenancy
Isolated workspaces with dedicated resources
Architecture
Technology Stack
Container Orchestration
de.iotb supports two container deployment modes for multi-tenant isolation.
Shared Containers
Cost-effective solution for small to medium workloads.
Features:
- Shared MongoDB instance
- Shared MQTT broker
- Shared file storage
- Lower operational cost
- Suitable for development and small deployments
Standalone Containers
Dedicated resources for compliance and performance.
Features:
- Isolated MongoDB instance
- Private MQTT broker
- Dedicated file storage
- Higher performance
- Required for enterprise and compliance
MQTT Topics
Topic Structure
{workspace_id}/devices/{device_id}/{category}/{type}Standard Topics
Telemetry:
ws_abc/devices/dev_123/telemetry/location
ws_abc/devices/dev_123/telemetry/sensors
ws_abc/devices/dev_123/telemetry/battery
ws_abc/devices/dev_123/telemetry/networkCommands:
ws_abc/devices/dev_123/commands/config
ws_abc/devices/dev_123/commands/update
ws_abc/devices/dev_123/commands/rebootStatus:
ws_abc/devices/dev_123/status/online
ws_abc/devices/dev_123/status/offline
ws_abc/devices/dev_123/status/errorDevice Management
Device Lifecycle
Registration
Register device with platform
const device = await iotAccess.request({
url: '/devices/register',
method: 'POST',
body: {
deviceId: 'dev_tracker_001',
type: 'gps_tracker',
manufacturer: 'Acme IoT',
model: 'Tracker Pro',
metadata: {
imei: '123456789012345',
firmware: '1.0.0'
}
}
})Provisioning
Generate credentials and configure device
const credentials = await iotAccess.request({
url: `/devices/${deviceId}/provision`,
method: 'POST'
})
// credentials.data contains:
// - clientId: MQTT client ID
// - username: MQTT username
// - password: MQTT password
// - topics: Allowed topic patternsConnection
Device connects to MQTT broker
// On device
const mqtt = require('mqtt')
const client = mqtt.connect('mqtts://iot.dedot.io', {
clientId: credentials.clientId,
username: credentials.username,
password: credentials.password
})
client.on('connect', () => {
console.log('Connected to IoT platform')
// Publish telemetry
client.publish(
`${workspaceId}/devices/${deviceId}/telemetry/location`,
JSON.stringify({
lat: 40.7128,
lng: -74.0060,
accuracy: 5,
timestamp: Date.now()
})
)
})Data Streaming
Continuous telemetry transmission
// Publish sensor data
setInterval(() => {
client.publish(
`${workspaceId}/devices/${deviceId}/telemetry/sensors`,
JSON.stringify({
temperature: 22.5,
humidity: 45,
pressure: 1013,
timestamp: Date.now()
})
)
}, 60000) // Every minuteData Models
Device
interface Device {
id: string
workspace: string
deviceId: string
type: 'gps_tracker' | 'sensor' | 'gateway' | 'custom'
status: 'active' | 'inactive' | 'suspended' | 'offline'
info: {
manufacturer: string
model: string
firmware: string
hardware: string
}
credentials: {
clientId: string
username: string
passwordHash: string
}
topics: {
subscribe: string[]
publish: string[]
}
lastSeen?: string
lastLocation?: {
lat: number
lng: number
timestamp: string
}
metadata?: Record<string, any>
createdAt: string
updatedAt: string
}Telemetry Record
interface TelemetryRecord {
id: string
workspace: string
deviceId: string
category: 'location' | 'sensors' | 'battery' | 'network' | 'custom'
data: Record<string, any>
timestamp: string
receivedAt: string
metadata?: {
source: string
quality: number
}
}Active Rules Engine
Automate actions based on device events and conditions.
Rule Structure
interface ActiveRule {
id: string
workspace: string
name: string
enabled: boolean
trigger: {
type: 'telemetry' | 'status' | 'command' | 'schedule'
deviceIds?: string[]
category?: string
condition?: {
field: string
operator: '==' | '!=' | '>' | '<' | '>=' | '<='
value: any
}
}
actions: Array<{
type: 'webhook' | 'notification' | 'command' | 'alert'
config: Record<string, any>
}>
cooldown?: number
maxExecutions?: number
createdAt: string
updatedAt: string
}Example Rules
Temperature Alert:
{
name: 'High Temperature Alert',
trigger: {
type: 'telemetry',
category: 'sensors',
condition: {
field: 'temperature',
operator: '>',
value: 30
}
},
actions: [
{
type: 'webhook',
config: {
url: 'https://alerts.example.com/webhook',
method: 'POST'
}
},
{
type: 'notification',
config: {
channels: ['email', 'sms'],
message: 'Device temperature exceeded threshold'
}
}
],
cooldown: 300 // 5 minutes
}Geofence:
{
name: 'Geofence Exit Alert',
trigger: {
type: 'telemetry',
category: 'location',
condition: {
field: 'within_area',
operator: '==',
value: false
}
},
actions: [
{
type: 'alert',
config: {
severity: 'high',
title: 'Device left geofence',
recipients: ['[email protected]']
}
}
]
}API Endpoints
Device Management
POST /devices/register - Register new device
GET /devices - List all devices
GET /devices/:id - Get device details
PATCH /devices/:id - Update device
DELETE /devices/:id - Remove device
POST /devices/:id/provision - Generate credentials
Telemetry
GET /telemetry/:deviceId - Get device telemetry
GET /telemetry/:deviceId/latest - Get latest reading
POST /telemetry/:deviceId - Insert telemetry (for HTTP devices)
DELETE /telemetry/:deviceId - Clear device telemetry
Commands
POST /commands/:deviceId - Send command to device
GET /commands/:deviceId - Get command history
GET /commands/:commandId/status - Check command status
Rules
POST /rules - Create active rule
GET /rules - List all rules
GET /rules/:id - Get rule details
PATCH /rules/:id - Update rule
DELETE /rules/:id - Delete rule
Real-time Data Access
WebSocket Connection
import io from 'socket.io-client'
const socket = io('wss://iot.dedot.io', {
auth: {
token: accessToken,
workspace: workspaceId
}
})
// Subscribe to device telemetry
socket.emit('subscribe:device', {
deviceId: 'dev_tracker_001',
categories: ['location', 'sensors']
})
// Listen for telemetry
socket.on('telemetry', (data) => {
console.log('New telemetry:', data)
updateDashboard(data)
})
// Listen for device status
socket.on('device:status', (data) => {
console.log('Device status:', data.status)
})Configuration
Environment Variables
# Server
IOT_PORT=3002
IOT_HOST=0.0.0.0
# Databases
MONGODB_WORKSPACE_URI=mongodb://localhost:27017/de-iot-workspace
MONGODB_IOT_URI=mongodb://localhost:27017/de-iot
# MQTT
MQTT_BROKER_URL=mqtt://localhost:1883
MQTT_WS_PORT=9001
MQTT_TLS_ENABLED=true
MQTT_CERT_PATH=/certs/server.crt
MQTT_KEY_PATH=/certs/server.key
# File Storage
AWS_ACCESS_KEY_ID=your-key
AWS_SECRET_ACCESS_KEY=your-secret
AWS_REGION=us-east-1
AWS_IOT_BUCKET=de-iot-storage
# Container Orchestration
ENABLE_AUTO_SCALING=true
MAX_SHARED_CONTAINERS=10
MAX_STANDALONE_CONTAINERS=100
# Redis (for pub/sub)
REDIS_URL=redis://localhost:6379Usage Examples
Publish Telemetry from Device
// GPS Tracker example
const mqtt = require('mqtt')
const client = mqtt.connect('mqtts://iot.dedot.io', {
clientId: 'tracker_001',
username: 'ws_abc_dev_123',
password: 'device_password'
})
client.on('connect', () => {
// Get GPS location
navigator.geolocation.getCurrentPosition((position) => {
// Publish location
client.publish(
'ws_abc/devices/dev_123/telemetry/location',
JSON.stringify({
lat: position.coords.latitude,
lng: position.coords.longitude,
accuracy: position.coords.accuracy,
speed: position.coords.speed,
heading: position.coords.heading,
timestamp: Date.now()
}),
{ qos: 1 }
)
})
})
// Listen for commands
client.subscribe('ws_abc/devices/dev_123/commands/#')
client.on('message', (topic, message) => {
const command = JSON.parse(message.toString())
console.log('Received command:', command)
// Execute command
if (command.type === 'reboot') {
rebootDevice()
} else if (command.type === 'config') {
updateConfig(command.config)
}
})Monitor Devices from Dashboard
import De from '@de./sdk'
const access = new De.Access({
workspace: 'your-workspace-id',
accessToken: 'your-token',
env: 'prod'
})
// Get all devices
const devices = await access.request({
url: '/devices',
method: 'GET',
query: {
status: 'active',
type: 'gps_tracker'
}
})
// Real-time telemetry
const socket = io('wss://iot.dedot.io', {
auth: { token: accessToken, workspace: workspaceId }
})
devices.data.forEach(device => {
socket.emit('subscribe:device', {
deviceId: device.deviceId,
categories: ['location']
})
})
socket.on('telemetry', (data) => {
// Update map with device location
updateMarker(data.deviceId, {
lat: data.data.lat,
lng: data.data.lng
})
})Security
Authentication
- Per-device credentials
- JWT tokens for API access
- TLS/SSL for MQTT connections
- Password hashing with bcrypt
Authorization
- Topic-based access control
- Publish/subscribe permissions
- Workspace isolation
- Role-based API access
Data Protection
- Encrypted data at rest
- TLS for data in transit
- Automatic data retention policies
- GDPR compliance tools
Monitoring
- Connection logging
- Anomaly detection
- Rate limiting per device
- Alert on suspicious activity
Deployment
Docker Compose
version: '3.8'
services:
de-iotb:
image: dedot/de-iotb:latest
ports:
- "3002:3002"
- "1883:1883" # MQTT
- "9001:9001" # MQTT WebSocket
environment:
- MONGODB_WORKSPACE_URI=mongodb://mongo:27017/de-iot-workspace
- MONGODB_IOT_URI=mongodb://mongo:27017/de-iot
- MQTT_BROKER_URL=mqtt://mosquitto:1883
- REDIS_URL=redis://redis:6379
depends_on:
- mongo
- mosquitto
- redis
networks:
- de-network
mosquitto:
image: eclipse-mosquitto:2
volumes:
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
- mosquitto-data:/mosquitto/data
networks:
- de-network
mongo:
image: mongo:6
volumes:
- iot-data:/data/db
networks:
- de-network
redis:
image: redis:7-alpine
networks:
- de-network
volumes:
mosquitto-data:
iot-data:
networks:
de-network:
driver: bridgeMonitoring
Health Check
GET /health
Response:
{
"status": "healthy",
"uptime": 259200,
"version": "1.5.0",
"services": {
"database": "connected",
"mqtt": "active",
"redis": "connected",
"storage": "healthy"
},
"stats": {
"activeDevices": 12543,
"mqttConnections": 12498,
"messagesPerSecond": 3421,
"containers": {
"shared": 5,
"standalone": 23
}
}
}
