# newrelic/nri-rabbitmq architecture

> Architecture diagram of the GitHub repository newrelic/nri-rabbitmq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/newrelic/nri-rabbitmq
- Repository: https://github.com/newrelic/nri-rabbitmq

## Overview

##### Main Components
- Integration Engine – Represented by the main executable (nri-rabbitmq) built from the source code.
- Command-Line Interface – Parsing of command-line arguments (located in src/args).
- Data Collection Modules:
– Client Module (src/client): Handles communication with RabbitMQ’s Management API.
– Data Processing/Conversion Module (src/data): Contains code to convert raw inputs and definitions.
– Inventory Module (src/inventory): Manages inventory data obtained from configuration files.
– Metrics Module (src/metrics): Processes performance metrics received from RabbitMQ.
- Build and Packaging Infrastructure:
– Build scripts, Makefile, and packaging scripts found in the build directory – highlight different target platforms (e.g., Windows MSI packages).
- Testing Infrastructure:
– Tests and sample configurations under tests/ and within src packages.

##### Relationships and Data Flow
- From the CLI, the integration invokes the client module which communicates with the RabbitMQ Management API.
- The client module passes data to the data processing module, where converters and definitions are applied.
- Data then branches out into:
- The Metrics Module – handling performance statistics.
- The Inventory Module – handling configuration-derived inventory details.
- That both modules ultimately feed into New Relic’s monitoring pipelines (which could be represented as an external service or New Relic backend).
- Optionally, include the build process (Makefile, build scripts) as a separate “deployment” or “build pipeline” component that packages the executable for distribution.
- Testing components (src tests and tests folder) separately, showing that they are invoked during the build process.

##### Architectural Patterns and Design Principles
- Modularity – Highlight how the code is split into distinct packages such as args, client, data, inventory, and metrics. This separation clarifies single responsibility for each module.
- Clear Separation between data collection (via the client and API calls) and processing (conversion functions, metrics, and inventory).
- Build pipelines supporting cross-platform packaging (with specific Windows packaging logic and scripts for Linux/Nix).

##### Relevant Technologies, Frameworks, or Libraries
- Golang as the primary programming language.
- New Relic-specific libraries or APIs (although not explicitly seen, the integration clearly depends on New Relic’s data ingestion).
- Package management and dependency locking are handled via govendor.
- The build system utilizing Makefiles, CI configuration (GitHub workflows in .github/workflows), and scripts for multi-platform builds.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Runtime Components
    A["User"]:::runtime
    B["CLI/Args Parser"]:::runtime
    C["Integration Engine"]:::runtime
    D["RabbitMQ Client"]:::runtime
    E["Data Converters"]:::runtime
    F["Metrics Processor"]:::runtime
    G["Inventory Processor"]:::runtime
    H["New Relic Reporting"]:::external

    %% Build and Testing Components
    subgraph "Build & Test Pipeline"
        I["Build Pipeline"]:::build
        J["Testing"]:::test
    end

    %% Flow Connections for Runtime
    A --> B
    B --> C
    C --> D
    D --> E
    E --> F
    E --> G
    F --> H
    G --> H

    %% Flow Connections for Build and Test
    I --> C
    J --> I

    %% Click Events
    click C "https://github.com/newrelic/nri-rabbitmq/blob/master/src/rabbitmq.go"
    click B "https://github.com/newrelic/nri-rabbitmq/tree/master/src/args"
    click D "https://github.com/newrelic/nri-rabbitmq/tree/master/src/client"
    click E "https://github.com/newrelic/nri-rabbitmq/tree/master/src/data"
    click F "https://github.com/newrelic/nri-rabbitmq/tree/master/src/metrics"
    click G "https://github.com/newrelic/nri-rabbitmq/tree/master/src/inventory"
    click I "https://github.com/newrelic/nri-rabbitmq/tree/master/build"
    click J "https://github.com/newrelic/nri-rabbitmq/tree/master/tests"

    %% Class Definitions (with colors)
    classDef runtime fill:#cce5ff,stroke:#1b5e20,stroke-width:2px;
    classDef external fill:#ffebcc,stroke:#ff8c00,stroke-width:2px;
    classDef build fill:#d1e7dd,stroke:#0f5132,stroke-width:2px;
    classDef test fill:#fde2e4,stroke:#d6336c,stroke-width:2px;
```
