# pangbit/moonpulsar architecture

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

- Interactive diagram: https://gitdiagram.com/pangbit/moonpulsar
- Repository: https://github.com/pangbit/moonpulsar
- Video tour (about a minute): https://gitdiagram.com/pangbit/moonpulsar/video

## Overview

moonpulsar is a native MoonBit Apache Pulsar binary-protocol client. An application connects through Client, creates a producer and consumer, sends a message, receives it, then acknowledges it. The library also exposes readers, administration, transactions, schemas, authentication, encryption, partitioned topics, and compression. The graph captures these documented capabilities and the protocol/connection layers indicated by the source tree; most implementation excerpts were not sampled, so internal wiring beyond the documented workflow is omitted.

Main entry points: [`client.mbt`](https://github.com/pangbit/moonpulsar/blob/main/client.mbt) (Client), [`producer.mbt`](https://github.com/pangbit/moonpulsar/blob/main/producer.mbt) (Producer), [`consumer.mbt`](https://github.com/pangbit/moonpulsar/blob/main/consumer.mbt) (Consumer), [`schema.mbt`](https://github.com/pangbit/moonpulsar/blob/main/schema.mbt) (Schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client API"]
  node_client["Client<br/>[client.mbt]"]
  node_options["Client Options<br/>[client_options.mbt]"]
end

subgraph group_messaging["Messaging"]
  node_producer["Producer<br/>[producer.mbt]"]
  node_consumer["Consumer<br/>[consumer.mbt]"]
  node_reader["Reader<br/>[reader.mbt]"]
  node_message["Message Model<br/>[message.mbt]"]
end

subgraph group_transport["Protocol Transport"]
  node_connection["Connection Manager"]
  node_connection_impl["Connection<br/>[connection.mbt]"]
  node_frame["Frame Codec<br/>[frame.mbt]"]
  node_protocol["Protocol Bindings<br/>[PulsarApi.proto]"]
  node_lookup["Topic Lookup<br/>[lookup.mbt]"]
end

subgraph group_capabilities["Extended Capabilities"]
  node_admin["Administration<br/>[admin.mbt]"]
  node_transactions["Transactions<br/>[transaction.mbt]"]
  node_schema["Schemas<br/>[schema.mbt]"]
  node_schema_codec["Schema Codecs<br/>[schema_codec.mbt]"]
  node_auth["Athenz Auth<br/>[athenz_zts.mbt]"]
  node_crypto["Message Encryption<br/>[message_crypto.mbt]"]
  node_compression["Compression<br/>[compression.mbt]"]
  node_telemetry["Telemetry<br/>[telemetry.mbt]"]
end

node_application(("Application"))
node_broker(("Pulsar Broker"))

node_application -->|"connects"| node_client
node_application -->|"configures"| node_client
node_client -->|"uses"| node_options
node_client -->|"creates"| node_producer
node_client -->|"creates"| node_consumer
node_client -->|"creates"| node_reader
node_client -->|"exposes"| node_admin
node_client -->|"connects"| node_broker
node_producer -->|"publishes"| node_broker
node_consumer -->|"receives and acknowledges"| node_broker
node_reader -->|"reads"| node_broker
node_connection -->|"manages"| node_connection_impl
node_connection_impl -->|"exchanges frames"| node_frame
node_frame -->|"encodes commands"| node_protocol
node_lookup -->|"resolves topics"| node_broker
node_producer -->|"sends"| node_message
node_consumer -->|"delivers"| node_message
node_producer -->|"supports"| node_schema
node_consumer -->|"supports"| node_schema
node_schema -->|"encodes and decodes"| node_schema_codec
node_producer -->|"supports"| node_compression
node_consumer -->|"supports"| node_compression
node_producer -->|"supports"| node_crypto
node_consumer -->|"supports"| node_crypto
node_client -->|"supports"| node_auth
node_client -->|"exposes"| node_transactions
node_client -->|"supports"| node_telemetry

click node_client "https://github.com/pangbit/moonpulsar/blob/main/client.mbt"
click node_options "https://github.com/pangbit/moonpulsar/blob/main/client_options.mbt"
click node_producer "https://github.com/pangbit/moonpulsar/blob/main/producer.mbt"
click node_consumer "https://github.com/pangbit/moonpulsar/blob/main/consumer.mbt"
click node_reader "https://github.com/pangbit/moonpulsar/blob/main/reader.mbt"
click node_message "https://github.com/pangbit/moonpulsar/blob/main/message.mbt"
click node_connection "https://github.com/pangbit/moonpulsar/blob/main/connection_manager.mbt"
click node_connection_impl "https://github.com/pangbit/moonpulsar/blob/main/connection.mbt"
click node_frame "https://github.com/pangbit/moonpulsar/blob/main/frame.mbt"
click node_protocol "https://github.com/pangbit/moonpulsar/blob/main/proto/PulsarApi.proto"
click node_lookup "https://github.com/pangbit/moonpulsar/blob/main/lookup.mbt"
click node_admin "https://github.com/pangbit/moonpulsar/blob/main/admin.mbt"
click node_transactions "https://github.com/pangbit/moonpulsar/blob/main/transaction.mbt"
click node_schema "https://github.com/pangbit/moonpulsar/blob/main/schema.mbt"
click node_schema_codec "https://github.com/pangbit/moonpulsar/blob/main/schema_codec.mbt"
click node_auth "https://github.com/pangbit/moonpulsar/blob/main/athenz_zts.mbt"
click node_crypto "https://github.com/pangbit/moonpulsar/blob/main/message_crypto.mbt"
click node_compression "https://github.com/pangbit/moonpulsar/blob/main/compression.mbt"
click node_telemetry "https://github.com/pangbit/moonpulsar/blob/main/telemetry.mbt"

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_client,node_options toneBlue
class node_producer,node_consumer,node_reader,node_message toneAmber
class node_connection,node_connection_impl,node_frame,node_protocol,node_lookup toneMint
class node_admin,node_transactions,node_schema,node_schema_codec,node_auth,node_crypto,node_compression,node_telemetry toneRose
class node_application,node_broker toneIndigo
```

## Components

### Client API

- [Client](https://github.com/pangbit/moonpulsar/blob/main/client.mbt): `client.mbt`
- [Client Options](https://github.com/pangbit/moonpulsar/blob/main/client_options.mbt): `client_options.mbt`

### Messaging

- [Producer](https://github.com/pangbit/moonpulsar/blob/main/producer.mbt): `producer.mbt`
- [Consumer](https://github.com/pangbit/moonpulsar/blob/main/consumer.mbt): `consumer.mbt`
- [Reader](https://github.com/pangbit/moonpulsar/blob/main/reader.mbt): `reader.mbt`
- [Message Model](https://github.com/pangbit/moonpulsar/blob/main/message.mbt): `message.mbt`

### Protocol Transport

- [Connection Manager](https://github.com/pangbit/moonpulsar/blob/main/connection_manager.mbt): `connection_manager.mbt`
- [Connection](https://github.com/pangbit/moonpulsar/blob/main/connection.mbt): `connection.mbt`
- [Frame Codec](https://github.com/pangbit/moonpulsar/blob/main/frame.mbt): `frame.mbt`
- [Protocol Bindings](https://github.com/pangbit/moonpulsar/blob/main/proto/PulsarApi.proto): `proto/PulsarApi.proto`
- [Topic Lookup](https://github.com/pangbit/moonpulsar/blob/main/lookup.mbt): `lookup.mbt`

### Extended Capabilities

- [Administration](https://github.com/pangbit/moonpulsar/blob/main/admin.mbt): `admin.mbt`
- [Transactions](https://github.com/pangbit/moonpulsar/blob/main/transaction.mbt): `transaction.mbt`
- [Schemas](https://github.com/pangbit/moonpulsar/blob/main/schema.mbt): `schema.mbt`
- [Schema Codecs](https://github.com/pangbit/moonpulsar/blob/main/schema_codec.mbt): `schema_codec.mbt`
- [Athenz Auth](https://github.com/pangbit/moonpulsar/blob/main/athenz_zts.mbt): `athenz_zts.mbt`
- [Message Encryption](https://github.com/pangbit/moonpulsar/blob/main/message_crypto.mbt): `message_crypto.mbt`
- [Compression](https://github.com/pangbit/moonpulsar/blob/main/compression.mbt): `compression.mbt`
- [Telemetry](https://github.com/pangbit/moonpulsar/blob/main/telemetry.mbt): `telemetry.mbt`

### Other components

- **Application**
- **Pulsar Broker**

## Connections

- Application → Client: connects
- Application → Client: configures
- Client → Client Options: uses
- Client → Producer: creates
- Client → Consumer: creates
- Client → Reader: creates
- Client → Administration: exposes
- Client → Pulsar Broker: connects
- Producer → Pulsar Broker: publishes
- Consumer → Pulsar Broker: receives and acknowledges
- Reader → Pulsar Broker: reads
- Connection Manager → Connection: manages
- Connection → Frame Codec: exchanges frames
- Frame Codec → Protocol Bindings: encodes commands
- Topic Lookup → Pulsar Broker: resolves topics
- Producer → Message Model: sends
- Consumer → Message Model: delivers
- Producer → Schemas: supports
- Consumer → Schemas: supports
- Schemas → Schema Codecs: encodes and decodes
- Producer → Compression: supports
- Consumer → Compression: supports
- Producer → Message Encryption: supports
- Consumer → Message Encryption: supports
- Client → Athenz Auth: supports
- Client → Transactions: exposes
- Client → Telemetry: supports
