> ## Documentation Index
> Fetch the complete documentation index at: https://developers.zite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Project structure

> How a Start workspace is laid out: where apps, automations, routes, and server code live, which files the platform owns, the generated .zite/ files, import conventions, and styling.

A workspace is a ZiteJS monorepo: one npm workspace holding every app and automation, the generated database
client, and a shared design system. Agents build inside it. This page is the map, so you and they know where
everything lives and which files are off limits.

## Layout

```text theme={"system"}
my-workspace/
├── package.json             # npm workspaces: apps/*, automations/*, packages/*
├── package-lock.json        # generated by npm
├── zite.config.json         # workspace config: the integrations every app can use
├── zite.schema.json         # the database schema, with SDK names
├── .zite/
│   └── db.ts                # generated database client (zitejs/db), never edit
├── context/                 # Markdown you write for the agent
├── packages/
│   └── components/          # shared design system → @project/components/*
├── automations/
│   └── weekly-digest/       # one directory per automation
│       └── src/
└── apps/
    └── helpdesk/            # one directory per app
        ├── src/
        │   ├── routes/
        │   │   ├── __root.tsx            # the document shell
        │   │   ├── index.tsx             # the page at /
        │   │   ├── _app.tsx              # a layout, e.g. guarding the pages in _app/
        │   │   ├── _app/                 # pages under that layout
        │   │   └── api/                  # API routes
        │   ├── lib/
        │   │   ├── requests.functions.ts # server functions pages call
        │   │   └── requests.server.ts    # server-only helpers
        │   ├── router.tsx                # creates the router
        │   ├── routeTree.gen.ts          # generated from src/routes/
        │   └── index.css                 # theme variables
        ├── public/                       # static files pages fetch
        ├── .zite/                        # generated: start.ts, integrations/, never edit
        ├── zite.config.json              # app config: accessMode, authentication, integrationSettings, ...
        ├── zite.auth.ts                  # optional sign-in hooks
        ├── package.json
        ├── tailwind.config.ts
        ├── vite.config.ts
        ├── postcss.config.js
        └── tsconfig.json, tsconfig.app.json
```

Each app lives in its own directory, `apps/<appDir>/`, alongside the workspace's other apps. Paths the
[build tools](https://developers.zite.com/mcp/build-tools.md) 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:

| File | What it is |
| - | - |
| `package-lock.json` | Generated by npm. Add a package with `npm install <pkg> -w apps/<appDir> --ignore-scripts`, which updates this file and the app's `package.json` |
| `vite.config.ts` | The platform builds the app with this file and its `zite()` plugin |
| `tsconfig.json`, `tsconfig.app.json` | The platform's compiler settings, including the `zitejs/*` aliases |
| `postcss.config.js` | The platform's CSS pipeline |
| `src/routeTree.gen.ts` | Regenerated from `src/routes/` by every check and build |
| `.zite/start.ts` | The platform's start instance. Its middleware runs before the app's own `src/start.ts` |

Two files you do edit have names the platform's generated files import, so keep them:

* `src/routes/__root.tsx` keeps `createRootRouteWithContext<ZiteRouterContext>()`.
* `src/router.tsx` keeps `export function getRouter()`.

## Inside an app

* `src/routes/` holds the pages, one file per route: `index.tsx` is `/`, `customers/$id.tsx` is
  `/customers/:id`, and a file or folder named `_name` is a layout that wraps the routes inside it without
  adding to the URL. See [Pages and loaders](https://developers.zite.com/framework/overview.md#pages-and-loaders).

* `src/routes/__root.tsx` is 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.tsx` creates the router with `createZiteRouter`. 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 with `preload` on a
  `<Link>`.

  ```tsx theme={"system"}
  // apps/helpdesk/src/router.tsx
  import { createZiteRouter } from 'zitejs/start';
  import { routeTree } from './routeTree.gen';

  export function getRouter() {
    return createZiteRouter({ routeTree, defaultPreload: 'intent' });
  }
  ```

* Server code lives in two kinds of file. `*.functions.ts` (for example `src/lib/customers.functions.ts`)
  exports the server functions pages call. `*.server.ts` holds server-only helpers, and page code never
  imports one: the build refuses it. See [Server functions](https://developers.zite.com/framework/overview.md#server-functions).

* API routes are routes under `src/routes/api/` with `server.handlers`. See
  [API routes](https://developers.zite.com/framework/api-routes.md).

* 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 in `automations/<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 })`
  from `zitejs/start`. Helpers go in other files under `src/`.
* 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](https://developers.zite.com/concepts/apps.md#automations).

## 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/`.

| File | Import as | Contains |
| - | - | - |
| `.zite/db.ts` (workspace root) | `zitejs/db` | The database client: a typed client per table, and raw SQL with `zite.sql()` |
| `apps/<dir>/.zite/integrations/index.ts` | `zitejs/integrations` | `integrations.get('<name>')`, for the app's connections |
| `apps/<dir>/.zite/integrations/email.ts` | `zitejs/email` | The `Email` client, once the app has an `email` settings entry |
| `apps/<dir>/.zite/start.ts` | | The platform's start instance |
| `apps/<dir>/src/routeTree.gen.ts` | | The route tree, from `src/routes/` |

`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 in `packages/components/`:
  shadcn/ui primitives, hooks, and utilities. Import primitives from `@project/components/ui/*`, for example
  `import { 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`).

The `@/` 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/`):

```typescript theme={"system"}
import { cn } from '@project/components/lib/utils';
```

`@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.css` and `tailwind.config.ts` for app-wide styling.
* Theme color variables that `tailwind.config.ts` consumes as `hsl(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 no `hsl()` 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 `:root` as the light baseline. Switch
  by putting the `dark` class on `<html>` (`document.documentElement`), rather than rewriting `:root`.
* `src/index.css` uses 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 `@tailwind` directives. `@tailwind base`
  expands into real CSS rules, and an `@import` after other rules fails the PostCSS build.

## Config files

* **`zite.config.json` at the workspace root** holds the connections every app can use, under
  `integrations`.
* **`zite.config.json` in each app** holds that app's settings: `accessMode`, `authentication`,
  `integrationSettings`, `seoSettings`, and more. See [App config](https://developers.zite.com/framework/app-config.md).
* **`zite.auth.ts` in an app**, next to its `zite.config.json`, holds optional sign-in hooks. See
  [App config](https://developers.zite.com/framework/app-config.md).

## 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.