Layout
apps/<appDir>/, alongside the workspace’s other apps. Paths the
build tools take are relative to the monorepo root, so app files are addressed by their
full path (apps/<appDir>/src/...), and root files such as .zite/db.ts without the apps/<appDir>/
prefix. create_app returns a new app’s dir.
Files the platform owns
The platform generates or owns these files. You can’t edit them:
Two files you do edit have names the platform’s generated files import, so keep them:
src/routes/__root.tsxkeepscreateRootRouteWithContext<ZiteRouterContext>().src/router.tsxkeepsexport function getRouter().
Inside an app
-
src/routes/holds the pages, one file per route:index.tsxis/,customers/$id.tsxis/customers/:id, and a file or folder named_nameis a layout that wraps the routes inside it without adding to the URL. See Pages and loaders. -
src/routes/__root.tsxis the document shell:<html>, the head, the stylesheet, and<NavigationProgress />, the thin bar shown while a click’s next page loads. It already mounts<Toaster />, so don’t add another. Edit it for app-wide head tags and wrappers, keeping<HeadContent />and<Scripts />. -
src/router.tsxcreates the router withcreateZiteRouter. Keep that call: it carries the signed-in user, the error screens, and a query client per request.defaultPreload: 'intent'loads a linked page, its loader included, when the link is hovered. Change it here for the whole app, or withpreloadon a<Link>. -
Server code lives in two kinds of file.
*.functions.ts(for examplesrc/lib/customers.functions.ts) exports the server functions pages call.*.server.tsholds server-only helpers, and page code never imports one: the build refuses it. See Server functions. -
API routes are routes under
src/routes/api/withserver.handlers. See API routes. -
Data an app ships with, such as a catalog, an archive, or a large lookup table, goes in the database, or
in
public/as a JSON file pages fetch. Importing it compiles it into the server bundle too.
create_app scaffolds apps/<dir>/ with a placeholder home page at src/routes/index.tsx. Replace it with
the app’s real pages.
Automations
An automation lives inautomations/<dir>/, which create_automation scaffolds with no src/index.ts yet:
- Write it as the default export of
src/index.ts:export default createAutomation({ description, on, run })fromzitejs/start. Helpers go in other files undersrc/. - The directory is its id.
- It has no routes, pages, components or styles, and its dependencies are the workspace root’s.
check_app, get_logs, and publish_app take an automation’s id as they take an app’s, commit builds it
with the rest, publishing turns its on on, and run_automation runs a built one once on real data. An app
holds no automations. See Apps.
Generated files
Files under any.zite/ directory are generated by ZiteJS: typed wrappers for the database and the app’s
SDKs. Read them for types, but never edit them: your changes there are overwritten. Import them through
their zitejs/* aliases, never by a relative path to .zite/.
zitejs/start, zitejs/auth, zitejs/meta, zitejs/upload, zitejs/pdf, and zitejs/schedules come
straight from the zitejs package, with nothing generated.
To check an app, run check_app once its changes are written. It regenerates the route tree and the role types from
your routes and zite.permissions.json, then type-checks. The platform builds the app itself, so you don’t run vite build, and a bare
type-check reads the generated files as they were last written.
Import conventions
- Platform code: always through
zitejs/*:import { zite } from 'zitejs/db'is the database client. Never import from.zite/by relative path. - Shared UI:
@project/components/*is the shared design-system package inpackages/components/: shadcn/ui primitives, hooks, and utilities. Import primitives from@project/components/ui/*, for exampleimport { Button } from '@project/components/ui/button'. - Your own files: components, hooks, and utilities you create under the app’s
src/, through relative paths (./components/Foo,../hooks/useBar).
@/ alias resolves to the app’s src/, which does not contain the shared primitives. hooks/*,
lib/utils, and components/{ui,markdown,markdown-editor,theme-switcher} live in @project/components/* and
must be imported from there.
The cn classname helper lives at @project/components/lib/utils (note the /lib/):
@project/components/utils does not exist and fails to compile.
Styling
- The theme lives in CSS variables in the app’s
src/index.css. Restyle by changing their values, and keep every variable it defines. - Edit
src/index.cssandtailwind.config.tsfor app-wide styling. - Theme color variables that
tailwind.config.tsconsumes ashsl(var(--...))(--primary,--background,--accent,--chart-*, and so on) must each be a bare, space-separated HSL triple, such as--primary: 222.2 47.4% 11.2%;, with nohsl()wrapper and no hex, rgb, or oklch. Otherwise the wrapped result is invalid CSS and the color silently doesn’t apply. - Leave non-color and composite variables (
--shadow-*,--radius,--font-*, and so on) in their native CSS format. Don’t rewrite them as HSL triples. - For dark mode, put the dark palette in the
.dark {}block and keep:rootas the light baseline. Switch by putting thedarkclass on<html>(document.documentElement), rather than rewriting:root. src/index.cssuses Tailwind v3 directives:@tailwind base; @tailwind components; @tailwind utilities;. Use these, not@import 'tailwindcss', which is Tailwind v4 syntax and breaks the build.- Any
@import, such as a Google Fonts URL, comes first, above the@tailwinddirectives.@tailwind baseexpands into real CSS rules, and an@importafter other rules fails the PostCSS build.
Config files
zite.config.jsonat the workspace root holds the connections every app can use, underintegrations.zite.config.jsonin each app holds that app’s settings:accessMode,authentication,integrationSettings,seoSettings, and more. See App config.zite.auth.tsin an app, next to itszite.config.json, holds optional sign-in hooks. See App config.
Context
context/ at the workspace root holds Markdown documents you write for the agent: data model notes,
policies, specs, process notes. context/index.json lists each file with a one-line description. The agent
reads the index first, then the entries relevant to what it’s doing, and leaves the files alone unless you
ask it to change them.