---
url: https://kit.kambium.net/docs/architecture.md
---
# Design and packages

Kambium Kit supplies reusable integration infrastructure. An application chooses its
engines, configures services and owns its product policy. An engine owns the
behavior of one integration kind. Keep those responsibilities explicit so an
engine can run in another host without importing that host's application.

## Ownership boundaries

| Layer | Owns | Typical application files |
| --- | --- | --- |
| Application | Installed engine catalog, infrastructure settings, routes, deployment, branding and access policy | `index.ts`, `dashboard/`, build and host configuration |
| Engine | Connection declarations, task handlers, provider processing, lifecycle validation and its configuration page | `engines/<kind>/` or an installed engine package |
| Core | Context construction, provider services, task execution, shared lifecycle coordination, authentication and workspaces | Supplied by the Kit |
| Dashboard and frontend foundations | Configured stores, shell, account/workspace controls and reusable engine UI | Composed by the application |
| CLI | App generation, local service lifecycle and process tooling | Invoked through generated npm scripts |

Application setup reads environment values and passes configuration to
`createServer`. Engine factories receive their credentials and options from that
host. A reusable engine should not discover the host's secret manager, environment
or installed-engine catalog for itself.

## Choose an entry point

New generated applications use `@kambium/kit`, which pins a coordinated combination
of core, shared contracts, shared components and dashboard. The CLI is installed
separately and pins the kit version used for generation.

| Import | Intended use |
| --- | --- |
| `@kambium/kit` | Engine definitions, portable contracts and error classes; browser-safe root |
| `@kambium/kit/shared/engine-runtime` | Browser-safe engine capability declarations |
| `@kambium/kit/shared/types` | Shared data and task payload contracts |
| `@kambium/kit/server` | `createServer` and server configuration; Node only |
| `@kambium/kit/build` | Server build tooling; Node only |
| `@kambium/kit/frontend` | Frontend stores and engine component contracts |
| `@kambium/kit/frontend/ui` | Engine page, setup and activity components |
| `@kambium/kit/dashboard` | Dashboard shell, sidebar, settings and engine routes |

Kit forwards the owning modules; it does not initialize services or create another
store instance. Backend-only applications can use core directly. When mixing
kit and direct package imports, keep their selected versions aligned to preserve
module identity and compatible peers. See the [kit contract](https://github.com/MartinMalinda/kambium/blob/main/packages/kit/README.md).

## Keep runtime declarations public

An engine's runtime metadata describes its kind and connection capabilities. The
backend definition supplies executable behavior, OAuth credentials and processing
policy. The dashboard imports runtime metadata without pulling server code or
secrets into the browser. See [Engine definitions](https://kit.kambium.net/docs/engines.md).

## Reuse operation services

A provider hook or engine task receives an `EngineContext` for one matched engine
instance. Pass that context or its existing services to helpers. Its lazy provider
services reuse the operation's PowerService. Constructing another service in each
helper can split token state, retries or in-flight coordination.

Long-lived workers, caches and connection infrastructure belong to their configured
server runtime. Per-operation identity, authorization and logs stay scoped to
that operation. Stateful behavior can belong in core; its scope and shutdown
must be defined. See [core ownership](https://github.com/MartinMalinda/kambium/blob/main/packages/core/README.md) and
[server lifetimes](https://github.com/MartinMalinda/kambium/blob/main/packages/core/server/README.md).

## Treat persistence as a contract

Engine kinds and task operation names are application-owned strings. Adding one
does not require changing a shared enum in the Kit. Existing database/API names such
as `sync`, `sync_id` and `SyncRecord` identify engine instances; preserve those
names when using their contracts.

Supabase Postgres stores engine instances and tasks. It also backs task claims
and distributed locks across replicas. Redis holds caches and temporary state.
Engines own recovery for any state they add.
See [Scaling](https://kit.kambium.net/docs/deployment.md#scaling) and [Database access and recovery](https://kit.kambium.net/docs/configuration.md#database-access-and-recovery).
The schema import metadata records files, while Supabase migration history
records database application. Startup of a hosted app never applies migrations.

Use explicit callback inputs and report failed work where it occurs. Task
recovery can replay work, so successful side effects need deliberate idempotency;
see [Task execution](https://kit.kambium.net/docs/tasks.md). A code rollback does not reverse stored data or
SQL changes; see [Update your application](https://kit.kambium.net/docs/updating.md).
