Skip to main content

Loader Configuration

The loader configuration is the backbone of every dcupl application. It is a schematic representation of your model and data structure and uses different techniques to enable the creation of composable applications.

It defines all Resources available in the project and how to combine them with Environments into different Applications

stateDiagram-v2 state LoaderConfiguration { [*] --> Applications [*] --> Environments [*] --> Resources state Applications { app1 : Bookstore app2 : Book Collection App } state Environments { localhost dcuplCloud } state Resources { state books.dcupl.json { tag_book1 : [model, book] } state authors.dcupl.json { tag_author1 : [model, author] } state books.csv { tag_book2 : [data, book] } state authors.json { tag_author2 : [model, author] } } }

Overview

The configuration file has the extension *.dcupl.lc.json. It lists all the resources (models and datasets) of your application. You can define variables in multiple environments and create multiple applications by combining different resources.

{
"resources": [...],
"environments": [...],
"applications": [...],
...
};

Resources

The core of the loading configuration is the resources array. Each item describes where the resource is fetched from - url - and if it is a model or a data resource - defined by its type. Valid types are model and data. For data resources you need to define the model definition they belong to.

For every resource you can define multiple tags, which may identify and groups of resources for other operations. For example you can apply a specific header to all the resources with the tag "authorization" or just load/reload data tagged with the tag "bookList".

// baseUrl is an environment variable and will be replaced on runtime
// ${baseUrl}/models/book.dcupl.json -> http://localhost:8083/models/book.dcupl.json

{
"resources": [
{
"url": "${baseUrl}/models/book.dcupl.json",
"type": "model",
"tags": []
},
{
"url": "${baseUrl}/data/book.csv",
"type": "data",
"model": "book",
"tags": ["bookList", "authorization"]
}
]
}

Environments

An environment can contain multiple variables, which are used to replace placeholders (${baseUrl}) in the loader configuration. Currently it's possible to replace the placeholders in resource URLs and header values. An Environment may also define reusable configurations for HTTP headers (headers) and HTTP query params (queryParams)

{
"key": "localhost",
"description": "My default environment for local development",
"variables": [
{
"key": "baseUrl",
"value": "http://localhost:8083"
},
{
"key": "auth_token",
"value": "__my_token_value__"
}
],
"headers": [...],
"queryParams": [...]
}

Headers

The most common use case is to add authorization headers for specific data resources, since they may contain sensitive data or are generated for specific users and roles. The condition allows to fine tune rules, when headers should actually be applied.

{
"key": "authorization",
"description": "The authorization header will be applied to all resources containing the tag 'order_data'",
"value": "Bearer ${auth_token}",
"tags": ["order_data"],
"condition": {
"applyIfVariableHasValue": "auth_token"
}
}

Query Params

Query params work the same way as headers. You can define reusable query param configurations and apply them to tagged resources.

{
"key": "some_param",
"description": "Some query param i like to reuse",
"tags": ["my_model", "my_data"],
"value": "some_value",
"condition": {
"applyIfVariableHasValue": "apply_my_query_param"
}
}

Applications

An application might load all resources or only a subset of your data depending on your selected tags. It can override custom variables and data transformers.

[
{
"key": "application",
"description": "Default application"
},
{
"key": "dev_user_123",
"description": "Bookstore application with specific resources and variable override for user_123",
"resourceTags": ["bookstore_models", "bookstore_data"],
"variables": [
{
"key": "userId",
"value": "user_123"
}
]
}
]

Use the dcupl CLI to push your entire workspace to the dcupl Console in order to debug and analyze model definitions and data apart from your business application.