$ show brotandgames/ciao
Ciao is a self-contained, zero-external-dependency HTTP(S) endpoint monitoring application built with Ruby on Rails 8. It schedules periodic health checks with cron syntax using the in-process rufus-scheduler, stores state in a local SQLite database, and notifies users of status changes via email or configurable webhooks (e.g., Slack, Rocket.Chat). The application also monitors TLS certificate expiration for HTTPS endpoints and sends alerts when certificates are due to expire. It provides a web UI with a dashboard, a RESTful JSON API, optional Prometheus metrics, and HTTP Basic authentication. The codebase is a standard Rails monolith with a single process for web server, scheduler, and background work, making it easy to deploy (Docker, Helm chart, or direct Ruby). The architecture is simple but effective for small-to-medium monitoring needs.
The LLM identified 3 files worth highlighting for reuse:
A simple string replacement renderer that substitutes predefined placeholders (__name__, __status_after__, __status_before__, __url__, __check_url__, __tls_expires_at__, __tls_expires_in_days__) with provided data. It is used by webhook notification payloads to generate custom messages. The component is isolated, has no external dependencies beyond the base class, and can be reused in any project that needs a lightweight placeholder-to-value template engine. It demonstrates the strategy pattern via the Ciao::Renderers::Base abstract class.
A parser that discovers webhook configurations from environment variables following a naming convention (CIAO_WEBHOOK_ENDPOINT_<NAME>, CIAO_WEBHOOK_PAYLOAD_<NAME>, CIAO_WEBHOOK_PAYLOAD_TLS_EXPIRES_<NAME>). It extracts endpoint URLs, payload templates, and TLS-specific payloads into a structured array. This pattern is reusable for any project that needs to dynamically load multiple named configurations from environment variables, and it encapsulates the parsing logic cleanly.
The abstract base class for all notification channels (mail, webhook). It defines the interface with a #notify(payload_data) method that raises NotImplementedError, ensuring subclasses implement the actual delivery. The constructor accepts an endpoint, payload template, and a renderer class, allowing dependency injection of the payload rendering strategy. This pattern cleanly separates notification logic from rendering and can be reused to add new notification channels (e.g., SMS, Telegram) without modifying existing code.