# orbien-org/orbien architecture

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

- Interactive diagram: https://gitdiagram.com/orbien-org/orbien
- Repository: https://github.com/orbien-org/orbien

## Overview

#### Purpose and Executables
Orbien is a Rust/Tokio reverse-tunneling system for exposing private services through a public server. Primary binaries are the client (`client/src/main.rs`) and server (`server/src/main.rs`), configured through TOML examples in `conf/orbien.toml` and `conf/orbien-server.toml`. It also ships a native desktop client, Java client library, and server dashboard UI.

#### Shared Protocol and Runtime Core
The `core` crate defines contracts shared by client and server: configuration, token authentication, framed control messages, network metadata, TLS, rate limiting, and transports. Key boundaries are `core/src/msg/codec.rs`, `core/src/auth/token.rs`, and `core/src/transport/mod.rs`. Supported transport implementations include TCP, KCP, QUIC, WebSocket, TLS, and Yamux TCP multiplexing.

#### Client Control Plane
The Rust client establishes and maintains a server control session, handles server requests for data connections, and owns tunnel lifecycle. Main control/session orchestration is in `client/src/control/session.rs`; tunnel registration and dispatch live in `client/src/tunnel/manager.rs` and `client/src/handle.rs`. Client configuration maps declared local services and tunnel types to outgoing registrations through `client/src/service.rs`.

#### Client Data Plane and Local Services
After control-plane negotiation, the client creates data connections and relays inbound public traffic to configured private services. Connector and tunnel implementations separate stream setup from protocol-specific forwarding: `client/src/connector.rs`, `client/src/tunnel/udp.rs`, and `client/src/tunnel/mod.rs`. The TLS-termination plugin (`client/src/plugin/tls_term.rs`) is a distinct boundary for client-side HTTPS termination.

#### Server Registration, Routing, and Tunnel Ingress
The server accepts authenticated client sessions, registers their tunnel definitions, maintains a pool of data connections, and routes public ingress to the owning client session. These stages are centered in `server/src/control/session/register.rs`, `server/src/control/session/data_pool.rs`, and `server/src/service/ingress.rs`. Protocol-specific public listeners/gateways are implemented under `server/src/tunnel/`, notably `tcp.rs`, `udp.rs`, `http.rs`, `https.rs`, and `gw.rs`.

#### Operations and Interfaces
The server exposes dashboard routes backed by in-memory client/tunnel and traffic state: `server/src/dashboard/routes.rs`, `server/src/service/session_registry.rs`, and `server/src/metrics/mod.rs`. The separate Vue/Vite dashboard consumes this API via `server-ui/src/api/client.ts`, with monitoring and inventory views in `server-ui/src/views/Monitor.vue` and `server-ui/src/views/Clients.vue`. This UI is an operations consumer, not part of forwarding-path correctness.

#### Additional Consumers and Deployment
`desktop/src/main.rs` hosts the native Slint GUI and launches/manages the Rust client runtime through `desktop/src/runtime.rs` and `desktop/src/config_bridge.rs`. Java integrations implement the same wire/control/data concepts using Netty (`client-java/orbien-client/src/main/java/io/github/lxien/orbien/client/OrbienClient.java`, `.../netty/ControlHandler.java`) and Spring Boot auto-configuration (`client-java/orbien-spring-boot-starter/src/main/java/io/github/lxien/orbien/boot/OrbienAutoConfiguration.java`). Docker builds target independent client/server images in `docker/Dockerfile.client` and `docker/Dockerfile.server`.

Main entry points: [`server/src/control/session/register.rs`](https://github.com/orbien-org/orbien/blob/main/server/src/control/session/register.rs) (Session registration), [`client/src/control/session.rs`](https://github.com/orbien-org/orbien/blob/main/client/src/control/session.rs) (Control session), [`client/src/connector.rs`](https://github.com/orbien-org/orbien/blob/main/client/src/connector.rs) (Data connector), [`server/src/service/ingress.rs`](https://github.com/orbien-org/orbien/blob/main/server/src/service/ingress.rs) (Ingress router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Shared Core"]
  node_core_config["Config and protocol<br/>shared contracts"]
  node_core_auth["Token authentication<br/>[token.rs]"]
  node_core_codec["Control codec<br/>wire protocol<br/>[codec.rs]"]
  node_core_transport["Transport layer<br/>transport abstraction<br/>[mod.rs]"]
end

subgraph group_client["Rust Client"]
  node_client_main["Client binary<br/>Tokio executable<br/>[main.rs]"]
  node_client_session["Control session<br/>session orchestration<br/>[session.rs]"]
  node_client_services["Service declarations<br/>tunnel configuration<br/>[service.rs]"]
  node_client_manager["Tunnel manager<br/>lifecycle dispatcher<br/>[manager.rs]"]
  node_client_connector["Data connector<br/>data-plane setup<br/>[connector.rs]"]
  node_client_tunnels["Tunnel forwarding<br/>protocol forwarding<br/>[mod.rs]"]
  node_client_tls["TLS termination plugin<br/>HTTPS plugin<br/>[tls_term.rs]"]
end

subgraph group_server["Rust Server"]
  node_server_main["Server binary<br/>Tokio executable<br/>[main.rs]"]
  node_server_register["Session registration<br/>control-plane registration<br/>[register.rs]"]
  node_server_pool["Data connection pool<br/>[data_pool.rs]"]
  node_server_ingress["Ingress router<br/>public traffic routing<br/>[ingress.rs]"]
  node_server_gateways["Public gateways<br/>protocol listeners"]
  node_server_registry[("Session registry<br/>runtime state")]
  node_server_metrics["Traffic metrics<br/>observability state<br/>[mod.rs]"]
  node_server_dashboard["Dashboard API routes<br/>operations API<br/>[routes.rs]"]
end

subgraph group_ops["Operations UI"]
  node_dashboard_ui["Vue dashboard<br/>operations frontend<br/>[client.ts]"]
end

subgraph group_consumers["Additional Consumers"]
  node_desktop["Desktop client<br/>Slint GUI<br/>[main.rs]"]
  node_java_client["Java client library<br/>Netty client<br/>[OrbienClient.java]"]
  node_spring_starter["Spring Boot starter<br/>auto-configuration"]
  node_docker_client["Client image<br/>Docker build<br/>[Dockerfile.client]"]
  node_docker_server["Server image<br/>Docker build<br/>[Dockerfile.server]"]
end

node_client_main -->|"starts"| node_client_session
node_client_services -->|"declares tunnels"| node_client_manager
node_client_session -->|"dispatches requests"| node_client_manager
node_client_manager -->|"opens data connections"| node_client_connector
node_client_connector -->|"supplies streams"| node_client_tunnels
node_client_tunnels -.->|"uses for HTTPS"| node_client_tls
node_client_session -->|"control frames"| node_core_codec
node_client_session -->|"authenticates with"| node_core_auth
node_client_connector -->|"uses"| node_core_transport
node_server_main -->|"accepts sessions"| node_server_register
node_server_register -->|"records tunnels"| node_server_registry
node_server_register -->|"manages"| node_server_pool
node_server_gateways -->|"public traffic"| node_server_ingress
node_server_ingress -->|"selects connection"| node_server_pool
node_server_ingress -->|"resolves owner"| node_server_registry
node_server_register -->|"validates tokens"| node_core_auth
node_server_register -->|"control frames"| node_core_codec
node_server_pool -->|"uses"| node_core_transport
node_server_registry -->|"inventory"| node_server_dashboard
node_server_metrics -->|"traffic state"| node_server_dashboard
node_server_dashboard -->|"operations API"| node_dashboard_ui
node_desktop -->|"manages runtime"| node_client_main
node_spring_starter -->|"configures"| node_java_client
node_java_client -.->|"control session"| node_server_register
node_docker_client -.->|"packages"| node_client_main
node_docker_server -.->|"packages"| node_server_main

click node_core_auth "https://github.com/orbien-org/orbien/blob/main/core/src/auth/token.rs"
click node_core_codec "https://github.com/orbien-org/orbien/blob/main/core/src/msg/codec.rs"
click node_core_transport "https://github.com/orbien-org/orbien/blob/main/core/src/transport/mod.rs"
click node_client_main "https://github.com/orbien-org/orbien/blob/main/client/src/main.rs"
click node_client_session "https://github.com/orbien-org/orbien/blob/main/client/src/control/session.rs"
click node_client_services "https://github.com/orbien-org/orbien/blob/main/client/src/service.rs"
click node_client_manager "https://github.com/orbien-org/orbien/blob/main/client/src/tunnel/manager.rs"
click node_client_connector "https://github.com/orbien-org/orbien/blob/main/client/src/connector.rs"
click node_client_tunnels "https://github.com/orbien-org/orbien/blob/main/client/src/tunnel/mod.rs"
click node_client_tls "https://github.com/orbien-org/orbien/blob/main/client/src/plugin/tls_term.rs"
click node_server_main "https://github.com/orbien-org/orbien/blob/main/server/src/main.rs"
click node_server_register "https://github.com/orbien-org/orbien/blob/main/server/src/control/session/register.rs"
click node_server_pool "https://github.com/orbien-org/orbien/blob/main/server/src/control/session/data_pool.rs"
click node_server_ingress "https://github.com/orbien-org/orbien/blob/main/server/src/service/ingress.rs"
click node_server_registry "https://github.com/orbien-org/orbien/blob/main/server/src/service/session_registry.rs"
click node_server_metrics "https://github.com/orbien-org/orbien/blob/main/server/src/metrics/mod.rs"
click node_server_dashboard "https://github.com/orbien-org/orbien/blob/main/server/src/dashboard/routes.rs"
click node_dashboard_ui "https://github.com/orbien-org/orbien/blob/main/server-ui/src/api/client.ts"
click node_desktop "https://github.com/orbien-org/orbien/blob/main/desktop/src/main.rs"
click node_java_client "https://github.com/orbien-org/orbien/blob/main/client-java/orbien-client/src/main/java/io/github/lxien/orbien/client/OrbienClient.java"
click node_spring_starter "https://github.com/orbien-org/orbien/blob/main/client-java/orbien-spring-boot-starter/src/main/java/io/github/lxien/orbien/boot/OrbienAutoConfiguration.java"
click node_docker_client "https://github.com/orbien-org/orbien/blob/main/docker/Dockerfile.client"
click node_docker_server "https://github.com/orbien-org/orbien/blob/main/docker/Dockerfile.server"

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_core_config,node_core_auth,node_core_codec,node_core_transport toneBlue
class node_client_main,node_client_session,node_client_services,node_client_manager,node_client_connector,node_client_tunnels,node_client_tls toneAmber
class node_server_main,node_server_register,node_server_pool,node_server_ingress,node_server_gateways,node_server_registry,node_server_metrics,node_server_dashboard toneMint
class node_dashboard_ui toneRose
class node_desktop,node_java_client,node_spring_starter,node_docker_client,node_docker_server toneIndigo
```

## Components

### Shared Core

Contracts and transport primitives shared by Rust client and server.

- **Config and protocol**: shared contracts · Configuration, framed messages, network metadata, TLS, and rate limits.
- [Token authentication](https://github.com/orbien-org/orbien/blob/main/core/src/auth/token.rs): auth · `core/src/auth/token.rs`
- [Control codec](https://github.com/orbien-org/orbien/blob/main/core/src/msg/codec.rs): wire protocol · `core/src/msg/codec.rs`
- [Transport layer](https://github.com/orbien-org/orbien/blob/main/core/src/transport/mod.rs): transport abstraction · TCP, KCP, QUIC, WebSocket, TLS, and Yamux implementations. · `core/src/transport/mod.rs`

### Rust Client

Private-network control and forwarding runtime.

- [Client binary](https://github.com/orbien-org/orbien/blob/main/client/src/main.rs): Tokio executable · `client/src/main.rs`
- [Control session](https://github.com/orbien-org/orbien/blob/main/client/src/control/session.rs): session orchestration · Maintains the authenticated server control connection. · `client/src/control/session.rs`
- [Service declarations](https://github.com/orbien-org/orbien/blob/main/client/src/service.rs): tunnel configuration · Maps local services and tunnel types to registrations. · `client/src/service.rs`
- [Tunnel manager](https://github.com/orbien-org/orbien/blob/main/client/src/tunnel/manager.rs): lifecycle dispatcher · `client/src/tunnel/manager.rs`
- [Data connector](https://github.com/orbien-org/orbien/blob/main/client/src/connector.rs): data-plane setup · `client/src/connector.rs`
- [Tunnel forwarding](https://github.com/orbien-org/orbien/blob/main/client/src/tunnel/mod.rs): protocol forwarding · Stream and UDP tunnel implementations relay to local services. · `client/src/tunnel/mod.rs`
- [TLS termination plugin](https://github.com/orbien-org/orbien/blob/main/client/src/plugin/tls_term.rs): HTTPS plugin · Performs client-side HTTPS termination. · `client/src/plugin/tls_term.rs`

### Rust Server

Public ingress, registration, and routing runtime.

- [Server binary](https://github.com/orbien-org/orbien/blob/main/server/src/main.rs): Tokio executable · `server/src/main.rs`
- [Session registration](https://github.com/orbien-org/orbien/blob/main/server/src/control/session/register.rs): control-plane registration · Authenticates clients and registers tunnel definitions. · `server/src/control/session/register.rs`
- [Data connection pool](https://github.com/orbien-org/orbien/blob/main/server/src/control/session/data_pool.rs): connection pool · `server/src/control/session/data_pool.rs`
- [Ingress router](https://github.com/orbien-org/orbien/blob/main/server/src/service/ingress.rs): public traffic routing · Routes public traffic to its owning client session. · `server/src/service/ingress.rs`
- **Public gateways**: protocol listeners · TCP, UDP, HTTP, HTTPS, and gateway listeners.
- [Session registry](https://github.com/orbien-org/orbien/blob/main/server/src/service/session_registry.rs): runtime state · In-memory client and tunnel inventory. · `server/src/service/session_registry.rs`
- [Traffic metrics](https://github.com/orbien-org/orbien/blob/main/server/src/metrics/mod.rs): observability state · `server/src/metrics/mod.rs`
- [Dashboard API routes](https://github.com/orbien-org/orbien/blob/main/server/src/dashboard/routes.rs): operations API · `server/src/dashboard/routes.rs`

### Operations UI

Observability and server administration surface.

- [Vue dashboard](https://github.com/orbien-org/orbien/blob/main/server-ui/src/api/client.ts): operations frontend · Monitoring and client inventory views consume the server API. · `server-ui/src/api/client.ts`

### Additional Consumers

Alternative client integrations and deployment targets.

- [Desktop client](https://github.com/orbien-org/orbien/blob/main/desktop/src/main.rs): Slint GUI · Hosts and manages the Rust client runtime. · `desktop/src/main.rs`
- [Java client library](https://github.com/orbien-org/orbien/blob/main/client-java/orbien-client/src/main/java/io/github/lxien/orbien/client/OrbienClient.java): Netty client · Implements the same control and data concepts for Java integrations. · `client-java/orbien-client/src/main/java/io/github/lxien/orbien/client/OrbienClient.java`
- [Spring Boot starter](https://github.com/orbien-org/orbien/blob/main/client-java/orbien-spring-boot-starter/src/main/java/io/github/lxien/orbien/boot/OrbienAutoConfiguration.java): auto-configuration · `client-java/orbien-spring-boot-starter/src/main/java/io/github/lxien/orbien/boot/OrbienAutoConfiguration.java`
- [Client image](https://github.com/orbien-org/orbien/blob/main/docker/Dockerfile.client): Docker build · `docker/Dockerfile.client`
- [Server image](https://github.com/orbien-org/orbien/blob/main/docker/Dockerfile.server): Docker build · `docker/Dockerfile.server`

## Connections

- Client binary → Control session: starts
- Service declarations → Tunnel manager: declares tunnels
- Control session → Tunnel manager: dispatches requests
- Tunnel manager → Data connector: opens data connections
- Data connector → Tunnel forwarding: supplies streams
- Tunnel forwarding → TLS termination plugin: uses for HTTPS
- Control session → Control codec: control frames
- Control session → Token authentication: authenticates with
- Data connector → Transport layer: uses
- Server binary → Session registration: accepts sessions
- Session registration → Session registry: records tunnels
- Session registration → Data connection pool: manages
- Public gateways → Ingress router: public traffic
- Ingress router → Data connection pool: selects connection
- Ingress router → Session registry: resolves owner
- Session registration → Token authentication: validates tokens
- Session registration → Control codec: control frames
- Data connection pool → Transport layer: uses
- Session registry → Dashboard API routes: inventory
- Traffic metrics → Dashboard API routes: traffic state
- Dashboard API routes → Vue dashboard: operations API
- Desktop client → Client binary: manages runtime
- Spring Boot starter → Java client library: configures
- Java client library → Session registration: control session
- Client image → Client binary: packages
- Server image → Server binary: packages
