SourceMonitor
SourceMonitor is a production-ready Rails 8 mountable engine for ingesting, normalising, scraping, and monitoring RSS/Atom/JSON feeds. It ships with a Tailwind-powered admin UI, Solid Queue job orchestration, Solid Cable realtime broadcasting, and an extensible configuration layer so host applications can offer full-stack feed operations without rebuilding infrastructure.
Note: Application developers consume SourceMonitor via RubyGems—add the gem to your host application's Gemfile and follow the guided installer. Clone this repository only when contributing to the engine itself.
Installation (RubyGems)
In your host Rails app:
bundle add source_monitor --version "~> 0.1.2"
# or add `gem "source_monitor", "~> 0.1.2"` manually, then run:
bundle installThis exposes bin/source_monitor (via Bundler binstubs) so you can run the guided workflow described below.
Highlights
- Full-featured source and item administration backed by Turbo Streams and Tailwind UI components
- Adaptive fetch pipeline (Feedjira + Faraday) with conditional GETs, retention pruning, and scrape orchestration
- Realtime dashboard metrics, batching/caching query layer, and Mission Control integration hooks
- Extensible scraper adapters (Readability included) with per-source settings and structured result metadata
- Declarative configuration DSL covering queues, HTTP, retention, events, model extensions, authentication, and realtime transports
- First-class observability through ActiveSupport notifications and
SourceMonitor::Metricscounters/gauges
Requirements
- Ruby 3.4.4 (we recommend rbenv for local development:
rbenv install 3.4.4 && rbenv local 3.4.4, but use whatever Ruby version manager suits your environment—asdf, chruby, rvm, or container-based workflows all work fine) - Rails ≥ 8.0.2.1 in the host application
- PostgreSQL 13+ (engine migrations use JSONB, SKIP LOCKED, advisory locks, and Solid Cable tables)
- Node.js 18+ (npm or Yarn) for asset linting and the Tailwind/esbuild bundling pipeline
- Solid Queue workers (Rails 8 default) and Solid Cable (default realtime adapter)
- Optional: Mission Control Jobs for dashboard linking, Redis if you opt into the Redis realtime adapter
Quick Start (Host Application)
Command prefixes: Examples below show bare
bundle,bin/rails, andbin/source_monitor. If you use rbenv/asdf or containerized tooling, prefix/adjust commands accordingly so they run inside your Ruby environment.
Install the Gem
Before running any SourceMonitor commands inside your host app, add the gem and install dependencies:
bundle add source_monitor --version "~> 0.1.2"
# or edit your Gemfile, then run
bundle installRecommended: Guided Workflow
-
Optional prerequisite check:
bin/rails source_monitor:setup:check -
Run the guided installer:
bin/source_monitor install --yes- Prompts for the mount path (default
/source_monitor), adds the gem entry when missing, runsbundle install,npm install(whenpackage.jsonexists), copies/deduplicates migrations, patches the initializer, and runs verification.
- Prompts for the mount path (default
-
Start workers / scheduler:
bin/rails solid_queue:startand, if you use recurring jobs,bin/jobs --recurring_schedule_file=config/recurring.yml. -
Verify anytime:
bin/source_monitor verify(also exposed asbin/rails source_monitor:setup:verify). The command prints a human summary plus JSON so CI can gate on Solid Queue and Action Cable health. - Visit the dashboard at the chosen mount path and trigger “Fetch Now” on a source to confirm everything is wired.
See docs/setup.md for the full workflow (prereq table, gem installation, rollback steps, telemetry flag, Devise system test template).
Manual Install (Advanced)
Prefer explicit Rails generator steps or need to customize each phase? The same document covers a full Manual Installation section so you can copy/paste each command into bespoke pipelines.
Troubleshooting advice lives in docs/troubleshooting.md.
Upgrading SourceMonitor
- Bump the gem version in your host
Gemfileand runbundle install(orbundle update source_monitorwhen targeting a specific release). - Re-run
bin/rails railties:install:migrations FROM=source_monitorand thenbin/rails db:migrateto pick up schema changes. - Compare your
config/initializers/source_monitor.rbagainst the newly generated template for configuration diffs (new queue knobs, HTTP options, etc.). - Review release notes for optional integrations—when enabling Mission Control, ensure
mission_control-jobsstays mounted and linked viaconfig.mission_control_dashboard_path. - Smoke test Solid Queue workers, Action Cable, and admin UI flows after the upgrade, and run
bin/source_monitor verifyso CI/deploys confirm workers/cable health before rollout.
Example Applications
-
examples/basic_host/template.rb– Minimal host that seeds a Rails blog source and redirects/to the dashboard. -
examples/advanced_host/template.rb– Production-style integration with Mission Control, Redis realtime, Solid Queue tuning, and metrics endpoint. -
examples/custom_adapter/template.rb– Registers the sample Markdown scraper adapter and seeds a Markdown-based source. -
examples/docker– Dockerfile, Compose stack, and entrypoint script that run any generated example alongside Postgres and Redis.
See examples/README.md for usage instructions.
Architecture at a Glance
-
Source Lifecycle –
SourceMonitor::Fetching::FetchRunnercoordinates advisory locking, fetch execution, retention pruning, and scrape enqueues. Source models store health metrics, failure states, and adaptive scheduling parameters. -
Item Processing –
SourceMonitor::Items::RetentionPruner,SourceMonitor::Scraping::Enqueuer, andSourceMonitor::Scraping::ItemScraperkeep content fresh, ensure deduplicated storage, and capture scrape metadata/logs. -
Scraping Pipeline – Adapters inherit from
SourceMonitor::Scrapers::Base, merging default + source + invocation settings and returning structured results. The bundled Readability adapter composesSourceMonitor::Scrapers::Fetchers::HttpFetcherandSourceMonitor::Scrapers::Parsers::ReadabilityParser. -
Realtime Dashboard –
SourceMonitor::Dashboard::Queriesbatches SQL, caches per-request responses, emits instrumentation (source_monitor.dashboard.*), and coordinates Turbo broadcasts via Solid Cable. -
Observability –
SourceMonitor::Metricstracks counters/gauges for fetches, scheduler runs, and dashboard activity. ActiveSupport notifications (source_monitor.fetch.*,source_monitor.scheduler.run, etc.) let you instrument external systems without monkey patches. -
Extensibility –
SourceMonitor.configureexposes namespaces for queue tuning, HTTP defaults, scraper registry, retention, event callbacks, model extensions, authentication hooks, realtime transports, health thresholds, and job metrics.
Admin Experience
- Dashboard cards summarising source counts, recent activity, queue visibility, and upcoming fetch schedules
- Source CRUD with scraping toggles, adaptive fetch controls, manual fetch triggers, and detailed fetch log timelines
- Item explorer showing feed vs scraped content, scrape status badges, and manual scrape actions via Turbo
- Fetch/scrape log viewers with HTTP status, duration, backtrace, and Solid Queue job references
Background Jobs & Scheduling
- Solid Queue becomes the Active Job adapter when the host app still uses the inline
:asyncadapter; queue names default tosource_monitor_fetchandsource_monitor_scrapeand honourActiveJob.queue_name_prefix. -
config/recurring.ymlschedules minute-level fetches and scrapes. Runbin/jobs --recurring_schedule_file=config/recurring.yml(or setSOLID_QUEUE_RECURRING_SCHEDULE_FILE) to load recurring tasks. Disable withSOLID_QUEUE_SKIP_RECURRING=true. - Retry/backoff behaviour is driven by
SourceMonitor.configure.fetching. Fetch completion events and item processors allow you to chain downstream workflows (indexing, notifications, etc.).
Configuration & API Surface
The generated initializer documents every setting. Key areas:
- Queue namespace/concurrency helpers (
SourceMonitor.queue_name(:fetch)) - HTTP, retry, and proxy settings (Faraday-backed)
- Scraper registry (
config.scrapers.register(:my_adapter, "MyApp::Scrapers::Custom")) - Retention defaults (
config.retention.items_retention_days,config.retention.strategy) - Lifecycle hooks (
config.events.after_item_created,config.events.register_item_processor) - Model extensions (table prefixes, included concerns, custom validations)
- Realtime adapter selection (
config.realtime.adapter = :solid_cable | :redis | :async) - Authentication helpers (
config.authentication.authenticate_with,authorize_with, etc.) - Mission Control toggles (
config.mission_control_enabled,config.mission_control_dashboard_path) - Health thresholds driving automatic pause/resume
See docs/configuration.md for exhaustive coverage and examples.
Deployment Considerations
- Copy engine migrations before every deploy and run
bin/rails db:migrate. - Precompile assets so SourceMonitor's bundled CSS/JS outputs are available at runtime.
- Run dedicated Solid Queue worker processes; consider a separate scheduler process for recurring jobs.
- Configure Action Cable (Solid Cable by default) and expose
/cablethrough your load balancer. - Monitor gauges/counters emitted by
SourceMonitor::Metricsand subscribe to notifications for alerting.
More production guidance, including process topology and scaling tips, is available in docs/deployment.md.
Troubleshooting & Support
Common installation and runtime issues (missing migrations, realtime not streaming, scraping failures, queue visibility gaps) are documented in docs/troubleshooting.md. When you report bugs, include your SourceMonitor::VERSION, Rails version, configuration snippet, and relevant fetch/scrape logs so we can reproduce quickly.
Development & Testing (Engine Repository)
- Install dependencies with
bundle installandnpm install(prefix withrbenv execif using rbenv). - Use
test/dummy/bin/devto boot the dummy app with npm CSS/JS watchers, Solid Queue worker, and Rails server. - Run tests via
bin/test-coverage(SimpleCov-enforced),bundle exec rake app:test:smokefor the fast subset, orbin/rails testfor targeted suites. - Quality checks:
bin/rubocop,bin/brakeman --no-pager,bin/lint-assets. - Record HTTP fixtures with VCR under
test/vcr_cassettes/and keep coverage ≥ 90% for new code.
Contributions follow the clean architecture and TDD guidelines in .ai/project_overview.md. Review .ai/tasks.md to align with the active roadmap slice before opening a pull request.
License
SourceMonitor is released under the MIT License.