Skip to main content

01 - Architecture Overview

System architecture for IoT and hardware integration with ML models


Table of Contents

  1. High-Level Architecture
  2. Data Flow Diagram
  3. Component Breakdown
  4. Communication Protocols
  5. Deployment Models

1. High-Level Architecture

System Layers

┌─────────────────────────────────────────────────────────────────────────┐
│ PRESENTATION LAYER │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Dashboard │ │ Mobile App │ │ SCADA HMI │ │ BIM Viewer │ │
│ │ (Next.js) │ │ (React Nat.)│ │ (Ignition) │ │ (Forge) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│ APPLICATION LAYER │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ ML API Services (FastAPI/Flask) │ │
│ │ /predict/reusability | /predict/treatment | /twin-engine │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ IoT Gateway Service (Node.js) │ │
│ │ MQTT Handler | OPC-UA Client | WebSocket Server | REST API │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│ INTEGRATION LAYER │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Message │ │ Stream │ │ Protocol │ │ Event │ │
│ │ Broker │ │ Processing │ │ Gateway │ │ Store │ │
│ │ (EMQX) │ │ (Kafka) │ │ (Kepware) │ │ (Redis) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│ EDGE LAYER │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Edge Computing Nodes │ │
│ │ Local Inference | Data Buffering | Protocol Conversion │ │
│ │ (Siemens IOT2050 / Raspberry Pi / Dell Edge Gateway) │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────────────────┐
│ DEVICE LAYER │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌───────┐ │
│ │ pH │ │ BOD/COD │ │ TSS │ │ Flow │ │ Temp │ │ DO │ │
│ │ Sensor │ │ Analyzer│ │ Sensor │ │ Meter │ │ Sensor │ │ Probe │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └───────┘ │
└─────────────────────────────────────────────────────────────────────────┘

2. Data Flow Diagram

Real-Time Data Flow

Sensor → Edge Gateway → MQTT Broker → IoT Service → ML API → Database
│ │ │ │
│ │ │ ▼
│ │ │ Blockchain
│ │ │ (Verification)
│ │ │
│ │ ▼
│ │ WebSocket → Dashboard
│ │
│ ▼
│ Time-Series DB
│ (InfluxDB)


Local Display (Optional)

Data Processing Pipeline


3. Component Breakdown

3.1 Sensor Layer

ComponentFunctionOutput
Water Quality SensorsMeasure parametersAnalog/Digital signals
Signal ConditionersConvert signals4-20mA / 0-10V
Local ControllersBasic processingModbus RTU data

3.2 Edge Layer

ComponentFunctionTechnology
Edge GatewayProtocol conversionSiemens IOT2050
Local BufferData persistenceSQLite / Redis
Edge InferenceLightweight MLTensorFlow Lite

3.3 Integration Layer

ComponentFunctionTechnology
MQTT BrokerMessage routingEMQX / Mosquitto
Stream ProcessorReal-time analyticsApache Kafka
Protocol GatewayOPC-UA to RESTKepware KEPServerEX

3.4 Application Layer

ComponentFunctionTechnology
IoT Gateway ServiceSensor data ingestionNode.js / Express
ML APIPredictionsFastAPI / Python
WebSocket ServerReal-time updatesSocket.io

3.5 Presentation Layer

ComponentFunctionTechnology
Web DashboardMonitoring UINext.js / React
Mobile AppField accessReact Native
SCADA HMIPlant operatorsIgnition

4. Communication Protocols

Protocol Stack

┌─────────────────────────────────────────────────────────┐
│ Application │ HTTP/REST │ WebSocket │ GraphQL │
├────────────────┼───────────┼───────────┼───────────────┤
│ Messaging │ MQTT │ AMQP │ Kafka │
├────────────────┼───────────┼───────────┼───────────────┤
│ Industrial │ OPC-UA │ Modbus TCP│ EtherNet/IP │
├────────────────┼───────────┼───────────┼───────────────┤
│ Field Level │ Modbus RTU│ HART │ 4-20mA │
├────────────────┼───────────┼───────────┼───────────────┤
│ Physical │ RS-485 │ Ethernet │ Wireless │
└─────────────────────────────────────────────────────────┘

Protocol Selection Guide

Use CaseRecommended ProtocolReason
Cloud to EdgeMQTTLightweight, pub/sub
Edge to PLCOPC-UAIndustry standard
Legacy SensorsModbus RTUWide compatibility
Real-time DashboardWebSocketBidirectional
Batch AnalyticsREST APISimple integration

5. Deployment Models

5.1 Cloud-Centric (Default)

[Sensors] → [Edge] → [Cloud IoT Platform] → [ML API] → [Dashboard]

Pros: Centralized, easy management, scalable Cons: Latency, internet dependency

5.2 Edge-Heavy

[Sensors] → [Edge + Local ML] → [Cloud Sync] → [Dashboard]

Pros: Low latency, offline capable Cons: Edge hardware cost, distributed management

[Sensors] → [Edge (Buffering + Alerts)] → [Cloud (ML + Storage)] → [Dashboard]

[Local HMI/SCADA]

Pros: Best of both worlds, resilient Cons: Complex setup


Next Steps


Last Updated: December 2024