# lejianwen/rustdesk-api architecture

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

- Interactive diagram: https://gitdiagram.com/lejianwen/rustdesk-api
- Repository: https://github.com/lejianwen/rustdesk-api

## Overview

RustDesk API is a Go service with PC-facing APIs, Web Admin endpoints, and a bundled Web Client. The principal flow is a client request routed through Gin middleware and controllers to domain services, which manage users, peers, address books, sharing, OAuth, and audit data. The Web Client configuration endpoint supplies server settings and address-book/share payloads for remote access. The README also documents user/device administration, LDAP and OAuth login, logs, server commands, and internationalization. Edges are limited to relationships demonstrated by excerpts or README statements; unsampled modules are represented only where their role is documented.

Main entry points: [`service/service.go`](https://github.com/lejianwen/rustdesk-api/blob/master/service/service.go) (Domain services), [`http/controller/api/webClient.go`](https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/api/webClient.go) (Web client config), [`http/http.go`](https://github.com/lejianwen/rustdesk-api/blob/master/http/http.go) (HTTP bootstrap), [`http/controller/admin`](https://github.com/lejianwen/rustdesk-api/tree/master/http/controller/admin) (Admin API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_api_routes["PC API routes<br/>[api.go]"]
  node_admin_routes["Admin routes<br/>[admin.go]"]
  node_web_routes["Web routes<br/>[router.go]"]
  node_http_boot["HTTP bootstrap<br/>[http.go]"]
  node_middleware["Request middleware"]
end

subgraph group_identity["Identity"]
  node_users["PC API users<br/>[login.go]"]
  node_pc_api["PC API"]
  node_oauth_flow["OAuth providers<br/>[oauth.go]"]
  node_ldap_flow["LDAP login<br/>[ldap.go]"]
  node_user_data["Users and tokens<br/>[user.go]"]
end

subgraph group_domain["RustDesk data"]
  node_service_layer["Domain services<br/>[service.go]"]
  node_peer_data["Peers and address books<br/>[addressBook.go]"]
  node_groups_tags["Groups and tags<br/>[group.go]"]
  node_share_data["Shares and logs<br/>[shareRecord.go]"]
  node_database[("Relational database<br/>[sqlite.go]")]
end

subgraph group_admin["Admin and operations"]
  node_admin_api["Admin API"]
  node_audit_ops["Audit and commands<br/>[audit.go]"]
  node_i18n["Translations<br/>[i18n.go]"]
end

subgraph group_client["Web client"]
  node_web_client_api["Web client config<br/>[webClient.go]"]
  node_web_static["Web client assets<br/>[main.ts]"]
  node_web_index["Web entry and config<br/>[index.go]"]
end

node_web_actor(("Web client user"))
node_pc_actor(("RustDesk PC client"))
node_admin_actor(("Admin user"))
node_oauth_provider(("OAuth provider"))
node_rustdesk_server(("RustDesk server"))

node_http_boot -->|"installs"| node_middleware
node_http_boot -->|"registers"| node_web_routes
node_http_boot -->|"registers"| node_admin_routes
node_http_boot -->|"registers"| node_api_routes
node_admin_routes -->|"routes to"| node_admin_api
node_web_routes -->|"routes to"| node_web_index
node_web_routes -->|"serves"| node_web_static
node_pc_actor -.->|"requests"| node_api_routes
node_admin_actor -->|"manages"| node_admin_routes
node_web_actor -->|"opens"| node_web_routes
node_api_routes -.->|"dispatches"| node_pc_api
node_pc_api -.->|"uses"| node_service_layer
node_admin_api -->|"uses"| node_service_layer
node_web_client_api -->|"loads peers"| node_service_layer
node_web_client_api -->|"formats payload"| node_peer_data
node_web_client_api -->|"returns settings"| node_rustdesk_server
node_service_layer -.->|"persists domain data"| node_database
node_service_layer -.->|"manages"| node_user_data
node_service_layer -.->|"manages"| node_peer_data
node_service_layer -.->|"manages"| node_groups_tags
node_service_layer -.->|"manages"| node_share_data
node_admin_api -.->|"supports"| node_audit_ops
node_users -.->|"authenticates with"| node_oauth_flow
node_users -.->|"authenticates with"| node_ldap_flow
node_oauth_flow -.->|"authorizes"| node_oauth_provider
node_web_index -.->|"configures client"| node_web_client_api
node_web_client_api -->|"resolves share"| node_share_data
node_admin_api -->|"translates messages"| node_i18n

click node_users "https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/api/login.go"
click node_api_routes "https://github.com/lejianwen/rustdesk-api/blob/master/http/router/api.go"
click node_admin_routes "https://github.com/lejianwen/rustdesk-api/blob/master/http/router/admin.go"
click node_web_routes "https://github.com/lejianwen/rustdesk-api/blob/master/http/router/router.go"
click node_http_boot "https://github.com/lejianwen/rustdesk-api/blob/master/http/http.go"
click node_middleware "https://github.com/lejianwen/rustdesk-api/tree/master/http/middleware"
click node_admin_api "https://github.com/lejianwen/rustdesk-api/tree/master/http/controller/admin"
click node_pc_api "https://github.com/lejianwen/rustdesk-api/tree/master/http/controller/api"
click node_web_client_api "https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/api/webClient.go"
click node_service_layer "https://github.com/lejianwen/rustdesk-api/blob/master/service/service.go"
click node_oauth_flow "https://github.com/lejianwen/rustdesk-api/blob/master/service/oauth.go"
click node_ldap_flow "https://github.com/lejianwen/rustdesk-api/blob/master/service/ldap.go"
click node_user_data "https://github.com/lejianwen/rustdesk-api/blob/master/model/user.go"
click node_peer_data "https://github.com/lejianwen/rustdesk-api/blob/master/model/addressBook.go"
click node_groups_tags "https://github.com/lejianwen/rustdesk-api/blob/master/model/group.go"
click node_share_data "https://github.com/lejianwen/rustdesk-api/blob/master/model/shareRecord.go"
click node_database "https://github.com/lejianwen/rustdesk-api/blob/master/lib/orm/sqlite.go"
click node_web_static "https://github.com/lejianwen/rustdesk-api/blob/master/resources/web/js/src/main.ts"
click node_web_index "https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/web/index.go"
click node_audit_ops "https://github.com/lejianwen/rustdesk-api/blob/master/service/audit.go"
click node_i18n "https://github.com/lejianwen/rustdesk-api/blob/master/global/i18n.go"

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_api_routes,node_admin_routes,node_web_routes,node_http_boot,node_middleware,node_web_actor,node_pc_actor,node_admin_actor toneBlue
class node_users,node_pc_api,node_oauth_flow,node_ldap_flow,node_user_data toneAmber
class node_service_layer,node_peer_data,node_groups_tags,node_share_data,node_database,node_rustdesk_server toneMint
class node_admin_api,node_audit_ops,node_i18n toneRose
class node_web_client_api,node_web_static,node_web_index,node_oauth_provider toneIndigo
```

## Components

### HTTP runtime

- [PC API routes](https://github.com/lejianwen/rustdesk-api/blob/master/http/router/api.go): `http/router/api.go`
- [Admin routes](https://github.com/lejianwen/rustdesk-api/blob/master/http/router/admin.go): `http/router/admin.go`
- [Web routes](https://github.com/lejianwen/rustdesk-api/blob/master/http/router/router.go): `http/router/router.go`
- [HTTP bootstrap](https://github.com/lejianwen/rustdesk-api/blob/master/http/http.go): `http/http.go`
- [Request middleware](https://github.com/lejianwen/rustdesk-api/tree/master/http/middleware): `http/middleware`

### Identity

- [PC API users](https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/api/login.go): `http/controller/api/login.go`
- [PC API](https://github.com/lejianwen/rustdesk-api/tree/master/http/controller/api): `http/controller/api`
- [OAuth providers](https://github.com/lejianwen/rustdesk-api/blob/master/service/oauth.go): `service/oauth.go`
- [LDAP login](https://github.com/lejianwen/rustdesk-api/blob/master/service/ldap.go): `service/ldap.go`
- [Users and tokens](https://github.com/lejianwen/rustdesk-api/blob/master/model/user.go): `model/user.go`

### RustDesk data

- [Domain services](https://github.com/lejianwen/rustdesk-api/blob/master/service/service.go): `service/service.go`
- [Peers and address books](https://github.com/lejianwen/rustdesk-api/blob/master/model/addressBook.go): `model/addressBook.go`
- [Groups and tags](https://github.com/lejianwen/rustdesk-api/blob/master/model/group.go): `model/group.go`
- [Shares and logs](https://github.com/lejianwen/rustdesk-api/blob/master/model/shareRecord.go): `model/shareRecord.go`
- [Relational database](https://github.com/lejianwen/rustdesk-api/blob/master/lib/orm/sqlite.go): `lib/orm/sqlite.go`

### Admin and operations

- [Admin API](https://github.com/lejianwen/rustdesk-api/tree/master/http/controller/admin): `http/controller/admin`
- [Audit and commands](https://github.com/lejianwen/rustdesk-api/blob/master/service/audit.go): `service/audit.go`
- [Translations](https://github.com/lejianwen/rustdesk-api/blob/master/global/i18n.go): `global/i18n.go`

### Web client

- [Web client config](https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/api/webClient.go): `http/controller/api/webClient.go`
- [Web client assets](https://github.com/lejianwen/rustdesk-api/blob/master/resources/web/js/src/main.ts): `resources/web/js/src/main.ts`
- [Web entry and config](https://github.com/lejianwen/rustdesk-api/blob/master/http/controller/web/index.go): `http/controller/web/index.go`

### Other components

- **Web client user**
- **RustDesk PC client**
- **Admin user**
- **OAuth provider**
- **RustDesk server**

## Connections

- HTTP bootstrap → Request middleware: installs (evidence: `http/http.go`)
- HTTP bootstrap → Web routes: registers (evidence: `http/http.go`)
- HTTP bootstrap → Admin routes: registers (evidence: `http/http.go`)
- HTTP bootstrap → PC API routes: registers (evidence: `http/http.go`)
- Admin routes → Admin API: routes to (evidence: `http/router/admin.go`)
- Web routes → Web entry and config: routes to (evidence: `http/router/router.go`)
- Web routes → Web client assets: serves (evidence: `http/router/router.go`)
- RustDesk PC client → PC API routes: requests (evidence: `README.md`)
- Admin user → Admin routes: manages (evidence: `http/router/admin.go`)
- Web client user → Web routes: opens (evidence: `http/router/router.go`)
- PC API routes → PC API: dispatches
- PC API → Domain services: uses
- Admin API → Domain services: uses (evidence: `http/controller/admin/oauth.go`)
- Web client config → Domain services: loads peers (evidence: `http/controller/api/webClient.go`)
- Web client config → Peers and address books: formats payload
- Web client config → RustDesk server: returns settings (evidence: `http/controller/api/webClient.go`)
- Domain services → Relational database: persists domain data
- Domain services → Users and tokens: manages
- Domain services → Peers and address books: manages
- Domain services → Groups and tags: manages
- Domain services → Shares and logs: manages
- Admin API → Audit and commands: supports
- PC API users → OAuth providers: authenticates with
- PC API users → LDAP login: authenticates with
- OAuth providers → OAuth provider: authorizes
- Web entry and config → Web client config: configures client
- Web client config → Shares and logs: resolves share (evidence: `http/controller/api/webClient.go`)
- Admin API → Translations: translates messages (evidence: `http/controller/admin/oauth.go`)
