# sgly123/netbox architecture

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

- Interactive diagram: https://gitdiagram.com/sgly123/netbox
- Repository: https://github.com/sgly123/netbox

## Overview

NetBox is a C++ network server framework. Its main startup path reads configuration, creates a worker pool and registered application, then starts a TCP server; network data is handled by the application and routed through protocol handlers to a result. The graph also preserves documented HTTP, Redis, WebSocket, UDP, medical, IoT, and vision capabilities. Some feature implementations were not sampled, so their links are shown only where documented or left unverified.

Main entry points: [`app/include/ApplicationServer.h`](https://github.com/sgly123/netbox/blob/main/app/include/ApplicationServer.h) (Application server), [`main.cpp`](https://github.com/sgly123/netbox/blob/main/main.cpp) (Server startup), [`Protocol/src/ProtocolRouter.cpp`](https://github.com/sgly123/netbox/blob/main/Protocol/src/ProtocolRouter.cpp) (Protocol router), [`NetFramework/include/server/TcpServer.h`](https://github.com/sgly123/netbox/blob/main/NetFramework/include/server/TcpServer.h) (TCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and applications"]
  node_config["Configuration reader"]
  node_entry["Server startup<br/>[main.cpp]"]
  node_registry["Application registry"]
  node_appbase["Application server"]
end

subgraph group_network["Network runtime"]
  node_tcp["TCP server<br/>[TcpServer.h]"]
  node_udpserver["UDP server<br/>[UdpServer.cpp]"]
  node_iofactory["I/O factory<br/>[IOFactory.h]"]
  node_multiplexer["I/O multiplexer<br/>[IOMultiplexer.h]"]
end

subgraph group_protocols["Protocol handling"]
  node_router["Protocol router<br/>[ProtocolRouter.cpp]"]
  node_simple["Simple Header"]
  node_http["HTTP protocol<br/>[HttpProtocol.h]"]
  node_websocketproto["WebSocket protocol"]
  node_redisproto["Redis RESP<br/>[RedisProtocol.cpp]"]
end

subgraph group_services["Product services"]
  node_echo["Echo and HTTP app<br/>[server.cpp]"]
  node_redis["Redis services"]
  node_websocket["WebSocket service"]
  node_im["IM service<br/>[IMServer.cpp]"]
  node_medical["Medical service"]
  node_udp["UDP echo service<br/>[UdpEchoServer.cpp]"]
  node_iot["IoT gateway"]
  node_vision["Vision service<br/>[VisionServer.cpp]"]
end

subgraph group_platform["Runtime support"]
  node_threadpool["Worker pool"]
  node_logger["Logging<br/>[Logger.h]"]
  node_metrics["Metrics collector<br/>[MetricsCollector.h]"]
end

node_operator(("Operator"))
node_client(("Network client"))

node_operator -->|"configures"| node_entry
node_entry -->|"loads config"| node_config
node_entry -->|"creates app"| node_registry
node_entry -->|"creates pool"| node_threadpool
node_entry -->|"starts app"| node_appbase
node_appbase -->|"inherits"| node_tcp
node_tcp -->|"creates I/O"| node_iofactory
node_iofactory -->|"selects implementation"| node_multiplexer
node_client -->|"connects"| node_tcp
node_tcp -.->|"delivers data"| node_appbase
node_appbase -.->|"routes data"| node_router
node_router -->|"dispatches"| node_simple
node_router -->|"dispatches"| node_http
node_simple -->|"provides packets"| node_echo
node_http -->|"handles requests"| node_echo
node_echo -->|"sends response"| node_client
node_router -.->|"dispatches"| node_websocketproto
node_websocketproto -.->|"handles frames"| node_websocket
node_router -.->|"dispatches"| node_redisproto
node_redisproto -.->|"handles commands"| node_redis
node_appbase -.->|"submits work"| node_threadpool
node_registry -->|"creates application"| node_appbase
node_udpserver -.->|"serves traffic"| node_udp
node_appbase -.->|"hosts application"| node_im
node_appbase -.->|"hosts application"| node_medical
node_appbase -.->|"hosts application"| node_websocket
node_appbase -.->|"hosts plugin"| node_iot
node_appbase -.->|"hosts plugin"| node_vision
node_entry -->|"initializes"| node_logger

click node_config "https://github.com/sgly123/netbox/blob/main/NetFramework/include/util/EnhancedConfigReader.h"
click node_entry "https://github.com/sgly123/netbox/blob/main/main.cpp"
click node_registry "https://github.com/sgly123/netbox/blob/main/NetFramework/src/app/ApplicationRegistry.cpp"
click node_appbase "https://github.com/sgly123/netbox/blob/main/app/include/ApplicationServer.h"
click node_echo "https://github.com/sgly123/netbox/blob/main/app/src/server.cpp"
click node_redis "https://github.com/sgly123/netbox/blob/main/app/src/RedisApplicationServer.cpp"
click node_websocket "https://github.com/sgly123/netbox/blob/main/app/src/WebSocketServer.cpp"
click node_im "https://github.com/sgly123/netbox/blob/main/app/src/IMServer.cpp"
click node_medical "https://github.com/sgly123/netbox/blob/main/app/src/ECGDeviceServer.cpp"
click node_udp "https://github.com/sgly123/netbox/blob/main/app/src/UdpEchoServer.cpp"
click node_iot "https://github.com/sgly123/netbox/blob/main/plugins/iot/IoTGatewayServer.cpp"
click node_vision "https://github.com/sgly123/netbox/blob/main/plugins/vision/VisionServer.cpp"
click node_tcp "https://github.com/sgly123/netbox/blob/main/NetFramework/include/server/TcpServer.h"
click node_udpserver "https://github.com/sgly123/netbox/blob/main/NetFramework/src/server/UdpServer.cpp"
click node_iofactory "https://github.com/sgly123/netbox/blob/main/NetFramework/include/IO/IOFactory.h"
click node_multiplexer "https://github.com/sgly123/netbox/blob/main/NetFramework/include/base/IOMultiplexer.h"
click node_router "https://github.com/sgly123/netbox/blob/main/Protocol/src/ProtocolRouter.cpp"
click node_simple "https://github.com/sgly123/netbox/blob/main/Protocol/include/SimpleHeaderProtocol.h"
click node_http "https://github.com/sgly123/netbox/blob/main/Protocol/include/HttpProtocol.h"
click node_websocketproto "https://github.com/sgly123/netbox/blob/main/Protocol/src/WebSocketProtocol.cpp"
click node_redisproto "https://github.com/sgly123/netbox/blob/main/Protocol/src/RedisProtocol.cpp"
click node_threadpool "https://github.com/sgly123/netbox/blob/main/NetFramework/src/base/DoubleLockThreadPool.cpp"
click node_logger "https://github.com/sgly123/netbox/blob/main/NetFramework/include/base/Logger.h"
click node_metrics "https://github.com/sgly123/netbox/blob/main/NetFramework/include/monitoring/MetricsCollector.h"

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_config,node_entry,node_registry,node_appbase,node_client toneBlue
class node_tcp,node_udpserver,node_iofactory,node_multiplexer toneAmber
class node_router,node_simple,node_http,node_websocketproto,node_redisproto toneMint
class node_echo,node_redis,node_websocket,node_im,node_medical,node_udp,node_iot,node_vision toneRose
class node_threadpool,node_logger,node_metrics,node_operator toneIndigo
```

## Components

### Startup and applications

- [Configuration reader](https://github.com/sgly123/netbox/blob/main/NetFramework/include/util/EnhancedConfigReader.h): `NetFramework/include/util/EnhancedConfigReader.h`
- [Server startup](https://github.com/sgly123/netbox/blob/main/main.cpp): `main.cpp`
- [Application registry](https://github.com/sgly123/netbox/blob/main/NetFramework/src/app/ApplicationRegistry.cpp): `NetFramework/src/app/ApplicationRegistry.cpp`
- [Application server](https://github.com/sgly123/netbox/blob/main/app/include/ApplicationServer.h): `app/include/ApplicationServer.h`

### Network runtime

- [TCP server](https://github.com/sgly123/netbox/blob/main/NetFramework/include/server/TcpServer.h): `NetFramework/include/server/TcpServer.h`
- [UDP server](https://github.com/sgly123/netbox/blob/main/NetFramework/src/server/UdpServer.cpp): `NetFramework/src/server/UdpServer.cpp`
- [I/O factory](https://github.com/sgly123/netbox/blob/main/NetFramework/include/IO/IOFactory.h): `NetFramework/include/IO/IOFactory.h`
- [I/O multiplexer](https://github.com/sgly123/netbox/blob/main/NetFramework/include/base/IOMultiplexer.h): `NetFramework/include/base/IOMultiplexer.h`

### Protocol handling

- [Protocol router](https://github.com/sgly123/netbox/blob/main/Protocol/src/ProtocolRouter.cpp): `Protocol/src/ProtocolRouter.cpp`
- [Simple Header](https://github.com/sgly123/netbox/blob/main/Protocol/include/SimpleHeaderProtocol.h): `Protocol/include/SimpleHeaderProtocol.h`
- [HTTP protocol](https://github.com/sgly123/netbox/blob/main/Protocol/include/HttpProtocol.h): `Protocol/include/HttpProtocol.h`
- [WebSocket protocol](https://github.com/sgly123/netbox/blob/main/Protocol/src/WebSocketProtocol.cpp): `Protocol/src/WebSocketProtocol.cpp`
- [Redis RESP](https://github.com/sgly123/netbox/blob/main/Protocol/src/RedisProtocol.cpp): `Protocol/src/RedisProtocol.cpp`

### Product services

- [Echo and HTTP app](https://github.com/sgly123/netbox/blob/main/app/src/server.cpp): `app/src/server.cpp`
- [Redis services](https://github.com/sgly123/netbox/blob/main/app/src/RedisApplicationServer.cpp): `app/src/RedisApplicationServer.cpp`
- [WebSocket service](https://github.com/sgly123/netbox/blob/main/app/src/WebSocketServer.cpp): `app/src/WebSocketServer.cpp`
- [IM service](https://github.com/sgly123/netbox/blob/main/app/src/IMServer.cpp): `app/src/IMServer.cpp`
- [Medical service](https://github.com/sgly123/netbox/blob/main/app/src/ECGDeviceServer.cpp): `app/src/ECGDeviceServer.cpp`
- [UDP echo service](https://github.com/sgly123/netbox/blob/main/app/src/UdpEchoServer.cpp): `app/src/UdpEchoServer.cpp`
- [IoT gateway](https://github.com/sgly123/netbox/blob/main/plugins/iot/IoTGatewayServer.cpp): `plugins/iot/IoTGatewayServer.cpp`
- [Vision service](https://github.com/sgly123/netbox/blob/main/plugins/vision/VisionServer.cpp): `plugins/vision/VisionServer.cpp`

### Runtime support

- [Worker pool](https://github.com/sgly123/netbox/blob/main/NetFramework/src/base/DoubleLockThreadPool.cpp): `NetFramework/src/base/DoubleLockThreadPool.cpp`
- [Logging](https://github.com/sgly123/netbox/blob/main/NetFramework/include/base/Logger.h): `NetFramework/include/base/Logger.h`
- [Metrics collector](https://github.com/sgly123/netbox/blob/main/NetFramework/include/monitoring/MetricsCollector.h): `NetFramework/include/monitoring/MetricsCollector.h`

### Other components

- **Operator**
- **Network client**

## Connections

- Operator → Server startup: configures
- Server startup → Configuration reader: loads config (evidence: `main.cpp`)
- Server startup → Application registry: creates app (evidence: `main.cpp`)
- Server startup → Worker pool: creates pool (evidence: `main.cpp`)
- Server startup → Application server: starts app (evidence: `main.cpp`)
- Application server → TCP server: inherits (evidence: `app/include/ApplicationServer.h`)
- TCP server → I/O factory: creates I/O (evidence: `NetFramework/include/server/TcpServer.h`)
- I/O factory → I/O multiplexer: selects implementation (evidence: `NetFramework/include/IO/IOFactory.h`)
- Network client → TCP server: connects
- TCP server → Application server: delivers data (evidence: `app/include/ApplicationServer.h`)
- Application server → Protocol router: routes data
- Protocol router → Simple Header: dispatches
- Protocol router → HTTP protocol: dispatches
- Simple Header → Echo and HTTP app: provides packets (evidence: `app/src/server.cpp`)
- HTTP protocol → Echo and HTTP app: handles requests (evidence: `app/src/server.cpp`)
- Echo and HTTP app → Network client: sends response (evidence: `app/src/server.cpp`)
- Protocol router → WebSocket protocol: dispatches
- WebSocket protocol → WebSocket service: handles frames
- Protocol router → Redis RESP: dispatches
- Redis RESP → Redis services: handles commands
- Application server → Worker pool: submits work
- Application registry → Application server: creates application
- UDP server → UDP echo service: serves traffic
- Application server → IM service: hosts application
- Application server → Medical service: hosts application
- Application server → WebSocket service: hosts application
- Application server → IoT gateway: hosts plugin
- Application server → Vision service: hosts plugin
- Server startup → Logging: initializes (evidence: `main.cpp`)
