# rabbitmq/rabbitmq-dotnet-client architecture

> Architecture diagram of the GitHub repository rabbitmq/rabbitmq-dotnet-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rabbitmq/rabbitmq-dotnet-client
- Repository: https://github.com/rabbitmq/rabbitmq-dotnet-client

## Overview

##### Main Components

a. Core Client Components:
- Connection Management Layer
- Channel Management Layer
- Consumer Dispatching System
- Protocol Implementation Layer
- Wire Formatting Layer
- Authentication Mechanisms
- Recovery System

b. Extension Components:
- OAuth2 Integration
- OpenTelemetry Integration
- SSL/TLS Support

##### Architectural Layers (from top to bottom)

- ConnectionFactory as the main entry point
- Public event handlers and consumer interfaces

Second Layer - Implementation:
- AutorecoveringConnection and Connection classes
- Channel implementation
- ConsumerDispatcher system
- Command handling system

Third Layer - Protocol:
- AMQP Protocol implementation
- Frame handling
- Wire formatting components
- Method implementations

Fourth Layer - Network:
- Socket handling
- SSL/TLS implementation
- Network byte ordering

##### Integration Points

- OAuth2 integration path
- OpenTelemetry hooks
- Recovery mechanism paths
- Event handling system connections

##### Key Relationships to Highlight

- ConnectionFactory → Connection → Channel hierarchy
- Consumer dispatch flow
- Protocol frame handling flow
- Recovery mechanism paths
- Authentication flow
- Event propagation paths

##### Implementation Details

Important subsystems:
**Connection Management**
- Connection Factory
- Connection Recovery
- Connection Lifecycle

**Channel Operations**
- Basic Operations
- Exchange Operations
- Queue Operations

**Protocol Implementation**
- Frame Handling
- Method Implementation
- Wire Formatting

**Consumer System**
- Async Consumer
- Event Handling
- Message Dispatch

##### Specific Implementation Notes

- Automatic recovery system
- Publisher confirms workflow
- Where SSL/TLS integration occurs
- OAuth2 integration points
- Where OpenTelemetry hooks in

Remember to include version information and supported platform details in a separate notes section, as these are critical for users of the library.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Core Component]:::core
        L2[Extension Module]:::extension
        L3[/Entry Point/]:::entrypoint
        L4[Error Handler]:::error
        L5[(Utility Component)]:::utility
    end

    subgraph "Public API Layer"
        CF[/ConnectionFactory/]:::entrypoint
        IConn[IConnection]:::core
        IChan[IChannel]:::core
        IProps[IBasicProperties]:::core
    end

    subgraph "Implementation Layer"
        ARC[AutorecoveringConnection]:::core
        Conn[Connection]:::core
        Chan[Channel]:::core
        CD[ConsumerDispatcher]:::core
        CMD[Command Handler]:::core
    end

    subgraph "Protocol Layer"
        AMQP[AMQP Protocol]:::core
        Frame[Frame Handler]:::core
        Wire[Wire Formatting]:::core
        Method[Method Implementation]:::core
    end

    subgraph "Network Layer"
        Socket[Socket Handler]:::core
        SSL[SSL/TLS Handler]:::core
        Network[Network Byte Order]:::utility
    end

    subgraph "Extensions"
        OAuth[OAuth2]:::extension
        OTel[OpenTelemetry]:::extension
        Auth[Authentication]:::extension
    end

    subgraph "Error Handling"
        Recovery[Recovery System]:::error
        ErrorHandler[Error Handler]:::error
    end

    %% Relationships
    CF --> ARC
    CF --> Conn
    ARC --> Chan
    Conn --> Chan
    Chan --> CD
    Chan --> CMD
    CMD --> AMQP
    AMQP --> Frame
    Frame --> Wire
    Wire --> Socket
    Socket --> SSL
    Socket --> Network

    %% Extension Relationships
    Auth -.-> Conn
    OAuth -.-> Auth
    OTel -.-> Chan
    Recovery -.-> ARC

    %% Styling
    classDef core fill:#a8d1f0,stroke:#000
    classDef extension fill:#90EE90,stroke:#000
    classDef entrypoint fill:#FFD700,stroke:#000
    classDef error fill:#FFB6C1,stroke:#000
    classDef utility fill:#D3D3D3,stroke:#000

    %% Click Events
    click CF "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/ConnectionFactory.cs"
    click IConn "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/IConnection.cs"
    click IChan "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/IChannel.cs"
    click ARC "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Impl/AutorecoveringConnection.cs"
    click Conn "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Impl/Connection.cs"
    click Chan "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Impl/Channel.cs"
    click CD "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/ConsumerDispatching/ConsumerDispatcherBase.cs"
    click AMQP "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Framing/Protocol.cs"
    click Frame "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Impl/Frame.cs"
    click Wire "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Impl/WireFormatting.cs"
    click SSL "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/Impl/SslHelper.cs"
    click OAuth "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client.OAuth2/OAuth2Client.cs"
    click OTel "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client.OpenTelemetry/TraceProviderBuilderExtensions.cs"
    click Auth "https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/projects/RabbitMQ.Client/IAuthMechanism.cs"
```
