# derekyrc/mini-netty architecture

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

- Interactive diagram: https://gitdiagram.com/derekyrc/mini-netty
- Repository: https://github.com/derekyrc/mini-netty

## Overview

mini-netty is a pure-JDK, educational Netty-style networking framework. Its principal workflow configures a client or server with a bootstrap, assigns channels to event loops, and carries channel I/O through a bidirectional handler pipeline; codecs can turn byte buffers into messages and back. The graph also preserves the documented buffer, async-result, logging, and idle-detection capabilities. Evidence is limited to the README and SOURCE INDEX references; unsampled implementation details and relationships are not assumed.

Main entry points: [`src/main/java/io/netty/channel/DefaultChannelPipeline.java`](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/DefaultChannelPipeline.java) (Handler Pipeline), [`src/main/java/io/netty/bootstrap/AbstractBootstrap.java`](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/AbstractBootstrap.java) (Bootstrap Base), [`src/main/java/io/netty/bootstrap/ServerBootstrap.java`](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/ServerBootstrap.java) (Server Bootstrap), [`src/main/java/io/netty/channel/nio/NioSocketChannel.java`](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioSocketChannel.java) (NIO Socket Channel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Bootstrap"]
  node_client_boot["Client Bootstrap<br/>[Bootstrap.java]"]
  node_server_boot["Server Bootstrap"]
  node_base_boot["Bootstrap Base"]
  node_options["Channel Options<br/>[ChannelOption.java]"]
end

subgraph group_runtime["I/O Runtime"]
  node_group["Event Loop Group"]
  node_loop["NIO Event Loop<br/>[NioEventLoop.java]"]
  node_server_channel["NIO Server Channel"]
  node_socket_channel["NIO Socket Channel"]
  node_channel["Channel Abstraction<br/>[Channel.java]"]
  node_future["Async Results<br/>[ChannelFuture.java]"]
end

subgraph group_pipeline["Channel Pipeline"]
  node_pipeline["Handler Pipeline"]
  node_context["Handler Context"]
  node_handler["Handler API"]
end

subgraph group_data["Buffers and Codecs"]
  node_buf["ByteBuf<br/>[ByteBuf.java]"]
  node_heap["Heap Buffer<br/>[HeapByteBuf.java]"]
  node_allocator["Buffer Allocator"]
  node_frame_decoder["Frame Decoders"]
  node_byte_decoder["Byte Decoder"]
  node_string_codec["String Codecs<br/>[StringDecoder.java]"]
  node_encoder["Message Encoder"]
end

subgraph group_handlers["Built-in Handlers"]
  node_logging["Logging Handler"]
  node_idle["Idle Detection"]
end

node_user(("Application"))
node_tcp(("TCP Peer"))

node_user -->|"configures server"| node_server_boot
node_user -->|"configures client"| node_client_boot
node_server_boot -->|"extends"| node_base_boot
node_client_boot -->|"extends"| node_base_boot
node_base_boot -->|"registers channels"| node_group
node_base_boot -->|"configures"| node_options
node_server_boot -->|"selects channel"| node_server_channel
node_client_boot -.->|"selects channel"| node_socket_channel
node_group -->|"selects loop"| node_loop
node_server_boot -->|"assigns boss worker"| node_group
node_server_channel -->|"accepts connections"| node_socket_channel
node_server_channel -->|"carries events"| node_pipeline
node_socket_channel -->|"exchanges I/O"| node_tcp
node_socket_channel -->|"carries events"| node_pipeline
node_channel -->|"exposes"| node_pipeline
node_base_boot -->|"returns operation result"| node_future
node_pipeline -->|"dispatches through"| node_context
node_context -->|"invokes"| node_handler
node_user -->|"installs handlers"| node_pipeline
node_byte_decoder -->|"reads bytes"| node_buf
node_frame_decoder -->|"specializes"| node_byte_decoder
node_string_codec -->|"decodes bytes"| node_buf
node_string_codec -->|"encodes strings"| node_encoder
node_allocator -.->|"allocates"| node_heap
node_heap -->|"implements"| node_buf
node_pipeline -->|"dispatches events"| node_logging
node_pipeline -->|"dispatches events"| node_idle

click node_client_boot "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/Bootstrap.java"
click node_server_boot "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/ServerBootstrap.java"
click node_base_boot "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/AbstractBootstrap.java"
click node_options "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/ChannelOption.java"
click node_group "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java"
click node_loop "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioEventLoop.java"
click node_server_channel "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioServerSocketChannel.java"
click node_socket_channel "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioSocketChannel.java"
click node_channel "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/Channel.java"
click node_future "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/ChannelFuture.java"
click node_pipeline "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/DefaultChannelPipeline.java"
click node_context "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java"
click node_handler "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/ChannelHandler.java"
click node_buf "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/buffer/ByteBuf.java"
click node_heap "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/buffer/HeapByteBuf.java"
click node_allocator "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/buffer/UnpooledByteBufAllocator.java"
click node_frame_decoder "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java"
click node_byte_decoder "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java"
click node_string_codec "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/string/StringDecoder.java"
click node_encoder "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java"
click node_logging "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/logging/LoggingHandler.java"
click node_idle "https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/timeout/IdleStateHandler.java"

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_boot,node_server_boot,node_base_boot,node_options toneBlue
class node_group,node_loop,node_server_channel,node_socket_channel,node_channel,node_future toneAmber
class node_pipeline,node_context,node_handler toneMint
class node_buf,node_heap,node_allocator,node_frame_decoder,node_byte_decoder,node_string_codec,node_encoder toneRose
class node_logging,node_idle,node_user,node_tcp toneIndigo
```

## Components

### Bootstrap

- [Client Bootstrap](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/Bootstrap.java): `src/main/java/io/netty/bootstrap/Bootstrap.java`
- [Server Bootstrap](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/ServerBootstrap.java): `src/main/java/io/netty/bootstrap/ServerBootstrap.java`
- [Bootstrap Base](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/bootstrap/AbstractBootstrap.java): `src/main/java/io/netty/bootstrap/AbstractBootstrap.java`
- [Channel Options](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/ChannelOption.java): `src/main/java/io/netty/channel/ChannelOption.java`

### I/O Runtime

- [Event Loop Group](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java): `src/main/java/io/netty/channel/nio/NioEventLoopGroup.java`
- [NIO Event Loop](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioEventLoop.java): `src/main/java/io/netty/channel/nio/NioEventLoop.java`
- [NIO Server Channel](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioServerSocketChannel.java): `src/main/java/io/netty/channel/nio/NioServerSocketChannel.java`
- [NIO Socket Channel](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/nio/NioSocketChannel.java): `src/main/java/io/netty/channel/nio/NioSocketChannel.java`
- [Channel Abstraction](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/Channel.java): `src/main/java/io/netty/channel/Channel.java`
- [Async Results](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/ChannelFuture.java): `src/main/java/io/netty/channel/ChannelFuture.java`

### Channel Pipeline

- [Handler Pipeline](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/DefaultChannelPipeline.java): `src/main/java/io/netty/channel/DefaultChannelPipeline.java`
- [Handler Context](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/AbstractChannelHandlerContext.java): `src/main/java/io/netty/channel/AbstractChannelHandlerContext.java`
- [Handler API](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/channel/ChannelHandler.java): `src/main/java/io/netty/channel/ChannelHandler.java`

### Buffers and Codecs

- [ByteBuf](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/buffer/ByteBuf.java): `src/main/java/io/netty/buffer/ByteBuf.java`
- [Heap Buffer](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/buffer/HeapByteBuf.java): `src/main/java/io/netty/buffer/HeapByteBuf.java`
- [Buffer Allocator](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/buffer/UnpooledByteBufAllocator.java): `src/main/java/io/netty/buffer/UnpooledByteBufAllocator.java`
- [Frame Decoders](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java): `src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java`
- [Byte Decoder](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java): `src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java`
- [String Codecs](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/string/StringDecoder.java): `src/main/java/io/netty/handler/codec/string/StringDecoder.java`
- [Message Encoder](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/codec/MessageToByteEncoder.java): `src/main/java/io/netty/handler/codec/MessageToByteEncoder.java`

### Built-in Handlers

- [Logging Handler](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/logging/LoggingHandler.java): `src/main/java/io/netty/handler/logging/LoggingHandler.java`
- [Idle Detection](https://github.com/derekyrc/mini-netty/blob/main/src/main/java/io/netty/handler/timeout/IdleStateHandler.java): `src/main/java/io/netty/handler/timeout/IdleStateHandler.java`

### Other components

- **Application**
- **TCP Peer**

## Connections

- Application → Server Bootstrap: configures server
- Application → Client Bootstrap: configures client
- Server Bootstrap → Bootstrap Base: extends (evidence: `src/main/java/io/netty/bootstrap/ServerBootstrap.java`)
- Client Bootstrap → Bootstrap Base: extends (evidence: `src/main/java/io/netty/bootstrap/Bootstrap.java`)
- Bootstrap Base → Event Loop Group: registers channels (evidence: `src/main/java/io/netty/bootstrap/AbstractBootstrap.java`)
- Bootstrap Base → Channel Options: configures (evidence: `src/main/java/io/netty/bootstrap/AbstractBootstrap.java`)
- Server Bootstrap → NIO Server Channel: selects channel
- Client Bootstrap → NIO Socket Channel: selects channel
- Event Loop Group → NIO Event Loop: selects loop (evidence: `src/main/java/io/netty/channel/nio/NioEventLoopGroup.java`)
- Server Bootstrap → Event Loop Group: assigns boss worker
- NIO Server Channel → NIO Socket Channel: accepts connections
- NIO Server Channel → Handler Pipeline: carries events
- NIO Socket Channel → TCP Peer: exchanges I/O
- NIO Socket Channel → Handler Pipeline: carries events
- Channel Abstraction → Handler Pipeline: exposes (evidence: `src/main/java/io/netty/channel/Channel.java`)
- Bootstrap Base → Async Results: returns operation result (evidence: `src/main/java/io/netty/bootstrap/AbstractBootstrap.java`)
- Handler Pipeline → Handler Context: dispatches through (evidence: `src/main/java/io/netty/channel/DefaultChannelPipeline.java`)
- Handler Context → Handler API: invokes (evidence: `src/main/java/io/netty/channel/AbstractChannelHandlerContext.java`)
- Application → Handler Pipeline: installs handlers
- Byte Decoder → ByteBuf: reads bytes (evidence: `src/main/java/io/netty/handler/codec/ByteToMessageDecoder.java`)
- Frame Decoders → Byte Decoder: specializes (evidence: `src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java`)
- String Codecs → ByteBuf: decodes bytes (evidence: `src/main/java/io/netty/handler/codec/string/StringDecoder.java`)
- String Codecs → Message Encoder: encodes strings
- Buffer Allocator → Heap Buffer: allocates
- Heap Buffer → ByteBuf: implements (evidence: `src/main/java/io/netty/buffer/HeapByteBuf.java`)
- Handler Pipeline → Logging Handler: dispatches events
- Handler Pipeline → Idle Detection: dispatches events
