Skip to main content

Application Startup explained

Let's start with the big picture. The dcupl SDK is like a global data store on steroids. It's designed to fetch and manage your data based on model definitions while providing a rich set of query and aggregation functions to help you make the most out of your data.

import { Dcupl } from '@dcupl/core';
import { DcuplAppLoader } from '@dcupl/loader';

const dcupl = new Dcupl({
config: {
projectId: 'Deo...',
apiKey: '4814...',
},
});

const loader = new DcuplAppLoader();
dcupl.loaders.add(loader);

Initialization in Two Steps

Getting the dcupl SDK up and running in your frontend application involves a straightforward two-step process:

  1. Create a dcupl Core Instance First, create a new dcupl Core instance. This serves as the foundation for your data management.

  2. Create a dcupl App Loader Instance Next, establish a dcupl App Loader instance and connect it to the Core. This loader is responsible for fetching and processing your application's data.

Configuration is Key

To make the magic happen, you need to provide the App Loader with a configuration. This configuration is essentially a detailed description of all the relevant data for your dcupl application. It neatly groups models and data into packages referred to as "applications."

// dcupl.lc.json
{
"applications": [
{
"key": "default",
"name": "Default",
"description": "Only loads applications tagged with 'A'",
"resourceTags": ["A"]
}
],
"resources": [
{
"url": "${baseUrl}/models/a.dcupl.json",
"type": "model",
"tags": ["A"]
},
{
"url": "${baseUrl}/models/b.dcupl.json",
"type": "modelB",
"tags": ["B"]
},
{
"url": "${baseUrl}/data/a.data.json",
"type": "data",
"model": "modelA",
"tags": ["A"]
},
{
"url": "${baseUrl}/data/b.data.json",
"type": "data",
"model": "modelB",
"tags": ["B"]
}
]
}

Loading and Processing

Once the configuration is in place, the App Loader springs into action. It loads the specified files based on your provided environment variables and settings. As the files are loaded, they are meticulously processed. Data is mapped to the predefined models, and efficient indices are created for lightning-fast querying.

Data, Ready for Action

By this point, all the data you need for your frontend application should be fetched and processed. Your application is now fully equipped to interact with the SDK. You can query, aggregate, pivot, and perform various data manipulations with ease.

A Note on Data Writes

It's important to note that the dcupl SDK is not designed for writing data back to APIs. We believe that this process should be handled through custom code since it often involves unpredictable and custom requirements.

Updating Fetched Data

Should you need to update data that's already been fetched, the dcupl SDK has you covered. You can seamlessly update your data through the SDK, ensuring that your application remains up-to-date with the latest information.

In conclusion, the dcupl SDK is a potent tool for frontend developers seeking robust data management capabilities. By following these simple steps, you'll have your application up and running with the power of dcupl behind it. Happy coding!