Exposing DB Queries in a Modular Monolith: Examples and Methods for Decoupling Views from Search with Subsystem API

This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.

Have you seen examples of how to expose DB query to the user, on the view, in a modular monolith? In the past, I’ve used the Ransack gem for this. And I’ve found a way to do it with a modular monolith, essentially passing the Ransack query hash: view->controller->subsystem API->service->ransack on model.

The most common means that I’ve seen of building these pages, especially when advanced queries can be constructed (user deciding which and how many filters to apply to the where clause) is through Ransack’s search form helpers (which integrates with things like simple_form). But that search_form helper requires a Ransack search object, which wants to be tied the model itself.

What have you seen/done to decouple the view from the search through a subsystem API while still creating an Advanced Query builder UI with clean code?

Maybe, not 100% what you’re looking for, but consider:
https://hammerstone.dev (provides Filter objects and UI helpers; a bit opinionated)
https://github.com/palkan/rubanok (only Filter (processor) objects, not UI integrations built-in; very flexible)