Categories:
Aura Configuration API server
aura-configuration-api is the component of Aura in charge of handling and centralizing configuration tasks.
Find in the current documents the description of this component, its architecture, components and processes.
Shared component between Aura Virtual Assistant and ATRIA
Introduction
aura-configuration-api is the component in charge of the management of all the configuration tasks in Aura. It is mainly a web server built on Typescript 4.3 using nodejs as engine. It is api-first designed, using OpenAPI v3 to provide the API definition.
aura-configuration-api server is divided into several modules and plugins, each of them managing different tasks, which are:
Modules
Administration: Administrative management module for general tasks such as exporting and importing configuration.Channel: Module in charge of managing the configuration of each Aura channel as well as the libraries associated with each channel (replacement for thebot-response.jsonconfiguration file).Skill: Module in charge of managing the configuration of each skill.Application: Module in charge of managing the configuration of each application.Component: Module in charge of managing the configuration of each Aura component.
Plugins
Preset: Module in charge of managing the configuration of each preset.Tv section: Module in charge of managing the configuration of each tv section.Suggestion: Module in charge of managing the configuration of each suggestions.Agent: Module in charge of managing the configuration of each agents.Agent base: Module in charge of managing the configuration of each agents base.Agent deployment: Module in charge of managing the configuration of each agents deployment.Routing filter: Module in charge of managing the configuration of each routing filters.Filter engine: Module in charge of managing filters engine.
Detailed information regarding aura-configuration-api is found in the following documents:
- Communication protocol and components.
- Environment variables
- Modules
- Aura Configuration API Codebase
- Aura Configuration API definition
- Synchronization by events
Aura configuration API architecture and components
The following figure shows the main components of the aura-configuration-api.
Server
The web server is implemented using express, which is the main web framework for NodeJS. It uses openapi-backend on top of express, to allow handling the OpenAPI v3 file.
It is in charge of setting up all the rest of the components that are needed during a request processing, as well as reading the aforementioned swagger file and setting up all the routes defined in it.
Middlewares
Each route published in the API definition file is handled by a controller, but before a request lands on its controller, it goes through a series of middlewares that provide some common steps needed by all the controllers of the server.
The following middlewares are executed at each request to the server:
Normal flow
helmet: Secure express app by setting various HTTP headers.body-parser(urlencoded): It parses URL-encoded bodies using querystring parsing (qs).body-parser(json): Maximum size of JSON body (current 50 MB).set-correlator: It sets the correlator to response header and response locals.log-http-request-response: Log HTTP request and response information.express-prom-bundle: It saves metrics information using Prometheus.oas_tools(swaggerMetadata): It interprets swagger resources and attaches metadata to request.oas_tools(swaggerValidator): It validates requests using swagger definition.oas_tools(swaggerRouter): It routes validated requests to appropriate controller.oas_tools(swaggerUi): It serves the swagger documents and Swagger UI.not-found-handler: It handles requests that have not been routed (Not Found).
Error flow
error-handler: Global error handler.
Controllers & Services
When the previous step is finished, the request lands on the controller. Each controller processes the request through a service, that is in charge of implementing the logic. Once the request has been processed, the controller prepares and sends the response.
There is a controller to manage requests associated with the server itself (generic controller) and a controller for each module, in charge of handling the requests of that module.
The event synchronization service can be enabled by setting the AURA_CONFIGURATION_EVENTS_ENABLED configuration variable to true.
Generic controller
As indicated above, the generic controller handles requests to provide information from the state of the server itself.
healthz: It is used to check if the server is online returning a simple status response:{"status": "ok"}.metrics: It gets Prometheus metrics information.heapStatistics: It gets memory usage information.heapSnapshot: It gets memory head snapshot from v8 engine.shutdown: Service to be invoked mainly by Kubernetes and allows to do a server graceful shutdown.
Modules controller
The controllers and services information of each module is described in the Modules section.
aura-configuration-api server is divided into several modules and plugins, each of them managing different tasks, which are:
Modules
Administration: Administrative management module for general tasks such as exporting and importing configuration.Channel: Module in charge of managing the configuration of each Aura channel as well as the libraries associated with each channel (replacement for thebot-response.jsonconfiguration file).Skill: Module in charge of managing the configuration of each skill.Application: Module in charge of managing the configuration of each application.Component: Module in charge of managing the configuration of each Aura component.
Access here detailed information of aura-configuration-api modules
Plugins
Preset: Plugin in charge of managing the configuration of each preset.TV section: Plugin responsible for the management of TV sections.Suggestion: Plugin responsible for the management of suggestions.Agent: Plugin in charge of managing the configuration of each agent.Agent base: Plugin in charge of managing the configuration of each agent base.Agent Deployment: Plugin responsible for managing the deployment of agents.Routing filter: Plugin responsible for managing the routing filters.Engine filter: Plugin responsible for managing the engine filter.
Access here detailed information of aura-configuration-api plugins
Database access
Most aura-configuration-api services access aura-configuration database to get or set the information of each module.
This database is a MongoDB one, with a collection for each module that stores information related to that module. To access this collection, the server implements a data access object with the queries needed by the services. This object follows the DAO (Data Access Object) pattern that provides a single access to the database, isolating the services from the real database schema and internals implementation.
Communication protocol
aura-configuration-api communication protocol is completely synchronous, this means that the answer of a request is included in the HTTP response related to the request.