# 7odaifa-ab/ddns-cloudflare-api architecture

> Architecture diagram of the GitHub repository 7odaifa-ab/ddns-cloudflare-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/7odaifa-ab/ddns-cloudflare-api
- Repository: https://github.com/7odaifa-ab/ddns-cloudflare-api

## Overview

##### Project type and purpose
- This is a Windows desktop application built on WPF (.NET 8.0) that implements the MVVM pattern.
- Its purpose is to act as a Dynamic DNS (DDNS) client for Cloudflare: fetching, updating, and logging DNS records.

##### File structure
- Top-level solution (.sln) and project folder (`DDNS_Cloudflare_API`)
- MVVM layers:
- Views: `Views/Pages` & `Views/Windows` (XAML + code‐behind)
- ViewModels: `ViewModels/Pages` & `ViewModels/Windows`
- Models: `Models` (AppConfig, DataColor)
- Services layer: `Services` (ApplicationHostService, PageService, ProfileTimerService)
- Helpers: `EncryptionHelper`, `EnumToBooleanConverter`
- Resources & Assets: localized strings, images
- Configuration & publishing: `Properties/PublishProfiles`, `app.manifest`
- External dependencies: Cloudflare REST API, Wpf.Ui library

##### README for additional insights
- Confirms MVVM, WPF UI, .NET 8.0
- Describes feature set: fetch/update records, system tray integration, multi-profile management, logging.

a. Main components:
- Desktop App (WPF UI Layer)
- ViewModels Layer (Presentation logic)
- Services Layer (API orchestration, timers)
- Models Layer (configuration, DTOs)
- Local Storage (profiles, logs)
- External Cloudflare API (HTTPS endpoint)
- System Tray / OS interaction
b. Relationships & interactions:
- User clicks UI control → binds to ViewModel command → invokes Service → calls Cloudflare API → returns JSON → Service updates Model → ViewModel exposes data → UI displays it.
- ProfileTimerService polls/updates record on schedule; writes logs.
c. Architectural patterns:
- MVVM separation: UI ↔ ViewModel ↔ Model
- Service abstraction for API calls & application management
- Dependency injection can be called out if used (e.g., constructor injection in ViewModels)
d. Technologies & frameworks:
- .NET 8.0, WPF UI Library (Wpf.Ui)
- JSON (System.Text.Json or Newtonsoft.Json)
- HTTP Client to Cloudflare REST API
- Local file I/O for logs and config (AppConfig.cs)
- XAML + C# code-behind for Views

##### Elements
- Labels: “UI (Views)”, “ViewModels”, “Services”, “Models”, “Local Storage”, “Cloudflare API”, “OS / System Tray”
- OS events → ApplicationHostService → ViewModel
- Blue rectangles for UI components
- Green for ViewModels
- Orange for Services

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Desktop Application"
        subgraph "Views (UI Layer)"
            HomePage["Home.xaml"]:::ui
            LogPage["Log.xaml"]:::ui
            RecordsPage["Records.xaml"]:::ui
            SettingsPage["SettingsPage.xaml"]:::ui
            SetupPage["SetupPage.xaml"]:::ui
            TutorialPage["Tutorial.xaml"]:::ui
            MainWindow["MainWindow.xaml"]:::ui
        end
        subgraph "ViewModels (Presentation Logic)"
            HomeVM["HomeViewModel"]:::vm
            DataVM["DataViewModel"]:::vm
            SettingsVM["SettingsViewModel"]:::vm
            SetupVM["SetupViewModel"]:::vm
            TutorialVM["TutorialViewModel"]:::vm
            MainWMVM["MainWindowViewModel"]:::vm
        end
        subgraph "Services (Business Logic)"
            AppHost["ApplicationHostService"]:::service
            PageSvc["PageService"]:::service
            TimerSvc["ProfileTimerService"]:::service
        end
        subgraph "Models (Data Tier)"
            AppConfig["AppConfig"]:::model
            DataColor["DataColor"]:::model
        end
    end

    LocalStorage["Local Storage<br/>(profiles.json, log.txt)"]:::storage
    Cloudflare["Cloudflare REST API"]:::external
    OS["System Tray / OS"]:::os

    %% Relationships
    HomePage <--> HomeVM
    LogPage <--> DataVM
    RecordsPage <--> DataVM
    SettingsPage <--> SettingsVM
    SetupPage <--> SetupVM
    TutorialPage <--> TutorialVM
    MainWindow <--> MainWMVM

    HomeVM -->|"FetchRecords()"| PageSvc
    DataVM -->|"UpdateRecord()"| PageSvc
    SettingsVM -->|"LoadConfig()"| AppHost
    SetupVM -->|"LoadConfig()"| AppHost
    TutorialVM -->|"LoadConfig()"| AppHost
    MainWMVM -->|"Initialize()"| AppHost

    AppHost -->|"ManageLifecycle()"| OS
    AppHost -->|"Navigate()"| PageSvc
    PageSvc -->|"Call API()"| Cloudflare
    TimerSvc -->|"PollSchedule()"| Cloudflare
    PageSvc -->|"PopulateDTOs()"| AppConfig
    TimerSvc -->|"WriteLogs()"| LocalStorage
    AppHost -->|"LoadConfig()"| AppConfig

    %% Click Events
    click HomePage "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Pages/Home.xaml"
    click LogPage "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Pages/Log.xaml"
    click RecordsPage "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Pages/Records.xaml"
    click SettingsPage "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Pages/SettingsPage.xaml"
    click SetupPage "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Pages/SetupPage.xaml"
    click TutorialPage "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Pages/Tutorial.xaml"
    click MainWindow "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Views/Windows/MainWindow.xaml"
    click HomeVM "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/ViewModels/Pages/HomeViewModel.cs"
    click DataVM "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/ViewModels/Pages/DataViewModel.cs"
    click SettingsVM "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/ViewModels/Pages/SettingsViewModel.cs"
    click SetupVM "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/ViewModels/Pages/SetupViewModel.cs"
    click TutorialVM "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/ViewModels/Pages/TutorialViewModel.cs"
    click MainWMVM "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/ViewModels/Windows/MainWindowViewModel.cs"
    click AppHost "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Services/ApplicationHostService.cs"
    click PageSvc "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Services/PageService.cs"
    click TimerSvc "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Services/ProfileTimerService.cs"
    click AppConfig "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Models/AppConfig.cs"
    click DataColor "https://github.com/7odaifa-ab/ddns-cloudflare-api/blob/main/DDNS_Cloudflare_API/Models/DataColor.cs"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef vm fill:#d4edda,stroke:#155724,color:#155724;
    classDef service fill:#fff3cd,stroke:#856404,color:#856404;
    classDef model fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef storage fill:#ffeeba,stroke:#856404,color:#856404,shape:cylinder;
    classDef external fill:#d1ecf1,stroke:#0c5460,color:#0c5460,shape:cloud;
    classDef os fill:#f8d7da,stroke:#721c24,color:#721c24;
```
