# mori-dv/watchtower architecture

> Architecture diagram of the GitHub repository mori-dv/watchtower, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mori-dv/watchtower
- Repository: https://github.com/mori-dv/watchtower

## Overview

Watchtower is a Go uptime-monitoring service: configured targets are scheduled, probed concurrently, evaluated for state transitions, then surfaced through alerts, metrics, logs, and management endpoints. The README documents the main runtime stages and capabilities; sampled startup code confirms wiring for storage, result processing, reloads, and HTTP routes. The frontend is a separate explanatory site with interactive architecture and observability sections, not a demonstrated live backend client. Some subsystem links rely on README descriptions because their implementation excerpts were not provided.

Main entry points: [`cmd/watchtower/main.go`](https://github.com/mori-dv/watchtower/blob/main/cmd/watchtower/main.go) (Service Entrypoint), [`frontend/src/App.tsx`](https://github.com/mori-dv/watchtower/blob/main/frontend/src/App.tsx) (Site Application), [`internal/checker/checker.go`](https://github.com/mori-dv/watchtower/blob/main/internal/checker/checker.go) (Probe Engine), [`internal/storage/store.go`](https://github.com/mori-dv/watchtower/blob/main/internal/storage/store.go) (State Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Probe Runtime"]
  node_targets["Target Config<br/>[config.go]"]
  node_scheduler["Scheduler<br/>[scheduler.go]"]
  node_pool["Worker Pool<br/>[pool.go]"]
  node_backoff["Retry Backoff<br/>[backoff.go]"]
  node_checker["Probe Engine<br/>[checker.go]"]
  node_httpcheck["HTTP Checks<br/>[http.go]"]
  node_tcpcheck["TCP Checks<br/>[tcp.go]"]
  node_icmpcheck["ICMP Checks<br/>[icmp.go]"]
end

subgraph group_reliability["State And Alerts"]
  node_state["State Evaluator<br/>[evaluator.go]"]
  node_storage[("State Storage<br/>[store.go]")]
  node_memory[("Memory Store<br/>[memory.go]")]
  node_redis[("Redis Store<br/>[redis.go]")]
  node_alerts["Alert Manager<br/>[manager.go]"]
  node_dispatchers["Alert Dispatchers<br/>[dispatcher.go]"]
end

subgraph group_operations["Operations And Telemetry"]
  node_entry["Service Entrypoint<br/>[main.go]"]
  node_api["Management API<br/>[status.go]"]
  node_metrics["Prometheus Metrics<br/>[prometheus.go]"]
  node_logging["Structured Logging<br/>[logger.go]"]
end

subgraph group_site["Explanatory Frontend"]
  node_siteapp["Site Application<br/>[App.tsx]"]
  node_siteentry["Site Entry<br/>[main.tsx]"]
  node_nav["Navigation Header"]
  node_indicators["Scroll Indicators"]
  node_hero["Hero Section<br/>[SectionHero.tsx]"]
  node_mechanics["Mechanics Demo"]
  node_observability["Observability Section"]
  node_mockdata["Demo Data<br/>[mockData.ts]"]
end

node_operator(("Operator"))
node_notification(("Notification Services"))
node_prometheus(("Prometheus Scraper"))
node_grafana["Grafana Dashboards<br/>[watchtower.json]"]
node_loki[("Loki Log Store<br/>[config.yml]")]
node_promtail["Promtail<br/>[promtail.yml]"]
node_mockserver["Mock Server<br/>[main.go]"]

node_operator -->|"configures"| node_targets
node_targets -->|"loads config"| node_entry
node_entry -->|"starts"| node_scheduler
node_scheduler -->|"queues jobs"| node_pool
node_pool -->|"runs probes"| node_checker
node_checker -->|"dispatches"| node_httpcheck
node_checker -->|"dispatches"| node_tcpcheck
node_checker -->|"dispatches"| node_icmpcheck
node_pool -->|"retries with"| node_backoff
node_entry -->|"evaluates results"| node_state
node_entry -->|"updates"| node_metrics
node_entry -->|"handles alerts"| node_alerts
node_entry -->|"logs results"| node_logging
node_entry -->|"registers routes"| node_api
node_entry -->|"selects store"| node_storage
node_state -->|"persists state"| node_storage
node_storage -->|"implemented by"| node_memory
node_storage -->|"implemented by"| node_redis
node_alerts -->|"checks cooldown"| node_storage
node_alerts -->|"dispatches events"| node_dispatchers
node_dispatchers -->|"sends alerts"| node_notification
node_prometheus -->|"scrapes"| node_metrics
node_metrics -->|"visualized in"| node_grafana
node_logging -->|"collected by"| node_promtail
node_promtail -->|"ships logs"| node_loki
node_operator -->|"queries status"| node_api
node_mockserver -.->|"provides test targets"| node_checker
node_siteentry -->|"renders"| node_siteapp
node_siteapp -->|"renders"| node_nav
node_siteapp -->|"renders"| node_indicators
node_siteapp -->|"renders"| node_hero
node_siteapp -->|"renders"| node_mechanics
node_siteapp -->|"renders"| node_observability
node_mechanics -.->|"illustrates monitoring"| node_mockdata

click node_targets "https://github.com/mori-dv/watchtower/blob/main/internal/config/config.go"
click node_scheduler "https://github.com/mori-dv/watchtower/blob/main/internal/scheduler/scheduler.go"
click node_pool "https://github.com/mori-dv/watchtower/blob/main/internal/worker/pool.go"
click node_backoff "https://github.com/mori-dv/watchtower/blob/main/internal/worker/backoff.go"
click node_checker "https://github.com/mori-dv/watchtower/blob/main/internal/checker/checker.go"
click node_httpcheck "https://github.com/mori-dv/watchtower/blob/main/internal/checker/http.go"
click node_tcpcheck "https://github.com/mori-dv/watchtower/blob/main/internal/checker/tcp.go"
click node_icmpcheck "https://github.com/mori-dv/watchtower/blob/main/internal/checker/icmp.go"
click node_state "https://github.com/mori-dv/watchtower/blob/main/internal/state/evaluator.go"
click node_storage "https://github.com/mori-dv/watchtower/blob/main/internal/storage/store.go"
click node_memory "https://github.com/mori-dv/watchtower/blob/main/internal/storage/memory.go"
click node_redis "https://github.com/mori-dv/watchtower/blob/main/internal/storage/redis.go"
click node_alerts "https://github.com/mori-dv/watchtower/blob/main/internal/alert/manager.go"
click node_dispatchers "https://github.com/mori-dv/watchtower/blob/main/internal/alert/dispatcher.go"
click node_entry "https://github.com/mori-dv/watchtower/blob/main/cmd/watchtower/main.go"
click node_api "https://github.com/mori-dv/watchtower/blob/main/internal/api/status.go"
click node_metrics "https://github.com/mori-dv/watchtower/blob/main/internal/metrics/prometheus.go"
click node_logging "https://github.com/mori-dv/watchtower/blob/main/internal/logging/logger.go"
click node_grafana "https://github.com/mori-dv/watchtower/blob/main/observability/grafana/provisioning/dashboards/watchtower.json"
click node_loki "https://github.com/mori-dv/watchtower/blob/main/observability/loki/config.yml"
click node_promtail "https://github.com/mori-dv/watchtower/blob/main/observability/promtail/promtail.yml"
click node_mockserver "https://github.com/mori-dv/watchtower/blob/main/cmd/mockserver/main.go"
click node_siteapp "https://github.com/mori-dv/watchtower/blob/main/frontend/src/App.tsx"
click node_siteentry "https://github.com/mori-dv/watchtower/blob/main/frontend/src/main.tsx"
click node_nav "https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/NavigationHeader.tsx"
click node_indicators "https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/ScrollIndicators.tsx"
click node_hero "https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/SectionHero.tsx"
click node_mechanics "https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/SectionMechanics.tsx"
click node_observability "https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/SectionObservability.tsx"
click node_mockdata "https://github.com/mori-dv/watchtower/blob/main/frontend/src/data/mockData.ts"

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_targets,node_scheduler,node_pool,node_backoff,node_checker,node_httpcheck,node_tcpcheck,node_icmpcheck toneBlue
class node_state,node_storage,node_memory,node_redis,node_alerts,node_dispatchers,node_loki toneAmber
class node_entry,node_api,node_metrics,node_logging,node_mockserver toneMint
class node_siteapp,node_siteentry,node_nav,node_indicators,node_hero,node_mechanics,node_observability,node_mockdata toneRose
class node_operator,node_notification,node_prometheus toneIndigo
class node_grafana,node_promtail toneTeal
```

## Components

### Probe Runtime

- [Target Config](https://github.com/mori-dv/watchtower/blob/main/internal/config/config.go): `internal/config/config.go`
- [Scheduler](https://github.com/mori-dv/watchtower/blob/main/internal/scheduler/scheduler.go): `internal/scheduler/scheduler.go`
- [Worker Pool](https://github.com/mori-dv/watchtower/blob/main/internal/worker/pool.go): `internal/worker/pool.go`
- [Retry Backoff](https://github.com/mori-dv/watchtower/blob/main/internal/worker/backoff.go): `internal/worker/backoff.go`
- [Probe Engine](https://github.com/mori-dv/watchtower/blob/main/internal/checker/checker.go): `internal/checker/checker.go`
- [HTTP Checks](https://github.com/mori-dv/watchtower/blob/main/internal/checker/http.go): `internal/checker/http.go`
- [TCP Checks](https://github.com/mori-dv/watchtower/blob/main/internal/checker/tcp.go): `internal/checker/tcp.go`
- [ICMP Checks](https://github.com/mori-dv/watchtower/blob/main/internal/checker/icmp.go): `internal/checker/icmp.go`

### State And Alerts

- [State Evaluator](https://github.com/mori-dv/watchtower/blob/main/internal/state/evaluator.go): `internal/state/evaluator.go`
- [State Storage](https://github.com/mori-dv/watchtower/blob/main/internal/storage/store.go): `internal/storage/store.go`
- [Memory Store](https://github.com/mori-dv/watchtower/blob/main/internal/storage/memory.go): `internal/storage/memory.go`
- [Redis Store](https://github.com/mori-dv/watchtower/blob/main/internal/storage/redis.go): `internal/storage/redis.go`
- [Alert Manager](https://github.com/mori-dv/watchtower/blob/main/internal/alert/manager.go): `internal/alert/manager.go`
- [Alert Dispatchers](https://github.com/mori-dv/watchtower/blob/main/internal/alert/dispatcher.go): `internal/alert/dispatcher.go`

### Operations And Telemetry

- [Service Entrypoint](https://github.com/mori-dv/watchtower/blob/main/cmd/watchtower/main.go): `cmd/watchtower/main.go`
- [Management API](https://github.com/mori-dv/watchtower/blob/main/internal/api/status.go): `internal/api/status.go`
- [Prometheus Metrics](https://github.com/mori-dv/watchtower/blob/main/internal/metrics/prometheus.go): `internal/metrics/prometheus.go`
- [Structured Logging](https://github.com/mori-dv/watchtower/blob/main/internal/logging/logger.go): `internal/logging/logger.go`

### Explanatory Frontend

- [Site Application](https://github.com/mori-dv/watchtower/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Site Entry](https://github.com/mori-dv/watchtower/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Navigation Header](https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/NavigationHeader.tsx): `frontend/src/components/NavigationHeader.tsx`
- [Scroll Indicators](https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/ScrollIndicators.tsx): `frontend/src/components/ScrollIndicators.tsx`
- [Hero Section](https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/SectionHero.tsx): `frontend/src/components/SectionHero.tsx`
- [Mechanics Demo](https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/SectionMechanics.tsx): `frontend/src/components/SectionMechanics.tsx`
- [Observability Section](https://github.com/mori-dv/watchtower/blob/main/frontend/src/components/SectionObservability.tsx): `frontend/src/components/SectionObservability.tsx`
- [Demo Data](https://github.com/mori-dv/watchtower/blob/main/frontend/src/data/mockData.ts): `frontend/src/data/mockData.ts`

### Other components

- **Operator**
- **Notification Services**
- **Prometheus Scraper**
- [Grafana Dashboards](https://github.com/mori-dv/watchtower/blob/main/observability/grafana/provisioning/dashboards/watchtower.json): `observability/grafana/provisioning/dashboards/watchtower.json`
- [Loki Log Store](https://github.com/mori-dv/watchtower/blob/main/observability/loki/config.yml): `observability/loki/config.yml`
- [Promtail](https://github.com/mori-dv/watchtower/blob/main/observability/promtail/promtail.yml): `observability/promtail/promtail.yml`
- [Mock Server](https://github.com/mori-dv/watchtower/blob/main/cmd/mockserver/main.go): `cmd/mockserver/main.go`

## Connections

- Operator → Target Config: configures (evidence: `README.md`)
- Target Config → Service Entrypoint: loads config (evidence: `cmd/watchtower/main.go`)
- Service Entrypoint → Scheduler: starts (evidence: `cmd/watchtower/main.go`)
- Scheduler → Worker Pool: queues jobs (evidence: `README.md`)
- Worker Pool → Probe Engine: runs probes (evidence: `README.md`)
- Probe Engine → HTTP Checks: dispatches (evidence: `README.md`)
- Probe Engine → TCP Checks: dispatches (evidence: `README.md`)
- Probe Engine → ICMP Checks: dispatches (evidence: `README.md`)
- Worker Pool → Retry Backoff: retries with (evidence: `README.md`)
- Service Entrypoint → State Evaluator: evaluates results (evidence: `cmd/watchtower/main.go`)
- Service Entrypoint → Prometheus Metrics: updates (evidence: `cmd/watchtower/main.go`)
- Service Entrypoint → Alert Manager: handles alerts (evidence: `cmd/watchtower/main.go`)
- Service Entrypoint → Structured Logging: logs results (evidence: `cmd/watchtower/main.go`)
- Service Entrypoint → Management API: registers routes (evidence: `cmd/watchtower/main.go`)
- Service Entrypoint → State Storage: selects store (evidence: `cmd/watchtower/main.go`)
- State Evaluator → State Storage: persists state (evidence: `README.md`)
- State Storage → Memory Store: implemented by (evidence: `README.md`)
- State Storage → Redis Store: implemented by (evidence: `README.md`)
- Alert Manager → State Storage: checks cooldown (evidence: `internal/alert/manager.go`)
- Alert Manager → Alert Dispatchers: dispatches events (evidence: `internal/alert/manager.go`)
- Alert Dispatchers → Notification Services: sends alerts (evidence: `README.md`)
- Prometheus Scraper → Prometheus Metrics: scrapes (evidence: `README.md`)
- Prometheus Metrics → Grafana Dashboards: visualized in (evidence: `README.md`)
- Structured Logging → Promtail: collected by (evidence: `README.md`)
- Promtail → Loki Log Store: ships logs (evidence: `README.md`)
- Operator → Management API: queries status (evidence: `README.md`)
- Mock Server → Probe Engine: provides test targets
- Site Entry → Site Application: renders (evidence: `frontend/src/main.tsx`)
- Site Application → Navigation Header: renders (evidence: `frontend/src/App.tsx`)
- Site Application → Scroll Indicators: renders (evidence: `frontend/src/App.tsx`)
- Site Application → Hero Section: renders (evidence: `frontend/src/App.tsx`)
- Site Application → Mechanics Demo: renders (evidence: `frontend/src/App.tsx`)
- Site Application → Observability Section: renders (evidence: `frontend/src/App.tsx`)
- Mechanics Demo → Demo Data: illustrates monitoring
