# piovezan1207/device-data-hub architecture

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

- Interactive diagram: https://gitdiagram.com/piovezan1207/device-data-hub
- Repository: https://github.com/piovezan1207/device-data-hub

## Overview

##### Project Type and Purpose
- This is a full-stack application designed for industrial device data distribution. Its primary goal is to centralize data from industrial devices (via MQTT brokers) and provide a web platform that manages device connections, facilitating the development of digital twins and dashboards.
- The README and file tree show two main domains: the web interface (for platform interactions) and a robot domain (for handling device-specific integrations).

##### Analyzing the File Structure
- Top-level organization:
– "app/app.py": Likely the main entrypoint for running the web application.
– "app/infra": Contains infrastructure scripts (e.g., SQLite table creation, key generator) for environment setup.
– "app/src/web": Contains the complete web platform with its controllers, gateways, presenters, core entities, and use cases. This represents the user-facing part of the system.
– "app/src/robot": Contains the robot domain logic, including integrations for various industrial devices (e.g., Kuka, MIR, Mitutoyo, Staubli, Yaskawa). This domain is integrated into the system—especially in terms of external web integrations.
- Configuration files and docker-related files (Dockerfile, docker-compose.yml, .env.example) indicate an ability to run the project in both local and containerized environments.

##### Incorporating the README Insights
- The README clearly explains that the system centralizes device data through MQTT brokers, implying a strong integration with both external industrial devices and MQTT messaging.
- The project description highlights that while devices are integrated via code (in the robot domain), management and connection functions are available through the web platform.

##### Elements
- Clear labels for each component (e.g., “Web Controller – RobotController”, “Database – SQLite”, “Robot Integration – Kuka/MIR/Staubli”, “Infra – Key Generation”).
- Data/Command flow from the web UI to controllers to use cases.
- Interaction from use cases to the robot domain (and vice versa) using adapter interfaces.
- Data flow from external industrial devices to MQTT brokers, and from brokers into the web application.
- Another for domain/business logic (use cases, core entities).
- A distinct style for infrastructure components (database, key generation).

Additional Note:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Layers
    ED("Industrial Devices"):::external
    MB("MQTT Brokers"):::external

    %% Web Platform Subgraph
    subgraph "Web Platform"
        direction TB
        %% Controllers Subgraph
        subgraph "Controllers"
            BC("BrokerController"):::presentation
            CC("ConnectionController"):::presentation
            RC("RobotController"):::presentation
        end
        %% Use Cases Subgraph
        subgraph "Use Cases"
            BUC("BrokerUseCases"):::domain
            CUC("ConnectionUseCases"):::domain
            RUC("RobotUseCases"):::domain
        end
        %% Presenters Subgraph
        subgraph "Presenters"
            BP("BrokerPresenter"):::presentation
            CP("ConnectionPresenter"):::presentation
            RP("RobotPresenter"):::presentation
        end
        DE("SQLite Database"):::infra
        WE("Web External Integration"):::domain
    end

    %% Robot Domain Subgraph
    subgraph "Robot Domain"
        direction TB
        RCOR("Robot Core Logic"):::domain
        RAD("Robot Adapters"):::domain
        REI("Robot External Integrations"):::domain
    end

    %% Infra Node
    INF("Infra - Security & Setup"):::infra

    %% Connections
    ED -->|"sendsData"| MB
    MB -->|"dataFlow"| BC

    %% Web Platform internal flow
    BC -->|"invokes"| BUC
    CC -->|"invokes"| CUC
    RC -->|"invokes"| RUC

    BUC -->|"formats"| BP
    CUC -->|"formats"| CP
    RUC -->|"formats"| RP

    %% Use Cases interaction with Database
    BUC ---|"dbAccess"| DE
    CUC ---|"dbAccess"| DE
    RUC ---|"dbAccess"| DE

    %% Infra supports Database
    INF -->|"setup"| DE

    %% Web External Integration to Robot Domain
    WE -->|"integrates"| RCOR
    RCOR -->|"utilizes"| RAD
    RAD -->|"communicatesWith"| REI

    %% Click Events
    click BC "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/adapters/controller/BrokerController.py"
    click CC "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/adapters/controller/ConnectionController.py"
    click RC "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/adapters/controller/RobotController.py"
    click BUC "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/core/usecases/BrokerUseCases.py"
    click CUC "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/core/usecases/ConnectionUseCases.py"
    click RUC "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/core/usecases/RobotUseCases.py"
    click BP "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/adapters/presenter/BrokerPresenter.py"
    click CP "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/adapters/presenter/ConnectionPresenter.py"
    click RP "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/adapters/presenter/RobotPresenter.py"
    click DE "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/External/datasources/SqliteDatabase.py"
    click WE "https://github.com/piovezan1207/device-data-hub/blob/main/app/src/web/External/integrations/connectionExternal.py"
    click RCOR "https://github.com/piovezan1207/device-data-hub/tree/main/app/src/robot/core"
    click RAD "https://github.com/piovezan1207/device-data-hub/tree/main/app/src/robot/adapters"
    click REI "https://github.com/piovezan1207/device-data-hub/tree/main/app/src/robot/External/integrations"
    click INF "https://github.com/piovezan1207/device-data-hub/tree/main/app/infra"

    %% Styles
    classDef external fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef presentation fill:#d6e9ff,stroke:#333,stroke-width:2px;
    classDef domain fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef infra fill:#f9e79f,stroke:#333,stroke-width:2px;
```
