# eclipse-zenoh/zenoh-pico architecture

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

- Interactive diagram: https://gitdiagram.com/eclipse-zenoh/zenoh-pico
- Repository: https://github.com/eclipse-zenoh/zenoh-pico

## Overview

Zenoh-Pico is a native C implementation of Zenoh for constrained devices. Applications open a session, declare publishers, subscribers, queryables or liveliness entities, then publish samples or issue queries; matching data and replies are delivered through session and transport layers to local or remote peers. The principal stages are API/session setup, data and query operations, protocol encoding, transport, and platform links. The README also describes storage/query and compute capabilities, but the excerpts do not establish a separate storage engine. Some subsystem links below reflect module responsibilities and documented capabilities; unsampled call wiring is not inferred.

Main entry points: [`src/link/link.c`](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/link.c) (Link selection), [`src/transport/manager.c`](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/manager.c) (Transport setup), [`src/net/query.c`](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/net/query.c) (Query and reply), [`src/transport/unicast.c`](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/unicast.c) (Unicast transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Application API"]
  node_api_entry["C API<br/>[api.c]"]
  node_publish_api["Publish and subscribe"]
  node_query_api["Query and reply<br/>[query.c]"]
  node_admin["Admin and liveliness<br/>[admin_space.c]"]
end

subgraph group_session["Session operations"]
  node_session["Session state<br/>[session.c]"]
  node_pubsub["Subscriptions and samples<br/>[subscription.c]"]
  node_query_session["Query tracking<br/>[query.c]"]
  node_queryables["Queryable matching<br/>[queryable.c]"]
  node_keyexpr["Key expressions<br/>[keyexpr.c]"]
  node_liveliness["Liveliness<br/>[liveliness.c]"]
  node_loopback["Local delivery<br/>[loopback.c]"]
end

subgraph group_wire["Protocol and transport"]
  node_codec["Wire codec<br/>[codec.c]"]
  node_protocol["Protocol messages<br/>[message.c]"]
  node_transport_manager["Transport setup<br/>[manager.c]"]
  node_unicast["Unicast transport<br/>[unicast.c]"]
  node_multicast["Multicast transport<br/>[multicast.c]"]
end

subgraph group_platform["Platform links"]
  node_link_manager["Link selection<br/>[link.c]"]
  node_link_tcp["TCP links<br/>[tcp.c]"]
  node_link_udp["UDP links<br/>[udp.c]"]
  node_link_serial["Serial links<br/>[serial.c]"]
  node_link_ws["WebSocket links<br/>[ws.c]"]
  node_system["Platform networking<br/>[platform.c]"]
end

node_application(("Application"))
node_peer(("Zenoh peers"))

node_application -->|"calls"| node_api_entry
node_api_entry -->|"opens session"| node_session
node_application -->|"publishes data"| node_publish_api
node_application -->|"issues queries"| node_query_api
node_application -->|"manages entities"| node_admin
node_query_api -->|"delivers locally"| node_loopback
node_query_api -->|"tracks replies"| node_query_session
node_pubsub -->|"matches keys"| node_keyexpr
node_queryables -->|"matches keys"| node_keyexpr
node_session -->|"opens transport"| node_transport_manager
node_transport_manager -->|"creates"| node_unicast
node_transport_manager -->|"creates"| node_multicast
node_unicast -->|"encodes messages"| node_codec
node_multicast -->|"encodes messages"| node_codec
node_codec -->|"serializes"| node_protocol
node_transport_manager -->|"selects link"| node_link_manager
node_link_manager -->|"opens TCP"| node_link_tcp
node_link_manager -->|"opens UDP"| node_link_udp
node_link_manager -->|"opens serial"| node_link_serial
node_link_manager -->|"opens WebSocket"| node_link_ws
node_link_tcp -->|"uses platform networking"| node_system
node_link_udp -->|"uses platform networking"| node_system
node_unicast -->|"exchanges messages"| node_peer
node_multicast -->|"exchanges messages"| node_peer
node_liveliness -->|"uses session"| node_session

click node_api_entry "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/api/api.c"
click node_query_api "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/net/query.c"
click node_admin "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/api/admin_space.c"
click node_session "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/net/session.c"
click node_pubsub "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/subscription.c"
click node_query_session "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/query.c"
click node_queryables "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/queryable.c"
click node_keyexpr "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/keyexpr.c"
click node_liveliness "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/liveliness.c"
click node_loopback "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/loopback.c"
click node_codec "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/protocol/codec.c"
click node_protocol "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/protocol/definitions/message.c"
click node_transport_manager "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/manager.c"
click node_unicast "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/unicast.c"
click node_multicast "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/multicast.c"
click node_link_manager "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/link.c"
click node_link_tcp "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/tcp.c"
click node_link_udp "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/udp.c"
click node_link_serial "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/serial.c"
click node_link_ws "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/ws.c"
click node_system "https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/system/common/platform.c"

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_api_entry,node_publish_api,node_query_api,node_admin toneBlue
class node_session,node_pubsub,node_query_session,node_queryables,node_keyexpr,node_liveliness,node_loopback toneAmber
class node_codec,node_protocol,node_transport_manager,node_unicast,node_multicast toneMint
class node_link_manager,node_link_tcp,node_link_udp,node_link_serial,node_link_ws,node_system toneRose
class node_application,node_peer toneIndigo
```

## Components

### Application API

- [C API](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/api/api.c): `src/api/api.c`
- **Publish and subscribe**
- [Query and reply](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/net/query.c): `src/net/query.c`
- [Admin and liveliness](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/api/admin_space.c): `src/api/admin_space.c`

### Session operations

- [Session state](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/net/session.c): `src/net/session.c`
- [Subscriptions and samples](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/subscription.c): `src/session/subscription.c`
- [Query tracking](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/query.c): `src/session/query.c`
- [Queryable matching](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/queryable.c): `src/session/queryable.c`
- [Key expressions](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/keyexpr.c): `src/session/keyexpr.c`
- [Liveliness](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/liveliness.c): `src/session/liveliness.c`
- [Local delivery](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/session/loopback.c): `src/session/loopback.c`

### Protocol and transport

- [Wire codec](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/protocol/codec.c): `src/protocol/codec.c`
- [Protocol messages](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/protocol/definitions/message.c): `src/protocol/definitions/message.c`
- [Transport setup](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/manager.c): `src/transport/manager.c`
- [Unicast transport](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/unicast.c): `src/transport/unicast.c`
- [Multicast transport](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/transport/multicast.c): `src/transport/multicast.c`

### Platform links

- [Link selection](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/link.c): `src/link/link.c`
- [TCP links](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/tcp.c): `src/link/unicast/tcp.c`
- [UDP links](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/udp.c): `src/link/unicast/udp.c`
- [Serial links](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/serial.c): `src/link/unicast/serial.c`
- [WebSocket links](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/link/unicast/ws.c): `src/link/unicast/ws.c`
- [Platform networking](https://github.com/eclipse-zenoh/zenoh-pico/blob/main/src/system/common/platform.c): `src/system/common/platform.c`

### Other components

- **Application**
- **Zenoh peers**

## Connections

- Application → C API: calls
- C API → Session state: opens session
- Application → Publish and subscribe: publishes data
- Application → Query and reply: issues queries
- Application → Admin and liveliness: manages entities
- Query and reply → Local delivery: delivers locally
- Query and reply → Query tracking: tracks replies
- Subscriptions and samples → Key expressions: matches keys
- Queryable matching → Key expressions: matches keys
- Session state → Transport setup: opens transport
- Transport setup → Unicast transport: creates
- Transport setup → Multicast transport: creates
- Unicast transport → Wire codec: encodes messages
- Multicast transport → Wire codec: encodes messages
- Wire codec → Protocol messages: serializes
- Transport setup → Link selection: selects link
- Link selection → TCP links: opens TCP
- Link selection → UDP links: opens UDP
- Link selection → Serial links: opens serial
- Link selection → WebSocket links: opens WebSocket
- TCP links → Platform networking: uses platform networking
- UDP links → Platform networking: uses platform networking
- Unicast transport → Zenoh peers: exchanges messages
- Multicast transport → Zenoh peers: exchanges messages
- Liveliness → Session state: uses session
