# jim-mclaugh/rxnetty architecture

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

- Interactive diagram: https://gitdiagram.com/jim-mclaugh/rxnetty
- Repository: https://github.com/jim-mclaugh/rxnetty

## Overview

##### Project type and purpose
- RxNetty is an open-source, multi-module Java library that adapts Netty’s low-level I/O and channels into a Reactive-Extensions (RxJava) style API.
- It provides a core abstraction layer over raw Netty channels (rxnetty-common), protocol-specific sublibraries for HTTP and TCP (rxnetty-http, rxnetty-tcp), spectator-integration modules for metrics (rxnetty-spectator-http, rxnetty-spectator-tcp), plus example and test-utility modules.

##### File structure
- Top-level modules in the Gradle settings.gradle:
- rxnetty-common – core abstractions (Connection, ChannelOperations, backpressure handlers).
- rxnetty-http – HTTP client/server on top of rxnetty-common.
- rxnetty-tcp – TCP client/server protocol layer.
- rxnetty-spectator-http/tcp – metrics instrumentation adapters on HTTP/TCP modules.
- rxnetty-examples – runnable code showcasing use-cases for HTTP, TCP, WebSocket, SSE, load-balancing, etc.
- rxnetty-test-utils – mocking/testing helpers for unit and integration tests.
- Each module has its own build.gradle, src/main/java, src/test/java, and configuration (checkstyle, Travis).

##### Key insights from the README
- Purpose: “Reactive Extension (Rx) adaptor for Netty”.
- Encourages exploring examples for common use cases (HTTP hello-world, TCP echo, streaming, secure connections).
- Guideline to build with Gradle and snapshot artifacts for 0.5.x.

##### Detail
- In protocol modules, show client vs. server classes (e.g., HttpClient/HttpServer).
- Major bridges (e.g., HttpClientToConnectionBridge).
- Flow of data: Netty channel events → core abstractions → protocol parser → Rx streams → subscriber code.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Dependencies
    subgraph "External Dependencies"
        Netty["Netty"]:::external
        RxJava["RxJava"]:::external
        SpectatorExt["Spectator"]:::external
    end

    %% Core Layer
    subgraph "Core Layer"
        CommonPackage["Core Package"]:::core
        Connection["Connection"]:::core
        ChannelOps["ChannelOperations"]:::core
        BackpressureHandler["BackpressureManagingHandler"]:::core
        EventPublisher["EventPublisher"]:::core
        ConnectionFactory["ConnectionFactory"]:::core
    end

    %% Protocol Layer
    subgraph "Protocol Layer"
        subgraph "HTTP Module"
            HttpModulePkg["HTTP Module"]:::protocol
            HttpClient["HttpClient"]:::protocol
            HttpServer["HttpServer"]:::protocol
            HttpClientBridge["HttpClientToConnectionBridge"]:::protocol
            HttpServerBridge["HttpServerToConnectionBridge"]:::protocol
        end
        subgraph "TCP Module"
            TcpModulePkg["TCP Module"]:::protocol
            TcpClient["TcpClient"]:::protocol
            TcpServer["TcpServer"]:::protocol
            TcpBridge["TcpServerConnectionToChannelBridge"]:::protocol
        end
    end

    %% Instrumentation Layer
    subgraph "Instrumentation Layer"
        subgraph "Spectator HTTP"
            HttpClientListener["HttpClientListener"]:::instrumentation
            HttpServerListener["HttpServerListener"]:::instrumentation
        end
        subgraph "Spectator TCP"
            TcpClientListener["TcpClientListener"]:::instrumentation
            TcpServerListener["TcpServerListener"]:::instrumentation
        end
    end

    %% Support Modules
    subgraph "Support Modules"
        subgraph "Examples"
            HelloWorld["HelloWorldServer"]:::support
            EchoServer["EchoServer"]:::support
        end
        subgraph "Test Utils"
            EmbeddedCF["EmbeddedConnectionFactory"]:::support
        end
    end

    %% Relationships
    Netty -->|drives| CommonPackage
    RxJava -->|provides API for| CommonPackage
    CommonPackage -->|extends to| HttpModulePkg
    CommonPackage -->|extends to| TcpModulePkg
    HttpModulePkg -->|instrumented by| HttpClientListener
    HttpModulePkg -->|instrumented by| HttpServerListener
    TcpModulePkg -->|instrumented by| TcpClientListener
    TcpModulePkg -->|instrumented by| TcpServerListener
    CommonPackage -->|used by| HelloWorld
    HttpModulePkg -->|used by| HelloWorld
    CommonPackage -->|used by| EchoServer
    TcpModulePkg -->|used by| EchoServer
    EmbeddedCF -->|tests| CommonPackage
    EmbeddedCF -->|tests| HttpModulePkg
    EmbeddedCF -->|tests| TcpModulePkg
    EmbeddedCF -->|tests| HttpClientListener
    EmbeddedCF -->|tests| TcpClientListener

    %% Click Events
    click CommonPackage "https://github.com/jim-mclaugh/rxnetty/tree/0.5.x/rxnetty-common/src/main/java/io/reactivex/netty"
    click Connection "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-common/src/main/java/io/reactivex/netty/channel/Connection.java"
    click ChannelOps "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-common/src/main/java/io/reactivex/netty/channel/ChannelOperations.java"
    click BackpressureHandler "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-common/src/main/java/io/reactivex/netty/channel/BackpressureManagingHandler.java"
    click EventPublisher "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-common/src/main/java/io/reactivex/netty/events/EventPublisher.java"
    click ConnectionFactory "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-common/src/main/java/io/reactivex/netty/client/ConnectionFactory.java"
    click HttpModulePkg "https://github.com/jim-mclaugh/rxnetty/tree/0.5.x/rxnetty-http/src/main/java/io/reactivex/netty/protocol/http"
    click HttpClient "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/client/HttpClient.java"
    click HttpServer "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/server/HttpServer.java"
    click HttpClientBridge "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/client/internal/HttpClientToConnectionBridge.java"
    click HttpServerBridge "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-http/src/main/java/io/reactivex/netty/protocol/http/server/HttpServerToConnectionBridge.java"
    click TcpModulePkg "https://github.com/jim-mclaugh/rxnetty/tree/0.5.x/rxnetty-tcp/src/main/java/io/reactivex/netty/protocol/tcp"
    click TcpClient "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-tcp/src/main/java/io/reactivex/netty/protocol/tcp/client/TcpClient.java"
    click TcpServer "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-tcp/src/main/java/io/reactivex/netty/protocol/tcp/server/TcpServer.java"
    click TcpBridge "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-tcp/src/main/java/io/reactivex/netty/protocol/tcp/server/TcpServerConnectionToChannelBridge.java"
    click HttpClientListener "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-spectator-http/src/main/java/io/reactivex/netty/spectator/http/HttpClientListener.java"
    click HttpServerListener "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-spectator-http/src/main/java/io/reactivex/netty/spectator/http/HttpServerListener.java"
    click TcpClientListener "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-spectator-tcp/src/main/java/io/reactivex/netty/spectator/tcp/TcpClientListener.java"
    click TcpServerListener "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-spectator-tcp/src/main/java/io/reactivex/netty/spectator/tcp/TcpServerListener.java"
    click HelloWorld "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-examples/src/main/java/io/reactivex/netty/examples/http/helloworld/HelloWorldServer.java"
    click EchoServer "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-examples/src/main/java/io/reactivex/netty/examples/tcp/echo/EchoServer.java"
    click EmbeddedCF "https://github.com/jim-mclaugh/rxnetty/blob/0.5.x/rxnetty-test-utils/src/main/java/io/reactivex/netty/test/util/EmbeddedConnectionFactory.java"

    %% Styles
    classDef external fill:#D6DBDF,stroke:#2E4053,color:#212F3C;
    classDef core fill:#AED6F1,stroke:#1B4F72,color:#1B2631;
    classDef protocol fill:#A9DFBF,stroke:#145A32,color:#1B2631;
    classDef instrumentation fill:#F5CBA7,stroke:#7E5109,color:#1B2631;
    classDef support fill:#D5D8DC,stroke:#626567,color:#1B2631;
```
