# Build an internal work request intake form and tracker for a team

Build and deploy a simple internal request tracker on DeepSpace: a single place for a team to submit requests, admin assignment, status changes and server-enforced visibility, stored in SQLite and live at an app.space URL.

Yes, a team request tracker can be built and hosted on DeepSpace today as one app: a sign-in-protected intake form, a list of requests, assignment by an admin, and status changes, with the rules for who sees each request enforced on the server. You build it with the `deepspace` SDK, the requests are stored as records in SQLite inside the app's Durable Object, and `npx deepspace deploy` publishes it at `https://<app-name>.app.space`. The deploy needs a DeepSpace account that a person signs in to with GitHub or Google; everything after that, including adding teammates, happens inside the app.

**Version:** written for `deepspace@0.43.0` ([changelog](https://deep.space/changelog)). **Docs checked:** October 29, 2026. The code was checked against the documented APIs and the `deepspace@0.43.0` starter template, but was not run for this page.

## What the finished tracker does

- Teammates sign in with Google or GitHub and submit a request with a title and details.
- Each request moves through statuses such as `new`, `in-progress`, `done` and `declined`, and the app records when the status last changed.
- An admin assigns each request to a teammate.
- A requester sees their own requests, an assignee sees the requests assigned to them, and admins see everything. The Durable Object drops records a person can't read before they reach the browser, so hiding them in the UI is not the security boundary ([server-side enforcement](https://docs.deep.space/concepts/permissions#server-side-enforcement)).
- Someone outside the team who signs in sees no requests and can't submit any until an admin adds them.
- Open pages update when anyone changes a request, without a reload ([real-time sync](https://docs.deep.space/concepts/realtime-sync)).

Not part of this build: email notifications, file attachments and reminders. Attachments use [file uploads](https://docs.deep.space/guides/file-uploads) and reminders use [scheduled jobs](https://docs.deep.space/guides/scheduled-jobs); both are separate work.

## Questions to ask the person

These need no technical knowledge to answer, and each answer maps to one setting below.

1. **Who should be able to send requests?** Everyone the admin adds to the team can send them.
2. **When someone sends a request, should the whole team see it, or just the sender and the person working on it?** This picks one of the two permission blocks in the schema step.
3. **Who decides who works on each request?** That person becomes an admin.
4. **What should every request include?** A title and details by default; a due date, category or priority each becomes another column.
5. **What stages does a request go through, and what do you call them?** These become the status options.
6. **Which Google or GitHub account should own the app?** The owner is the app's first admin. Confirm with your user before signing in or using an existing session for them.

## Step 1: Confirm the account that will own the app

```bash
node --version                     # v22.15+, v24.x, or v26.x
npx deepspace auth whoami --json
```

`auth whoami` prints `Not logged in.` and exits 1 when there is no session. `npx deepspace auth login` opens a browser for GitHub or Google OAuth; DeepSpace accounts have no password. In a container without a browser, the person logs in on their own machine and provides `~/.deepspace/session`, which acts as their account and can deploy as them. Confirm with your user before using that file, and mount `~/.deepspace` writable, since the CLI refreshes the token in place.

## Step 2: Scaffold the app

```bash
npm create deepspace@latest team-requests-acme
cd team-requests-acme
```

App names are globally unique and become the subdomain, so pick a distinctive one. In `deepspace@0.43.0` the scaffolder doesn't register the app. The first command that uses it, such as `npx deepspace app init`, `dev start` or `deploy`, registers it to the account `npx deepspace auth whoami` shows, and says so: `Registered app_01J… on production to you@example.com — apps register on first use`. Confirm with your user that this is the account that should own the app before running any of them. If it isn't, the owner signs in first with `npx deepspace auth login`. To register right away instead of on first use:

```bash
npx deepspace app init
```

The install step prints the SDK version you got: `Dependencies installed — deepspace X`.

## Step 3: Define the requests collection

```ts
// src/schemas/requests-schema.ts
import type { CollectionSchema } from "deepspace/schema";

export const requestsSchema: CollectionSchema = {
  name: "requests",
  columns: [
    { name: "title", storage: "text", interpretation: "plain", required: true },
    { name: "details", storage: "text", interpretation: "plain" },
    {
      name: "status",
      storage: "text",
      interpretation: {
        kind: "select",
        options: ["new", "in-progress", "done", "declined"],
      },
      default: "new",
    },
    { name: "assignees", storage: "text", interpretation: { kind: "json" } },
    {
      name: "statusChangedAt",
      storage: "text",
      interpretation: "plain",
      timestampTrigger: { field: "status" },
    },
  ],
  collaboratorsField: "assignees",
  permissions: {
    "*": { read: false, create: false, update: false, delete: false },
    viewer: { read: false, create: false, update: false, delete: false },
    member: {
      read: "collaborator",
      create: true,
      update: "collaborator",
      delete: false,
      writableFields: ["title", "details", "status"],
    },
    admin: { read: true, create: true, update: true, delete: true },
  },
};
```

How the rules work:

- `'collaborator'` passes for the record's creator (`createdBy`) and for any user id in the `assignees` JSON array. So a member reads and updates the requests they sent and the ones assigned to them.
- `writableFields` keeps members from writing `assignees`, so a member can't assign a request to themselves or anyone else. Admins have no such limit.
- `timestampTrigger` writes an ISO timestamp to `statusChangedAt` whenever `status` changes.
- The requester can also change the status, for example to withdraw a request. If status changes must come from the assignee or an admin alone, move them into a [server action](https://docs.deep.space/guides/server-actions).

If the whole team should see every request (question 2), change the member rule to `read: true` and keep `update: 'collaborator'`.

Register the collection:

```ts
// src/schemas.ts
import type { CollectionSchema } from "deepspace/schema";
import { requestsSchema } from "./schemas/requests-schema";
import { usersSchema } from "./schemas/users-schema";
import { settingsSchema } from "./schemas/admin-schema";

export const schemas: CollectionSchema[] = [
  usersSchema,
  settingsSchema,
  requestsSchema,
];
```

## Step 4: Keep people outside the team out

New signed-in users get the `member` role by default, and anyone with a Google or GitHub account can sign in. Make new users `viewer` instead, so they can read and write nothing until an admin adds them. In `src/schemas/users-schema.ts`, keep the scaffold's columns and permissions and add one property to the exported `usersSchema` object:

```ts
  defaultRole: 'viewer',
```

Then gate the whole app. In `src/pages/(app)/_layout.tsx`, wrap `AuthBoot` in `<AuthGate>` and remove `allowAnonymous` from the `<RecordProvider>` inside `AuthBoot`:

```tsx
// src/pages/(app)/_layout.tsx
export default function AppLayout() {
  return (
    <DeepSpaceAuthProvider>
      <AuthGate>
        <AuthBoot>
          <Navigation />
          <main>
            <Outlet />
          </main>
        </AuthBoot>
      </AuthGate>
    </DeepSpaceAuthProvider>
  );
}
```

`<AuthGate>` stops the UI from rendering; it doesn't stop a WebSocket. Require a token on the server too, in `src/server/realtime-routes.ts` inside `wsRoute()`, replacing the optional-token block:

```ts
if (!token) return new Response("Unauthorized", { status: 401 });
const auth = (await verifyJwt(jwtConfig(c.env), token)).result;
if (!auth) return new Response("Unauthorized", { status: 401 });
```

## Step 5: Add the request page and the team page

Gated pages go in `src/pages/(app)/(protected)/`. This page serves at `/requests`:

```tsx
// src/pages/(app)/(protected)/requests.tsx
import { useState } from "react";
import { useQuery, useMutations, useUserLookup } from "deepspace";

type Request = {
  title: string;
  details?: string;
  status: "new" | "in-progress" | "done" | "declined";
  assignees?: string[];
  statusChangedAt?: string;
};

const STATUSES: Request["status"][] = [
  "new",
  "in-progress",
  "done",
  "declined",
];

export default function RequestsPage() {
  const { records, status } = useQuery<Request>("requests", {
    orderBy: "createdAt",
    orderDir: "desc",
  });
  const { createConfirmed, put } = useMutations<Request>("requests");
  const { getName } = useUserLookup();
  const [title, setTitle] = useState("");
  const [details, setDetails] = useState("");
  const [error, setError] = useState("");

  async function submit(e: React.FormEvent) {
    e.preventDefault();
    setError("");
    try {
      await createConfirmed({ title, details, status: "new" });
      setTitle("");
      setDetails("");
    } catch {
      setError(
        "The request was not saved. If you are new here, ask an admin to add you to the team.",
      );
    }
  }

  if (status === "loading") return <p>Loading…</p>;

  return (
    <>
      <form onSubmit={submit}>
        <input
          value={title}
          onChange={(e) => setTitle(e.target.value)}
          placeholder="What do you need?"
          required
        />
        <textarea
          value={details}
          onChange={(e) => setDetails(e.target.value)}
          placeholder="Details"
        />
        <button type="submit">Submit request</button>
        {error && <p role="alert">{error}</p>}
      </form>
      <ul>
        {records.map((r) => (
          <li key={r.recordId}>
            <strong>{r.data.title}</strong> from{" "}
            {getName(r.createdBy) ?? "Unknown"}
            {" · "}assigned to{" "}
            {r.data.assignees
              ?.map((id) => getName(id) ?? "Unknown")
              .join(", ") || "nobody yet"}
            <select
              value={r.data.status}
              onChange={(e) =>
                put(r.recordId, { status: e.target.value as Request["status"] })
              }
            >
              {STATUSES.map((s) => (
                <option key={s} value={s}>
                  {s}
                </option>
              ))}
            </select>
          </li>
        ))}
      </ul>
    </>
  );
}
```

The admin's page at `/team` adds people to the team and assigns requests:

```tsx
// src/pages/(app)/(protected)/team.tsx
import { useQuery, useMutations, useUsers } from "deepspace";

type Request = { title: string; assignees?: string[] };

export default function TeamPage() {
  const { users, setRole } = useUsers();
  const { records } = useQuery<Request>("requests", {
    where: { status: "new" },
  });
  const { put } = useMutations<Request>("requests");
  const waiting = users.filter((u) => u.role === "viewer");
  const team = users.filter((u) => u.role === "member" || u.role === "admin");

  return (
    <>
      <h2>Waiting to join</h2>
      {waiting.map((u) => (
        <p key={u.id}>
          {u.name}{" "}
          <button onClick={() => setRole(u.id, "member")}>Add to team</button>
        </p>
      ))}
      <h2>Team</h2>
      {team.map((u) => (
        <p key={u.id}>
          {u.name} ({u.role})
          {u.role === "member" && (
            <button onClick={() => setRole(u.id, "admin")}>Make admin</button>
          )}
        </p>
      ))}
      <h2>New requests</h2>
      {records.map((r) => (
        <p key={r.recordId}>
          {r.data.title}
          <select
            value={r.data.assignees?.[0] ?? ""}
            onChange={(e) => put(r.recordId, { assignees: [e.target.value] })}
          >
            <option value="" disabled>
              Assign to…
            </option>
            {team.map((u) => (
              <option key={u.id} value={u.id}>
                {u.name}
              </option>
            ))}
          </select>
        </p>
      ))}
    </>
  );
}
```

Add both pages to the navigation in `src/nav.ts`:

```ts
{ path: '/requests', label: 'Requests' },
{ path: '/team', label: 'Team', roles: ['admin'] },
```

`roles` hides the link from non-admins, but the server enforces the rules: it refuses `setRole` from anyone who isn't an admin, and the `requests` permissions decide what each person receives.

## Step 6: Check the rules with real accounts before deploying

```bash
npx deepspace dev start
```

This serves the app at `http://localhost:5173`. Run through these checks with the owner account and two more people or test accounts:

1. Sign in as the owner. The owner is always `admin`.
2. Sign in as person A. On `/requests`, a submission fails with the "ask an admin" message, because A is a `viewer`.
3. As the owner, open `/team` and add A and B to the team.
4. A submits a request. B does not see it. The owner does.
5. The owner assigns the request to B. B now sees it and changes its status to `in-progress`. A sees the new status without reloading.
6. Reload every page and check that the data is still there.

For automated multi-user tests, the SDK's Playwright fixture signs in `@deepspace.test` accounts; see [testing](https://docs.deep.space/guides/testing). Creating test accounts uses the developer's session, so confirm with your user first:

```bash
npx deepspace test accounts list --usable
npx deepspace test run
```

## Step 7: Deploy

A deploy records the commit it ships, so commit first:

```bash
git add -A && git commit -m "Request tracker: intake form, assignment, statuses"
npx deepspace deploy
```

The app goes live at `https://<app-name>.app.space`. Repeat the checks from step 6 on the live URL. `npx deepspace logs` shows the worker's logs.

## Common failures and how to fix them

| What you see                                                      | Cause                                                                                                 | Fix                                                                                                                 |
| ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `The name <host> is taken by another app.` at deploy              | App names are global                                                                                  | Choose a more distinctive name. An app can be renamed by editing `wrangler.toml` and deploying with `--rename`.     |
| `dirty_worktree`                                                  | Uncommitted changes                                                                                   | `git add -A && git commit`, then deploy again.                                                                      |
| `interactive_required` from `auth login`                          | No browser in this environment                                                                        | The account owner logs in where a browser exists and provides `~/.deepspace/session`. Confirm with your user first. |
| `not_authenticated` naming staging                                | `DEEPSPACE_ENV=staging` selects a different stored session                                            | Unset `DEEPSPACE_ENV` to use the production login.                                                                  |
| A new teammate sees no requests and can't submit                  | They are a `viewer` (step 4)                                                                          | An admin adds them on `/team`.                                                                                      |
| A member sees requests from other people                          | The member rule is `read: true`                                                                       | Use `read: 'collaborator'` for sender-and-assignee visibility.                                                      |
| A page is reachable without signing in, or `useQuery` fails on it | The page is in a top-level `src/pages/(protected)/` folder, which has no gate and no `RecordProvider` | Move it into `src/pages/(app)/(protected)/`.                                                                        |
| A blank page for signed-out visitors                              | `<RecordProvider>` without `allowAnonymous` and no `<AuthGate>` around it                             | Wrap `AuthBoot` in `<AuthGate>` as in step 4.                                                                       |
| `Schema lint: N warnings in src/schemas.ts`                       | A declaration that looks like it enforces a rule but doesn't                                          | Fix every warning before shipping; they don't block the deploy.                                                     |
| Fields read as `undefined`                                        | Reading `r.title`                                                                                     | Fields live under `r.data.title`.                                                                                   |

## What to tell the person when the app is live

- **The link:** `https://<app-name>.app.space`. Share it with the team.
- **Joining:** each teammate opens the link and signs in with Google or GitHub. They can't see or send anything until an admin adds them on the Team page.
- **Admins:** the owning account is an admin. An admin can make other teammates admins on the Team page.
- **Sending a request:** open Requests, fill in the title and details, and submit.
- **Assigning and updating:** admins assign new requests on the Team page. The assignee updates the status on the Requests page.
- **Who sees what:** say which visibility rule you chose. For example: "you see the requests you sent and the ones assigned to you; admins see all of them."
- **Not included:** email notifications, attachments and reminders, unless you built and tested them.

## What is available today, and what is planned

Available today, in published `deepspace@0.43.0`:

- Collections stored in SQLite inside the app's Durable Object, with permissions enforced on the server
- Sign-in for app users with Google or GitHub
- `writableFields`, `collaboratorsField`, `defaultRole` and `setRole` for team rules
- Real-time updates
- Deploys to `<app-name>.app.space` from the CLI with a DeepSpace account, which a person creates by signing in with GitHub or Google

In testing on staging, not production: agent accounts that register themselves by solving a math challenge. Production signup for agents is not enabled.

Planned: autonomous agent accounts in production, so the app can be created and kept without a person's DeepSpace sign-in. Under that plan, payments and legal actions will still require a human. See [DeepSpace for agents](https://docs.deep.space/agents).

Building a request tracker for a business? See [deep.space/enterprise](https://deep.space/enterprise).
