Skip to content

eliona-smart-building-assistant/app-template

Repository files navigation

Replace the following strings globally with the real app name:
  • app-name with app's repo name. Use - if the app name contains spaces or other separators (such as dots). All letters are lower-cased. For names containing dots, adapt the documentation links.
  • app_schema_name and app\\_schema\\_name with app's db schema name. Use _ if the app name contains spaces. All letters are lower-cased.
  • App Name with app's real name. Letters can be mixed-cased, depends on using e.g. brand names.

Eliona App for App Name

The App Name app is used to access App Name.

Configuration

The app needs environment variables and database tables for configuration. To edit the database tables the app provides an own API access.

Registration in Eliona

To start and initialize an app in an Eliona environment, the app has to be registered in Eliona. For this, entries in database tables public.eliona_app and public.eliona_store are necessary.

This initialization can be handled by the reset.sql script.

Environment variables

Todo: Describe further environment variables tables the app needs for configuration

  • CONNECTION_STRING: configures the Eliona database. Otherwise, the app can't be initialized and started (e.g. postgres://user:pass@localhost:5432/iot).

  • INIT_CONNECTION_STRING: configures the Eliona database for app initialization like creating schema and tables (e.g. postgres://user:pass@localhost:5432/iot). Default is content of CONNECTION_STRING.

  • API_ENDPOINT: configures the endpoint to access the Eliona API v2. Otherwise, the app can't be initialized and started. (e.g. http://api-v2:3000/v2)

  • API_TOKEN: defines the secret to authenticate the app and access the Eliona API.

  • API_SERVER_PORT(optional): define the port the API server listens. The default value is Port 3000. Todo: Decide if the app needs its own API. If so, an API server have to implemented and the port have to be configurable.

  • LOG_LEVEL(optional): defines the minimum level that should be logged. The default level is info.

Database tables

Todo: Describe the database objects the app needs for configuration

Todo: Decide if the app uses its own data and which data should be accessible from outside the app. This is always the case with configuration data. If so, the app needs its own API server to provide access to this data. To define the API use an openapi.yaml file and generators to build the server stub.

The app requires configuration data that remains in the database. To do this, the app creates its own database schema app_schema_name during initialization. To modify and handle the configuration data the app provides an API access. Have a look at the API specification how the configuration tables should be used.

  • app_schema_name.example_table: Todo: Describe the database table in short.

Generation: to generate access method to database see Generation section below.

References

App API

The app provides its own API to access configuration data and other functions. The full description of the API is defined in the openapi.yaml OpenAPI definition file.

Generation: to generate api server stub see Generation section below.

Eliona

Todo: Describe all the data the app writes to eliona

Tools

Generate API server stub

For the API server the OpenAPI Generator for go-server is used to generate a server stub. The easiest way to generate the server files is to use one of the predefined generation script which use the OpenAPI Generator Docker image.

.\generate-api-server.cmd # Windows
./generate-api-server.sh # Linux

Generate Database access

For the database access SQLBoiler is used. The easiest way to generate the database files is to use one of the predefined generation script which use the SQLBoiler implementation. Please note that the database connection in the sqlboiler.toml file have to be configured.

.\generate-db.cmd # Windows
./generate-db.sh # Linux