Skip to content

Monorepository

Overview

The monorepository directories are organized like this:

├── core                                # the typescript monorepository code   ├── apps
│      ├── amqp-consumers              # AMQP consumers for message processing      ├── api                         # API services including management-api and websocket-server         ├── management-api          # NestJS backend for device management         └── websocket-server        # WebSocket server for real-time communication      ├── azure-functions             # functions to be deployed with Azure Functions         ├── influxdb                # InfluxDB related functions         ├── ingestion               # Data ingestion functions         └── redis                   # Redis related functions      ├── caddy                       # Caddy reverse proxy configuration and webserver for front-ends      ├── client                      # Frontend applications         ├── management-front-end    # Angular front-end to manage devices         └── settings-app            # Angular front-end to manage platform settings (tenants, roles, users...)      ├── ingestion                   # Data ingestion service      ├── keycloak                    # Identity and access management      ├── rabbitmq                    # Message broker configuration      └── redis                       # Redis configuration and health checks   └── shared                          # models and logic that can be reused in the apps       ├── api                         # Shared API components and utilities       ├── client                      # Shared client components (could be any framework, but for now it's Angular)       ├── communication               # Communication bus, DTOs, and protocols       ├── ingestion                   # Shared ingestion models and utilities       └── models                      # Shared data models and types
├── dev-tools                           # Development and testing tools
├── docs                                # all of the project's documentation
├── infrastructure                      # terraform description of platform environment to deploy
├── kubernetes                          # Kubernetes manifests and configuration
├── ocis                                # Docker images used in the pipelines
├── pipelines                           # CI/CD pipeline scripts
└── testing                             # Testing utilities and integration tests

1. Packages Installation

If you clone the project, or just pull some modifications, to install all or new node_modules you must execute this command from the root 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 check that the version of the package you want to install matches with the version that can be found in all workspaces. Having only one /node_modules directory at the root prevents having conflicts issues. Same thing for package-lock.json, this file is only needed at the root.

You have 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 versions 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",
    "start:websocket-server": "npm run start --workspace=websocket-server",
    "start:websocket-server:dev": "npm run start:dev --workspace=websocket-server",
    "start:websocket-server:debug": "npm run start:debug --workspace=websocket-server",
    "build:front": "npm run build --workspace=management-front-end",
    "build:management-api": "npm run build --workspace=management-api",
    "build:ingestion": "npm run build --workspace=ingestion",
    "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/shared/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 that can be reused in custom front apps. They 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.