e20-co326-MQTT-Data-Anomaly-Detection

System Architecture Document

1. Purpose

This document describes the current CO326 Industrial Digital Twin implementation. The project is now centered on one industrial use case: Motor-01 overheating monitoring with relay trip simulation.

2. Use Case Scope

3. High-Level Architecture

flowchart LR
    P[Motor-01 Publisher] -->|Sparkplug DDATA| M[MQTT Broker]
    M --> N[Node-RED Flow]
    N -->|UNS Telemetry| M
    M --> B[Backend Service]
    B --> A[AI Brain]
    B --> I[InfluxDB Historian]
    B --> F[Frontend Dashboard]
    B -->|Sparkplug DCMD| M
    M --> P
    N -->|Auto Trip DCMD| M
    I --> G[Grafana]

4. MQTT Namespace

The payload uses Sparkplug-style metric names in JSON so the simulated services, Node-RED, and React dashboard can inspect the values without a protobuf dependency.

5. Data Flow

sequenceDiagram
    participant P as Publisher
    participant M as MQTT
    participant N as Node-RED
    participant B as Backend
    participant A as AI Brain
    participant I as InfluxDB
    participant F as Frontend

    P->>M: DDATA Motor/WindingTemperature + Relay/FeedbackState
    M->>N: Sparkplug telemetry
    N->>M: UNS telemetry
    M->>B: UNS telemetry
    B->>A: POST /predict(motorTemperatureC)
    A-->>B: anomaly + score
    B->>B: estimate RUL
    B->>I: write motor_overheat_monitor point
    B-->>F: emit motor-data
    F->>B: POST /api/relay-command
    B->>M: DCMD Relay/Command
    M->>P: Relay command
    P->>P: update simulated relay

6. Four-Layer IIoT Mapping

Layer 1: Perception Layer

Layer 2: Transport Layer

Layer 3: Edge Logic Layer

Layer 4: Application Layer

7. Historian Fields

Measurement: motor_overheat_monitor