# technologiescollege/blockly-at-rduino architecture

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

- Interactive diagram: https://gitdiagram.com/technologiescollege/blockly-at-rduino
- Repository: https://github.com/technologiescollege/blockly-at-rduino

## Overview

##### Main Components
- Web User Interface (UI): Represented by the HTML files (e.g., index.html, index_AIO.html, index_IDE.html) and styled using CSS (in the “css” folder). This is where users interact with the drag-and-drop Blockly environment.
- Blockly Core & Customization: The “core” directory holds custom integrations with Blockly (e.g., integration files like block_instance.js, field_instance.js, type definitions, and other Blockly-related engine code). Also, the “lang” and “toolbox” directories supply multi-language support and necessary block tool definitions.
- Block Definitions: The “blocks” directory contains a multitude of subdirectories, each dedicated to particular modules or functionalities (such as sensor libraries, communication modules, and brand-specific blocks like “Adafruit”, “DFRobot”, “Robobox”, etc.). This clearly shows an extensive modular design for different hardware components.
- Code Generators: In the “generators” folder, there are subdirectories like “Blockly”, “BlocklyArduino”, “arduino”, “python”, etc. These are responsible for producing the final code (e.g., Arduino code and Python code) from the visual configuration.
- Examples & Documentation: The “examples” and “documentation” directories house sample projects and guides that help users understand how to use various blocks and functionalities.
- Developer Tools & Auxiliary Applications: The “tools” directory includes resources for RGB configuration interfaces, IoT web servers, and even serial console and supervision tools. These support extended functionalities like uploading code and live supervision via the PyMata-AIO server.
- External Interfaces: The README indicates optional Electron-based versions which provide advanced features such as local serial console and firmware upload. These should be represented as optional modules interfacing with the core application.

##### Relationships and Interactions
- The user interacts with the Web UI (frontend), and the UI leverages the Blockly framework (enhanced by additional “core” components) to allow visual programming.
- Custom blocks are defined in the “blocks” directory; when the user assembles these blocks, the corresponding XML configuration is processed.
- The ‘generators’ then translate the visual block configuration into executable Arduino code.
- Users can save and load projects (through XML/INO files) and, when ready, utilize integrated tools (from “tools” and separate Electron version) to upload the code to the Arduino board or monitor it via a serial console.
- There is a data flow from UI → Blockly engine → Code generators → Arduino hardware (potentially via serial data and real-time supervision provided by PyMata-AIO).

##### Important Architectural Patterns/Design Principles
- Modular Architecture: Notice how the blocks are separated by categories (for different hardware devices and brand-specific modules). This modular design supports extensibility.
- Separation of Concerns: The project clearly separates the UI, block definitions, code generation, and hardware interfacing layers.
- Multi-language Support: The “lang” directory shows that the system is designed with internationalization in mind, enabling different language versions.
- Extensibility/Plugin Support: The architecture supports the addition of new blocks and generators, as indicated by the many different sub-directories and extensible toolbox definitions.

##### Relevant Technologies and Frameworks
- Frontend: HTML, CSS, and JavaScript (with JQuery for certain UI elements, as observed in the “libs” folder).
- Blockly Library: A core dependency for the drag-and-drop block programming.
- Arduino IDE Compatibility: The generated Arduino code is designed to be copy-paste–ready for the Arduino IDE.
- Additional Libraries: Canvas2Image, Smoothie charts, and others in “core/libs” indicate usage of libraries for handling UI dynamics and possibly real-time charting (especially pertinent in the supervision tools).

##### Detailing Important Architectural Elements
- Provide any data stores (for saving XML or INO files) as part of “Storage” elements.
- Showing a feedback loop for real-time supervision where data from the Arduino (via PyMata-AIO) is fed back to the web UI.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (UI)"
        UI_HTML["HTML Files"]
        UI_CSS["CSS Files"]
    end

    %% Blockly Engine & Core
    subgraph "Blockly Engine & Core"
        BE_Core["Core Integration"]
        BE_Compressed["Compressed Blockly Engine"]
        BE_Libs["Core Libraries"]
    end

    %% Block Definitions Module
    subgraph "Block Definitions Module"
        BD_Dir["Blocks Directory"]
        BD_Typing["Blocks Typings & Colors"]
    end

    %% Code Generators
    subgraph "Code Generators"
        CG_Blockly["Blockly Generators"]
        CG_Arduino["Arduino Generators"]
        CG_Python["Python Generators"]
        CG_Microbit["Microbit Generators"]
    end

    %% Examples & Documentation
    subgraph "Examples & Documentation"
        ED_Examples["Examples"]
        ED_Doc["Documentation"]
    end

    %% Developer Tools & Auxiliary Applications
    subgraph "Developer Tools & Auxiliary Applications"
        DT_RGB["RGB Configuration Tools"]
        DT_IoT["IoT Web Server Tools"]
        DT_Factory["Block Factory"]
        DT_Screen["Screen/Duino Tools"]
        DT_Serial["Serial Console"]
        DT_Supervision["Supervision Tools"]
    end

    %% External Interfaces
    subgraph "External Interfaces"
        EI_Electron["Electron Version"]
        EI_Serial["Serial Console Interface"]
    end

    %% Multi-language Support
    subgraph "Multi-language Support"
        ML_Lang["Language Files"]
    end

    %% Connections / Data Flow
    UI_HTML -->|"sends inputs"| BE_Core
    UI_CSS -->|"styles UI"| BE_Core

    BE_Core -->|"accesses"| BD_Dir
    BE_Core -->|"initiates"| CG_Blockly
    BE_Core --> BE_Compressed
    BE_Libs --> BE_Core

    BD_Dir -->|"provides definitions"| CG_Arduino
    BD_Dir --> CG_Python
    BD_Dir --> CG_Microbit

    CG_Blockly -->|"generates XML"| CG_Arduino

    CG_Arduino -->|"produces Arduino code"| DT_Serial
    CG_Arduino --> DT_Supervision
    CG_Arduino --> EI_Electron

    DT_Serial -->|"interfaces with"| EI_Serial
    DT_Supervision -->|"feedback"| UI_HTML

    %% Additional Resources
    UI_HTML -->|"project save/load"| ED_Examples
    UI_HTML --> ED_Doc
    BE_Core --> ML_Lang

    %% Styles
    classDef frontend fill:#a6cee3,stroke:#08457E,stroke-width:2px,color:black;
    classDef engine fill:#b2df8a,stroke:#033E1C,stroke-width:2px,color:black;
    classDef modules fill:#fbb4ae,stroke:#990000,stroke-width:2px,color:black;
    classDef generators fill:#cab2d6,stroke:#4B0082,stroke-width:2px,color:black;
    classDef docs fill:#ffff99,stroke:#666600,stroke-width:2px,color:black;
    classDef tools fill:#d9d9d9,stroke:#333333,stroke-width:2px,color:black;
    classDef external fill:#fccde5,stroke:#b30059,stroke-width:2px,color:black;
    classDef multi fill:#ccebc5,stroke:#006600,stroke-width:2px,color:black;

    %% Applying classes to nodes
    class UI_HTML,UI_CSS frontend;
    class BE_Core,BE_Compressed,BE_Libs engine;
    class BD_Dir,BD_Typing modules;
    class CG_Blockly,CG_Arduino,CG_Python,CG_Microbit generators;
    class ED_Examples,ED_Doc docs;
    class DT_RGB,DT_IoT,DT_Factory,DT_Screen,DT_Serial,DT_Supervision tools;
    class EI_Electron,EI_Serial external;
    class ML_Lang multi;

    %% Click Events
    click UI_HTML "https://github.com/technologiescollege/blockly-at-rduino/blob/gh-pages//index.html"
    click UI_CSS "https://github.com/technologiescollege/blockly-at-rduino/blob/gh-pages//css/blockly@rduino.css"
    click BE_Core "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//core/Ardublockly"
    click BE_Compressed "https://github.com/technologiescollege/blockly-at-rduino/blob/gh-pages//core/blockly_compressed.js"
    click BE_Libs "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//core/libs"
    click BD_Dir "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//blocks"
    click BD_Typing "https://github.com/technologiescollege/blockly-at-rduino/blob/gh-pages//blocks/blocks_colors.js"
    click CG_Blockly "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//generators/Blockly"
    click CG_Arduino "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//generators/arduino"
    click CG_Python "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//generators/python"
    click CG_Microbit "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//generators/microbit"
    click ED_Examples "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//examples"
    click ED_Doc "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//documentation"
    click DT_RGB "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//tools/RGB"
    click DT_IoT "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//tools/TZ51/iotwebserver"
    click DT_Factory "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//tools/factory"
    click DT_Screen "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//tools/screenduino"
    click DT_Serial "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//tools/serialconsole"
    click DT_Supervision "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//tools/supervision"
    click EI_Electron "https://github.com/technologiescollege/blockly-at-rduino/blob/gh-pages//index_electron.html"
    click EI_Serial "https://github.com/technologiescollege/blockly-at-rduino/blob/gh-pages//tools/serialconsole/serialconsole.html"
    click ML_Lang "https://github.com/technologiescollege/blockly-at-rduino/tree/gh-pages//lang"
```
