# qiubrian/dns-client architecture

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

- Interactive diagram: https://gitdiagram.com/qiubrian/dns-client
- Repository: https://github.com/qiubrian/dns-client

## Overview

This is a command-line DNS lookup client: it accepts a hostname or IP and DNS server address, constructs a query, sends it over UDP, validates the reply, and prints decoded DNS records. The sampled code shows the network request and response-parsing stages, including name decoding and question/record parsing. The excerpts omit parts of the lookup orchestration, so those links are marked unverified rather than presented as confirmed calls.

Main entry points: [`main.cpp`](https://github.com/qiubrian/dns-client/blob/main/main.cpp) (UDP Query)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Lookup CLI"]
  node_entry["Argument Entry<br/>[main.cpp]"]
  node_lookup["Lookup Setup<br/>[main.cpp]"]
end

subgraph group_dns["DNS Query and Parsing"]
  node_query["UDP Query<br/>[main.cpp]"]
  node_response["Response Validation<br/>[main.cpp]"]
  node_questions["Question Parsing<br/>[main.cpp]"]
  node_records["Record Parsing<br/>[main.cpp]"]
  node_names["Name Decoding<br/>[main.cpp]"]
end

node_user(("CLI User"))
node_dnsserver(("DNS Server"))

node_user -.->|"provides arguments"| node_entry
node_entry -.->|"starts lookup"| node_lookup
node_lookup -.->|"dispatches query"| node_query
node_query -->|"sends UDP query"| node_dnsserver
node_query -->|"parses reply"| node_response
node_response -->|"parses questions"| node_questions
node_response -->|"parses sections"| node_records
node_questions -->|"decodes names"| node_names
node_records -->|"decodes names"| node_names

click node_entry "https://github.com/qiubrian/dns-client/blob/main/main.cpp"
click node_lookup "https://github.com/qiubrian/dns-client/blob/main/main.cpp"
click node_query "https://github.com/qiubrian/dns-client/blob/main/main.cpp"
click node_response "https://github.com/qiubrian/dns-client/blob/main/main.cpp"
click node_questions "https://github.com/qiubrian/dns-client/blob/main/main.cpp"
click node_records "https://github.com/qiubrian/dns-client/blob/main/main.cpp"
click node_names "https://github.com/qiubrian/dns-client/blob/main/main.cpp"

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_entry,node_lookup,node_user toneBlue
class node_query,node_response,node_questions,node_records,node_names toneAmber
class node_dnsserver toneMint
```

## Components

### Lookup CLI

- [Argument Entry](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`
- [Lookup Setup](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`

### DNS Query and Parsing

- [UDP Query](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`
- [Response Validation](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`
- [Question Parsing](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`
- [Record Parsing](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`
- [Name Decoding](https://github.com/qiubrian/dns-client/blob/main/main.cpp): `main.cpp`

### Other components

- **CLI User**
- **DNS Server**

## Connections

- CLI User → Argument Entry: provides arguments
- Argument Entry → Lookup Setup: starts lookup (evidence: `main.cpp`)
- Lookup Setup → UDP Query: dispatches query (evidence: `main.cpp`)
- UDP Query → DNS Server: sends UDP query (evidence: `main.cpp`)
- UDP Query → Response Validation: parses reply (evidence: `main.cpp`)
- Response Validation → Question Parsing: parses questions (evidence: `main.cpp`)
- Response Validation → Record Parsing: parses sections (evidence: `main.cpp`)
- Question Parsing → Name Decoding: decodes names (evidence: `main.cpp`)
- Record Parsing → Name Decoding: decodes names (evidence: `main.cpp`)
