How ygqygq2/easy-check works
Project Type and Purpose
• easy-check is a cross-platform (Windows, Linux, macOS) desktop application built with Go (backend) and React/TypeScript (frontend) via the Wails framework.
• It periodically pings a user-defined list of hosts, logs the results (time-series DB + log files), displays status on a UI, aggregates alert conditions, and sends notifications (e.g., Feishu). It also supports OS-level auto-start on boot.
File-Structure Analysis
• Top-level directories:
• cmd / main.go & main_*: entrypoints for different OS builds.
• internal/: Go packages implementing core logic (scheduler, checker, aggregator, notifier, logger, DB, config, etc.).
• frontend/: React/Vite app, bound to Go via Wails (bindings folder).
• configs/: YAML file for host list & intervals.
• build/ & scripts/: CI/CD pipelines and platform packaging (macOS .app, Linux AppImage/nfpm, Windows NSIS).
• Patterns: clear separation of UI (frontend) and service layer (internal), event-driven scheduling/queue modules, dependency injection via wire.
README Insights
• Configuration-driven host list and interval.
• Scripts to install as a service/auto-start.
• Features: UI, periodic pings, log persistence, aggregation, notification.
• UI Layer (React front end inside Wails webview)
• RPC / Binding Layer (Wails bridges)
• Core Services (Go internal packages):
– Scheduler: triggers ping jobs on interval
– Checker: executes ping logic per host (platform-specific implementations)
– Aggregator: processes raw results to detect alerts/recoveries
– Notifier: sends alerts via Feishu (external API) or noop
– Logger: writes to time-series DB + log files; exposes WebSocket for live UI updates
– Config Watcher: reads configs/config.yaml and hot-reloads
– Queue: internal job queue for decoupling
• Data Storage:
– Time-series DB (.tsdb)
– Flat log files
• External Dependencies:
– Target Hosts (network)
– Feishu (HTTP API)
– OS (auto-start service/install scripts)
1. UI → RPC → Core Services (user changes settings, requests data).
2. Config Watcher → Scheduler (provides host list & intervals).
3. Scheduler → Queue → Checker (job dispatch).
4. Checker → Logger (records timestamped results).
5. Logger → DB & log file (persistence).
6. Logger → WebSocket → UI (live updates).
7. Logger → Aggregator → Notifier → External Service (Feishu).
8. UI ↔ Config Watcher (edit & persist config).
c. Architectural Patterns & Principles:
• Modular, layered architecture (UI / RPC / Services / Data).
• Event-driven & queue-based decoupling between scheduler and checker.
• Dependency injection for testability (wire).
• Cross-platform abstractions for ping and restart.
• Filesystem + embedded DB for persistence; WebSocket for real-time UI.
d. Key Technologies & Frameworks:
• Go (backend), Wails (bindings & packaging), React + Vite (frontend), TypeScript, TSDB, NSIS/AppImage/nfpm, GitHub Actions, GoReleaser.