# valeriansaliou/vigil architecture

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

- Interactive diagram: https://gitdiagram.com/valeriansaliou/vigil
- Repository: https://github.com/valeriansaliou/vigil

## Overview

1. Vigil is a single Rust service that combines three major responsibilities: monitoring, alerting, and serving a public status page. The runtime is split into internal subsystems rather than separate services, but there are clear boundaries between probe ingestion, health aggregation, notifications, and HTTP response rendering.

2. `src/main.rs` is the composition root. It likely wires configuration, logging, the probe/aggregator loop, notifier backends, and the responder HTTP server into one process. The app is configured entirely from `config.cfg` plus environment-variable interpolation.

3. The configuration subsystem (`src/config`) is central to the architecture. It parses server settings, branding, probe definitions, notification targets, metrics thresholds, and plugin settings. It also includes defaults, regex helpers, and logger setup, so configuration is not just input data but the main control plane for how the service behaves.

4. The probing subsystem (`src/prober`) is the input side of the system. It supports four monitoring modes: `poll` for active checks, `push` for external reporters, `script` for shell-based checks, and `local` for reports coming from a separate Vigil Local daemon. This is where HTTP/TCP/SSH/ICMP reachability, application health, and local service status enter the system.

5. Probe execution is asynchronous and stateful. The `mode`, `replica`, `report`, `states`, and `status` modules suggest a normalized pipeline that turns raw probe results into a common health model. A node can report `healthy`, `sick`, or `dead`, with thresholds driven by the metrics configuration and per-node overrides.

6. The aggregator subsystem (`src/aggregator`) is the health decision layer. It consumes probe reports and turns them into service-level state, handling transitions, retries, and any logic required to compare multiple replicas or node signals. This is the point where raw check outcomes become the canonical status used by the rest of the app.

7. The notifier subsystem (`src/notifier`) is the outbound side effect layer. It has a shared abstraction plus channel-specific implementations for Email, Slack, Twilio, Zulip, Telegram, Pushover, Gotify, Matrix, Webex, XMPP, and Webhook. Notifications are triggered on status changes, startup, and optional reminders, so the architecture includes a clear event-to-notification path.

8. The responder subsystem (`src/responder`) is the public HTTP-facing layer. It serves the status page and related endpoints, renders templates from `res/assets/templates`, and uses static assets under `res/assets` for CSS/JS/images/fonts. It also contains dedicated routes for administrative and machine-oriented APIs.

9. There are two important API boundaries: the manager API and the reporter API. The manager side is authenticated by `manager_token` and is used for administrative actions such as announcements; the reporter side is authenticated by `reporter_token` and accepts health submissions from external Vigil Reporter libraries. The optional MCP server adds a read-only endpoint for AI/tooling access to probe data.

10. Announcements are a first-class public-facing feature, not an afterthought. They live in the responder layer, which means the status page can display operational messages independently from normal health state, likely driven by manager-authenticated writes.

11. External integrations materially shape the architecture. Vigil talks outward to SMTP, Twilio, Slack, Zulip, Telegram, Pushover, Gotify, Matrix, Webex, XMPP, and arbitrary webhooks; it can also query RabbitMQ via plugin configuration to evaluate queue health. These integrations sit behind dedicated adapter modules, keeping transport-specific code out of the core monitoring logic.

12. Probe execution has explicit security and runtime boundaries. Script probes run as shell subprocesses, ICMP probes require raw-socket capability, and local monitoring is offloaded to a separate Vigil Local daemon for LAN-restricted targets. That means the system intentionally spans multiple trust zones: public status serving, internal monitoring, and optional local agents.

13. Packaging and deployment are part of the repo structure: Docker, Debian packaging, GitHub Actions, and release scripts are included. This suggests the intended deployment model is a single long-running server binary, packaged for Linux distros or containerized, rather than a distributed microservice set.

Main entry points: [`src/responder/routes.rs`](https://github.com/valeriansaliou/vigil/blob/master/src/responder/routes.rs) (Routes), [`src/main.rs`](https://github.com/valeriansaliou/vigil/blob/master/src/main.rs) (Main), [`src/config/config.rs`](https://github.com/valeriansaliou/vigil/blob/master/src/config/config.rs) (Schema), [`src/notifier/mod.rs`](https://github.com/valeriansaliou/vigil/blob/master/src/notifier/mod.rs) (Notify core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_src["Source"]
  node_main["Main<br/>composition root<br/>[main.rs]"]
end

subgraph group_config["Config"]
  node_config_reader["Reader<br/>config input<br/>[reader.rs]"]
  node_config_schema["Schema<br/>config model<br/>[config.rs]"]
  node_config_defaults["Defaults<br/>[defaults.rs]"]
  node_config_regex["Regex<br/>config helper<br/>[regex.rs]"]
  node_config_logger["Logger<br/>logging setup<br/>[logger.rs]"]
end

subgraph group_prober["Prober"]
  node_prober_manager["Probe mgr<br/>probe orchestration<br/>[manager.rs]"]
  node_probe_modes["Modes<br/>[mode.rs]"]
  node_probe_replica["Replica<br/>[replica.rs]"]
  node_probe_report["Report<br/>[report.rs]"]
  node_probe_states["States<br/>[states.rs]"]
  node_probe_status["Status<br/>health model<br/>[status.rs]"]
end

subgraph group_aggregator["Aggregator"]
  node_agg_manager["Health agg<br/>state aggregation<br/>[manager.rs]"]
end

subgraph group_notifier["Notifier"]
  node_notify_core["Notify core<br/>notification core<br/>[mod.rs]"]
  node_notify_email["Email<br/>mailer adapter<br/>[email.rs]"]
  node_notify_slack["Slack<br/>chat adapter<br/>[slack.rs]"]
  node_notify_webhook["Webhook<br/>http adapter<br/>[webhook.rs]"]
end

subgraph group_responder["Responder"]
  node_resp_routes["Routes<br/>[routes.rs]"]
  node_resp_announcements["Announcements<br/>public messages<br/>[announcements.rs]"]
  node_resp_manager["Manager API<br/>admin api<br/>[manager.rs]"]
  node_resp_mcp["MCP<br/>read-only api<br/>[mcp.rs]"]
  node_resp_context["Context<br/>page model<br/>[context.rs]"]
  node_resp_payload["Payload<br/>response model<br/>[payload.rs]"]
end

subgraph group_assets["Assets"]
  node_tpl_index["Status page<br/>template<br/>[index.tera]"]
  node_asset_css["Styles<br/>static css<br/>[index.css]"]
  node_asset_js["Scripts<br/>static js<br/>[index.js]"]
end

node_main -->|"loads"| node_config_reader
node_main -->|"initializes"| node_config_logger
node_main -->|"starts"| node_prober_manager
node_main -->|"wires"| node_agg_manager
node_main -->|"starts"| node_notify_core
node_main -->|"serves"| node_resp_routes
node_config_reader -->|"parses"| node_config_schema
node_config_schema -->|"uses"| node_config_defaults
node_config_schema -->|"uses"| node_config_regex
node_config_schema -->|"configures"| node_prober_manager
node_config_schema -->|"configures"| node_notify_core
node_config_schema -->|"configures"| node_resp_routes
node_prober_manager -->|"orchestrates"| node_probe_modes
node_prober_manager -->|"tracks"| node_probe_replica
node_probe_modes -->|"emits"| node_probe_report
node_probe_replica -->|"updates"| node_probe_states
node_probe_report -->|"normalizes"| node_probe_status
node_probe_status -->|"feeds"| node_agg_manager
node_agg_manager -->|"triggers"| node_notify_core
node_agg_manager -->|"publishes"| node_resp_context
node_notify_core -->|"adapts"| node_notify_email
node_notify_core -->|"adapts"| node_notify_slack
node_notify_core -->|"adapts"| node_notify_webhook
node_resp_routes -->|"builds"| node_resp_context
node_resp_routes -->|"serves"| node_resp_announcements
node_resp_routes -->|"exposes"| node_resp_manager
node_resp_routes -->|"exposes"| node_resp_mcp
node_resp_routes -->|"serializes"| node_resp_payload
node_resp_context -->|"renders"| node_tpl_index
node_resp_context -.->|"uses"| node_asset_css
node_resp_context -.->|"uses"| node_asset_js
node_resp_announcements -.->|"shares"| node_resp_payload

click node_main "https://github.com/valeriansaliou/vigil/blob/master/src/main.rs"
click node_config_reader "https://github.com/valeriansaliou/vigil/blob/master/src/config/reader.rs"
click node_config_schema "https://github.com/valeriansaliou/vigil/blob/master/src/config/config.rs"
click node_config_defaults "https://github.com/valeriansaliou/vigil/blob/master/src/config/defaults.rs"
click node_config_regex "https://github.com/valeriansaliou/vigil/blob/master/src/config/regex.rs"
click node_config_logger "https://github.com/valeriansaliou/vigil/blob/master/src/config/logger.rs"
click node_prober_manager "https://github.com/valeriansaliou/vigil/blob/master/src/prober/manager.rs"
click node_probe_modes "https://github.com/valeriansaliou/vigil/blob/master/src/prober/mode.rs"
click node_probe_replica "https://github.com/valeriansaliou/vigil/blob/master/src/prober/replica.rs"
click node_probe_report "https://github.com/valeriansaliou/vigil/blob/master/src/prober/report.rs"
click node_probe_states "https://github.com/valeriansaliou/vigil/blob/master/src/prober/states.rs"
click node_probe_status "https://github.com/valeriansaliou/vigil/blob/master/src/prober/status.rs"
click node_agg_manager "https://github.com/valeriansaliou/vigil/blob/master/src/aggregator/manager.rs"
click node_notify_core "https://github.com/valeriansaliou/vigil/blob/master/src/notifier/mod.rs"
click node_notify_email "https://github.com/valeriansaliou/vigil/blob/master/src/notifier/email.rs"
click node_notify_slack "https://github.com/valeriansaliou/vigil/blob/master/src/notifier/slack.rs"
click node_notify_webhook "https://github.com/valeriansaliou/vigil/blob/master/src/notifier/webhook.rs"
click node_resp_routes "https://github.com/valeriansaliou/vigil/blob/master/src/responder/routes.rs"
click node_resp_announcements "https://github.com/valeriansaliou/vigil/blob/master/src/responder/announcements.rs"
click node_resp_manager "https://github.com/valeriansaliou/vigil/blob/master/src/responder/manager.rs"
click node_resp_mcp "https://github.com/valeriansaliou/vigil/blob/master/src/responder/mcp.rs"
click node_resp_context "https://github.com/valeriansaliou/vigil/blob/master/src/responder/context.rs"
click node_resp_payload "https://github.com/valeriansaliou/vigil/blob/master/src/responder/payload.rs"
click node_tpl_index "https://github.com/valeriansaliou/vigil/blob/master/res/assets/templates/index.tera"
click node_asset_css "https://github.com/valeriansaliou/vigil/blob/master/res/assets/stylesheets/index.css"
click node_asset_js "https://github.com/valeriansaliou/vigil/blob/master/res/assets/javascripts/index.js"

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_main,node_tpl_index,node_asset_css,node_asset_js toneBlue
class node_config_reader,node_config_schema,node_config_defaults,node_config_regex,node_config_logger toneAmber
class node_prober_manager,node_probe_modes,node_probe_replica,node_probe_report,node_probe_states,node_probe_status toneMint
class node_agg_manager toneRose
class node_notify_core,node_notify_email,node_notify_slack,node_notify_webhook toneIndigo
class node_resp_routes,node_resp_announcements,node_resp_manager,node_resp_mcp,node_resp_context,node_resp_payload toneTeal
```

## Components

### Source

Core Rust service code

- [Main](https://github.com/valeriansaliou/vigil/blob/master/src/main.rs): composition root · Wires config, probing, aggregation, notifications, and HTTP serving · `src/main.rs`

### Config

Configuration and logging control plane

- [Reader](https://github.com/valeriansaliou/vigil/blob/master/src/config/reader.rs): config input · Loads and interpolates config.cfg and environment values · `src/config/reader.rs`
- [Schema](https://github.com/valeriansaliou/vigil/blob/master/src/config/config.rs): config model · Defines server, branding, probes, notifications, metrics, and plugins · `src/config/config.rs`
- [Defaults](https://github.com/valeriansaliou/vigil/blob/master/src/config/defaults.rs): config defaults · Provides fallback values and baseline settings · `src/config/defaults.rs`
- [Regex](https://github.com/valeriansaliou/vigil/blob/master/src/config/regex.rs): config helper · Regex helpers used by configuration parsing and matching · `src/config/regex.rs`
- [Logger](https://github.com/valeriansaliou/vigil/blob/master/src/config/logger.rs): logging setup · Initializes logging from configuration · `src/config/logger.rs`

### Prober

Probe ingestion and normalization

- [Probe mgr](https://github.com/valeriansaliou/vigil/blob/master/src/prober/manager.rs): probe orchestration · Coordinates probe execution and report collection · `src/prober/manager.rs`
- [Modes](https://github.com/valeriansaliou/vigil/blob/master/src/prober/mode.rs): probe modes · Active poll, push, script, and local monitoring modes · `src/prober/mode.rs`
- [Replica](https://github.com/valeriansaliou/vigil/blob/master/src/prober/replica.rs): probe replica · Models per-replica probe execution and state · `src/prober/replica.rs`
- [Report](https://github.com/valeriansaliou/vigil/blob/master/src/prober/report.rs): probe report · Normalizes raw probe results into shared reports · `src/prober/report.rs`
- [States](https://github.com/valeriansaliou/vigil/blob/master/src/prober/states.rs): health states · Defines healthy, sick, and dead thresholds and transitions · `src/prober/states.rs`
- [Status](https://github.com/valeriansaliou/vigil/blob/master/src/prober/status.rs): health model · Canonical probe status used across the service · `src/prober/status.rs`

### Aggregator

Health decision layer

- [Health agg](https://github.com/valeriansaliou/vigil/blob/master/src/aggregator/manager.rs): state aggregation · Turns probe reports into service-level health decisions · `src/aggregator/manager.rs`

### Notifier

Outbound alert adapters

- [Notify core](https://github.com/valeriansaliou/vigil/blob/master/src/notifier/mod.rs): notification core · Shared notification abstraction and dispatch logic · `src/notifier/mod.rs`
- [Email](https://github.com/valeriansaliou/vigil/blob/master/src/notifier/email.rs): mailer adapter · SMTP email notification backend · `src/notifier/email.rs`
- [Slack](https://github.com/valeriansaliou/vigil/blob/master/src/notifier/slack.rs): chat adapter · Slack notification backend · `src/notifier/slack.rs`
- [Webhook](https://github.com/valeriansaliou/vigil/blob/master/src/notifier/webhook.rs): http adapter · Generic webhook notification backend · `src/notifier/webhook.rs`

### Responder

HTTP status and API layer

- [Routes](https://github.com/valeriansaliou/vigil/blob/master/src/responder/routes.rs): http routes · Public endpoints for status, APIs, and responses · `src/responder/routes.rs`
- [Announcements](https://github.com/valeriansaliou/vigil/blob/master/src/responder/announcements.rs): public messages · Operational announcements shown on the status page · `src/responder/announcements.rs`
- [Manager API](https://github.com/valeriansaliou/vigil/blob/master/src/responder/manager.rs): admin api · Authenticated administrative actions using manager_token · `src/responder/manager.rs`
- [MCP](https://github.com/valeriansaliou/vigil/blob/master/src/responder/mcp.rs): read-only api · Optional read-only endpoint for tooling access · `src/responder/mcp.rs`
- [Context](https://github.com/valeriansaliou/vigil/blob/master/src/responder/context.rs): page model · Builds rendering context for status and API responses · `src/responder/context.rs`
- [Payload](https://github.com/valeriansaliou/vigil/blob/master/src/responder/payload.rs): response model · Defines response bodies and API payload shapes · `src/responder/payload.rs`

### Assets

Static UI assets and templates

- [Status page](https://github.com/valeriansaliou/vigil/blob/master/res/assets/templates/index.tera): template · Primary Tera template for the public status page · `res/assets/templates/index.tera`
- [Styles](https://github.com/valeriansaliou/vigil/blob/master/res/assets/stylesheets/index.css): static css · Stylesheets for the public status page · `res/assets/stylesheets/index.css`
- [Scripts](https://github.com/valeriansaliou/vigil/blob/master/res/assets/javascripts/index.js): static js · Client-side behavior for the public status page · `res/assets/javascripts/index.js`

## Connections

- Main → Reader: loads · Bootstraps runtime settings from config and environment
- Main → Logger: initializes · Sets up logging before other subsystems
- Main → Probe mgr: starts · Runs probe ingestion and monitoring loops
- Main → Health agg: wires · Connects probe outputs to health aggregation
- Main → Notify core: starts · Enables outbound notifications
- Main → Routes: serves · Starts the public HTTP responder
- Reader → Schema: parses · Fills the central configuration model
- Schema → Defaults: uses · Applies fallback values
- Schema → Regex: uses · Supports pattern-based matching and validation
- Schema → Probe mgr: configures · Supplies probe definitions and runtime thresholds
- Schema → Notify core: configures · Supplies notification targets and triggers
- Schema → Routes: configures · Supplies server, branding, and API settings
- Probe mgr → Modes: orchestrates · Dispatches work across monitoring modes
- Probe mgr → Replica: tracks · Handles replica-aware execution
- Modes → Report: emits · Produces normalized probe reports
- Replica → States: updates · Maps execution outcomes to health thresholds
- Report → Status: normalizes · Converts raw results into canonical status
- Status → Health agg: feeds · Provides canonical health input to aggregation
- Health agg → Notify core: triggers · Raises alerts on meaningful state changes
- Health agg → Context: publishes · Exposes current service health to the UI layer
- Notify core → Email: adapts · Sends email notifications
- Notify core → Slack: adapts · Sends Slack notifications
- Notify core → Webhook: adapts · Sends webhook notifications
- Routes → Context: builds · Prepares view state and API context
- Routes → Announcements: serves · Displays and updates announcements
- Routes → Manager API: exposes · Hosts manager-authenticated admin actions
- Routes → MCP: exposes · Hosts optional read-only tooling access
- Routes → Payload: serializes · Formats JSON and API payloads
- Context → Status page: renders · Feeds the public status page template
- Context → Styles: uses · Pairs UI state with static styling
- Context → Scripts: uses · Pairs UI state with client-side behavior
- Announcements → Payload: shares · Reuses response shapes for announcement data
