01 - Architecture Overview
System architecture for IoT and hardware integration with ML models
Table of Contents
- High-Level Architecture
- Data Flow Diagram
- Component Breakdown
- Communication Protocols
- 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
| Component | Function | Output |
|---|---|---|
| Water Quality Sensors | Measure parameters | Analog/Digital signals |
| Signal Conditioners | Convert signals | 4-20mA / 0-10V |
| Local Controllers | Basic processing | Modbus RTU data |
3.2 Edge Layer
| Component | Function | Technology |
|---|---|---|
| Edge Gateway | Protocol conversion | Siemens IOT2050 |
| Local Buffer | Data persistence | SQLite / Redis |
| Edge Inference | Lightweight ML | TensorFlow Lite |
3.3 Integration Layer
| Component | Function | Technology |
|---|---|---|
| MQTT Broker | Message routing | EMQX / Mosquitto |
| Stream Processor | Real-time analytics | Apache Kafka |
| Protocol Gateway | OPC-UA to REST | Kepware KEPServerEX |
3.4 Application Layer
| Component | Function | Technology |
|---|---|---|
| IoT Gateway Service | Sensor data ingestion | Node.js / Express |
| ML API | Predictions | FastAPI / Python |
| WebSocket Server | Real-time updates | Socket.io |
3.5 Presentation Layer
| Component | Function | Technology |
|---|---|---|
| Web Dashboard | Monitoring UI | Next.js / React |
| Mobile App | Field access | React Native |
| SCADA HMI | Plant operators | Ignition |
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 Case | Recommended Protocol | Reason |
|---|---|---|
| Cloud to Edge | MQTT | Lightweight, pub/sub |
| Edge to PLC | OPC-UA | Industry standard |
| Legacy Sensors | Modbus RTU | Wide compatibility |
| Real-time Dashboard | WebSocket | Bidirectional |
| Batch Analytics | REST API | Simple 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
5.3 Hybrid (Recommended for Neilsoft)
[Sensors] → [Edge (Buffering + Alerts)] → [Cloud (ML + Storage)] → [Dashboard]
↓
[Local HMI/SCADA]
Pros: Best of both worlds, resilient Cons: Complex setup
Next Steps
- Proceed to 02-HARDWARE-SENSORS.md for sensor recommendations
- Review 04-PROTOCOL-ADAPTERS.md for protocol implementation details
Last Updated: December 2024