Architecture
Last updated
This page shows how the go-web-monitor packages layer together in one diagram, then lists each layer's responsibility, the principles shared across layers, and its deployment shape.
System Overview
graph TB
Main[cmd/tui main] -->|util.Read / util.Save| Store[(.webMonitor.json)]
Main -->|service.New| Monitor[service.Monitor]
Main -->|service.NewUI| UI[service.UI]
UI -->|Ticker every minute / refresh| Monitor
UI -->|command methods| Monitor
Monitor -->|Check: HEAD → GET| Site[Target site]
Monitor -->|util.CheckExpire| TLS[Target site :443]
Monitor -->|sendEmail / TestEmail| SMTP[service.SMTP]
SMTP --> Mail[Mail server]
Monitor -->|Save| Store- graph TB
- Main[cmd/tui main] -->|util.Read / util.Save| Store[(.webMonitor.json)]
- Main -->|service.New| Monitor[service.Monitor]
- Main -->|service.NewUI| UI[service.UI]
- UI -->|Ticker every minute / refresh| Monitor
- UI -->|command methods| Monitor
- Monitor -->|Check: HEAD → GET| Site[Target site]
- Monitor -->|util.CheckExpire| TLS[Target site :443]
- Monitor -->|sendEmail / TestEmail| SMTP[service.SMTP]
- SMTP --> Mail[Mail server]
- Monitor -->|Save| Store
Layers
| Layer | Package / File | Responsibility |
|---|---|---|
| Entry | cmd/tui/main.go | Creates or reads .webMonitor.json, wires Monitor and UI, then runs |
| Interface | internal/service/ui.go | tview interface, one-minute schedule, command parsing, table and panel rendering |
| Monitor core | internal/service/monitor.go | Watch list and status table, HTTP probing, failure counting, alert triggering, SMTP config management |
| Mailer | internal/service/smtp.go | Picks plain / implicit TLS / STARTTLS by port and sends HTML email |
| Utilities | internal/util/ | JSON config file IO and SSL certificate days remaining |
| Data model | internal/model/model.go | Website, Config, MonitorData |
Cross-Cutting Principles
| Principle | Implementation |
|---|---|
| One persistence file | All state and settings live in .webMonitor.json in the current directory; no database or external service |
| State lives in Monitor | UI holds no data and reads or writes only through Monitor getters and command methods |
Shared state guarded by sync.RWMutex | list, status, config, and isShow share one lock |
| Standard-library networking | HTTP, TLS, and SMTP use only the standard library; the only third-party packages are tview and tcell |
Deployment Shape
Uptime Kuma and Gatus run as self-hosted services that serve a web dashboard or status page, and both ship Docker images. updo and statusok are Go programs you start from a terminal, closer to this project: updo shows an interactive TUI and sends desktop or webhook notifications, and statusok reads a
config.json and notifies through Slack or SMTP email. go-web-monitor is a single TUI process with no web server: the watch list and SMTP settings live in one .webMonitor.json that you change with commands inside the interface, every site is checked once a minute with HEAD first and GET as the fallback, each row shows the SSL certificate days remaining, and an email goes out only after 5 consecutive offline checks.Further Reading
- Full module-level diagrams (module internals, sequence, state machines): doc/architecture.md
- The flow of one check round: Monitoring Cycle