meteor-boilerplate icon indicating copy to clipboard operation
meteor-boilerplate copied to clipboard

structure for multiple modules/sub projects?

Open thearabbit opened this issue 10 years ago • 1 comments

I have more then one modules in the same project like this:

cpanel: (manage user account, company and branch info ...)

loan system

saving system

account system

and all of modules work with together. how to build structure for this?

thearabbit avatar Feb 19 '15 02:02 thearabbit

I wrote a blog post about this awhile ago: http://www.patrickcoffey.io/post/structuring-meteor-applications

Here's a snippet that is relevant and may answer your question:

Organizing files by feature

I've found that one of the best ways to organize files is to group them by feature. (I refer to "sets of features" as "modules", just for clarity.) For instance, if you have a feature of your application that handles user dashboards and login details, they should be grouped into folders that have the same name within their environment-specific folder, like so:

  • /client/modules/user_dashboard - Holds view files, interface event handlers, route definitions, etc.
  • /server/modules/user_dashboard - Holds publication functions, permission settings, etc.
  • /lib/modules/user_dashboard - Holds collection definitions, and data validation/formatting functions, etc.

This organization pattern helps developers separate code files by module. Using this pattern enables multiple developers to work on the same project without conflict. It also makes maintenance a lot easier, and allows for organized documentation.

The difficult thing about this pattern is knowing when a block of code should be placed in an existing module, and when it should be in it's own module. I've found that following one rule can help mitigate this problem: If a piece of code is directly/exclusively used by, specifically related to, and accurately defined by a module that currently exists, place it in that module. If a piece of code may have multiple dependents and isn't specifically related to any of it's dependents, it should be it's own module.

patrickocoffeyo avatar Jun 02 '15 23:06 patrickocoffeyo