Could Someone Give me Advice on Best Practices for Multi-Module Applications in ColdBox?

Hello there,

I have been working with ColdBox for a while and have recently taken on a project that involves building a fairly complex application using a multi module architecture. While I am familiar with the basics of creating and organizing modules; I am seeking some advice on best practices; particularly for larger applications.

What are the recommended ways for modules to communicate with each other? I have read about using the message box and module services; but I am curious if there are any other approaches or patterns that work well; especially in terms of maintaining loose coupling and scalability.

In cases where several modules need to share certain services or utilities; how do you typically handle this? Do you place these shared components in a core or common module, or is there another strategy that works better?

Managing routes and event handling across multiple modules can get tricky. What are some effective ways to keep routing organized and ensure that event handlers are appropriately scoped and not conflicting?

When dealing with multiple modules; what are the best practices for implementing security; particularly regarding authentication and authorization? How do you ensure that security rules are consistently applied across all modules?

Also, I have gone through this post; https://community.ortussolutions.com/t/what-is-a-good-way-to-set-up-an-application-to-be-used-by-multiple-clients-domain-enterprise-aws-devops/ which definitely helped me out a lot.

For those who have experience with deploying multi module applications; how do you manage versioning and updates? Are there any tools or workflows that have proven helpful in streamlining this process?

Thank you in advance for your help and assistance. :innocent:

Hi roberrttt

An unrelated Google search led me to your post. This is an interesting question and I’d like to learn more about what other people are doing, too.

Here’s my approach:

  1. Lean on the ColdBox routing DSL and routing by convention as much as possible. Each module correlates to subdirectories in the URL (same name/mapping). Consistent handler and actions names in each module for similar actions (e.g. handler named “sprokets” and actions named edit and view in each).
  2. Write custom routes in each module’s config/Router.cfc file as needed (i.e., for pattern placeholders).
  3. Put common services into a separate module and call it something like “utilities.” This is mostly for services or system-wide objects. For me, this module has no handlers and is strictly for back-end processes.
  4. I use CBSecurity. The rules are set in JSON file each module’s config. The global validator is in that utilities module.
  5. I use Git to manage versioning and updates and that meets my needs. For more complex needs, I would look for ideas from that other post you mentioned about multiple clients , altering the entry point (URL) to directory correlation in moduleConfig file, and the approach that Maria described in this blog post about versioning APIs: Modularizing Your API in ColdBox: Easy Versioning Made Simple

There is some repetitive code in the modules’ security and routing with this approach, but I find it easy to manage because it’s mostly confined to the config files and some thin handlers (e.g. send update actions to the update utility).

Hope this reply reaches you in time to help!

  • Annette