|
| 1 | +# Architecture |
| 2 | + |
| 3 | +Local host health-check daemon. Runs checks, tracks state, sends alerts on transitions. |
| 4 | + |
| 5 | +## System Context |
| 6 | + |
| 7 | +```mermaid |
| 8 | +graph LR |
| 9 | + Cron[LaunchAgent] -->|interval| Daemon |
| 10 | + Daemon -->|shell exec| Checks[Health Checks] |
| 11 | + Daemon -->|on transition| Notify[Notifiers] |
| 12 | + Notify --> Ntfy[(ntfy)] |
| 13 | + Notify --> Cmd[(command)] |
| 14 | + CLI[CLI] -->|one-shot| Checks |
| 15 | + CLI -->|TUI| Status[Status View] |
| 16 | + Status --> Checks |
| 17 | + Daemon & CLI -->|read| Config[(~/.config/config.toml)] |
| 18 | + Daemon -->|write| Alerts[(alerts.log)] |
| 19 | +``` |
| 20 | + |
| 21 | +## Components |
| 22 | + |
| 23 | +| Component | Responsibility | |
| 24 | +|-----------|---------------| |
| 25 | +| **cmd** | Cobra CLI: check, status, daemon, init, validate, notify | |
| 26 | +| **runner** | Execute checks, filter, collect results | |
| 27 | +| **daemon** | Continuous loop, fail/recover transition tracking | |
| 28 | +| **notify** | Alert backends (ntfy, command), cooldown logic | |
| 29 | +| **tui** | Bubbletea status display, watch mode | |
| 30 | +| **config** | TOML parsing, validation | |
| 31 | + |
| 32 | +## Check Lifecycle |
| 33 | + |
| 34 | +```mermaid |
| 35 | +stateDiagram-v2 |
| 36 | + [*] --> Passing: check passes |
| 37 | + [*] --> Failing: check fails |
| 38 | + Passing --> Failing: check fails → alert CRIT |
| 39 | + Failing --> Passing: check passes → alert RECOVERED |
| 40 | + Failing --> Failing: still failing (cooldown suppresses) |
| 41 | +``` |
| 42 | + |
| 43 | +## Key Design Decisions |
| 44 | + |
| 45 | +| Decision | Choice | Why | |
| 46 | +|----------|--------|-----| |
| 47 | +| Shell-exec checks | Run any command | Maximum flexibility, no custom check API | |
| 48 | +| Detect only (v1) | No auto-remediation | Keep it simple, alert humans | |
| 49 | +| Transition alerts | Only on state change | No alert spam | |
| 50 | +| Cooldown per backend | Configurable per notifier | Different urgency per channel | |
| 51 | +| Status TUI bypasses bubbletea in non-watch | Direct View() render | Works without TTY (CI, pipes) | |
0 commit comments