I have been building a Rails app that started small but is quickly expanding. I followed the standard MVC pattern in the beginning but I am finding it harder to manage things as the app grows. There are more features, more business logic & I have started using service objects, concerns & background jobs but it is getting a little chaotic.
I want to know how others in the community keep their projects clean & maintainable when they reach this stage. Do you use any patterns, folder structures or gems that help with organization? How early do you break things into modules or services?
I did take a rails course a while back but it mostly focused on CRUD apps & did not go into app architecture for more complex projects. So I want to hear how real-world developers handle scaling their codebase.
What has worked for me is to use OOD to decompose the logic into different domain objects that live either on lib/ or on app/domain. I recommend you take a look at Sandi Metz books and this article that provides some practical examples of different rails design patterns you can use.
Use service objects, form objects, and interactors early. Group by domain instead of Rails’ default (e.g., app/domains/payments). Use gems like dry-rb, Interactor, or Trailblazer if complexity grows. Background jobs in app/jobs, shared logic in lib/ or app/services. Refactor often. Clean architecture or DDD patterns help when scaling.