# anshumanfauzdar/predictive-maintenance architecture

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

- Interactive diagram: https://gitdiagram.com/anshumanfauzdar/predictive-maintenance
- Repository: https://github.com/anshumanfauzdar/predictive-maintenance

## Overview

##### Project Type and Purpose

**Project Type:**
This project is an **embedded mechatronics system** designed for **predictive maintenance**. It integrates various hardware components like microcontrollers, sensors, and actuators with software firmware to monitor and analyze industrial equipment in real-time.

**Purpose:**
The system aims to provide real-time monitoring of machinery by collecting data from cameras, microphones, and temperature sensors. It leverages WiFi connectivity to send data to the cloud for further analysis and implements machine learning algorithms on the edge for immediate detection of anomalies such as noise, vibration, or temperature irregularities. Additionally, it includes a modular 3D-printed structure for housing the hardware components and a Human-Machine Interface (HMI) for data visualization.

##### File Structure

**Top-Level Directories and Files:**

- **.github/workflows:** Contains CI/CD pipelines for Arduino and Nuttx builds, indicating automated testing and deployment processes.
- **3D:** Houses 3D-printed STL files for various components, suggesting a focus on custom hardware enclosures and mounts.
- **firmware:** Central directory for all firmware-related code, structured into testing, Python scripts, and WiFi configurations.
- **LICENSE & README.md:** Standard project documentation and licensing.

**Key Observations:**

- **Modular Structure:** The presence of separate directories for firmware testing and WiFi configurations points towards a modular architecture, facilitating scalability and maintenance.
- **Use of Microcontrollers:** Directories like `nodemcu` and `spresense` indicate the use of specific microcontrollers for different functionalities.
- **Automation:** GitHub workflows for Arduino and Nuttx suggest automated building and testing processes, enhancing reliability.
- **3D Integration:** The `3D` directory with multiple STL files highlights the integration of hardware design with the software system.

##### README for Additional Insights

- **Promised Features:** The README outlines features like camera monitoring, noise detection, WiFi connectivity, temperature sensing, speaker notifications, HMI, modular 3D-printed structure, and cloud server integration.
- **Development Lifecycle:** Emphasis on using Git for version control and structured branching strategies indicates a collaborative and organized development approach.
- **Road Map:** Details the step-by-step development tasks, emphasizing critical components like bootloader burning, camera setup, WiFi connectivity, sensor integration, and deployment to Edge Impulse for machine learning.

**a. Identify the Main Components:**

- **Hardware Components:**
- **Microcontrollers:** ESP8266/32, NodeMCU, Spresense
- **Sensors:** Camera, Microphone, Temperature Sensor
- **Actuators:** Speakers
- **HMI Display:** For data visualization
- **3D-Printed Structure:** Modular enclosures and mounts
- **Connectivity Modules:** WiFi modules

- **Software Components:**
- **Firmware:** For sensor data acquisition and processing
- **Testing Scripts:** Python-based GUI and data handling
- **Machine Learning Models:** For anomaly detection on the edge
- **Cloud Server:** For data storage and advanced analytics

- **External Services:**
- **Edge Impulse:** For deploying machine learning models
- **Cloud Services:** For data aggregation and remote monitoring

**b. Determine Relationships and Interactions:**

- **Data Flow:**
1. **Sensors** collect real-time data (images, noise levels, temperature).
2. **Microcontrollers** process this data locally, performing initial filtering.
3. Processed data is sent via **WiFi modules** to the **cloud server**.
4. **Machine Learning Models** on the edge analyze data for anomalies.
5. Upon detection, **actuators** (speakers) provide immediate notifications.
6. **HMI Display** presents real-time and historical data to users.
7. Data and insights are stored and further processed in the **cloud** for long-term analysis and predictive maintenance.

**c. Highlight Architectural Patterns or Design Principles:**

- **Modular Architecture:** Separates hardware components and firmware into distinct modules, facilitating easy updates and scalability.
- **Edge Computing:** Implements machine learning directly on microcontrollers for real-time anomaly detection, reducing latency.
- **Separation of Concerns:** Differentiates between data acquisition, processing, and user interface layers.
- **Automated CI/CD Pipelines:** Ensures consistent and reliable firmware deployment through GitHub workflows.

**d. Include Relevant Technologies, Frameworks, or Libraries:**

- **Firmware Development:** Arduino IDE for ESP8266/32 and NodeMCU, possibly using PlatformIO for Spresense.
- **Programming Languages:** C/C++ for firmware, Python for testing scripts.
- **Machine Learning:** Edge Impulse for deploying models on microcontrollers.
- **Version Control:** Git and GitHub for source code management and CI/CD.
- **3D Design Software:** For creating and modifying STL files used in the 3D-printed structures.

##### Elements

- **Clear Labels:** Name each component accurately (e.g., ESP32 Microcontroller, Camera Module, Cloud Server).

##### Importance of Detail and Architectural Elements

- **Including All Major Components:** Don’t omit any critical hardware or software elements.
- **Capturing Interactions:** Clearly show how components interact, including data dependencies and communication protocols.
- **Avoiding Overcomplication:** While detail is essential, maintain clarity by organizing components logically and avoiding clutter.
- **Documenting Design Choices:** Use annotations or legends to explain significant architectural decisions or patterns.

##### Final Recommendations

- **Iterate and Review:** Share initial drafts with team members to ensure accuracy and completeness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities

    %% Subgraphs and modules
    subgraph Hardware
        S1["Camera"]:::sensor
        S2["Microphone"]:::sensor
        S3["Temperature Sensor"]:::sensor
        MCU1["NodeMCU Microcontroller"]:::hardware
        MCU2["Spresense Microcontroller"]:::hardware
        MCU3["ESP8266/32 Microcontrollers"]:::hardware
        WFM["WiFi Connectivity Modules"]:::hardware
        Act["Speakers"]:::actuator
        structure["3D-Printed Structure"]:::hardware
    end

    subgraph Software
        FW["Firmware"]:::software
        TS["Testing Scripts"]:::software
        ML["Machine Learning Models"]:::software
        HMI["HMI Display"]:::software
    end

    subgraph Cloud
        CS["Cloud Server"]:::cloud
        EI["Edge Impulse"]:::external
        CLD["Cloud Services"]:::external
    end

    %% Connections
    S1 --> MCU1
    S2 --> MCU1
    S3 --> MCU1
    S1 --> MCU2
    S2 --> MCU2
    S3 --> MCU2
    S1 --> MCU3
    S2 --> MCU3
    S3 --> MCU3
    MCU1 --> FW
    MCU2 --> FW
    MCU3 --> FW
    FW --> WFM
    WFM --> CS
    FW --> ML
    ML --> Act
    FW --> HMI
    HMI --> CS
    CS --> CLD
    ML --> EI

    %% Click Events
    click MCU1 "https://github.com/anshumanfauzdar/predictive-maintenance/blob/main/firmware/testing/wifi/nodemcu/nodemcu.ino"
    click MCU2 "https://github.com/anshumanfauzdar/predictive-maintenance/blob/main/firmware/testing/wifi/spresense/spresense.ino"
    click MCU3 "https://github.com/anshumanfauzdar/predictive-maintenance/blob/main/.github/workflows/arduino.yaml"
    click WFM "https://github.com/anshumanfauzdar/predictive-maintenance/tree/main/firmware/testing/wifi/"
    click structure "https://github.com/anshumanfauzdar/predictive-maintenance/tree/main/3D/"
    click FW "https://github.com/anshumanfauzdar/predictive-maintenance/tree/main/firmware/"
    click TS "https://github.com/anshumanfauzdar/predictive-maintenance/tree/main/firmware/testing/python/"
    click ML "https://github.com/anshumanfauzdar/predictive-maintenance/blob/main/firmware/testing/python/serial_read_edge_impulse.py"
    click HMI "https://github.com/anshumanfauzdar/predictive-maintenance/blob/main/firmware/testing/python/gui.py"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef software fill:#90EE90,stroke:#000,stroke-width:1px
    classDef sensor fill:#FFA500,stroke:#000,stroke-width:1px
    classDef actuator fill:#FFB6C1,stroke:#000,stroke-width:1px
    classDef cloud fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
