# azure/azure-iot-explorer architecture

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

- Interactive diagram: https://gitdiagram.com/azure/azure-iot-explorer
- Repository: https://github.com/azure/azure-iot-explorer

## Overview

Based on our analysis of both the file tree and README, Azure IoT Explorer is a rich, full‐stack, cross-platform application with both web and Electron desktop deployments. Its primary purpose is to provide an interactive UI for managing and monitoring Azure IoT Hub devices, offering multiple authentication methods (connection string and Azure Active Directory), complete device CRUD operations, as well as advanced functionalities for Plug and Play interactions with devices. The architecture is structured along front-end components, state management, API services, and the Electron/Node integration for native desktop support.

##### Core Components
- Frontend/UI Layer:
- Built using React (notice the extensive use of TSX files) with a modular structure for pages such as Home, Device List, Device Details, IoT Hub, and Plug and Play.
- Components are grouped by feature (authentication, devices, connection strings, navigation, notifications, etc.).
- Styling and global state management are also part of the frontend.

- State Management/Business Logic:
- Use of Redux/reducers, sagas, and context providers is evident in directories like src/app/authentication, src/app/deviceList, and similar folders for devices and modules.
- This layer orchestrates application state, API calls, and user interactions.

- API Services Layer:
- Contains numerous files in src/app/api for data transforms, service calls (e.g., to IoT Hub, event hub, and Azure subscription endpoints), and error handling.
- It encapsulates logic on how the UI consumes Azure service responses and interacts with external Azure resources.

- Electron Integration / Server/Backend Layer:
- Located in the “public” folder (with electron.ts, contextBridge, factories) and “src/server” folder.
- Provides a local Node/Electron process that supports desktop integration, packaging, and any local server functions.

- External Services:
- Azure IoT Hub, Azure Active Directory, and related Azure services are the external dependencies.
- The interface and model definitions for Plug and Play and device management demonstrate integration with these cloud services.

##### Relationships and Interactions
- The UI components issue actions (via Redux actions or sagas) that trigger state changes.
- These actions call API service methods which in turn communicate with Azure endpoints or local server components.
- The Electron layer provides a bridge between the browser context (UI) and native OS functionalities.
- Pipelines and CI/CD (GitHub workflows, pipelines directory) handle build, test, and packaging processes.
- Data flows from external services (Azure IoT Hub, Azure AD) to the API layer, then to the state management, and finally to the UI for display and user interaction.

##### Architectural Patterns and Technologies
- Componentized UI design with separation of concerns (clear division between views, state management, and business logic).
- Use of asynchronous patterns (sagas) to handle API calls and data streaming.
- Integration of web and desktop platforms via Electron.
- A layered architecture where the presentation (React components) is decoupled from the service layers (API and server code).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend/UI Components
    subgraph "Frontend/UI Components"
        A1["Home View"]:::frontend
        A1a["Home Navigation"]:::frontend
        A2["Device List UI"]:::frontend
        A2a["Device Details UI"]:::frontend
        A3["IoT Hub UI"]:::frontend
        A4["Plug and Play UI"]:::frontend
    end

    %% State Management / Business Logic
    subgraph "State Management (Redux/Sagas)"
        B1["Authentication State"]:::state
        B2["Device List State"]:::state
        B3["Other Device State"]:::state
        B4["Global/Shared State"]:::state
    end

    %% API Services Layer
    subgraph "API Services Layer"
        C1["API Service Calls"]:::api
        C2["Data Transforms & Models"]:::api
    end

    %% Electron Integration / Server Backend
    subgraph "Electron Integration / Server Backend"
        D1["Electron & Context Bridge"]:::electron
        D2["Local Server Processes"]:::electron
    end

    %% External Services
    subgraph "External Services"
        E1["Azure IoT Hub"]:::external
        E2["Azure AD"]:::external
        E3["Event Hubs"]:::external
    end

    %% CI/CD & Build Pipelines
    subgraph "CI/CD & Build Pipelines"
        F1["Pipelines"]:::cicd
        F2["GitHub Workflows"]:::cicd
    end

    %% ----------------- Connections -----------------

    %% Frontend to State Management (dispatch actions)
    A1 -->|"dispatch"| B1
    A1a -->|"dispatch"| B1
    A2 -->|"dispatch"| B2
    A2a -->|"dispatch"| B2
    A3 -->|"dispatch"| B3
    A4 -->|"dispatch"| B4

    %% State Management to API Services (trigger API calls)
    B1 -->|"triggerAPI"| C1
    B2 -->|"triggerAPI"| C1
    B3 -->|"triggerAPI"| C1
    B4 -->|"triggerAPI"| C1

    %% API Services calling External Services
    C1 -->|"call"| E1
    C1 -->|"call"| E2
    C1 -->|"call"| E3

    %% External Services response flows back to API layer
    E1 -->|"response"| C2
    E2 -->|"response"| C2
    E3 -->|"response"| C2

    %% API Services updating State Management
    C2 -->|"updateState"| B1

    %% State Management updating Frontend/UI
    B1 -.->|"updateUI"| A1
    B2 -.->|"updateUI"| A2
    B3 -.->|"updateUI"| A3
    B4 -.->|"updateUI"| A4

    %% Electron Integration interactions with Frontend
    A1 ---|"bridgeCall"| D1
    A2 ---|"bridgeCall"| D1
    A3 ---|"bridgeCall"| D1
    A4 ---|"bridgeCall"| D1

    %% Local Server Processes supporting Electron
    D2 -->|"nativeSupport"| D1

    %% CI/CD Pipelines building and packaging (influencing Electron integration)
    F1 -->|"buildPackage"| D1
    F2 -->|"buildPackage"| D1

    %% ----------------- Click Events -----------------

    %% Frontend/UI Components Clicks
    click A1 "https://github.com/azure/azure-iot-explorer/blob/main/src/app/home/components/homeView.tsx"
    click A1a "https://github.com/azure/azure-iot-explorer/blob/main/src/app/home/components/homeViewNavigation.tsx"
    click A2 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/devices/deviceList/components"
    click A2a "https://github.com/azure/azure-iot-explorer/tree/main/src/app/devices/deviceIdentity/components"
    click A3 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/iotHub/components"
    click A4 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/devices/pnp/components"

    %% State Management Clicks
    click B1 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/authentication"
    click B2 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/devices/deviceList"
    click B3 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/devices/deviceTwin"
    click B3 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/devices/directMethod"
    click B4 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/shared"

    %% API Services Clicks
    click C1 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/api/services"
    click C2 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/api/dataTransforms"
    click C2 "https://github.com/azure/azure-iot-explorer/tree/main/src/app/api/models"

    %% Electron Integration Clicks
    click D1 "https://github.com/azure/azure-iot-explorer/blob/main/public/electron.ts"
    click D1 "https://github.com/azure/azure-iot-explorer/blob/main/public/contextBridge.ts"
    click D1 "https://github.com/azure/azure-iot-explorer/tree/main/public/factories"
    click D1 "https://github.com/azure/azure-iot-explorer/tree/main/public/handlers"
    click D1 "https://github.com/azure/azure-iot-explorer/tree/main/public/interfaces"
    click D1 "https://github.com/azure/azure-iot-explorer/tree/main/public/utils"
    click D2 "https://github.com/azure/azure-iot-explorer/tree/main/src/server"

    %% CI/CD Clicks
    click F1 "https://github.com/azure/azure-iot-explorer/tree/main/pipelines"
    click F2 "https://github.com/azure/azure-iot-explorer/blob/main/.github/workflows/nodejs.yml"

    %% ----------------- Styles -----------------
    classDef frontend fill:#FAD,stroke:#333,stroke-width:2px;
    classDef state fill:#ADF,stroke:#333,stroke-width:2px;
    classDef api fill:#DFA,stroke:#333,stroke-width:2px;
    classDef electron fill:#FFD,stroke:#333,stroke-width:2px;
    classDef external fill:#DDF,stroke:#333,stroke-width:2px;
    classDef cicd fill:#FDF,stroke:#333,stroke-width:2px;
```
