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

Self developed modules are called local modules and are located in the src/module directory of the project

If want to create a new module named as demo-student, go to 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 --suite=
Name Description
moduleName Module Name, such as demo-student
template Template Name, such as module-business
suite Suite Name: A module can belong to a suite or exist independently
  • template: Three module templates are currently available:
Name Description
module-business this template creates business-related code that greatly simplifies the workload
module-business-details files related to master-details business are added on the basis of module-business
module this template contains only the basic skeleton code files

Troika: Suite, Module, App

To cope with the development of large projects, CabloyJS provides troika: Suite, Module and App

  • Suites/Modules: Used to organize source codes, refer to: Suite

  • Apps: Used to provide different UI layouts for different business scenarios and different end users, refer to: App