With Hanami you can build your project by following the Monolith-First principle. As you add more code to the project, you can grow it organically, by splitting the project into several Hanami apps.

    A real world Hanami project could have dozens of Hanami apps in the same project (for example, web for the front-end, admin for the administration, api for a JSON API, etc…) You might want to deploy them to different servers, even though they’re all a part of the same project. For example, most of the servers could be used for the web app (for customers on the site), a couple could be used for an api (perhaps for customers using mobile apps), and you could have a single server running and admin application, since it’ll likely get less traffic than the other two.

    We support this, with selective booting:

    1. # config/environment.rb
    2. # ...
    3. Hanami.configure do
    4. if Hanami.app?(:web)
    5. require_relative '../apps/web/application'
    6. mount Web::Application, at: '/'
    7. end
    8. if Hanami.app?(:api)
    9. require_relative '../apps/api/application'
    10. mount Api::Application, at: '/api'
    11. end
    12. if Hanami.app?(:admin)
    13. require_relative '../apps/admin/application'
    14. mount Admin::Application, at: '/admin'
    15. end
    16. end

    You can declare which apps to use with the HANAMI_APPS environment variable. You can provide a single app, or several apps (joined with commas):

    1. $ HANAMI_APPS=web,api bundle exec hanami server

    This would start only the web and api applications.