# pip513/cove-watchdog architecture

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

- Interactive diagram: https://gitdiagram.com/pip513/cove-watchdog
- Repository: https://github.com/pip513/cove-watchdog

## Overview

Cove missed-backup watchdog is an hourly monitor for backups that stop running, including failures hidden by Cove’s aggregate status. Its main workflow fetches per-device source history, evaluates it against monitoring rules, plans alerts and recoveries using saved state, then delivers email; it also sends a scheduled weekly heartbeat report and failure notices. The graph reflects documented Azure scheduling and storage plus relationships visible in the supplied source index. Some implementation excerpts were partial, so uncertain internal call details are omitted.

Main entry points: [`cove/deliver.py`](https://github.com/pip513/cove-watchdog/blob/main/cove/deliver.py) (Delivery orchestration), [`cove/dispatch.py`](https://github.com/pip513/cove-watchdog/blob/main/cove/dispatch.py) (Alert and cadence planning), [`cove/runner.py`](https://github.com/pip513/cove-watchdog/blob/main/cove/runner.py) (Check orchestration), [`run_watchdog.py`](https://github.com/pip513/cove-watchdog/blob/main/run_watchdog.py) (Watchdog runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_azure_function["Azure Function<br/>[function_app.py]"]
  node_watchdog["Watchdog runner<br/>[run_watchdog.py]"]
  node_configuration["Environment settings<br/>[env.py]"]
end

subgraph group_cove["Cove data and detection"]
  node_check["Check orchestration<br/>[runner.py]"]
  node_cove_api["Cove API"]
  node_api_client["API client<br/>[client.py]"]
  node_device_fetch["Device and source fetch<br/>[devices.py]"]
  node_datasource_names["Datasource catalogue<br/>[datasources.py]"]
  node_detection["Per-source detection<br/>[detection.py]"]
end

subgraph group_decisions["Alert decisions"]
  node_dispatch["Alert and cadence planning<br/>[dispatch.py]"]
  node_health["Failure classification<br/>[health.py]"]
  node_state[("Alert history store<br/>[state.py]")]
end

subgraph group_communication["Reports and email"]
  node_delivery["Delivery orchestration<br/>[deliver.py]"]
  node_message_rendering["Alert rendering<br/>[messages.py]"]
  node_weekly_report["Weekly report<br/>[report.py]"]
  node_smtp["SMTP delivery<br/>[notify.py]"]
end

node_timer(("Hourly timer"))
node_mail_service["SMTP relay"]

node_timer -->|"triggers hourly"| node_azure_function
node_azure_function -->|"invokes"| node_watchdog
node_watchdog -->|"runs check"| node_check
node_check -->|"reads settings"| node_configuration
node_check -->|"authenticates"| node_api_client
node_api_client -->|"queries"| node_cove_api
node_check -->|"fetches fleet"| node_device_fetch
node_device_fetch -->|"requests devices"| node_api_client
node_device_fetch -->|"uses catalogue"| node_datasource_names
node_check -->|"evaluates sources"| node_detection
node_detection -->|"evaluates devices"| node_device_fetch
node_watchdog -->|"plans notices"| node_dispatch
node_dispatch -->|"uses check outcome"| node_detection
node_dispatch -->|"handles failures"| node_health
node_dispatch -->|"checks schedule"| node_weekly_report
node_dispatch -->|"reads and commits"| node_state
node_watchdog -->|"delivers plan"| node_delivery
node_delivery -->|"uses plan"| node_dispatch
node_delivery -->|"renders failures"| node_health
node_delivery -->|"renders alerts"| node_message_rendering
node_delivery -->|"renders report"| node_weekly_report
node_delivery -->|"sends messages"| node_smtp
node_smtp -->|"sends email"| node_mail_service
node_azure_function -->|"persists history"| node_state

click node_azure_function "https://github.com/pip513/cove-watchdog/blob/main/function_app.py"
click node_watchdog "https://github.com/pip513/cove-watchdog/blob/main/run_watchdog.py"
click node_check "https://github.com/pip513/cove-watchdog/blob/main/cove/runner.py"
click node_api_client "https://github.com/pip513/cove-watchdog/blob/main/cove/client.py"
click node_device_fetch "https://github.com/pip513/cove-watchdog/blob/main/cove/devices.py"
click node_datasource_names "https://github.com/pip513/cove-watchdog/blob/main/cove/datasources.py"
click node_detection "https://github.com/pip513/cove-watchdog/blob/main/cove/detection.py"
click node_configuration "https://github.com/pip513/cove-watchdog/blob/main/cove/env.py"
click node_dispatch "https://github.com/pip513/cove-watchdog/blob/main/cove/dispatch.py"
click node_health "https://github.com/pip513/cove-watchdog/blob/main/cove/health.py"
click node_state "https://github.com/pip513/cove-watchdog/blob/main/cove/state.py"
click node_delivery "https://github.com/pip513/cove-watchdog/blob/main/cove/deliver.py"
click node_message_rendering "https://github.com/pip513/cove-watchdog/blob/main/cove/messages.py"
click node_weekly_report "https://github.com/pip513/cove-watchdog/blob/main/cove/report.py"
click node_smtp "https://github.com/pip513/cove-watchdog/blob/main/cove/notify.py"

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_azure_function,node_watchdog,node_configuration toneBlue
class node_check,node_cove_api,node_api_client,node_device_fetch,node_datasource_names,node_detection toneAmber
class node_dispatch,node_health,node_state toneMint
class node_delivery,node_message_rendering,node_weekly_report,node_smtp toneRose
class node_timer,node_mail_service toneIndigo
```

## Components

### Runtime orchestration

- [Azure Function](https://github.com/pip513/cove-watchdog/blob/main/function_app.py): `function_app.py`
- [Watchdog runner](https://github.com/pip513/cove-watchdog/blob/main/run_watchdog.py): `run_watchdog.py`
- [Environment settings](https://github.com/pip513/cove-watchdog/blob/main/cove/env.py): `cove/env.py`

### Cove data and detection

- [Check orchestration](https://github.com/pip513/cove-watchdog/blob/main/cove/runner.py): `cove/runner.py`
- **Cove API**
- [API client](https://github.com/pip513/cove-watchdog/blob/main/cove/client.py): `cove/client.py`
- [Device and source fetch](https://github.com/pip513/cove-watchdog/blob/main/cove/devices.py): `cove/devices.py`
- [Datasource catalogue](https://github.com/pip513/cove-watchdog/blob/main/cove/datasources.py): `cove/datasources.py`
- [Per-source detection](https://github.com/pip513/cove-watchdog/blob/main/cove/detection.py): `cove/detection.py`

### Alert decisions

- [Alert and cadence planning](https://github.com/pip513/cove-watchdog/blob/main/cove/dispatch.py): `cove/dispatch.py`
- [Failure classification](https://github.com/pip513/cove-watchdog/blob/main/cove/health.py): `cove/health.py`
- [Alert history store](https://github.com/pip513/cove-watchdog/blob/main/cove/state.py): `cove/state.py`

### Reports and email

- [Delivery orchestration](https://github.com/pip513/cove-watchdog/blob/main/cove/deliver.py): `cove/deliver.py`
- [Alert rendering](https://github.com/pip513/cove-watchdog/blob/main/cove/messages.py): `cove/messages.py`
- [Weekly report](https://github.com/pip513/cove-watchdog/blob/main/cove/report.py): `cove/report.py`
- [SMTP delivery](https://github.com/pip513/cove-watchdog/blob/main/cove/notify.py): `cove/notify.py`

### Other components

- **Hourly timer**
- **SMTP relay**

## Connections

- Hourly timer → Azure Function: triggers hourly (evidence: `README.md`)
- Azure Function → Watchdog runner: invokes (evidence: `function_app.py`)
- Watchdog runner → Check orchestration: runs check (evidence: `run_watchdog.py`)
- Check orchestration → Environment settings: reads settings (evidence: `cove/runner.py`)
- Check orchestration → API client: authenticates (evidence: `cove/runner.py`)
- API client → Cove API: queries (evidence: `cove/client.py`)
- Check orchestration → Device and source fetch: fetches fleet (evidence: `cove/runner.py`)
- Device and source fetch → API client: requests devices (evidence: `cove/devices.py`)
- Device and source fetch → Datasource catalogue: uses catalogue (evidence: `cove/devices.py`)
- Check orchestration → Per-source detection: evaluates sources (evidence: `cove/runner.py`)
- Per-source detection → Device and source fetch: evaluates devices (evidence: `cove/detection.py`)
- Watchdog runner → Alert and cadence planning: plans notices (evidence: `run_watchdog.py`)
- Alert and cadence planning → Per-source detection: uses check outcome (evidence: `cove/dispatch.py`)
- Alert and cadence planning → Failure classification: handles failures (evidence: `cove/dispatch.py`)
- Alert and cadence planning → Weekly report: checks schedule (evidence: `cove/dispatch.py`)
- Alert and cadence planning → Alert history store: reads and commits (evidence: `cove/dispatch.py`)
- Watchdog runner → Delivery orchestration: delivers plan (evidence: `run_watchdog.py`)
- Delivery orchestration → Alert and cadence planning: uses plan (evidence: `cove/deliver.py`)
- Delivery orchestration → Failure classification: renders failures (evidence: `cove/deliver.py`)
- Delivery orchestration → Alert rendering: renders alerts (evidence: `cove/deliver.py`)
- Delivery orchestration → Weekly report: renders report (evidence: `cove/deliver.py`)
- Delivery orchestration → SMTP delivery: sends messages (evidence: `cove/deliver.py`)
- SMTP delivery → SMTP relay: sends email (evidence: `cove/notify.py`)
- Azure Function → Alert history store: persists history (evidence: `README.md`)
