The architecture behind Tecton extensions
If you haven't already, read our guide on Tecton extensions first to learn what extensions are and why they exist. Now we'll dive into how the two main Tecton packages, q2-tecton-sdk and q2-tecton-platform, work together to enable extensions to run inside a host platform.
The Tecton framework operates on a client-server model where:
q2-tecton-sdk is the "client" - used by individual extensions to connect to and communicate with the platformq2-tecton-platform is the "server" - used by the host application that boots, manages, and provides functionality to extensionsThis micro-frontend architecture enables extensions to run in isolation while communicating with the host platform through a well-defined API.
The q2-tecton-sdk package provides the feature-level API that extensions use to connect to and communicate with the platform.
When a feature calls connect(), the q2-tecton-sdk package performs several initialization tasks:
q2-tecton-platform packageThis means features get both the communication capabilities (actions/sources) and the visual components (web components and styling) they need, all from a single connect() call.
Use q2-tecton-sdk when:
Here is an example of using q2-tecton-sdk in a Vue.js application with Pinia for state management. We'll first import the connect function from the SDK package and use it to establish a connection to the platform. The platform capabilities supported by the platform are then made available to the feature for interaction and we will set them on our store for global access.
import { connect } from 'q2-tecton-sdk';
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { useGlobalStore } from '@/store';
import App from '@/App.vue';
import router from '@/router';
connect().then(capabilities => {
const { actions, sources } = capabilities;
const app = createApp(App);
app.use(router);
const pinia = createPinia();
app.use(pinia);
const store = useGlobalStore();
// Set sources and actions on the store
store.sources = sources;
store.actions = actions;
app.mount('#app');
});The q2-tecton-platform package allows a parent application to host and manage Tecton-based extensions. The platform initializes Tecton by providing a compiled set of Tecton configuration objects for the features it will host and a platform adapter object that defines the Tecton capabilities the platform integrates and supports. The platform also exposes outlets for features and handles loading feature configuration into the correct outlets.
Use q2-tecton-platform when:
Here is an example of how the q2-tecton-platform package is used to initialize a platform. The init function is called with a platform adapter that provides the control functions for Tecton APIs that the platform supports and a Tecton configuration object that defines the features and their modules to be hosted by the platform. The initialization returns several functions that the platform can use to manage Tecton features and their configurations.
import { init } from 'q2-tecton-platform';
const platformAdapter = {
// Control functions
requestPlatformData: (url, method, data) => { /* ... */ },
showModal: (options) => { /* ... */ },
getFeatureConfig: (configVariables) => { /* ... */ },
getCurrentLanguage: () => 'en-US',
getCurrentTheme: () => 'default',
};
const tectonConfig = {
features: {
// Feature configurations
CustomExtension1: {
modules: { /* ... */ }
},
CustomExtension2: {
modules: { /* ... */ }
},
}
};
const {
tectonParamsChanged,
updateConfig,
verifyConfig,
configLookup,
teardown,
} = init(tectonConfig, platformAdapter);For more on Tecton platforms and setting one up, see our walkthrough guide on Setting up a Platform.
Now that we understand the roles of the Tecton SDK and Platform packages, let's look a basic communication flow between a feature and the platform:
q2-tecton-platform and the init() function and provides platform adapterq2-tecton-sdk with connect()q2-tecton-sdk sets up communication channel with q2-tecton-platform and receives actions and sources supported by platform adapterq2-tecton-sdk provides actions and sources to feature for platform interactionactions or sources to request platform servicesq2-tecton-sdk communicates requests to q2-tecton-platformq2-tecton-platform executes requests via platform adapter control functions and responds to q2-tecton-sdkq2-tecton-sdk receives responses and provides results/data to features
This architecture enables true isolation while providing a powerful communication layer between extensions and the platform.