# ahsaboy/magisk-netbird architecture

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

- Interactive diagram: https://gitdiagram.com/ahsaboy/magisk-netbird
- Repository: https://github.com/ahsaboy/magisk-netbird

## Overview

Magisk NetBird wraps the official NetBird daemon for Android. The main workflow is installing the module, configuring it, joining a network through the service command, and maintaining connectivity and status across reboots and network changes. The graph also preserves documented CA trust, resolver, ACTION-button, and uninstall behavior. Source excerpts were unavailable, so relationships are limited to those stated in the README; the daemon binary is represented by its existing enclosing directory.

Main entry points: [`netbird`](https://github.com/ahsaboy/magisk-netbird/tree/main/netbird) (NetBird daemon), [`netbird/scripts/netbird.service`](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/netbird.service) (Service commands), [`netbird/scripts/module-status.sh`](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/module-status.sh) (Status watcher), [`action.sh`](https://github.com/ahsaboy/magisk-netbird/blob/main/action.sh) (ACTION refresh)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_install["Module setup"]
  node_installer["Magisk installer"]
  node_customize["Install customization<br/>[customize.sh]"]
end

subgraph group_runtime["NetBird runtime"]
  node_settings["Runtime settings<br/>[settings.sh]"]
  node_envfile["Environment template"]
  node_servicecmd["Service commands<br/>[netbird.service]"]
  node_bootservice["Boot service<br/>[service.sh]"]
  node_daemon["NetBird daemon"]
  node_state[("Daemon state")]
  node_management["NetBird management"]
end

subgraph group_maintenance["Status and maintenance"]
  node_statuswatch["Status watcher<br/>[module-status.sh]"]
  node_action["ACTION refresh<br/>[action.sh]"]
  node_catrust["Custom CA trust<br/>[cert-trust.sh]"]
  node_uninstall["Rule cleanup<br/>[uninstall.sh]"]
  node_modulemeta["Dynamic module status<br/>[module.prop]"]
end

subgraph group_platform["Android platform"]
  node_androidnet["Android networking"]
  node_resolver["Linux resolver config<br/>[resolv.conf]"]
  node_certstore[("User CA certificates")]
end

node_operator(("Root operator"))

node_operator -->|"runs commands"| node_servicecmd
node_installer -.->|"installs module"| node_customize
node_customize -.->|"installs binaries"| node_daemon
node_servicecmd -->|"loads defaults"| node_settings
node_servicecmd -->|"loads overrides"| node_envfile
node_servicecmd -->|"controls daemon"| node_daemon
node_bootservice -.->|"starts daemon"| node_daemon
node_daemon -->|"stores state"| node_state
node_daemon -->|"connects to"| node_management
node_daemon -->|"uses resolver"| node_resolver
node_action -->|"refreshes trust"| node_catrust
node_action -->|"refreshes rules"| node_androidnet
node_action -->|"prints status"| node_servicecmd
node_catrust -->|"loads certificates"| node_certstore
node_statuswatch -->|"probes and restarts"| node_daemon
node_statuswatch -->|"reapplies route rule"| node_androidnet
node_statuswatch -->|"refreshes status"| node_modulemeta
node_uninstall -->|"removes added rules"| node_androidnet

click node_installer "https://github.com/ahsaboy/magisk-netbird/blob/main/META-INF/com/google/android/update-binary"
click node_customize "https://github.com/ahsaboy/magisk-netbird/blob/main/customize.sh"
click node_settings "https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/settings.sh"
click node_envfile "https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/netbird.env.example"
click node_servicecmd "https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/netbird.service"
click node_bootservice "https://github.com/ahsaboy/magisk-netbird/blob/main/service.sh"
click node_daemon "https://github.com/ahsaboy/magisk-netbird/tree/main/netbird"
click node_statuswatch "https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/module-status.sh"
click node_action "https://github.com/ahsaboy/magisk-netbird/blob/main/action.sh"
click node_catrust "https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/cert-trust.sh"
click node_uninstall "https://github.com/ahsaboy/magisk-netbird/blob/main/uninstall.sh"
click node_modulemeta "https://github.com/ahsaboy/magisk-netbird/blob/main/module.prop"
click node_resolver "https://github.com/ahsaboy/magisk-netbird/blob/main/system/etc/resolv.conf"

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_installer,node_customize toneBlue
class node_settings,node_envfile,node_servicecmd,node_bootservice,node_daemon,node_state,node_management toneAmber
class node_statuswatch,node_action,node_catrust,node_uninstall,node_modulemeta toneMint
class node_androidnet,node_resolver,node_certstore toneRose
class node_operator toneIndigo
```

## Components

### Module setup

- [Magisk installer](https://github.com/ahsaboy/magisk-netbird/blob/main/META-INF/com/google/android/update-binary): `META-INF/com/google/android/update-binary`
- [Install customization](https://github.com/ahsaboy/magisk-netbird/blob/main/customize.sh): `customize.sh`

### NetBird runtime

- [Runtime settings](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/settings.sh): `netbird/settings.sh`
- [Environment template](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/netbird.env.example): `netbird/netbird.env.example`
- [Service commands](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/netbird.service): `netbird/scripts/netbird.service`
- [Boot service](https://github.com/ahsaboy/magisk-netbird/blob/main/service.sh): `service.sh`
- [NetBird daemon](https://github.com/ahsaboy/magisk-netbird/tree/main/netbird): `netbird`
- **Daemon state**
- **NetBird management**

### Status and maintenance

- [Status watcher](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/module-status.sh): `netbird/scripts/module-status.sh`
- [ACTION refresh](https://github.com/ahsaboy/magisk-netbird/blob/main/action.sh): `action.sh`
- [Custom CA trust](https://github.com/ahsaboy/magisk-netbird/blob/main/netbird/scripts/cert-trust.sh): `netbird/scripts/cert-trust.sh`
- [Rule cleanup](https://github.com/ahsaboy/magisk-netbird/blob/main/uninstall.sh): `uninstall.sh`
- [Dynamic module status](https://github.com/ahsaboy/magisk-netbird/blob/main/module.prop): `module.prop`

### Android platform

- **Android networking**
- [Linux resolver config](https://github.com/ahsaboy/magisk-netbird/blob/main/system/etc/resolv.conf): `system/etc/resolv.conf`
- **User CA certificates**

### Other components

- **Root operator**

## Connections

- Root operator → Service commands: runs commands (evidence: `README.md`)
- Magisk installer → Install customization: installs module
- Install customization → NetBird daemon: installs binaries
- Service commands → Runtime settings: loads defaults (evidence: `README.md`)
- Service commands → Environment template: loads overrides (evidence: `README.md`)
- Service commands → NetBird daemon: controls daemon (evidence: `README.md`)
- Boot service → NetBird daemon: starts daemon
- NetBird daemon → Daemon state: stores state (evidence: `README.md`)
- NetBird daemon → NetBird management: connects to (evidence: `README.md`)
- NetBird daemon → Linux resolver config: uses resolver (evidence: `README.md`)
- ACTION refresh → Custom CA trust: refreshes trust (evidence: `README.md`)
- ACTION refresh → Android networking: refreshes rules (evidence: `README.md`)
- ACTION refresh → Service commands: prints status (evidence: `README.md`)
- Custom CA trust → User CA certificates: loads certificates (evidence: `README.md`)
- Status watcher → NetBird daemon: probes and restarts (evidence: `README.md`)
- Status watcher → Android networking: reapplies route rule (evidence: `README.md`)
- Status watcher → Dynamic module status: refreshes status (evidence: `README.md`)
- Rule cleanup → Android networking: removes added rules (evidence: `README.md`)
