# realtimelogic/opc-ua-examples architecture

> Architecture diagram of the GitHub repository realtimelogic/opc-ua-examples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/realtimelogic/opc-ua-examples
- Repository: https://github.com/realtimelogic/opc-ua-examples

## Overview

1. This repository is a set of self-contained OPC UA example deployments for Real Time Logic’s OPC-UA stack, intended to run on the Mako Server runtime. The architectural unit is usually a single example directory started with `mako -l::Directory-Name`.

2. The repo is split into three primary domains: server examples under `servers/`, client examples under `client/`, and embedded/device examples under `esp32/`. That separation is the main architectural boundary: each domain demonstrates a different role in the OPC UA ecosystem.

3. The server-side examples are mostly Lua-based OPC UA servers. Files such as `servers/*/opcua_server.lua` and `servers/*/opcua_server.lsp` define the server behavior, while `.preload` markers indicate Mako-managed startup hooks and module loading. These examples cover data exposure, node creation, browsing, reading/writing, and server configuration.

4. Several server examples include an embedded web UI. In those cases, `index.html`, `ua_server.js`, and `vue.js` sit beside the OPC UA server logic, showing a two-tier model: browser UI on top, OPC UA endpoint underneath. The `embed_web_server` and `server_http` / `server_basic128rsa15` examples illustrate this integration.

5. Security is a distinct architectural concern in the server examples. The presence of `.pem` and `.key` files, along with example names like `basic128rsa15`, indicates secured OPC UA endpoints using certificates and encrypted channels. There is also a `server_config` example that likely focuses on runtime configuration rather than application logic.

6. The client side demonstrates OPC UA consumers rather than providers. `client/auth_username` and `client/auth_x509` show different authentication paths against OPC UA servers, while `client/start` contains the entry script for a browser-synchronized or interactive client flow. The inclusion of certificates in `auth_x509` reinforces the security/authentication boundary.

7. The ESP32 examples represent the hardware/device edge. `esp32/1wire` contains Lua modules for 1-wire sensor access, DS18B20 temperature reading, MQTT publishing, and an OPC UA server bridge. This is the clearest end-to-end data pipeline in the repo: physical sensor → Lua driver → MQTT publish / OPC UA exposure.

8. `esp32/ignition` is a separate embedded control example built around an LED and button. Its assets and `opc-led-button-server.xlua` suggest a hardware control loop where the microcontroller exposes or reacts to OPC UA variables/events tied to local GPIO state.

9. The data flow patterns are intentionally simple and repetitive across examples: device state or application variables are made available through OPC UA nodes; clients browse/read/write those nodes; optional web UIs render or control the same state through JavaScript calling into the server layer. This makes the repo useful for understanding OPC UA from both producer and consumer perspectives.

10. The repo relies on the Mako Server plugin model rather than a standalone application framework. That runtime choice matters architecturally because each example is packaged as a deployable directory with startup hooks, static assets, Lua logic, and optional certificates all co-located.

11. At the root, `index.lsp` and `local_server.lua` act as top-level helpers or entry points for local/demo execution. They are not the main application boundary so much as convenience scaffolding around the example directories.

12. For diagramming, the key boxes are: Mako Server runtime, OPC UA server examples, OPC UA client examples, browser/web UI examples, ESP32 device examples, and external dependencies such as certificates, MQTT, and physical sensors/buttons. The important arrows are server/client OPC UA sessions, browser-to-server HTTP/JS interaction, and hardware-to-server data acquisition/control.

Main entry points: [`servers/start/start_server.lua`](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/start/start_server.lua) (Server start), [`esp32/1wire/.lua/opcua_server_mqtt.lua`](https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/opcua_server_mqtt.lua) (1-wire), [`servers/server_basic128rsa15/opcua_server.lsp`](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_basic128rsa15/opcua_server.lsp) (Secure server), [`servers/embed_web_server/opcua_server.lsp`](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/embed_web_server/opcua_server.lsp) (Embedded web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_mako_server["Mako Server<br/>runtime"]
  node_root_entry["Root entry<br/>demo entry<br/>[index.lsp]"]
  node_local_helper["Local helper<br/>demo launcher<br/>[local_server.lua]"]
end

subgraph group_servers["Server examples"]
  node_server_start["Server start<br/>launcher<br/>[start_server.lua]"]
  node_server_nodes["Add nodes<br/>opcua server<br/>[opcua_server.lua]"]
  node_server_browse["Browse<br/>opcua server<br/>[opcua_server.lua]"]
  node_server_data["Data source<br/>opcua server<br/>[opcua_server.lua]"]
  node_server_read["Read data<br/>opcua server<br/>[opcua_server.lua]"]
  node_server_write["Write data<br/>opcua server<br/>[opcua_server.lua]"]
  node_server_config["Server config<br/>config demo<br/>[opcua_server.lua]"]
  node_embed_web["Embedded web UI<br/>hybrid server<br/>[opcua_server.lsp]"]
  node_secure_server["Secure server<br/>secured server<br/>[opcua_server.lsp]"]
  node_http_server["HTTP server<br/>web server<br/>[opcua_server.lsp]"]
end

subgraph group_client["Client examples"]
  node_client_start["Client start<br/>launcher"]
  node_client_user["Username auth<br/>opcua client<br/>[auth_username.lua]"]
  node_client_x509["X509 auth<br/>opcua client<br/>[auth_x509.lua]"]
end

subgraph group_esp32["ESP32 examples"]
  node_esp1wire["1-wire<br/>device bridge"]
  node_esp_ignition["Ignition<br/>gpio control"]
  node_sensor_hw{{"Sensors<br/>hardware<br/>[ds18b20.lua]"}}
  node_gpio_hw{{"LED & button<br/>hardware"}}
  node_mqtt_bus(("MQTT<br/>message bus<br/>[mqtt_publish.lua]"))
end

node_mako_server -->|"hosts"| node_root_entry
node_mako_server -->|"hosts"| node_local_helper
node_mako_server -->|"launches"| node_server_start
node_mako_server -->|"launches"| node_client_start
node_mako_server -->|"launches"| node_esp1wire
node_mako_server -->|"launches"| node_esp_ignition
node_server_start -->|"example"| node_server_nodes
node_server_start -->|"example"| node_server_browse
node_server_start -->|"example"| node_server_data
node_server_start -->|"example"| node_server_read
node_server_start -->|"example"| node_server_write
node_server_start -->|"example"| node_server_config
node_server_start -->|"example"| node_embed_web
node_server_start -->|"example"| node_secure_server
node_server_start -->|"example"| node_http_server
node_embed_web -.->|"shares UI pattern"| node_secure_server
node_http_server -.->|"shares UI pattern"| node_secure_server
node_client_start -->|"auth flow"| node_client_user
node_client_start -->|"auth flow"| node_client_x509
node_client_user -.->|"connects to"| node_server_nodes
node_client_x509 -.->|"connects to"| node_secure_server
node_esp1wire -->|"reads"| node_sensor_hw
node_esp1wire -->|"publishes"| node_mqtt_bus
node_esp1wire -.->|"exposes"| node_server_data
node_esp_ignition -->|"controls"| node_gpio_hw
node_server_data -.->|"served by"| node_client_user
node_embed_web -.->|"browser sync"| node_root_entry

click node_root_entry "https://github.com/realtimelogic/opc-ua-examples/blob/master/index.lsp"
click node_local_helper "https://github.com/realtimelogic/opc-ua-examples/blob/master/local_server.lua"
click node_server_start "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/start/start_server.lua"
click node_server_nodes "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/add_nodes/opcua_server.lua"
click node_server_browse "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/browse/opcua_server.lua"
click node_server_data "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/data_source/opcua_server.lua"
click node_server_read "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/read_data/opcua_server.lua"
click node_server_write "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/write_data/opcua_server.lua"
click node_server_config "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_config/opcua_server.lua"
click node_embed_web "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/embed_web_server/opcua_server.lsp"
click node_secure_server "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_basic128rsa15/opcua_server.lsp"
click node_http_server "https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_http/opcua_server.lsp"
click node_client_start "https://github.com/realtimelogic/opc-ua-examples/blob/master/client/start/start_broswing_sync.lua"
click node_client_user "https://github.com/realtimelogic/opc-ua-examples/blob/master/client/auth_username/auth_username.lua"
click node_client_x509 "https://github.com/realtimelogic/opc-ua-examples/blob/master/client/auth_x509/auth_x509.lua"
click node_esp1wire "https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/opcua_server_mqtt.lua"
click node_esp_ignition "https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/ignition/opc-led-button-server.xlua"
click node_sensor_hw "https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/ds18b20.lua"
click node_gpio_hw "https://github.com/realtimelogic/opc-ua-examples/tree/master/esp32/ignition/ignition-led-and-button-images"
click node_mqtt_bus "https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/mqtt_publish.lua"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mako_server,node_root_entry,node_local_helper toneBlue
class node_server_start,node_server_nodes,node_server_browse,node_server_data,node_server_read,node_server_write,node_server_config,node_embed_web,node_secure_server,node_http_server toneAmber
class node_client_start,node_client_user,node_client_x509 toneMint
class node_esp1wire,node_esp_ignition,node_sensor_hw,node_gpio_hw,node_mqtt_bus toneRose
```

## Components

### Runtime

Mako Server packaging and shared demo entry points

- **Mako Server**: runtime · Directory-based runtime for launching each example
- [Root entry](https://github.com/realtimelogic/opc-ua-examples/blob/master/index.lsp): demo entry · Top-level local/demo helpers · `index.lsp`
- [Local helper](https://github.com/realtimelogic/opc-ua-examples/blob/master/local_server.lua): demo launcher · Convenience local server script · `local_server.lua`

### Server examples

OPC UA provider examples and server-side UI integrations

- [Server start](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/start/start_server.lua): launcher · Entry point for server example directories · `servers/start/start_server.lua`
- [Add nodes](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/add_nodes/opcua_server.lua): opcua server · Server example focused on node creation · `servers/add_nodes/opcua_server.lua`
- [Browse](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/browse/opcua_server.lua): opcua server · Server example for browsing the address space · `servers/browse/opcua_server.lua`
- [Data source](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/data_source/opcua_server.lua): opcua server · Server example exposing dynamic data · `servers/data_source/opcua_server.lua`
- [Read data](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/read_data/opcua_server.lua): opcua server · Server example centered on read access · `servers/read_data/opcua_server.lua`
- [Write data](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/write_data/opcua_server.lua): opcua server · Server example centered on write access · `servers/write_data/opcua_server.lua`
- [Server config](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_config/opcua_server.lua): config demo · Server example focused on runtime configuration · `servers/server_config/opcua_server.lua`
- [Embedded web UI](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/embed_web_server/opcua_server.lsp): hybrid server · OPC UA server paired with browser UI · `servers/embed_web_server/opcua_server.lsp`
- [Secure server](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_basic128rsa15/opcua_server.lsp): secured server · OPC UA server with basic128rsa15 security and web UI · `servers/server_basic128rsa15/opcua_server.lsp`
- [HTTP server](https://github.com/realtimelogic/opc-ua-examples/blob/master/servers/server_http/opcua_server.lsp): web server · Browser UI example backed by OPC UA logic · `servers/server_http/opcua_server.lsp`

### Client examples

OPC UA consumer examples and authentication flows

- [Client start](https://github.com/realtimelogic/opc-ua-examples/blob/master/client/start/start_broswing_sync.lua): launcher · Entry point for interactive client flow · `client/start/start_broswing_sync.lua`
- [Username auth](https://github.com/realtimelogic/opc-ua-examples/blob/master/client/auth_username/auth_username.lua): opcua client · Client example using username authentication · `client/auth_username/auth_username.lua`
- [X509 auth](https://github.com/realtimelogic/opc-ua-examples/blob/master/client/auth_x509/auth_x509.lua): opcua client · Client example using certificate-based authentication · `client/auth_x509/auth_x509.lua`

### ESP32 examples

Embedded device and hardware-edge examples

- [1-wire](https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/opcua_server_mqtt.lua): device bridge · ESP32 sensor bridge with Lua modules and MQTT/OPC UA integration · `esp32/1wire/.lua/opcua_server_mqtt.lua`
- [Ignition](https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/ignition/opc-led-button-server.xlua): gpio control · ESP32 LED/button control example · `esp32/ignition/opc-led-button-server.xlua`
- [Sensors](https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/ds18b20.lua): hardware · 1-wire temperature sensor input · `esp32/1wire/.lua/ds18b20.lua`
- [LED & button](https://github.com/realtimelogic/opc-ua-examples/tree/master/esp32/ignition/ignition-led-and-button-images): hardware · Local GPIO control and input · `esp32/ignition/ignition-led-and-button-images`
- [MQTT](https://github.com/realtimelogic/opc-ua-examples/blob/master/esp32/1wire/.lua/mqtt_publish.lua): message bus · Optional publish path from device example · `esp32/1wire/.lua/mqtt_publish.lua`

## Connections

- Mako Server → Root entry: hosts · Runs top-level demo helpers
- Mako Server → Local helper: hosts · Runs local server helper
- Mako Server → Server start: launches · Starts server example directories
- Mako Server → Client start: launches · Starts client example directories
- Mako Server → 1-wire: launches · Runs embedded device example packages
- Mako Server → Ignition: launches · Runs embedded control example packages
- Server start → Add nodes: example · Server-side node creation demo
- Server start → Browse: example · Server-side browse demo
- Server start → Data source: example · Server-side data source demo
- Server start → Read data: example · Server-side read demo
- Server start → Write data: example · Server-side write demo
- Server start → Server config: example · Server configuration demo
- Server start → Embedded web UI: example · Hybrid OPC UA plus browser UI demo
- Server start → Secure server: example · Secured server demo
- Server start → HTTP server: example · HTTP and browser integration demo
- Embedded web UI → Secure server: shares UI pattern · Both combine OPC UA server logic with web assets
- HTTP server → Secure server: shares UI pattern · Both pair browser UI with server-side OPC UA logic
- Client start → Username auth: auth flow · Username/password client path
- Client start → X509 auth: auth flow · Certificate-based client path
- Username auth → Add nodes: connects to · Consumes OPC UA server endpoints
- X509 auth → Secure server: connects to · Consumes secured OPC UA endpoints
- 1-wire → Sensors: reads · Acquires temperature and sensor data
- 1-wire → MQTT: publishes · Sends device data over MQTT
- 1-wire → Data source: exposes · Bridges device data into OPC UA nodes
- Ignition → LED & button: controls · Maps OPC UA state to LED/button GPIO
- Data source → Username auth: served by · Data source example consumed by clients
- Embedded web UI → Root entry: browser sync · Web UI synchronized through server-side entry points
