# darcas/smart-dns-promises architecture

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

- Interactive diagram: https://gitdiagram.com/darcas/smart-dns-promises
- Repository: https://github.com/darcas/smart-dns-promises

## Overview

SmartDns is a small Node.js DNS-resolution library. Its principal workflow is to configure the process-wide resolver, resolve a URL’s hostname, and return the resolved address and rewritten URL; caching and lookup statistics support that workflow. The runtime implementation is concentrated in `src/index.ts`. The source excerpt was not provided, so the internal component boundaries and calls below rely on README descriptions rather than inspected implementation details.

Main entry points: [`src/index.ts`](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts) (URL resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Application"))
node_factory["Singleton factory<br/>[index.ts]"]
node_dnsconfig["DNS configuration<br/>[index.ts]"]
node_dns["Node DNS"]
node_resolver["URL resolver<br/>[index.ts]"]
node_cache[("Lookup cache<br/>[index.ts]")]
node_stats["Lookup statistics<br/>[index.ts]"]
node_provider["DNS providers<br/>[index.ts]"]
node_httpclients["HTTP clients"]

node_caller -->|"creates instance"| node_factory
node_caller -->|"resolves URL"| node_resolver
node_caller -->|"sets servers"| node_dnsconfig
node_dnsconfig -->|"configures process"| node_dns
node_provider -->|"selects servers"| node_dnsconfig
node_resolver -.->|"uses caching"| node_cache
node_resolver -.->|"looks up hostname"| node_dns
node_resolver -.->|"updates counters"| node_stats
node_dns -->|"serves lookups"| node_httpclients

click node_factory "https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts"
click node_dnsconfig "https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts"
click node_resolver "https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts"
click node_cache "https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts"
click node_stats "https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts"
click node_provider "https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts"

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_caller,node_dns,node_provider toneIndigo
class node_factory,node_dnsconfig,node_resolver,node_stats toneTeal
class node_cache toneAmber
class node_httpclients toneBlue
```

## Components

### Other components

- **Application**
- [Singleton factory](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts): `src/index.ts`
- [DNS configuration](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts): `src/index.ts`
- **Node DNS**
- [URL resolver](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts): `src/index.ts`
- [Lookup cache](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts): `src/index.ts`
- [Lookup statistics](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts): `src/index.ts`
- [DNS providers](https://github.com/darcas/smart-dns-promises/blob/master/src/index.ts): `src/index.ts`
- **HTTP clients**

## Connections

- Application → Singleton factory: creates instance (evidence: `README.md`)
- Application → URL resolver: resolves URL (evidence: `README.md`)
- Application → DNS configuration: sets servers (evidence: `README.md`)
- DNS configuration → Node DNS: configures process (evidence: `README.md`)
- DNS providers → DNS configuration: selects servers (evidence: `README.md`)
- URL resolver → Lookup cache: uses caching (evidence: `src/index.ts`)
- URL resolver → Node DNS: looks up hostname
- URL resolver → Lookup statistics: updates counters (evidence: `src/index.ts`)
- Node DNS → HTTP clients: serves lookups (evidence: `README.md`)
