Mantra how-to guide

Components locations: the right organization

How to distribute your project components in Mantra components locations

07-Mar-2022
A  A  A 

As a project is getting bigger, this is, with more and more functionality and components, to organize project assets it's getting more important over time.

Mantra framework forces some kind of assets to be well organized (the locations for views under /ui folder, post and get handlers inside /controllers and so on).

But when your project start to have lots of components, is necesary to arrange them as well.

This site, for example, in the time of writing this, has about 80 components, thus, they are organized in diferent folders according to their purpose.

In "ComponentsLocations" of mantraconfig.json file, you can set a number of locations for your components.

Use that property wisely, for example:

  • "/components/base": location for low level components of your projects that exposes functionality to others of higher levels.

  • "/components/admin": location for components with some kind of administration functionality.

  • "/components/events": location for components which manage aplications events.

  • etc.

Given that sort of organization, you can manage yor project components much better.