Modules
A module is a template describing how to handle a particular service or piece of equipment.
Each module contains the following items within the codebase:
├── assets - images used in module documentation
├── client
│ ├── components - any custom components used in this module
│ ├── panels - the container panels defined - usually 'ConfigPanel', 'MainPanel' etc
│ ├── Module.jsx - provides routing using <BugModuleWrapper /> and <Route>s
│ └── Toolbar.jsx - adds custom UI to the UI toolbar
├── container
│ ├── api - hosts routes and express server logic
│ ├── services - usually service handlers for API calls eg 'interface-get', 'interface-list', 'interface-enable'
│ ├── utils - utility scripts local to this module
│ ├── workers - worker scripts used to poll the device or service
│ ├── Dockerfile - automatically generated by BUG
│ └── package.json - NPM module configuration including package dependencies
├── CHANGELOG.md - automatically generated by Github Actions
├── module.json - BUG configuration file for this module
├── README.md - a markup file containing useful information.
└── TODO.md - an optional list of work to do. Developers only.
Panels
A panel is a single instance of a module running on BUG. You can run multiple panels of each module.
Communication
Workers
- Workers within module containers fetch data directly from devices or external services and write to the shared Mongo database.
- Workers handle device communication asynchronously.
API
- Panels communicate only with the BUG Core API.
- The frontend reads data from the BUG Core, not directly from devices or module containers.
- NodeCache or other local caches can be used within containers for temporary data.
- The frontend interacts only with BUG Core, not module containers.