Skip to content
Search docs
Search the docs and jump to the section
Sign in

Werker architecture

How the repository is divided into apps and packages, what each one owns, and the tools that check it.

The processes and the limits that follow from them are in how it's built.

Package structure

apps/app/              SvelteKit UI and Node server; calls core, and
                       uses rules for pure logic the browser shares
apps/site/             Public site, docs, blog and waiting list; UI and rules only
apps/reels/            The web app's pages as scripted demos for the site
apps/worker/           Starts the run engine; enqueue script
apps/cli/              The command werker, for npm; types only
packages/ui/           Theme, logo and UI primitives; no dependencies
packages/domain/       Shared types; no dependencies
packages/rules/        Deterministic decisions over domain values
packages/db/           Postgres access, migrations, row-level security
packages/connections/  Provider adapters, secrets, capability bindings
packages/auth/         Sign-in, sessions, workspaces and roles (Better Auth)
packages/core/         Use cases the apps call
packages/runtime/      Run engine: queue claims, Pi harness, workflows
packages/scripts/      Runs an assistant's script in its own process
tools/checks/          Executable package and import boundaries
docs/                  Generated glossary of the docs in apps/site

Packages use the @werkerai npm scope. The project domain is werker.cloud: the public site is at the apex and the app at app.werker.cloud, both deployed on Coolify (public site, Coolify).

Source entrypoints are under each package's src/index.ts.

Dependency direction

PackageMay depend on
domainnothing
rulesdomain
dbdomain
connectionsdomain, rules
authdomain, db
coredomain, rules, db, connections, auth
runtimedomain, rules, db, connections
scriptsdomain
uinothing
webcore, domain, rules, scripts, ui
siteui, rules
reelsweb, domain, ui
workerruntime, core, domain
clidomain

Each package may depend only on the packages its policy lists in tools/checks/policy.ts. Which package owns which third-party dependency, and the other enforced rules, are in executable boundary checks.

Packages

One line each; the README has the detail.

Apps

  • apps/app: the signed-in SvelteKit app and Node server. Product copy is in apps/app/src/lib/messaging/. GET /api/health reports process liveness only. How pages update live: database and events.

  • apps/site: the public landing page, pages, docs and blog, prerendered, with a Node server for the waiting list (public site). The app's / redirects to the dashboard or to sign-in.

  • apps/reels: plays apps/app's pages with made-up data, for the public site to run in an iframe (reels⁠ (opens in a new tab)). pnpm reels:build writes it into the site's static files.

  • apps/worker: src/main.ts starts the run engine; src/enqueue.ts queues a run or workflow.

  • apps/cli: the command werker, for npm as @werkerai/cli. It talks to a Werker over HTTP and bundles the types it shares (API, CLI and MCP).

Tooling and checks

  • Node 24.15+ and pnpm 12.
  • SvelteKit 3 and Svelte 5 with the Node adapter.
  • Strict TypeScript and shared tsconfig.base.json.
  • Tailwind CSS 4.
  • Vite+ for development, builds, linting, formatting, and Vitest.
  • Playwright Chromium for browser component tests.
  • wiki0 for documentation indexing and linting.

Dependency versions are centralised in the pnpm catalogue. pnpm check runs boundary checks, package type checks, and root tooling type checks.

Tests

  • pnpm test:boundaries: Node tests for the checker and source parser.
  • pnpm test:packages: Vitest tests for the package APIs.
  • Web client project: *.svelte.test.ts in real Chromium.
  • Web server project: other *.test.ts in Node.

pnpm test:unit runs all four groups. Tests require no credentials.

Configuration and deployment

Local development uses Postgres from compose.yaml (pnpm db:up, port 54329). In development (pnpm dev) the worker reads WERKER_SECRET_KEY from the root .env through nopeek; pnpm start reads an .env if there is one.

The schema is the migrations in packages/db/sql/, applied in name order by pnpm db:migrate and recorded in schema_migrations. 001_schema.sql is the baseline. Every change is a new numbered file, and the existing ones are frozen. packages/db/schema.sql is the schema those files produce, generated by pnpm db:schema (CI fails when it is out of date) and never edited by hand. The rules for foreign keys and their indexes are at the top of 001_schema.sql.

pnpm db:migrate applies a file once, so an edited file does not reach an existing database. pnpm db:reset drops the local database and rebuilds it: migrations and the dev seed. The seed adds the dev user, a connection for each provider key in .env, and the sandbox host from WERKER_SANDBOX_HOST in .env (for example ssh://user@box); without it, eval cases that need a shell are skipped. The reset loses runs, workflows, agents and workspace-b (which pnpm db:rls-check needs; pnpm add-user adds it back, with an email no other workspace has).

SvelteKit configuration lives in apps/app/vite.config.ts. The optional root .env is read during development and builds, and loaded by the production start command. ORIGIN sets the canonical origin during the build; runtime HOST and PORT control the Node listener.

Local environment files, build output, databases, and browser reports are ignored by Git. .env.example⁠ (opens in a new tab) contains non-secret examples.

This page as markdown apps/site/src/content/docs/engineering/architecture.md