# hazaveh/verify-domain architecture

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

- Interactive diagram: https://gitdiagram.com/hazaveh/verify-domain
- Repository: https://github.com/hazaveh/verify-domain

## Overview

##### Project type and purpose
- This is a standalone PHP library/package (“hazaveh/verify-domain”) that exposes a simple API to verify domain ownership via three strategies: DNS TXT records, file‐based verification, and meta‐tag verification.
- It has almost zero runtime dependencies and is intended to be used in any PHP >5 application or injected via a DI container.

##### File structure
- src/Contracts/HandlerInterface.php – defines the contract for all verification handlers.
- src/Handler/LookupHandler.php – the real network‐capable implementation that performs HTTP or DNS lookups.
- src/Handler/MockLookupHandler.php – a stub for testing or offline use.
- src/VerifyDomain.php – the façade class that users instantiate or inject; it orchestrates the verification flows.
- tests/ – Pest/phpunit tests and HTML stub demonstrating sample data.
- CI and coding-style files (.github, .php-cs-fixer.php, phpunit.xml, composer.json).

##### README for additional insights
- Three public methods on VerifyDomain:
a. verifyByDNS(domain, expectedValue)
b. verifyByFile(domain, filename, expectedContent)
c. verifyByMeta(domain, metaName, expectedContent)
- Under the hood, all methods delegate to a HandlerInterface implementation (default LookupHandler).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Client["Client Application"]:::client

    %% Core Components
    VerifyDomain["VerifyDomain<br/>src/VerifyDomain.php"]:::core
    HandlerInterface["HandlerInterface<br/>src/Contracts/HandlerInterface.php"]:::interface

    subgraph "Handlers"
        direction TB
        LookupHandler["LookupHandler<br/>src/Handler/LookupHandler.php"]:::core
        MockLookupHandler["MockLookupHandler<br/>src/Handler/MockLookupHandler.php"]:::stub
    end

    %% External Services
    DNS["External DNS Server"]:::external
    Web["External Web Server"]:::external

    %% Testing
    subgraph "Testing"
        direction TB
        DomainTest["DomainOwnershipTest<br/>tests/Unit/DomainOwnershipTest.php"]:::test
        HTMLStub["HTML Stub<br/>tests/Stubs/html.html"]:::test
    end

    %% CI/CD & Config
    subgraph "CI/CD & Config"
        direction TB
        CI["GitHub Actions<br/>.github/workflows/php.yml"]:::ci
        Style["Coding Style Rules<br/>.php-cs-fixer.php"]:::ci
        PHPUnitCfg["PHPUnit Config<br/>phpunit.xml"]:::ci
        Composer["Composer Definition<br/>composer.json"]:::ci
    end

    %% Flow
    Client -->|"verifyByX() call"| VerifyDomain
    VerifyDomain -->|"depends on"| HandlerInterface
    HandlerInterface -->|"implemented by"| LookupHandler
    HandlerInterface -->|"implemented by"| MockLookupHandler
    LookupHandler -->|"DNS TXT query"| DNS
    LookupHandler -->|"HTTP GET for file/meta"| Web
    LookupHandler -->|"returns boolean"| VerifyDomain
    MockLookupHandler -->|"returns boolean"| VerifyDomain

    DomainTest -->|"tests via MockLookupHandler"| VerifyDomain
    HTMLStub -.->|"provided to tests"| DomainTest

    CI -->|"runs tests"| DomainTest
    CI -->|"checks coding style"| Style
    CI -->|"loads PHPUnit config"| PHPUnitCfg
    CI -->|"reads package info"| Composer

    %% Click Events
    click VerifyDomain "https://github.com/hazaveh/verify-domain/blob/master/src/VerifyDomain.php"
    click HandlerInterface "https://github.com/hazaveh/verify-domain/blob/master/src/Contracts/HandlerInterface.php"
    click LookupHandler "https://github.com/hazaveh/verify-domain/blob/master/src/Handler/LookupHandler.php"
    click MockLookupHandler "https://github.com/hazaveh/verify-domain/blob/master/src/Handler/MockLookupHandler.php"
    click DomainTest "https://github.com/hazaveh/verify-domain/blob/master/tests/Unit/DomainOwnershipTest.php"
    click HTMLStub "https://github.com/hazaveh/verify-domain/blob/master/tests/Stubs/html.html"
    click CI "https://github.com/hazaveh/verify-domain/blob/master/.github/workflows/php.yml"
    click Style "https://github.com/hazaveh/verify-domain/blob/master/.php-cs-fixer.php"
    click PHPUnitCfg "https://github.com/hazaveh/verify-domain/blob/master/phpunit.xml"
    click Composer "https://github.com/hazaveh/verify-domain/blob/master/composer.json"

    %% Styles
    classDef interface fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef stub fill:#FFFFE0,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef test fill:#FFEFD5,stroke:#333,stroke-width:1px;
    classDef ci fill:#E6E6FA,stroke:#333,stroke-width:1px;
    classDef client fill:#FFFFFF,stroke:#333,stroke-width:1px;
```
