@benshi.ai/js-sdk
Version:
Benshi SDK
17 lines (10 loc) • 1.63 kB
Markdown
# Architecture

This architecture is based on `hexagonal architecture`, with the next considerations:
* `Adapters` (also called drivers), to interact with the native APIs. The modules in this library does not expose business logic, that is, they know nothing about the use cases where they are involved. For instance, the network driver exposes an API to `get` and `send` information from and to the internet, regardless whether they are sending logs, catalog or whatever. More than one module may have the same responsibility, chosen one or another depending on contextual information, for instance, if the environment is NodeJS or Browser, or if the URL has some specific parameter. For these case, use `factories`, so the main core is not aware of this decisions.
* `Repositories`. They provide an API that exposes domain concepts, like nudges, logs, catalog, etc. They must be initialized with a driver. For instance, `Catalog` repository needs the `Network` driver.
* `Core logic`.
* there is one module per block (Elearning, Navigation, etc), within the folder `modules`, that exposes the public API, used by the application.
* some logs require additional data. This data should be injected in the corresponding `module`. This way, the underneath components, like `BsSender` or `BsCore` does not need to include specific logic for events.
* data validation uses the `typescript` definition, which has been `compiled` with `ts-interface-checker`. This simplifies the task to the extend to use a single function for all the logs: `injectEvent`
[Back](./Readme.md)