# abh/geodns architecture

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

- Interactive diagram: https://gitdiagram.com/abh/geodns
- Repository: https://github.com/abh/geodns

## Overview

GeoDNS is an authoritative DNS server for geographically targeted responses. Its main path is DNS client request → server dispatch → zone label selection using client IP/ECS and geographic targeting → DNS response; zones are loaded and refreshed from JSON files. The graph also preserves the documented HTTP/Prometheus interface, query logging, and health checks. Edges are limited to calls visible in excerpts or relationships explicitly documented in the README; unsampled subsystem internals are represented only where their source paths are supported.

Main entry points: [`geodns.go`](https://github.com/abh/geodns/blob/main/geodns.go) (Process bootstrap), [`server/serve.go`](https://github.com/abh/geodns/blob/main/server/serve.go) (Request resolution), [`server/server.go`](https://github.com/abh/geodns/blob/main/server/server.go) (DNS listener and mux), [`zones/muxmanager.go`](https://github.com/abh/geodns/blob/main/zones/muxmanager.go) (Zone reload manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["DNS runtime"]
  node_bootstrap["Process bootstrap<br/>[geodns.go]"]
  node_dnsserver["DNS listener and mux<br/>[server.go]"]
  node_request["Request resolution<br/>[serve.go]"]
  node_edns["EDNS handling<br/>[edns.go]"]
end

subgraph group_zones["Zone management"]
  node_zone["Zone selection<br/>[zone.go]"]
  node_zonefile["Zone file parser<br/>[reader.go]"]
  node_zonemgr["Zone reload manager<br/>[muxmanager.go]"]
  node_picker["Record picker<br/>[picker.go]"]
end

subgraph group_geo["Geo targeting"]
  node_targeting["Target calculation<br/>[targeting.go]"]
  node_geoip["GeoIP provider<br/>[geoip2.go]"]
  node_geoprovider["Geo provider API<br/>[geo.go]"]
end

subgraph group_ops["Operations"]
  node_health["Health testing<br/>[healthtest.go]"]
  node_healthchecks["Health test types<br/>[healthtesters.go]"]
  node_healthstatus["Health status<br/>[status.go]"]
  node_querylog["Query logging<br/>[querylog.go]"]
  node_avrolog["Avro output<br/>[avro.go]"]
  node_http["HTTP interface<br/>[http.go]"]
  node_metrics["Prometheus metrics<br/>[server.go]"]
  node_config["Runtime configuration<br/>[appconfig.go]"]
end

node_client(("DNS client"))
node_geoipdb[("GeoIP databases")]

node_client -->|"sends query"| node_dnsserver
node_dnsserver -->|"dispatches"| node_request
node_request -->|"checks EDNS"| node_edns
node_request -.->|"selects records"| node_zone
node_request -->|"gets targets"| node_targeting
node_targeting -->|"looks up location"| node_geoprovider
node_geoprovider -.->|"implemented by"| node_geoip
node_geoip -.->|"reads databases"| node_geoipdb
node_bootstrap -->|"starts"| node_dnsserver
node_bootstrap -->|"starts reloads"| node_zonemgr
node_zonemgr -.->|"parses zones"| node_zonefile
node_zonemgr -->|"registers zones"| node_dnsserver
node_zone -.->|"selects records"| node_picker
node_bootstrap -->|"initializes provider"| node_geoip
node_bootstrap -->|"reads settings"| node_config
node_bootstrap -->|"configures logger"| node_querylog
node_request -->|"records queries"| node_querylog
node_querylog -.->|"writes Avro"| node_avrolog
node_request -->|"serves health answers"| node_health
node_health -.->|"uses testers"| node_healthchecks
node_health -.->|"updates status"| node_healthstatus
node_bootstrap -->|"starts interface"| node_http
node_http -->|"serves metrics"| node_metrics
node_dnsserver -->|"records counters"| node_metrics

click node_bootstrap "https://github.com/abh/geodns/blob/main/geodns.go"
click node_dnsserver "https://github.com/abh/geodns/blob/main/server/server.go"
click node_request "https://github.com/abh/geodns/blob/main/server/serve.go"
click node_edns "https://github.com/abh/geodns/blob/main/edns/edns.go"
click node_zone "https://github.com/abh/geodns/blob/main/zones/zone.go"
click node_zonefile "https://github.com/abh/geodns/blob/main/zones/reader.go"
click node_zonemgr "https://github.com/abh/geodns/blob/main/zones/muxmanager.go"
click node_picker "https://github.com/abh/geodns/blob/main/zones/picker.go"
click node_targeting "https://github.com/abh/geodns/blob/main/targeting/targeting.go"
click node_geoip "https://github.com/abh/geodns/blob/main/targeting/geoip2/geoip2.go"
click node_geoprovider "https://github.com/abh/geodns/blob/main/targeting/geo/geo.go"
click node_health "https://github.com/abh/geodns/blob/main/health/healthtest/healthtest.go"
click node_healthchecks "https://github.com/abh/geodns/blob/main/health/healthtest/healthtesters.go"
click node_healthstatus "https://github.com/abh/geodns/blob/main/health/status.go"
click node_querylog "https://github.com/abh/geodns/blob/main/querylog/querylog.go"
click node_avrolog "https://github.com/abh/geodns/blob/main/querylog/avro.go"
click node_http "https://github.com/abh/geodns/blob/main/http.go"
click node_metrics "https://github.com/abh/geodns/blob/main/server/server.go"
click node_config "https://github.com/abh/geodns/blob/main/appconfig/appconfig.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_bootstrap,node_dnsserver,node_request,node_edns,node_client toneBlue
class node_zone,node_zonefile,node_zonemgr,node_picker,node_geoipdb toneAmber
class node_targeting,node_geoip,node_geoprovider toneMint
class node_health,node_healthchecks,node_healthstatus,node_querylog,node_avrolog,node_http,node_metrics,node_config toneRose
```

## Components

### DNS runtime

- [Process bootstrap](https://github.com/abh/geodns/blob/main/geodns.go): `geodns.go`
- [DNS listener and mux](https://github.com/abh/geodns/blob/main/server/server.go): `server/server.go`
- [Request resolution](https://github.com/abh/geodns/blob/main/server/serve.go): `server/serve.go`
- [EDNS handling](https://github.com/abh/geodns/blob/main/edns/edns.go): `edns/edns.go`

### Zone management

- [Zone selection](https://github.com/abh/geodns/blob/main/zones/zone.go): `zones/zone.go`
- [Zone file parser](https://github.com/abh/geodns/blob/main/zones/reader.go): `zones/reader.go`
- [Zone reload manager](https://github.com/abh/geodns/blob/main/zones/muxmanager.go): `zones/muxmanager.go`
- [Record picker](https://github.com/abh/geodns/blob/main/zones/picker.go): `zones/picker.go`

### Geo targeting

- [Target calculation](https://github.com/abh/geodns/blob/main/targeting/targeting.go): `targeting/targeting.go`
- [GeoIP provider](https://github.com/abh/geodns/blob/main/targeting/geoip2/geoip2.go): `targeting/geoip2/geoip2.go`
- [Geo provider API](https://github.com/abh/geodns/blob/main/targeting/geo/geo.go): `targeting/geo/geo.go`

### Operations

- [Health testing](https://github.com/abh/geodns/blob/main/health/healthtest/healthtest.go): `health/healthtest/healthtest.go`
- [Health test types](https://github.com/abh/geodns/blob/main/health/healthtest/healthtesters.go): `health/healthtest/healthtesters.go`
- [Health status](https://github.com/abh/geodns/blob/main/health/status.go): `health/status.go`
- [Query logging](https://github.com/abh/geodns/blob/main/querylog/querylog.go): `querylog/querylog.go`
- [Avro output](https://github.com/abh/geodns/blob/main/querylog/avro.go): `querylog/avro.go`
- [HTTP interface](https://github.com/abh/geodns/blob/main/http.go): `http.go`
- [Prometheus metrics](https://github.com/abh/geodns/blob/main/server/server.go): `server/server.go`
- [Runtime configuration](https://github.com/abh/geodns/blob/main/appconfig/appconfig.go): `appconfig/appconfig.go`

### Other components

- **DNS client**
- **GeoIP databases**

## Connections

- DNS client → DNS listener and mux: sends query (evidence: `README.md`)
- DNS listener and mux → Request resolution: dispatches (evidence: `server/server.go`)
- Request resolution → EDNS handling: checks EDNS (evidence: `server/serve.go`)
- Request resolution → Zone selection: selects records
- Request resolution → Target calculation: gets targets (evidence: `server/serve.go`)
- Target calculation → Geo provider API: looks up location (evidence: `targeting/targeting.go`)
- Geo provider API → GeoIP provider: implemented by
- GeoIP provider → GeoIP databases: reads databases
- Process bootstrap → DNS listener and mux: starts (evidence: `geodns.go`)
- Process bootstrap → Zone reload manager: starts reloads (evidence: `geodns.go`)
- Zone reload manager → Zone file parser: parses zones
- Zone reload manager → DNS listener and mux: registers zones (evidence: `zones/muxmanager.go`)
- Zone selection → Record picker: selects records
- Process bootstrap → GeoIP provider: initializes provider (evidence: `geodns.go`)
- Process bootstrap → Runtime configuration: reads settings (evidence: `geodns.go`)
- Process bootstrap → Query logging: configures logger (evidence: `geodns.go`)
- Request resolution → Query logging: records queries (evidence: `server/serve.go`)
- Query logging → Avro output: writes Avro
- Request resolution → Health testing: serves health answers (evidence: `server/serve.go`)
- Health testing → Health test types: uses testers
- Health testing → Health status: updates status
- Process bootstrap → HTTP interface: starts interface (evidence: `geodns.go`)
- HTTP interface → Prometheus metrics: serves metrics (evidence: `http.go`)
- DNS listener and mux → Prometheus metrics: records counters (evidence: `server/server.go`)
