# benoitpralong/tpnodered architecture

> Architecture diagram of the GitHub repository benoitpralong/tpnodered, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benoitpralong/tpnodered
- Repository: https://github.com/benoitpralong/tpnodered

## Overview

This repository defines a Docker-based industrial/IoT stack. Its principal workflow sends UTF-8 messages through Kafka and Node-RED into PostgreSQL, while Node-RED also reads the OPC UA `CAB` tag into TimescaleDB and writes a random value to `Direction`. Separate branches provide Kafka administration and log observability. Relationships are based on the README; aside from the OPC UA server, implementation excerpts were not provided, so internal details of those services are not inferred.

Main entry points: [`nodered/flows.json`](https://github.com/benoitpralong/tpnodered/blob/main/nodered/flows.json) (Node-RED flows), [`docker-compose.yml`](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml) (Kafka broker), [`opcua-server/server.py`](https://github.com/benoitpralong/tpnodered/blob/main/opcua-server/server.py) (OPC UA server), [`observability/alloy-config.alloy`](https://github.com/benoitpralong/tpnodered/blob/main/observability/alloy-config.alloy) (Alloy collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Integration workflow"]
  node_kafka["Kafka broker<br/>[docker-compose.yml]"]
  node_nodered["Node-RED flows<br/>[flows.json]"]
end

subgraph group_data["Data services"]
  node_postgres[("PostgreSQL<br/>[docker-compose.yml]")]
  node_postgres_schema["PostgreSQL schema"]
  node_timescaledb[("TimescaleDB<br/>[docker-compose.yml]")]
  node_timescale_schema["Timescale schema"]
end

subgraph group_industrial["Industrial interface"]
  node_opcua["OPC UA server<br/>[server.py]"]
end

subgraph group_observability["Observability"]
  node_alloy["Alloy collector<br/>[alloy-config.alloy]"]
  node_loki[("Loki log store<br/>[loki-config.yml]")]
  node_grafana["Grafana dashboards"]
  node_grafana_loki_source["Loki datasource<br/>[loki.yml]"]
end

subgraph group_admin["Administration"]
  node_schema_registry["Schema Registry<br/>[docker-compose.yml]"]
  node_akhq["AKHQ console<br/>[docker-compose.yml]"]
  node_pgadmin["pgAdmin<br/>[docker-compose.yml]"]
end

node_producer(("Message producer"))

node_producer -->|"sends messages"| node_kafka
node_kafka -->|"provides messages"| node_nodered
node_nodered -->|"inserts text"| node_postgres
node_nodered -->|"reads CAB; writes Direction"| node_opcua
node_nodered -->|"stores sample"| node_timescaledb
node_postgres_schema -->|"initializes schema"| node_postgres
node_timescale_schema -->|"initializes schema"| node_timescaledb
node_opcua -->|"emits logs"| node_alloy
node_alloy -->|"forwards logs"| node_loki
node_grafana -->|"provisions datasource"| node_grafana_loki_source
node_grafana_loki_source -->|"queries logs"| node_loki

click node_kafka "https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml"
click node_nodered "https://github.com/benoitpralong/tpnodered/blob/main/nodered/flows.json"
click node_postgres "https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml"
click node_postgres_schema "https://github.com/benoitpralong/tpnodered/blob/main/postgres-init/001-timescaledb.sql"
click node_timescaledb "https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml"
click node_timescale_schema "https://github.com/benoitpralong/tpnodered/blob/main/timescaledb-init/001-timescaledb.sql"
click node_opcua "https://github.com/benoitpralong/tpnodered/blob/main/opcua-server/server.py"
click node_alloy "https://github.com/benoitpralong/tpnodered/blob/main/observability/alloy-config.alloy"
click node_loki "https://github.com/benoitpralong/tpnodered/blob/main/observability/loki-config.yml"
click node_grafana "https://github.com/benoitpralong/tpnodered/tree/main/observability/grafana/provisioning/dashboards"
click node_grafana_loki_source "https://github.com/benoitpralong/tpnodered/blob/main/observability/grafana/provisioning/datasources/loki.yml"
click node_schema_registry "https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml"
click node_akhq "https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml"
click node_pgadmin "https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml"

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_kafka,node_nodered toneBlue
class node_postgres,node_postgres_schema,node_timescaledb,node_timescale_schema toneAmber
class node_opcua toneMint
class node_alloy,node_loki,node_grafana,node_grafana_loki_source toneRose
class node_schema_registry,node_akhq,node_pgadmin,node_producer toneIndigo
```

## Components

### Integration workflow

- [Kafka broker](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml): `docker-compose.yml`
- [Node-RED flows](https://github.com/benoitpralong/tpnodered/blob/main/nodered/flows.json): `nodered/flows.json`

### Data services

- [PostgreSQL](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml): `docker-compose.yml`
- [PostgreSQL schema](https://github.com/benoitpralong/tpnodered/blob/main/postgres-init/001-timescaledb.sql): `postgres-init/001-timescaledb.sql`
- [TimescaleDB](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml): `docker-compose.yml`
- [Timescale schema](https://github.com/benoitpralong/tpnodered/blob/main/timescaledb-init/001-timescaledb.sql): `timescaledb-init/001-timescaledb.sql`

### Industrial interface

- [OPC UA server](https://github.com/benoitpralong/tpnodered/blob/main/opcua-server/server.py): `opcua-server/server.py`

### Observability

- [Alloy collector](https://github.com/benoitpralong/tpnodered/blob/main/observability/alloy-config.alloy): `observability/alloy-config.alloy`
- [Loki log store](https://github.com/benoitpralong/tpnodered/blob/main/observability/loki-config.yml): `observability/loki-config.yml`
- [Grafana dashboards](https://github.com/benoitpralong/tpnodered/tree/main/observability/grafana/provisioning/dashboards): `observability/grafana/provisioning/dashboards`
- [Loki datasource](https://github.com/benoitpralong/tpnodered/blob/main/observability/grafana/provisioning/datasources/loki.yml): `observability/grafana/provisioning/datasources/loki.yml`

### Administration

- [Schema Registry](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml): `docker-compose.yml`
- [AKHQ console](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml): `docker-compose.yml`
- [pgAdmin](https://github.com/benoitpralong/tpnodered/blob/main/docker-compose.yml): `docker-compose.yml`

### Other components

- **Message producer**

## Connections

- Message producer → Kafka broker: sends messages (evidence: `readme.md`)
- Kafka broker → Node-RED flows: provides messages (evidence: `readme.md`)
- Node-RED flows → PostgreSQL: inserts text (evidence: `readme.md`)
- Node-RED flows → OPC UA server: reads CAB; writes Direction (evidence: `readme.md`)
- Node-RED flows → TimescaleDB: stores sample (evidence: `readme.md`)
- PostgreSQL schema → PostgreSQL: initializes schema (evidence: `readme.md`)
- Timescale schema → TimescaleDB: initializes schema (evidence: `readme.md`)
- OPC UA server → Alloy collector: emits logs (evidence: `readme.md`)
- Alloy collector → Loki log store: forwards logs (evidence: `readme.md`)
- Grafana dashboards → Loki datasource: provisions datasource (evidence: `readme.md`)
- Loki datasource → Loki log store: queries logs (evidence: `readme.md`)
