On this page
Level: C4 L3, components of the web container. Read this if you are an engineer changing apps/web and need to know which layer owns a rule, where a request enters and which packages it may call.
Up/Down: up: L2 Containers. Siblings: Worker components. Cross-cutting rules it relies on: Tenancy and security.
In short#
apps/web is a thin shell: a proxy classifies the host, server components read through an in-process tRPC caller, route handlers serve APIs, and every tenant query runs inside one transaction that carries the organization pin. Business rules, schemas and formatting live in workspace packages.
Components#
| Component | Where | Owns |
|---|---|---|
| Proxy | apps/ |
Host classification (platform host or tenant host), sign-in redirect, public-route bypass, CSP nonce, body-size caps |
| Pages | apps/, admin, auth, share, help |
Server components for reads; client components only for interactive islands |
| Route handlers | apps/ |
trpc, platform/, internal (called by the issuer), webhooks, ingest, exports, chat, mcp, metrics, health: validate, call a typed server function, return a narrow response |
| Session | apps/ |
NextAuth with a JWT session, passkeys, TOTP, per-organization LDAP and OpenID login |
| Procedures | apps/ |
The only entry to organization data, see below |
| Routers | apps/ |
One feature router per domain under one root; named Zod input schemas, superjson transport |
| Server functions | apps/ |
Data shaping, caches, ports to the worker; no business rule that another process needs |
| In-process caller | apps/ |
Lets a server component call a router without HTTP, with the same context and the same procedures |
Procedures#
The organization comes from the request host, never from a cookie; the cookie decides only on a platform host. A procedure type decides what a resolver may touch:
| Procedure | Guarantees |
|---|---|
public |
Request logging only |
authed |
A valid session |
superAdminProcedure |
Platform staff; no organization membership |
orgProcedure |
An active, non-suspended organization; the whole resolver runs in one transaction that carries the organization pin |
brandProcedure, chatProcedure |
Organization and brand pinned; a restricted membership with no brand is refused |
rateLimited |
A Redis-backed rate limit runs before the scoped transaction opens |
A resolver that must call out (a vendor, a model) uses the orchestrated variant and opens short scoped phases around the call, so no connection is held across network I/O.
Server components and client islands#
Read-heavy surfaces render on the server and fetch through the in-process caller. A client island is a component that needs state, effects or browser APIs. Per-route JavaScript budgets are ratcheted in CI (Limits and budgets). Heavy chart and widget code loads on demand.
The assistant path#
The chat route resolves the organization and brand, builds the tool set from the plugins and data the organization has, and streams through an ordered model failover chain from @yng/ai. Each tool call re-pins the organization and brand scope before it reads, and the answer stream is masked for the viewer. Marketing tools missing from a gated-off organization raise an error instead of being served. Detail: System architecture.
Issuer sidecar#
apps/idp is a separate container, not part of the web process. It serves OpenID Connect discovery, keys, authorize, token and end-session; reads the signing-key table with a select-only database role; and asks the web app for the session through /api/internal/idp/* with a bearer token. Contract: Platform API and events.
Package dependencies#
An arrow points to what a layer imports. Packages inside one layer may import each other; none imports a layer above it. @yng/schema sits at the bottom and owns the tables, row-level-security policy SQL and the runtime privilege manifest. apps/worker cannot import apps/web, which is why shared limits live in packages.
Where it stops#
The web container holds no durable state apart from the upload staging directory used by organization archive uploads. Readiness per capability: Project status.