# kazeyukiro/3m-ui architecture

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

- Interactive diagram: https://gitdiagram.com/kazeyukiro/3m-ui
- Repository: https://github.com/kazeyukiro/3m-ui

## Overview

3m-ui is a self-hosted Mihomo server management panel. An administrator signs in through the browser, then manages listeners, users, routing, subscriptions, traffic, cluster peers, and operations; the backend exposes REST APIs and configures the Mihomo core. The graph preserves these documented product branches, plus persistence and certificate handling. Source excerpts show application startup, frontend routing, and selected UI/API interactions; several backend service links and unsampled feature implementations are represented only at the level documented in the README.

Main entry points: [`backend/internal/router/router.go`](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/router/router.go) (Gin REST API), [`frontend/src/App.tsx`](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/App.tsx) (Admin pages), [`frontend/src/api/client.ts`](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/api/client.ts) (API client), [`backend/internal/database/database.go`](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/database/database.go) (SQLite database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Admin interface"]
  node_app["Admin pages<br/>[App.tsx]"]
  node_authui["Auth state<br/>[authStore.ts]"]
  node_api_client["API client<br/>[client.ts]"]
  node_listener_ui["Listener management<br/>[Listeners.tsx]"]
  node_users_ui["User management<br/>[Users.tsx]"]
  node_routing_ui["Routing editor<br/>[Routing.tsx]"]
  node_cluster_ui["Cluster management<br/>[Cluster.tsx]"]
  node_ops_ui["Operations pages<br/>[Settings.tsx]"]
end

subgraph group_api["Panel services"]
  node_http["Gin REST API<br/>[router.go]"]
  node_auth["Authentication<br/>[api.go]"]
  node_listeners["Listener service<br/>[service.go]"]
  node_users["User service<br/>[service.go]"]
  node_subscriptions["Subscription conversion<br/>[client.go]"]
  node_traffic["Traffic accounting<br/>[service.go]"]
  node_cluster["Cluster service<br/>[service.go]"]
  node_system["System operations<br/>[service.go]"]
  node_telegram["Telegram management<br/>[bot.go]"]
  node_server["Panel server<br/>[app.go]"]
end

subgraph group_proxy["Mihomo runtime"]
  node_routing["Routing config<br/>[server_routing.go]"]
  node_core["Mihomo manager<br/>[manager.go]"]
end

subgraph group_state["Persistent state"]
  node_database[("SQLite database<br/>[database.go]")]
  node_certs["Certificate store<br/>[store.go]"]
end

node_admin(("Administrator"))
node_mihomo["Mihomo core"]
node_telegram_service["Telegram service"]

node_admin -->|"uses"| node_app
node_app -->|"tracks session"| node_authui
node_app -->|"routes to"| node_listener_ui
node_app -->|"routes to"| node_users_ui
node_app -->|"routes to"| node_routing_ui
node_app -->|"routes to"| node_cluster_ui
node_app -->|"routes to"| node_ops_ui
node_listener_ui -->|"requests through"| node_api_client
node_users_ui -.->|"requests through"| node_api_client
node_routing_ui -->|"requests through"| node_api_client
node_cluster_ui -->|"requests through"| node_api_client
node_ops_ui -.->|"requests through"| node_api_client
node_api_client -->|"calls REST"| node_http
node_server -->|"mounts routes"| node_http
node_http -.->|"serves authentication"| node_auth
node_http -.->|"serves listener APIs"| node_listeners
node_http -.->|"serves user APIs"| node_users
node_http -->|"serves subscriptions"| node_subscriptions
node_http -.->|"serves traffic APIs"| node_traffic
node_http -.->|"serves cluster APIs"| node_cluster
node_http -->|"serves routing APIs"| node_routing
node_http -.->|"serves operations"| node_system
node_telegram_service -->|"provides bot"| node_telegram
node_listeners -->|"reads and writes"| node_database
node_users -->|"reads and writes"| node_database
node_traffic -.->|"persists usage"| node_database
node_cluster -->|"stores peers"| node_database
node_subscriptions -->|"loads user data"| node_database
node_listeners -.->|"uses certificates"| node_certs
node_server -->|"hydrates certificates"| node_certs
node_server -->|"starts panel runtime"| node_core
node_core -->|"manages core"| node_mihomo
node_routing -->|"loads routing data"| node_database
node_core -.->|"applies config"| node_routing
node_system -.->|"controls core"| node_core
node_server -.->|"integrates optionally"| node_telegram_service

click node_app "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/stores/authStore.ts"
click node_api_client "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/api/client.ts"
click node_listener_ui "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Listeners.tsx"
click node_users_ui "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Users.tsx"
click node_routing_ui "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Routing.tsx"
click node_cluster_ui "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Cluster.tsx"
click node_ops_ui "https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Settings.tsx"
click node_http "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/router/router.go"
click node_auth "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/auth/api.go"
click node_listeners "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/listener/service.go"
click node_users "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/user/service.go"
click node_subscriptions "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/converter/client.go"
click node_traffic "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/traffic/service.go"
click node_cluster "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/cluster/service.go"
click node_routing "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/mihomo/config/server_routing.go"
click node_core "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/mihomo/manager.go"
click node_system "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/system/service.go"
click node_telegram "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/telegram/bot.go"
click node_database "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/database/database.go"
click node_certs "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/certstore/store.go"
click node_server "https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/app/app.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_app,node_authui,node_api_client,node_listener_ui,node_users_ui,node_routing_ui,node_cluster_ui,node_ops_ui toneBlue
class node_http,node_auth,node_listeners,node_users,node_subscriptions,node_traffic,node_cluster,node_system,node_telegram,node_server toneAmber
class node_routing,node_core toneMint
class node_database,node_certs toneRose
class node_admin,node_mihomo,node_telegram_service toneIndigo
```

## Components

### Admin interface

- [Admin pages](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Auth state](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/stores/authStore.ts): `frontend/src/stores/authStore.ts`
- [API client](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Listener management](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Listeners.tsx): `frontend/src/pages/Listeners.tsx`
- [User management](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Users.tsx): `frontend/src/pages/Users.tsx`
- [Routing editor](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Routing.tsx): `frontend/src/pages/Routing.tsx`
- [Cluster management](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Cluster.tsx): `frontend/src/pages/Cluster.tsx`
- [Operations pages](https://github.com/kazeyukiro/3m-ui/blob/main/frontend/src/pages/Settings.tsx): `frontend/src/pages/Settings.tsx`

### Panel services

- [Gin REST API](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/router/router.go): `backend/internal/router/router.go`
- [Authentication](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/auth/api.go): `backend/internal/auth/api.go`
- [Listener service](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/listener/service.go): `backend/internal/listener/service.go`
- [User service](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/user/service.go): `backend/internal/user/service.go`
- [Subscription conversion](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/converter/client.go): `backend/internal/converter/client.go`
- [Traffic accounting](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/traffic/service.go): `backend/internal/traffic/service.go`
- [Cluster service](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/cluster/service.go): `backend/internal/cluster/service.go`
- [System operations](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/system/service.go): `backend/internal/system/service.go`
- [Telegram management](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/telegram/bot.go): `backend/internal/telegram/bot.go`
- [Panel server](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/app/app.go): `backend/internal/app/app.go`

### Mihomo runtime

- [Routing config](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/mihomo/config/server_routing.go): `backend/internal/mihomo/config/server_routing.go`
- [Mihomo manager](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/mihomo/manager.go): `backend/internal/mihomo/manager.go`

### Persistent state

- [SQLite database](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/database/database.go): `backend/internal/database/database.go`
- [Certificate store](https://github.com/kazeyukiro/3m-ui/blob/main/backend/internal/certstore/store.go): `backend/internal/certstore/store.go`

### Other components

- **Administrator**
- **Mihomo core**
- **Telegram service**

## Connections

- Administrator → Admin pages: uses
- Admin pages → Auth state: tracks session (evidence: `frontend/src/App.tsx`)
- Admin pages → Listener management: routes to (evidence: `frontend/src/App.tsx`)
- Admin pages → User management: routes to (evidence: `frontend/src/App.tsx`)
- Admin pages → Routing editor: routes to (evidence: `frontend/src/App.tsx`)
- Admin pages → Cluster management: routes to (evidence: `frontend/src/App.tsx`)
- Admin pages → Operations pages: routes to (evidence: `frontend/src/App.tsx`)
- Listener management → API client: requests through (evidence: `frontend/src/pages/Listeners.tsx`)
- User management → API client: requests through
- Routing editor → API client: requests through (evidence: `frontend/src/pages/Routing.tsx`)
- Cluster management → API client: requests through (evidence: `frontend/src/pages/Cluster.tsx`)
- Operations pages → API client: requests through
- API client → Gin REST API: calls REST
- Panel server → Gin REST API: mounts routes (evidence: `backend/internal/app/app.go`)
- Gin REST API → Authentication: serves authentication
- Gin REST API → Listener service: serves listener APIs
- Gin REST API → User service: serves user APIs
- Gin REST API → Subscription conversion: serves subscriptions
- Gin REST API → Traffic accounting: serves traffic APIs
- Gin REST API → Cluster service: serves cluster APIs
- Gin REST API → Routing config: serves routing APIs
- Gin REST API → System operations: serves operations
- Telegram service → Telegram management: provides bot
- Listener service → SQLite database: reads and writes (evidence: `backend/internal/listener/service.go`)
- User service → SQLite database: reads and writes (evidence: `backend/internal/user/service.go`)
- Traffic accounting → SQLite database: persists usage
- Cluster service → SQLite database: stores peers (evidence: `backend/internal/cluster/service.go`)
- Subscription conversion → SQLite database: loads user data (evidence: `backend/internal/converter/client.go`)
- Listener service → Certificate store: uses certificates
- Panel server → Certificate store: hydrates certificates (evidence: `backend/internal/app/app.go`)
- Panel server → Mihomo manager: starts panel runtime
- Mihomo manager → Mihomo core: manages core
- Routing config → SQLite database: loads routing data (evidence: `backend/internal/mihomo/config/server_routing.go`)
- Mihomo manager → Routing config: applies config
- System operations → Mihomo manager: controls core
- Panel server → Telegram service: integrates optionally
