v0.1.0

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
  1. graph TB
  2. Main[cmd/tui main] -->|util.Read / util.Save| Store[(.webMonitor.json)]
  3. Main -->|service.New| Monitor[service.Monitor]
  4. Main -->|service.NewUI| UI[service.UI]
  5. UI -->|Ticker every minute / refresh| Monitor
  6. UI -->|command methods| Monitor
  7. Monitor -->|Check: HEAD → GET| Site[Target site]
  8. Monitor -->|util.CheckExpire| TLS[Target site :443]
  9. Monitor -->|sendEmail / TestEmail| SMTP[service.SMTP]
  10. SMTP --> Mail[Mail server]
  11. Monitor -->|Save| Store

Layers


LayerPackage / FileResponsibility
Entrycmd/tui/main.goCreates or reads .webMonitor.json, wires Monitor and UI, then runs
Interfaceinternal/service/ui.gotview interface, one-minute schedule, command parsing, table and panel rendering
Monitor coreinternal/service/monitor.goWatch list and status table, HTTP probing, failure counting, alert triggering, SMTP config management
Mailerinternal/service/smtp.goPicks plain / implicit TLS / STARTTLS by port and sends HTML email
Utilitiesinternal/util/JSON config file IO and SSL certificate days remaining
Data modelinternal/model/model.goWebsite, Config, MonitorData

Cross-Cutting Principles


PrincipleImplementation
One persistence fileAll state and settings live in .webMonitor.json in the current directory; no database or external service
State lives in MonitorUI holds no data and reads or writes only through Monitor getters and command methods
Shared state guarded by sync.RWMutexlist, status, config, and isShow share one lock
Standard-library networkingHTTP, 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


中文