# manoj-kr24/domain-name-system architecture

> Architecture diagram of the GitHub repository manoj-kr24/domain-name-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manoj-kr24/domain-name-system
- Repository: https://github.com/manoj-kr24/domain-name-system

## Overview

##### Project type and purpose
- This is a Python-based client-server DNS simulation tool with three primary roles:
- DNS Server (dnsServer.py) – hosts and resolves records
- DNS Client/Resolver (resolver.py) – sends lookup queries
- DNS Manager (dnsManager.py) – adds/removes records
- It uses plain‐text files (domains_databaseIPV4.txt, domains_databaseIPV6.txt) as persistent storage of DNS records.

##### File structure
- Top level:
- dnsServer.py – server process listening on a socket, loading/storing the “DNS tree”
- resolver.py – client process issuing queries over sockets
- dnsManager.py – client/process issuing management commands
- domains_databaseIPV4.txt & domains_databaseIPV6.txt – backing stores for A and AAAA records
- README.md – project description and usage
- No hidden subdirectories or microservices: a classic single‐node client‐server application.

##### README for additional insights
- Networking via Python’s socket library
- In-memory DNS tree built on startup from the text files
- Supports add/remove operations by the manager, which updates both in-memory tree and text file
- Future enhancements: caching, error handling, GUI

a. Main components to show:
- DNS Client/Resolver
- DNS Server
- DNS Manager
- Persistent Storage
- (Optional) In-memory DNS Tree inside the server
b. Relationships and interactions:
- Resolver → Server: “DNS_QUERY” over TCP/UDP
- Server → Resolver: “DNS_RESPONSE”
- Manager → Server: “ADD_RECORD” / “REMOVE_RECORD”
- Server ↔ Persistent Storage: read on startup, write on updates
c. Architectural patterns and principles:
- Client-Server model (single server instance)
- Separation of concerns: resolution vs. management vs. storage
- Single source of truth for DNS records in text files and in-memory tree
d. Key technologies and libraries:
- Python 3.x
- socket (network I/O)
- Custom tree data structure for DNS zones
- Plain-text flat files for persistence

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Clients"
        DNS_Resolver["DNS Client/Resolver"]:::network
        DNS_Manager["DNS Manager"]:::network
    end

    DNS_Resolver -->|"QUERY(name)\nUDP:53"| Network[(Network)]:::network_boundary
    DNS_Manager -->|"UPDATE(command)\nTCP:5300"| Network

    subgraph "Server"
        direction TB
        DNS_Server["DNS Server"]:::server
        subgraph "Server Subsystems"
            direction TB
            InMemory["In-memory DNS Tree"]:::internal
            Persistence["Persistence Layer"]:::internal
        end
    end

    Network -->|"DNS_QUERY(name)"| DNS_Server
    DNS_Server -->|"DNS_RESPONSE(A/AAAA)"| Network

    DNS_Server -->|"load on startup"| Persistence
    DNS_Server -->|"lookup(name)"| InMemory
    Persistence -->|"read on startup\nwrite on update"| IPv4_Store["domains_databaseIPV4.txt"]:::storage
    Persistence -->|"read on startup\nwrite on update"| IPv6_Store["domains_databaseIPV6.txt"]:::storage

    README["README.md"]:::doc

    click DNS_Server "https://github.com/manoj-kr24/domain-name-system/blob/main/dnsServer.py"
    click DNS_Resolver "https://github.com/manoj-kr24/domain-name-system/blob/main/resolver.py"
    click DNS_Manager "https://github.com/manoj-kr24/domain-name-system/blob/main/dnsManager.py"
    click IPv4_Store "https://github.com/manoj-kr24/domain-name-system/blob/main/domains_databaseIPV4.txt"
    click IPv6_Store "https://github.com/manoj-kr24/domain-name-system/blob/main/domains_databaseIPV6.txt"
    click README "https://github.com/manoj-kr24/domain-name-system/blob/main/README.md"

    classDef network fill:#87CEFA,stroke:#000,stroke-width:1px;
    classDef network_boundary stroke-dasharray: 5 5,stroke:#777,fill:none;
    classDef server fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef internal fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef storage fill:#90EE90,stroke:#000,stroke-width:1px,shape:cylinder;
    classDef doc fill:#F0E68C,stroke:#000,stroke-width:1px;
```
