# gblach/hexgateway architecture

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

- Interactive diagram: https://gitdiagram.com/gblach/hexgateway
- Repository: https://github.com/gblach/hexgateway

## Overview

##### Project type and purpose
- This is a hardware-centric gateway board (“HexGateway”) combining three network-capable chips (nRF52840, ESP32-C3, ENC28J60) into a single PCB design.
- Purpose: receive Bluetooth LE / OpenThread / Zigbee on the nRF52840, WiFi on the ESP32-C3, and Ethernet on the ENC28J60, and forward traffic between them (e.g., BLE → WiFi/Ethernet).

##### File structure
- Top level:
- KiCad project files (`HexGateway.kicad_sch`, `.kicad_pcb`, `sym-lib-table`, `fp-lib-table`, component libraries and 3D models under `.pretty` and `.models`).
- `boards/arm/hexgw1`: Zephyr board definition (CMakeLists.txt, Kconfig, DTS, pin-control, defconfig).
- You also have CSV BOM, Gerber ZIP, footprint libraries, and device programming connector schematics.

##### Extract insights from README
- Hardware modules U1 (nRF52840), U101 (ESP32-C3), U201 (ENC28J60).
- Programmers and connectors: Segger J-Link on J1/J2 for nRF52840, ESP-Prog on J101/J102 for ESP32-C3.
- Software stack: nRF52840 runs user code on Zephyr RTOS (custom board in `boards/arm/hexgw1`), ESP32-C3 runs AT firmware, ENC28J60 is controlled via SPI by nRF52840 or ESP32-C3 (depending on design).

##### Elements
- Clear labels: “nRF52840 + Zephyr”, “ESP32-C3 + ESP-AT”, “ENC28J60”, “Power Regulator”, “RJ45”, “Antennas”, “Programmer Headers”
- Data flows between MCUs and controllers (SPI/UART lines)
- External network flows in/out of antennas/ethernet port
- Programming flows into MCUs
- Firmware/software blocks in another (e.g., green)

1. Power & ground bus at the center bottom.
2. Three rectangular blocks above it: nRF52840 on left, ESP32-C3 center, ENC28J60 right.
6. Block with firmware: “Zephyr RTOS + your application” on nRF52840, “ESP-AT firmware” on ESP32-C3, “SPI Ethernet Controller” on ENC28J60.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Interfaces
    subgraph "External Interfaces"
        BLE["BLE/Thread/Zigbee"]:::external
        WiFiCloud["WiFi Cloud"]:::external
        EthLAN["Ethernet LAN"]:::external
    end

    %% Board Outline
    subgraph "HexGateway Board (KiCad project)"
        direction TB
        %% Hardware Modules
        subgraph "Hardware Modules"
            direction TB
            NRF["nRF52840 + Zephyr"]:::hw
            ESPMCU["ESP32-C3 + ESP-AT"]:::hw
            ENC["ENC28J60 (SPI Ethernet Controller)"]:::hw
        end

        %% Connectors and Antennas
        subgraph "Connectors / Antennas / Programmers"
            direction TB
            ANT_RF["Antenna Ports (BLE/Zigbee, WiFi)"]:::hw
            RJ45["RJ45 MagJack + Transformer"]:::hw
            Prog1["Prog Headers J1/J2"]:::hw
            Prog2["Prog Headers J101/J102"]:::hw
        end

        %% Software / Firmware
        subgraph "Software & Firmware"
            direction TB
            ZephyrBSP["Zephyr BSP: boards/arm/hexgw1/"]:::sw
        end

        %% KiCad Project Files
        subgraph "KiCad Project Files"
            direction TB
            SCH["HexGateway.kicad_sch"]:::doc
            PCB["HexGateway.kicad_pcb"]:::doc
            SYM["sym-lib-table"]:::doc
            FP["fp-lib-table"]:::doc
            BOM["HexGateway.csv"]:::doc
            GERB["HexGateway.zip"]:::doc
        end

        %% Footprint Libraries
        subgraph "Footprint Libraries (.pretty)"
            direction TB
            CrystalsPr["Crystals.pretty"]:::doc
            ESP32Pr["ESP32-C3.pretty"]:::doc
            RJ45Pr["RJ45_Hanrun_HR911105A.pretty"]:::doc
            SMAPr["SMA_EdgeMount.pretty"]:::doc
        end

        %% 3D Model Libraries
        subgraph "3D Model Libraries (.models)"
            direction TB
            RJ45Mo["RJ45_Hanrun_HR911105A.models"]:::doc
            SMAMo["SMA_EdgeMount.models"]:::doc
        end
    end

    %% Connections between External Interfaces and Modules
    BLE --> NRF
    WiFiCloud --> ESPMCU
    EthLAN --> RJ45 --> ENC

    %% Internal Buses and Signals
    NRF -->|"SPI bus"| ENC
    NRF -->|"UART/SPI"| ESPMCU
    NRF --> ANT_RF
    ESPMCU --> ANT_RF

    %% Power Rails
    Power["3.3V & GND Rail"]:::hw
    Power --> NRF
    Power --> ESPMCU
    Power --> ENC

    %% Programmers
    Prog1 --> NRF
    Prog2 --> ESPMCU

    %% Software Links
    NRF --> ZephyrBSP

    %% Click Events
    click SCH "https://github.com/gblach/hexgateway/blob/main/HexGateway.kicad_sch"
    click PCB "https://github.com/gblach/hexgateway/blob/main/HexGateway.kicad_pcb"
    click SYM "https://github.com/gblach/hexgateway/tree/main/sym-lib-table"
    click FP "https://github.com/gblach/hexgateway/tree/main/fp-lib-table"
    click BOM "https://github.com/gblach/hexgateway/blob/main/HexGateway.csv"
    click GERB "https://github.com/gblach/hexgateway/blob/main/HexGateway.zip"
    click CrystalsPr "https://github.com/gblach/hexgateway/blob/main/Crystals.pretty"
    click ESP32Pr "https://github.com/gblach/hexgateway/blob/main/ESP32-C3.pretty"
    click RJ45Pr "https://github.com/gblach/hexgateway/blob/main/RJ45_Hanrun_HR911105A.pretty"
    click SMAPr "https://github.com/gblach/hexgateway/blob/main/SMA_EdgeMount.pretty"
    click RJ45Mo "https://github.com/gblach/hexgateway/blob/main/RJ45_Hanrun_HR911105A.models"
    click SMAMo "https://github.com/gblach/hexgateway/blob/main/SMA_EdgeMount.models"
    click ZephyrBSP "https://github.com/gblach/hexgateway/tree/main/boards/arm/hexgw1/"

    %% Styles
    classDef hw fill:#D0E5FF,stroke:#3B7DDD,color:#000;
    classDef sw fill:#DFFFD0,stroke:#7DBD3B,color:#000;
    classDef external fill:#FFD0D0,stroke:#DD3B3B,color:#000;
    classDef doc fill:#F0F0F0,stroke:#AAAAAA,color:#000;
```
