# domainreseller/whmcs-dna architecture

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

- Interactive diagram: https://gitdiagram.com/domainreseller/whmcs-dna
- Repository: https://github.com/domainreseller/whmcs-dna

## Overview

##### Project type and purpose
- This is a WHMCS “Registrar” module named DomainNameAPI.
- Its purpose is to plug into WHMCS (a PHP-based billing/automation platform) and provide domain registration, transfer, renewal, pricing and sync operations via the external DomainNameAPI SOAP service.

##### File structure
- Top-level: only this module under modules/registrars/domainnameapi.
- domainnameapi.php: the main module entry point exporting WHMCS registrar functions (config, register, transfer, renew, nameserver operations, pricing/TLD sync hooks).
- cache/: local response cache (for speed/reducing API calls).
- lib/: core client library (dna.php), plus Services/Language for loading localized messages.
- lang/: per-language message files.
- childns.tpl: the admin/customer template snippet for custom child nameserver UI.
- whmcs.json: module metadata (name, version, author).

##### README insights
- Describes installation into WHMCS directories, required PHP version and SOAP extension, user settings in WHMCS Admin.
- Walks through domain pricing config, TLD sync tools, error logs, and testing matrix.
- Mentions two external interactions: DomainNameAPI SOAP WSDL endpoint & WHMCS database.

##### Main components
a. WHMCS Core Platform
- UI Layer (Admin & Client Area pages)
- Module Loader / Registrar Manager
- MySQL Database (for storing domain records, pricing, sync state)
b. DomainNameAPI Module
- Configuration Definition (whmcs.json + config array in domainnameapi.php)
- Business Logic (domainnameapi.php functions: RegisterDomain, TransferDomain, RenewDomain, GetNameservers, EPP code, etc.)
- Template (childns.tpl)
- Cache Subsystem (cache/index.php for persisting API responses)
- Client Library (lib/dna.php)
- Localization Layer (Services/Language + lang/*.php)
c. External Service
- DomainNameAPI SOAP Web Service (WSDL endpoint)

##### Relationships and interactions
- WHMCS UI → invokes registrar functions in the module.
- Module Business Logic → loads config + localization → builds SOAP requests via dna.php → sends via PHP SOAPClient → receives response.
- Responses are parsed, optionally cached, then returned to WHMCS to update DB & show to user.
- Pricing/TLD Sync flows: Cron/Tools → module sync functions → compare & update WHMCS DB.

##### Architectural patterns & design principles
- Plugin Architecture: module is self-contained and invoked by WHMCS core hooks.
- Layered Design: UI templates, orchestration layer (domainnameapi.php), service client, caching, localization.
- Adapter Pattern: dna.php adapts between WHMCS data structures and the external SOAP API.
- Configuration-Driven: whmcs.json + dynamic config fields drive behavior.

##### Technologies & frameworks
- PHP 7.4+ with SOAP extension
- WHMCS Module API
- SOAP Web Service (WSDL)
- File-based caching
- Smarty templates (childns.tpl)

##### Essential details to capture
- All major registrar operations (Register, Transfer, Renew, EPP, Nameservers, Availability, Price Sync, TLD Sync)
- Caching layer between module and API
- Localization loading before operation
- Module metadata and config driving UI/logic
- External dependency on SOAP WSDL endpoint
- Integration points with WHMCS DB and UI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% WHMCS Core Layer
    subgraph "WHMCS Core" 
        direction TB
        UI_Admin["Admin & Client UI"]:::core
        RegistrarMgr["Registrar Manager"]:::core
        DB[(MySQL Database)]:::database
    end

    %% DomainNameAPI Module
    subgraph "DomainNameAPI Module"
        direction TB
        Config["Configuration Definition"]:::config
        EntryLogic["Module Entry & Business Logic"]:::logic
        Template["UI Template (childns.tpl)"]:::template

        subgraph "Cache & Localization"
            direction TB
            Cache["File Cache"]:::cache
            LocalizationService["Localization Service Class"]:::localization
            LangFiles["Language Files"]:::localization
        end

        subgraph "Client Library"
            direction TB
            Bootstrap["Library Bootstrap"]:::library
            DNA["SOAP Adapter (dna.php)"]:::library
        end
    end

    %% External Service
    SOAP["DomainNameAPI SOAP Service"]:::external
    CronJob["Cron/Tool Sync"]:::core

    %% Connections
    UI_Admin --> RegistrarMgr
    RegistrarMgr --> EntryLogic
    CronJob --> EntryLogic
    EntryLogic --> Config
    EntryLogic --> LocalizationService
    LocalizationService --> LangFiles
    EntryLogic --> Cache
    Cache --> DNA
    EntryLogic --> DNA
    DNA --> SOAP
    SOAP --> DNA
    DNA --> EntryLogic
    EntryLogic --> DB
    DB --> UI_Admin

    %% Click Events
    click Config "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/whmcs.json"
    click EntryLogic "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/domainnameapi.php"
    click Template "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/childns.tpl"
    click Cache "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/cache/index.php"
    click DNA "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/lib/dna.php"
    click Bootstrap "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/lib/index.php"
    click LocalizationService "https://github.com/domainreseller/whmcs-dna/blob/main/modules/registrars/domainnameapi/lib/Services/Language.php"
    click LangFiles "https://github.com/domainreseller/whmcs-dna/tree/main/modules/registrars/domainnameapi/lang/"

    %% Styles
    classDef core fill:#d0e7ff,stroke:#036,stroke-width:1px;
    classDef config fill:#e0ffe0,stroke:#097,stroke-width:1px;
    classDef logic fill:#e0ffe0,stroke:#097,stroke-width:1px;
    classDef template fill:#eaffd0,stroke:#a60,stroke-width:1px;
    classDef cache fill:#ffe0b3,stroke:#d65,stroke-width:1px;
    classDef localization fill:#ffe0b3,stroke:#d65,stroke-width:1px;
    classDef library fill:#e0ffe0,stroke:#097,stroke-width:1px;
    classDef database fill:#ccc,stroke:#666,stroke-width:1px;
    classDef external fill:#f0f0f0,stroke:#999,stroke-width:1px,stroke-dasharray: 5 5;
```
