# ivoafonsobispo/iomt-ai-ids architecture

> Architecture diagram of the GitHub repository ivoafonsobispo/iomt-ai-ids, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivoafonsobispo/iomt-ai-ids
- Repository: https://github.com/ivoafonsobispo/iomt-ai-ids

## Overview

##### Project Overview & Main Components
- IoMT Devices/Edge Nodes: Represent the physical medical devices and associated microcontrollers. Under “IoMT Scenario Code” you see implementations for Arduino Yun and ESP32 circuits, which serve as data-gathering devices and (possibly) attack simulation endpoints.
- Data Capture and Pre-Processing: The “Captures” and “Datasets” directories (along with the Scripts for BLE and IP-based fields extraction) indicate that data is gathered and then forwarded to further analysis. Show how raw network captures (pcap files) and logs are processed via scripts that clean and extract relevant fields.
- Machine Learning Pipeline: A significant portion of the repository is the “Machine Learning” directory. Divide this section into two parts: one handling BLE-based models and another focusing on IP-based models. Include notebooks for data pre-processing, feature extraction, model training (with Python libraries), and saved models (such as .h5 files for neural networks).

##### Relationships and Interactions
- Attack Injection and Simulation: Show how the “Attacks” module inserts or simulates various types of intrusions, thereby creating anomalous traffic. This traffic is then captured alongside regular network packets.
- ML Analysis: Illustrate how both BLE and IP-based data are used to train multiple models employing different ML methodologies (DNN, Decision Trees, Naive Bayes, etc.) and how they eventually inform the IDS component.

##### Architectural Patterns and Design Principles
- Modularity: Emphasize a layered architecture with distinct modules (data capture, pre-processing, ML model training, and deployment).
- Separation of Concerns: Clearly segregate network-level components from data analysis components and the IoMT device simulation aspects.
- Extensibility: Indicate that the system is designed in a way that allows for additional type-specific modules (e.g., additional attack types, alternative ML algorithms).

##### Technologies and Frameworks
- Hardware/Embedded Code: Arduino YUN and ESP32 use embedded C/C++.
- Communication Protocols: MQTT for IoMT attacks and CoAP servers used in network communication.
- Scripting and Data Handling: Shell scripts and Python (server.py in CoAP Server, various Python scripts and Jupyter Notebooks) play key roles.
- Machine Learning: Jupyter Notebooks indicate usage of Python ML libraries (TensorFlow, Keras, scikit-learn, etc.), although specific libraries might be inferred from saved model formats (e.g., .h5 suggests Keras/TensorFlow).
- Data Capture Tools: Use of pcap files points to network capture utilities possibly based on Wireshark/tshark protocols.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% IoMT Edge Devices
    subgraph "IoMT Edge Devices"
        A1["Arduino YUN Circuit"]:::hardware
        A2["ESP32 Circuit"]:::hardware
    end

    %% Communication Servers
    subgraph "Communication Servers"
        B["MQTT/CoAP Communication Servers"]:::network
    end

    %% Network Traffic
    subgraph "Network Traffic"
        C["Data Capture (Traffic Capturing)"]:::capture
        T["Traffic Data Gathering"]:::automation
    end

    %% Network Attacks
    D["Network Attacks Module"]:::attacks

    %% Data Pre-Processing
    subgraph "Data Pre-Processing"
        E["BLE Fields Extractor"]:::processing
        F["IP-Based Fields Extractor"]:::processing
    end

    %% Machine Learning Pipeline
    subgraph "Machine Learning Pipeline"
        G["Machine Learning Pipeline"]:::ml
    end

    %% Data Storage
    subgraph "Data Storage"
        H["Datasets / Saved Datasets"]:::storage
        I["Saved Models (BLE)"]:::storage
        J["Saved Models (IP)"]:::storage
    end

    %% Documentation
    subgraph "Documentation"
        K["Docs & Diagrams"]:::doc
    end

    %% Connections from IoMT Devices to Communication Servers
    A1 -->|"data"| B
    A2 -->|"data"| B

    %% Communication Servers to Traffic Gathering and Data Capture
    B -->|"protocol"| C
    B -->|"protocol"| T

    %% Traffic Gathering feeds into Data Capture
    T -->|"capture trigger"| C

    %% Network Attacks inject anomalies into Data Capture
    D -->|"injects"| C

    %% Data Capture to Data Pre-Processing
    C -->|"raw data"| E
    C -->|"raw data"| F

    %% Pre-Processing to ML Pipeline
    E -->|"features"| G
    F -->|"features"| G

    %% ML Pipeline outputs to Data Storage
    G -->|"models"| I
    G -->|"models"| J
    G -->|"processed data"| H

    %% Feedback: ML Pipeline sends alerts back to IoMT Edge Devices
    G -->|"alerts"| A1
    G -->|"alerts"| A2

    %% Documentation provides guidelines to ML Pipeline
    K -->|"guidance"| G

    %% Click Events
    click A1 "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/IoMT Scenario Code/Arduino YUN Circuit"
    click A2 "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/IoMT Scenario Code/ESP32 Circuit"
    click B "https://github.com/ivoafonsobispo/iomt-ai-ids/blob/main/IoMT Scenario Code/Coap Server/server.py"
    click D "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Attacks and Scripts/IoMT Attacks"
    click C "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Captures"
    click E "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Scripts/BLE Fields Extractor"
    click F "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Scripts/IP-Based Fields Extractor"
    click G "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Machine Learning"
    click H "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Datasets"
    click I "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Machine Learning/BLE/Saved Models"
    click J "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Machine Learning/IP-Based/Packets/Saved Models"
    click K "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Docs and Diagrams"
    click T "https://github.com/ivoafonsobispo/iomt-ai-ids/tree/main/Scripts/IoMT-TrafficData_Gatherer"

    %% Styles
    classDef hardware fill:#ffcccc,stroke:#cc0033,stroke-width:2px;
    classDef network fill:#ccffcc,stroke:#006600,stroke-width:2px;
    classDef capture fill:#ccccff,stroke:#0000cc,stroke-width:2px;
    classDef automation fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
    classDef processing fill:#e6e6e6,stroke:#999999,stroke-width:2px;
    classDef ml fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef storage fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef doc fill:#dad8f1,stroke:#2200ff,stroke-width:2px;
    classDef attacks fill:#f4cccc,stroke:#dd0000,stroke-width:2px;
```
