About Modularization

In large-scale web business systems, it is inevitable to include a large number of businesses and functions. CabloyJS adopts a modular architecture, and the actual business code development is carried out in modules

When we develop a business system, we must first plan how many modules we need to split the system into. Which modules directly adopt the built-in core modules of CabloyJS, which modules are contributed by the third-party community, and the remaining modules are self-developed

Benefits of Modularization

  1. Business decoupling: clear code structure and fully decoupled business logic

  2. Division of cooperation, team development: the business system is divided into modules, which is conducive to the decomposition and allocation of development tasks

  3. Focus of attention: a module contains the frontend UI and backend API interface of a sub business, which can reduce internal communication friction and improve development efficiency during development

  4. Reduce mental burden: the namespace isolation mechanism of the module helps to reduce the mental burden during development. When we name variables for components such as controller, service, config, etc. in the module, we don’t have to worry that this name will conflict with other modules, which can also make variable naming more concise and natural

  5. Business logic reuse: Taking modules as development units, it is convenient to deposit technical assets and reuse them in different systems

Create Module

If want to create a new module named as demo-student, enter the project path and run the cli command:

  1. 1$ cd /path/to/project
  2. 2$ npm run cli :create:module demo-student -- --template=module-business
  • Three module templates are currently available:
Name Description
module-business this template creates business-related code that greatly simplifies the workload
module-business-details module-business + details related code files
module this template contains only the basic skeleton code files