Monorepository
Overview
The monorepository directories are organized like this:
├── core # the typescript monorepository code
│ ├── apps
│ │ ├── azure-functions # functions to be deployed with Azure Functions
│ │ ├── client
│ │ │ ├── management-front-end # angular front-end to manage devices
│ │ │ └── settings-app # angular front-end to manage platform settings (tenants, roles, users ...)
│ │ └── management-api # nestJS backend
│ └── shared # models and logic that can be reused in the apps
│ ├── communication
│ ├── client # Shared client components (could be any framework, but for now it's Angular)
│ └── models
├── device-simulator # CLI to send data to IoT Hub
├── docs # all of the project's documentation
├── infrastructure # terraform description of platform environment to deploy
├── ocis # Open Container Images to speed up the GitLab pipelines
└── website # rendering of the documentation in /docs
1. Packages Installation
If you clone the project, or just pull some modifications, to install all or new nodes_modules you must execute this command from the root (/iot-manager
) of the monorepository:
npm i
⚠️ To install new packages DO NOT install it from the project directory concerned, otherwise the entire package.json is going to be read and all these modules will be installed all over again in this directory. Please checkout the version of the package you want to install matches with version that can be found in all workspaces. Having only one /node_modules
directory at the root prevents of having conflicts issues. Same thing for package-lock.json
, this file is only needed at the root.
You got two possibilities to do it the right way :
- Install package from the root this way:
npm i yourpackage --workspace=nameoftheworkspace
- Add the module manually to the package.json of the concerned workspace and go back to the root and execute:
npm i
⚠️ Careful, new dependencies must match with the versions of others to avoid conflicts and keep only one node_modules directory at the root. Otherwise npm is going to dispatch these other version in the workspace concerned.
2. Start, Build and Tests
To start your application, build it or test it you can still launch it from the directory concerned.
You can also launch the script from the root that you can find in the package.json:
"scripts": {
"start:front": "npm run start --workspace=management-front-end",
"start:settings": "npm run start --workspace=settings-app",
"start:management-api": "npm run start --workspace=management-api",
"start:management-api:dev": "npm run start:dev --workspace=management-api",
"start:management-api:debug": "npm run start:debug --workspace=management-api",
"build:front": "npm run build --workspace=management-front-end",
"build:management-api": "npm run build --workspace=management-api",
"build:amqp-consumers": "npm run build --workspace=amqp-consumers",
"build:settings": "npm run build --workspace=settings-app",
"build:websocket-server": "npm run build --workspace=websocket-server"
}
3. DTOs
All DTOs used in the projects must be provided by core/apps/communication/dtos
:
- APIs are implementing these DTOs
- All frontend apps are importing these DTOs
The alias core/shared/dtos/*
is intended for all DTOs imports.
4. Modules and Services
Kamea provides modules and services than can be reused in custom front app. There are all located in core/shared/client/angular
.
All components from wiotm-libs
must be in the @NgModule
exports
so we can use them when we import a module.