# tongtf/alidns-ddns architecture

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

- Interactive diagram: https://gitdiagram.com/tongtf/alidns-ddns
- Repository: https://github.com/tongtf/alidns-ddns

## Overview

alidns-ddns is a single-file Rust dynamic DNS client for Aliyun. Its workflow resolves settings, periodically detects IPv4 and/or IPv6 changes, queries the matching DNS records, and updates or adds records through Aliyun’s signed API. The README documents the IPv6 selection policy and supported modes; sampled code confirms configuration resolution, ipify lookup, and API request/reconciliation behavior. The excerpt omits some runtime-loop and IPv6 implementation details, so those links follow documented behavior rather than inspected call sites.

Main entry points: [`src/main.rs`](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs) (Runtime loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_configuration["Configuration"]
  node_cli["CLI arguments"]
  node_environment["Environment"]
  node_configfile["Config file"]
  node_entry["Runtime loop<br/>[main.rs]"]
  node_resolve["Config resolution<br/>[main.rs]"]
end

subgraph group_address["IP Detection"]
  node_ipv4["IPv4 detection<br/>[main.rs]"]
  node_ipv6["IPv6 selection<br/>[main.rs]"]
end

subgraph group_dns["DNS Updates"]
  node_reconcile["Record reconciliation<br/>[main.rs]"]
  node_api["Signed API client<br/>[main.rs]"]
end

node_user(("Operator"))
node_ipify(("ipify API"))
node_interfaces(("Local interfaces"))
node_aliyun(("Aliyun DNS API"))

node_user -->|"provides options"| node_cli
node_user -->|"provides settings"| node_configfile
node_user -->|"sets variables"| node_environment
node_entry -->|"loads settings"| node_resolve
node_cli -->|"overrides"| node_resolve
node_environment -->|"supplies values"| node_resolve
node_configfile -->|"supplies values"| node_resolve
node_entry -->|"detects address"| node_ipv4
node_entry -->|"detects address"| node_ipv6
node_ipv4 -->|"requests IPv4"| node_ipify
node_ipv6 -->|"enumerates addresses"| node_interfaces
node_entry -->|"checks records"| node_reconcile
node_reconcile -->|"queries or mutates"| node_api
node_api -->|"sends signed requests"| node_aliyun

click node_entry "https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs"
click node_resolve "https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs"
click node_ipv4 "https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs"
click node_ipv6 "https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs"
click node_reconcile "https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs"
click node_api "https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs"

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_cli,node_environment,node_configfile,node_entry,node_resolve toneBlue
class node_ipv4,node_ipv6 toneAmber
class node_reconcile,node_api,node_ipify,node_aliyun toneMint
class node_user,node_interfaces toneIndigo
```

## Components

### Configuration

- **CLI arguments**
- **Environment**
- **Config file**
- [Runtime loop](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs): `src/main.rs`
- [Config resolution](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs): `src/main.rs`

### IP Detection

- [IPv4 detection](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs): `src/main.rs`
- [IPv6 selection](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs): `src/main.rs`

### DNS Updates

- [Record reconciliation](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs): `src/main.rs`
- [Signed API client](https://github.com/tongtf/alidns-ddns/blob/main/src/main.rs): `src/main.rs`

### Other components

- **Operator**
- **ipify API**
- **Local interfaces**
- **Aliyun DNS API**

## Connections

- Operator → CLI arguments: provides options
- Operator → Config file: provides settings
- Operator → Environment: sets variables
- Runtime loop → Config resolution: loads settings
- CLI arguments → Config resolution: overrides
- Environment → Config resolution: supplies values
- Config file → Config resolution: supplies values
- Runtime loop → IPv4 detection: detects address
- Runtime loop → IPv6 selection: detects address
- IPv4 detection → ipify API: requests IPv4
- IPv6 selection → Local interfaces: enumerates addresses
- Runtime loop → Record reconciliation: checks records
- Record reconciliation → Signed API client: queries or mutates
- Signed API client → Aliyun DNS API: sends signed requests
