# duoluo1234/routeros-cn-panel architecture

> Architecture diagram of the GitHub repository duoluo1234/routeros-cn-panel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/duoluo1234/routeros-cn-panel
- Repository: https://github.com/duoluo1234/routeros-cn-panel

## Overview

RouterOS 中文管理面板 is a Go web application for viewing and safely managing RouterOS devices through a bundled browser UI. The principal workflow is browser login, authenticated API access, then reading overview or resource data and submitting validated changes; writes are recorded for audit and can be reverted. Separate capabilities include bulk import, device actions, Mangle grouping, and live WAN rates. The excerpts establish the HTTP handlers, REST client, resource validation, journal, and rate collection; some UI wiring and handler internals are not shown, so documented API relationships use README evidence.

Main entry points: [`main.go`](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go) (HTTP application), [`ros.go`](https://github.com/duoluo1234/routeros-cn-panel/blob/main/ros.go) (REST client), [`snmp.go`](https://github.com/duoluo1234/routeros-cn-panel/blob/main/snmp.go) (WAN rate collection), [`static/index.html`](https://github.com/duoluo1234/routeros-cn-panel/blob/main/static/index.html) (Management UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_browser["Management UI<br/>[index.html]"]
end

subgraph group_api["API workflows"]
  node_server["HTTP application<br/>[main.go]"]
  node_sessions["Login sessions<br/>[main.go]"]
  node_resource_api["Resource listing and CRUD<br/>[main.go]"]
  node_overview["Overview dashboard<br/>[main.go]"]
  node_bulk["Bulk import<br/>[main.go]"]
  node_actions["Device actions<br/>[main.go]"]
  node_mangle["Mangle grouping<br/>[main.go]"]
  node_registry["Resource registry and validation<br/>[schema.go]"]
  node_extended["IPv6 and routing resources<br/>[resources_ext.go]"]
end

subgraph group_ros["RouterOS access"]
  node_rosclient["REST client<br/>[ros.go]"]
  node_routeros["RouterOS device"]
end

subgraph group_telemetry["Telemetry and audit"]
  node_rates["WAN rate collection<br/>[snmp.go]"]
  node_journal[("Change journal<br/>[journal.go]")]
  node_version["Version compatibility check<br/>[rosversion.go]"]
end

node_operator(("Operator"))
node_snmp["SNMP service"]
node_wanlab["External rate source"]

node_operator -->|"uses"| node_browser
node_browser -->|"calls API"| node_server
node_server -->|"authenticates"| node_sessions
node_server -->|"routes overview"| node_overview
node_server -->|"routes list and writes"| node_resource_api
node_server -->|"routes import"| node_bulk
node_server -->|"routes actions"| node_actions
node_server -->|"routes grouping"| node_mangle
node_resource_api -->|"validates resources"| node_registry
node_registry -->|"registers resources"| node_extended
node_overview -->|"reads device data"| node_rosclient
node_resource_api -->|"reads and writes"| node_rosclient
node_bulk -->|"writes rows"| node_rosclient
node_actions -->|"executes commands"| node_rosclient
node_mangle -.->|"reads rules"| node_rosclient
node_rosclient -->|"REST requests"| node_routeros
node_resource_api -->|"records changes"| node_journal
node_server -->|"lists and reverts"| node_journal
node_overview -->|"gets interface rates"| node_rates
node_rates -->|"queries counters"| node_snmp
node_rates -.->|"requests rates"| node_wanlab
node_rates -->|"fallback counters"| node_rosclient
node_overview -->|"checks compatibility"| node_version
node_version -->|"reads system version"| node_rosclient

click node_browser "https://github.com/duoluo1234/routeros-cn-panel/blob/main/static/index.html"
click node_server "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_sessions "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_resource_api "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_overview "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_bulk "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_actions "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_mangle "https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go"
click node_registry "https://github.com/duoluo1234/routeros-cn-panel/blob/main/schema.go"
click node_extended "https://github.com/duoluo1234/routeros-cn-panel/blob/main/resources_ext.go"
click node_rosclient "https://github.com/duoluo1234/routeros-cn-panel/blob/main/ros.go"
click node_rates "https://github.com/duoluo1234/routeros-cn-panel/blob/main/snmp.go"
click node_journal "https://github.com/duoluo1234/routeros-cn-panel/blob/main/journal.go"
click node_version "https://github.com/duoluo1234/routeros-cn-panel/blob/main/rosversion.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_browser toneBlue
class node_server,node_sessions,node_resource_api,node_overview,node_bulk,node_actions,node_mangle,node_registry,node_extended toneAmber
class node_rosclient,node_routeros toneMint
class node_rates,node_journal,node_version toneRose
class node_operator,node_snmp,node_wanlab toneIndigo
```

## Components

### Web interface

- [Management UI](https://github.com/duoluo1234/routeros-cn-panel/blob/main/static/index.html): `static/index.html`

### API workflows

- [HTTP application](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Login sessions](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Resource listing and CRUD](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Overview dashboard](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Bulk import](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Device actions](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Mangle grouping](https://github.com/duoluo1234/routeros-cn-panel/blob/main/main.go): `main.go`
- [Resource registry and validation](https://github.com/duoluo1234/routeros-cn-panel/blob/main/schema.go): `schema.go`
- [IPv6 and routing resources](https://github.com/duoluo1234/routeros-cn-panel/blob/main/resources_ext.go): `resources_ext.go`

### RouterOS access

- [REST client](https://github.com/duoluo1234/routeros-cn-panel/blob/main/ros.go): `ros.go`
- **RouterOS device**

### Telemetry and audit

- [WAN rate collection](https://github.com/duoluo1234/routeros-cn-panel/blob/main/snmp.go): `snmp.go`
- [Change journal](https://github.com/duoluo1234/routeros-cn-panel/blob/main/journal.go): `journal.go`
- [Version compatibility check](https://github.com/duoluo1234/routeros-cn-panel/blob/main/rosversion.go): `rosversion.go`

### Other components

- **Operator**
- **SNMP service**
- **External rate source**

## Connections

- Operator → Management UI: uses (evidence: `README.md`)
- Management UI → HTTP application: calls API (evidence: `README.md`)
- HTTP application → Login sessions: authenticates (evidence: `main.go`)
- HTTP application → Overview dashboard: routes overview (evidence: `README.md`)
- HTTP application → Resource listing and CRUD: routes list and writes (evidence: `README.md`)
- HTTP application → Bulk import: routes import (evidence: `README.md`)
- HTTP application → Device actions: routes actions (evidence: `README.md`)
- HTTP application → Mangle grouping: routes grouping (evidence: `README.md`)
- Resource listing and CRUD → Resource registry and validation: validates resources (evidence: `main.go`)
- Resource registry and validation → IPv6 and routing resources: registers resources (evidence: `resources_ext.go`)
- Overview dashboard → REST client: reads device data (evidence: `main.go`)
- Resource listing and CRUD → REST client: reads and writes (evidence: `main.go`)
- Bulk import → REST client: writes rows (evidence: `README.md`)
- Device actions → REST client: executes commands (evidence: `main.go`)
- Mangle grouping → REST client: reads rules
- REST client → RouterOS device: REST requests (evidence: `ros.go`)
- Resource listing and CRUD → Change journal: records changes (evidence: `main.go`)
- HTTP application → Change journal: lists and reverts (evidence: `README.md`)
- Overview dashboard → WAN rate collection: gets interface rates (evidence: `main.go`)
- WAN rate collection → SNMP service: queries counters (evidence: `snmp.go`)
- WAN rate collection → External rate source: requests rates (evidence: `snmp.go`)
- WAN rate collection → REST client: fallback counters
- Overview dashboard → Version compatibility check: checks compatibility (evidence: `main.go`)
- Version compatibility check → REST client: reads system version (evidence: `rosversion.go`)
