Is it possible to have a top level module? (dry-system)

Hey all,

Is it possible to have a top level module with dry-system? Standard ruby app, using agoo as the web server. File structure is as follows:

├── orders
│   ├── repositories
│   │   └── repo_1.rb
│   ├── consumers
│   │   └── consumer_1.rb
│   ├── tasks

Before adding dry-system; everything is under the Orders module and works fine. So Orders::Repositories::Repo1 etc etc. I can’t see to figure this out with dry-system however.

This is what my current container looks like:

require "dry/system/container"

class Application < Dry::System::Container
  # use :logging
  use :monitoring
  use :env, inferrer: -> { ENV.fetch("RACK_ENV", :development).to_sym }

  configure do |config| = :order
    config.auto_register = %w[lib]

  load_paths! "config", "lib", "system"

# requiring other dependecies here like pry, bundler/setup etc.

I’ve managed this in a previous project with nested containers. We had an application container, and another container for the top-level module. Is this the expected way to do it?

Because we had weird issues where a file out of the blue, didn’t get auto registrered (After working fine for months) and we had to require it manually after that. If it’s the expected way to to do it then that’s fine I will do it again, if not then can somoene advise on how they achieved it? Thanks.

I feel like this file structure is a common pattern in ruby so I’m suprised there is little documentation/examples covering it. Will add one if I get a solid solution.

I strongly recommend using an application namespace. I’ve no idea how and if dry-system can work correctly without this. If you’re having issues then please create a sample setup so we could look into it.