# kguibene/natscpp architecture

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

- Interactive diagram: https://gitdiagram.com/kguibene/natscpp
- Repository: https://github.com/kguibene/natscpp

## Overview

natspp is a small embeddable C++ NATS client. An application connects through the client API; the runtime performs the INFO/CONNECT handshake, sends publish and subscription commands, dispatches received messages to handlers, and can block until stopped. The README also describes a demo that exercises these operations. The graph focuses on the library’s runtime; the demo is omitted as an example application. The source excerpts show socket and dispatch behavior, but do not establish broader NATS-server capabilities such as TLS or authentication.

Main entry points: [`src/nats.cpp`](https://github.com/kguibene/natscpp/blob/main/src/nats.cpp) (Client Runtime), [`include/nats.hpp`](https://github.com/kguibene/natscpp/blob/main/include/nats.hpp) (Client API)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_application(("Application"))
node_client_api["Client API<br/>[nats.hpp]"]
node_client_runtime["Client Runtime<br/>[nats.cpp]"]
node_nats_server[("NATS Server")]

node_application -->|"calls"| node_client_api
node_client_api -->|"implemented by"| node_client_runtime
node_client_runtime -->|"sends protocol commands"| node_nats_server
node_nats_server -->|"sends protocol messages"| node_client_runtime
node_client_runtime -->|"dispatches callbacks"| node_application

click node_client_api "https://github.com/kguibene/natscpp/blob/main/include/nats.hpp"
click node_client_runtime "https://github.com/kguibene/natscpp/blob/main/src/nats.cpp"

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_application toneIndigo
class node_client_api,node_client_runtime toneBlue
class node_nats_server toneAmber
```

## Components

### Other components

- **Application**
- [Client API](https://github.com/kguibene/natscpp/blob/main/include/nats.hpp): `include/nats.hpp`
- [Client Runtime](https://github.com/kguibene/natscpp/blob/main/src/nats.cpp): `src/nats.cpp`
- **NATS Server**

## Connections

- Application → Client API: calls
- Client API → Client Runtime: implemented by (evidence: `src/nats.cpp`)
- Client Runtime → NATS Server: sends protocol commands (evidence: `src/nats.cpp`)
- NATS Server → Client Runtime: sends protocol messages (evidence: `src/nats.cpp`)
- Client Runtime → Application: dispatches callbacks (evidence: `src/nats.cpp`)
