TotisWorkers Architecture
TotisWorkers runs Cloudflare-Workers-shaped TypeScript/JavaScript handlers on an embedded QuickJS-ng engine inside a per-request sandbox. It is a standalone application that owns its storage directly through the file-system module — there is no S3 server underneath. Each app lives under apps/<appId>/ on the file-system: its source, compiled worker, SQL database, static site and bindings all live there, and its secrets live in the instance vault.
Layers
- Front door (
:workers-app) —WorkersApp+PrefixRouterroute by origin: the platform host (hosts.platform, required) serves the bundled system app (the platform console and its/v1API), while each app is reached at<label>.<base>on every configuredhosts.appsbase (or/apps/<label>/when no apps base is set) and at its custom domains.hosts.appsmay be one wildcard base or a list (the first is primary);<label>is<app>-<project>-<org>plus-<env>outside production.hosts.consoleUrl(optional) is the public console origin used for links in system email, defaulting tohttps://<hosts.platform>.cloudflaredexposes the server publicly. - Control plane (
:tiny-s3-sandbox· platform) — the system app drives orgs, projects, apps, deploys, secrets, databases, storage and domains throughenv.PLATFORM(PlatformOps). TheHostRegistryrecords every app (storage rootapps/<appId>), theVaultencrypts secrets under the instance KEK, andAppDeployerbundles, stores and migrates a deployed Worker. - Bundler (
WorkerBundler, SWC→wasm) — server-side bundles rawworker.ts: strips types, inlines the SDK, wiresexport default. Source stays at_code_/worker.ts; compiled output at_code_/worker.js. - Execution sandbox (
:tiny-s3-runtime) — a JS worker runs on aJsRuntime, which keeps warm per-app state so a cold start becomes a small per-call cost. Two implementations run the same QuickJS-ng engine behind one contract:QuickJsJsRuntimein-process (side-loaded native QuickJS-ng via FFM; the default, runs on any OS with no KVM) andHyperlightJsRuntime(the same engine in a KVM micro-VM for stronger isolation, Linux/KVM only). The host useshyperlightwhere KVM is available, elsequickjs. Each request runs the worker'sfetchon a warm context. - Host capabilities (
HostBridge→HostBridgeImpl) — the only authority a guest gets, executed host-side under the caller's identity. EachhostExtop is looked up in a registry ofHostOpscontributed by the owning subsystem (DB, S3 and bucket bindings, fetch, KV, queues, caches, analytics, images, email, logging, andenv.PLATFORMfor the system app only), then checked against the capabilities the run was granted. - Outbound email (
:tiny-s3-workers-email, connections in:tiny-s3-workers-connections) — org email connections (SMTP with STARTTLS/implicit TLS, or a provider API: Mailjet, Resend, Postmark, SendGrid, Mailgun, Amazon SES) with write-only credentials in the vault, host-built MIME, per-org/per-app send quotas, a 30-day send log, and SSRF-guarded egress (private SMTP relays need anemailentry in the instance's private address allow-list). The system app sends invitations and password reset through an instance connection. - Data, cache & egress —
env.DBbinds the app's own SQL engine (:tiny-s3-sql, row store + MergeTree) living atapps/<appId>/_data_/db;env.CACHEis an in-process TTL cache (WorkerCache, per-node, non-durable);env.S3signs host-side via the AWS SDK to an external bucket;fetchis SSRF-guarded byEgressGuard/HttpEgress. - Observability (
:tiny-s3-sandbox-telemetry) —TelemetryRegistrycollects logs, DB metrics, and a per-app worker-error ring;ResourceGovernorenforces CPU/memory/disk/rate limits and quota. - Platform modules — the host is split by layer, each its own Gradle module under
workers/:workers-registry(HostRegistry, value types) → the host subsystems (workers-egress,workers-email,workers-vault,workers-storage,workers-connections,workers-kv,workers-queues,workers-analytics,workers-images,workers-cron,workers-cache,workers-sockets), each with its ownHostOps→sandbox(WorkersServer,HostBridgeImpl, app code and sites, and theSystemApihook) →workers-platform(PlatformOpsand its op groups, bootstrap, and the bundled management app and console), wired to the sandbox by the app. Each module depends only on the layers below it. Each module owns one package root,dev.totis.workers.<module>;BoundaryTestinworkers/archenforces the layering. - Storage (file-system module) — the underlying
FileSystemholds every app's root (apps/<appId>/): code, SQL data, and static site. Secrets live in the instance vault, encrypted under the KEK.
See also: TypeScript Workers · Worker SDK reference · Deploy API.