# cyberhorizonltd/4wire architecture

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

- Interactive diagram: https://gitdiagram.com/cyberhorizonltd/4wire
- Repository: https://github.com/cyberhorizonltd/4wire

## Overview

##### Project type and purpose
- 4wire is a *protocol library* (not a web app or microservice).
- Its purpose is to let two devices (microcontrollers or small computers) communicate over four GPIO lines at >1 kb/s.
- The repository provides *platform-specific sender/receiver examples* for ESP32, Heltec WiFi Lora, Raspberry Pi Pico, Raspberry Pi 5, Ubuntu and Windows.

##### File structure
- There are no “frontend” or “backend” folders—this is embedded/IoT code.
- The top‐level `sources/` directory holds all implementations:
- `*_sender.*` (C++ or Python)
- `*_receiver.*` (C++ or Python)
- Configuration (pin definitions) is done in source files.
- No deployment scripts—these are cross‐compiled or run directly on the target hardware.

##### README for additional insights
- It defines a *hierarchical model* with two roles: **Sender** and **Receiver**.
- The four signals are: **clock**, **data**, **notify**, **enable**.
- The communication is synchronous: the Sender toggles clock/data/notify, the Receiver responds via enable.

##### Putting it all together
1) Sender asserts notify → Receiver
2) Receiver asserts enable → Sender
3) Sender toggles clock/data for each bit
4) Receiver reads data, de-asserts enable
5) Repeat until notify is de-asserted

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Sender"
        SENDER_CORE["Generic Sender Protocol"]:::sender
        ESP32_SENDER["ESP32_WROOM32 Sender"]:::platform
        HELTEC_SENDER["Heltec WiFi LoRa V3 Sender"]:::platform
        RPI_PICO_MP_SENDER["Raspberry Pi Pico (MicroPython) Sender"]:::platform
        RPI_PICO_SDK_SENDER["Raspberry Pi Pico (Pico SDK C++) Sender"]:::platform
        UBUNTU_SENDER["Ubuntu File Sender"]:::platform
        WIN11_BIN_SENDER["Windows 11 Binary Sender"]:::platform
        WIN11_FILE_SENDER["Windows 11 File Sender"]:::platform
        SENDER_CORE --> ESP32_SENDER
        SENDER_CORE --> HELTEC_SENDER
        SENDER_CORE --> RPI_PICO_MP_SENDER
        SENDER_CORE --> RPI_PICO_SDK_SENDER
        SENDER_CORE --> UBUNTU_SENDER
        SENDER_CORE --> WIN11_BIN_SENDER
        SENDER_CORE --> WIN11_FILE_SENDER
    end

    subgraph "Receiver"
        RECEIVER_CORE["Generic Receiver Protocol"]:::receiver
        ESP32_RECEIVER["ESP32_WROOM32 Receiver"]:::platform
        HELTEC_RECEIVER["Heltec WiFi LoRa V3 Receiver"]:::platform
        RPI5_RECEIVER["Raspberry Pi 5 Receiver"]:::platform
        UBUNTU_RECEIVER["Ubuntu File Receiver"]:::platform
        WIN11_BIN_RECEIVER["Windows 11 Binary Receiver"]:::platform
        WIN11_FILE_RECEIVER["Windows 11 File Receiver"]:::platform
        RECEIVER_CORE --> ESP32_RECEIVER
        RECEIVER_CORE --> HELTEC_RECEIVER
        RECEIVER_CORE --> RPI5_RECEIVER
        RECEIVER_CORE --> UBUNTU_RECEIVER
        RECEIVER_CORE --> WIN11_BIN_RECEIVER
        RECEIVER_CORE --> WIN11_FILE_RECEIVER
    end

    SENDER_CORE -->|"clock"| RECEIVER_CORE
    SENDER_CORE -->|"data"| RECEIVER_CORE
    SENDER_CORE -->|"notify"| RECEIVER_CORE
    RECEIVER_CORE -->|"enable"| SENDER_CORE

    linkStyle 0 stroke:#0f0,stroke-width:2px
    linkStyle 1 stroke:#00f,stroke-width:2px
    linkStyle 2 stroke:#ff0,stroke-width:2px
    linkStyle 3 stroke:#f00,stroke-width:2px

    click ESP32_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/esp32_wroom32_sender.cpp"
    click ESP32_RECEIVER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/esp32_wroom32_receiver.cpp"
    click HELTEC_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/heltec_wifi_lora_v3_sender.cpp"
    click HELTEC_RECEIVER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/heltec_wifi_lora_v3_receiver.cpp"
    click RPI5_RECEIVER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/rpi_5_receiver.py"
    click RPI_PICO_MP_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/rpi_pico_micropython_sender.py"
    click RPI_PICO_SDK_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/rpi_pico_pico_sdk_sender.cpp"
    click UBUNTU_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/ubuntu_file_sender.cpp"
    click UBUNTU_RECEIVER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/ubuntu_file_receiver.cpp"
    click WIN11_BIN_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/win11_binary_sender.py"
    click WIN11_BIN_RECEIVER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/win11_binary_receiver.py"
    click WIN11_FILE_SENDER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/win11_file_sender.py"
    click WIN11_FILE_RECEIVER "https://github.com/cyberhorizonltd/4wire/blob/main/sources/win11_file_receiver.py"

    classDef sender fill:#e0ffe0,stroke:#00aa00
    classDef receiver fill:#ffe0e0,stroke:#aa0000
    classDef platform fill:#f8f8f8,stroke:#333333,stroke-dasharray: 2 2
```
