Aidbox project
Use zen-lang to configure Aidbox

Aidbox project

To start configuring Aidbox with zen-lang you need to create an Aidbox project.
Aidbox project is a directory with zen-lang edn files. Aidbox project can be shared with many Aidbox instances giving them the same configuration.

Load project using environment variables

Aidbox uses environment variables to load project.

AIDBOX_ZEN_PATHS

The AIDBOX_ZEN_PATHS environment variable is used to specify how Aidbox loads project.
Format:
1
AIDBOX_ZEN_PATHS=<source>:<format>:<path>[,<source>:<format>:<path>]*
Copied!
Source is either url or path. url is used to download Aidbox project from the remote location; path is used to load Aidbox project from the filesystem.
Format can be zip, dir or edn. Note that dir is only applicable to the path source.
Table of source and format compatibility:
source\format
zip
dir
edn
url
✓
​
✓
path
✓
✓
✓
Example:
1
AIDBOX_ZEN_PATHS=url:zip:https://github.com/zen-lang/fhir/releases/download/0.2.13-1/hl7-fhir-us-core.zip
Copied!

AIDBOX_ZEN_LOAD

The AIDBOX_ZEN_LOAD environment variable is used to load a single namespace represented as edn.
Format:
1
AIDBOX_ZEN_LOAD=<zen-edn>
Copied!
Example:
1
AIDBOX_ZEN_LOAD='{ns my-zen-namespace import #{zen-proj1 zen-proj2 zen-proj3
Copied!
The AIDBOX_ZEN_ENTRYPOINT environment variable specifies a zen namespace or a zen symbol. Aidbox starts reading its configuration from the entrypoint.
Format:
Using a zen namespace as an entrypoint:
1
AIDBOX_ZEN_ENTRYPOINT=zen.namespace
Copied!
Using a zen symbol as an entrypoint:
1
AIDBOX_ZEN_ENTRYPOINT=zen.namespace/zen-symbol
Copied!
Examples:
1
AIDBOX_ZEN_ENTRYPOINT=aidbox-project1/dev-server
2
AIDBOX_ZEN_ENTRYPOINT=aidbox-project2
Copied!

AIDBOX_ZEN_DEV_MODE

The AIDBOX_ZEN_DEV_MODE environment variable is used to enable the hot reloading of the aidbox project.
Format: if the variable is defined in the environment then Zen dev mode is enabled.
Hot reloading works only with directories and files in local file system. I.e. path:dir and path:edn in AIDBOX_ZEN_PATHS.
AIDBOX_ZEN_ENTRY, AIDBOX_ZEN_PROJECT, BOX_ENTRYPOINT are deprecated.

AIDBOX_ZEN_PROJECT, AIDBOX_ZEN_ENTRY, BOX_ENTRYPOINT

Deprecated. Use AIDBOX_ZEN_PATHS and AIDBOX_ZEN_ENTRYPOINT instead.
AIDBOX_ZEN_PROJECT environment variable is used to load the Aidbox project from the path specified.
AIDBOX_ZEN_ENTRY environment variable is used to specify zen project entry namespace.
BOX_ENTRYPOINT environment variable is used to specify zen entry symbol.

Examples

You can see an example in the 🎓 Profiling with zen-lang tutorial.

Configure Aidbox Project via aidbox/system

This section is still under active development check it out later 🚧

Seed Import

You can declare a set of resources in Aidbox project and get them loaded in one or many Aidboxes on start. To do this you need to describe the seed service in the system entrypoint.

Example

1
{ns importbox
2
import #{aidbox
3
zenbox}
4
​
5
seed
6
{:zen/tags #{aidbox/service}
7
:engine aidbox/seed
8
:files ["patients.ndjson.gz"]
9
:resources [{:id "rpt-1" :resourceType "Patient"}
10
{:id "rpt-2" :resourceType "Patient"}]}
11
​
12
importbox
13
{:zen/tags #{aidbox/system}
14
:zen/desc "Import box for test"
15
:services {:seed seed}}}
Copied!
In this example importbox/importbox is the system entrypoint defined in the AIDBOX_ZEN_ENTRYPOINT variable, the files described in the :files field are located inside the zen project defined in the variable AIDBOX_ZEN_PATHS.

Seed Service

:files - which ndjson.gz files will be imported at system startup. These files must be located inside the zen project described in the variable AIDBOX_ZEN_PATHS.
:resources - in-place resources definitions that will be imported at system startup.
:resources are imported sequentially, so make sure you don't break referential integrity.