Quickstart
On this page
From an empty folder to a running endpoint, then your own entity and
operation. You need Node, and uv for the Python
server (the workspace pins Python 3.12 in backend/.python-version).
Every npx globetrotter … below runs the Globetrotter CLI, inside a project made
from the bundle (node globetrotter-<version>/install.mjs new my-api --as backend:
Install Globetrotter). Until Globetrotter is published, people changing it
can run the CLI from a checkout of the repository instead:
node <repo>/packages/cli/bin/globetrotter.mjs <command> --cwd <your project>;
init from a clone packs the packages into vendor/globetrotter/*.tgz, and
npm install in the new project installs from those: no registry needed.
1. Make the project
$ npx globetrotter init my-api --as backend
+ globetrotter.config.json
+ package.json
+ vendor/globetrotter/ (packed from this clone; package.json installs from it; commit it)
+ .gitignore
+ .gitattributes
+ designs/my-api.service.json
+ backend/pyproject.toml
+ CLAUDE.md
✓ designs/my-api.service.json (1 entity, 1 service, 4 operations)
1 note (list-unbounded): service_session and lint_design say it in full
→ backend/contract/my-api.openapi.json
→ backend/packages/my_api_contract/pyproject.toml
… (about 40 more files)
→ backend/Dockerfile (yours: written once, never changed after)
! backend/ (30 python files of my-api not formatted: the python target's formatter is not installed in backend/ yet (`uv sync` there installs it); …)
→ uv lock (in backend/): the Python workspace's first lockfile (uv.lock)The starter service is an item entity (an id, a title, a done flag) and an
Items service at /items with four operations: list, get, create and
complete. It is valid and passes lint as written; the one note, list-unbounded,
says the list has no page size (see Lists are bounded). The → lines list each
file sync wrote, the Python packages among them. If the line
! run npm install then npx globetrotter sync appears instead, run those two
commands.
init ends with the commands to run next. Run them from the project folder:
$ cd my-api
$ npm install # first time only
$ npx globetrotter sync # validate, lint, write the contract, the Python packages and migration 0001 (init writes none)
$ cd backend && uv sync # install the Python workspace
$ npx globetrotter sync --cwd .. # format what was written before uv installed the formatter
$ GLOBETROTTER_ENV=local uv run python -m my_api_core.migrate # apply 0001, which that sync wrote
$ GLOBETROTTER_ENV=local uv run python -m my_api_fastapi # the service at http://localhost:8000 (PORT=… moves it)The package prefix is the design's name with - as _: my_api.
With organisations: seed the development people
A design with organisations (set_auth with tenancy) starts with nobody in
one. Without this step the pages answer You are not in a workspace yet. Ask an
owner to add you, then sign in again. to everyone, and check_auth has nobody
to press as a member. After migrate, once, from backend/:
$ GLOBETROTTER_ENV=local uv run python -m my_api_core.devseed # Python
$ GLOBETROTTER_ENV=local cargo run -p my-api -- devseed # RustIt makes the organisation dev and puts each development person in it (the
lowest role the lowest, the highest the highest), plus dev-other with the
lowest person alone. It runs only with GLOBETROTTER_ENV=local, says so
otherwise and writes nothing; running it twice adds nothing; a database that
already has an organisation of its own needs --anyway. Then sign in again: the
sign-in page of the app in development says who is there, the top role first,
for example In development, sign in as manager@example.com with the password dev-manager (the top role: it can do everything), or clinician@example.com with the password dev-clinician. A design with sign-in and no organisations has a devseed too
(uv run python -m <app>_core.devseed): it makes one person for each rung of the
ladder, <role>@example.com with the password dev-<role>, and, with the
accounts block, an account row at that role. Run it once after the migrations
before you sign in; a design with sign-in off has none.
Migrate prints one line per store, for example db: applied 0001, or
db: up to date, nothing to apply when it has nothing to do. The server logs
uvicorn's lines and Application startup complete.. Without GLOBETROTTER_ENV the
server and migrate stop with one line: an unset environment is production, and
local is only ever said outright. For a server, see
Deploy and operate.
2. Call it
With the server running, in another terminal:
$ curl localhost:8000/items
$ curl -X POST localhost:8000/items/actions/create \
-H 'content-type: application/json' -d '{"title": "Write the docs"}'
$ curl localhost:8000/items
$ curl -X POST localhost:8000/items/actions/create \
-H 'content-type: application/json' -d '{"title": ""}'The first call answers an empty list. The create answers
{"item": {"id": "…", "title": "Write the docs", "done": false}}, the row it
made, with its generated id. The next list holds that row. The last call is
refused with status 400 and the words the design gives the field,
{"error":"An item needs a title.","field":"title","fields":{"title":"An item needs a title."}}.
The routes are the contract's: a list is GET /items, one row is
GET /items/{id}, a command is POST /items/actions/<name>. See
the route rules.
3. Call it from the studio
$ npx globetrotter devThis starts the studio at http://localhost:3100 and the backend beside it
(uv sync the first time, migrate, serve; --no-backend leaves the service to
you). A project with no pages opens on the Backend view. Pick the Items
service, pick list and press Try it. It runs the real operation in the
running backend and shows the status, the body and the audit rows the request
left. See Studio and agents.

4. Run its tests
$ uv run pytesttests/test_audit_operation.py .. [ 16%]
tests/test_contract.py .... [ 50%]
tests/test_processes.py ..... [ 91%]
tests/test_read_rules.py . [100%]
============================== 12 passed in 3.45s ==============================This is run from backend/. It starts a throwaway sqlite database, migrates it
and calls every operation against the contract with Schemathesis. An
operation you have not written yet is reported under "still to write", not as a
failure.
5. Add an entity and an operation
Open designs/my-api.service.json, or use the studio's + Entity and
+ Query, or the agent's tools (add_entity, add_operation). By hand,
add an entity to entities:
{
"id": "note", "type": "Entity", "props": { "name": "note", "store": "db" },
"slots": { "fields": [
{ "id": "note-id", "type": "Field", "props": { "name": "id", "type": "uuid", "key": true } },
{ "id": "note-text", "type": "Field", "props": { "name": "text", "type": "text" } }
] }
}and a service to services:
{
"id": "notes", "type": "Service", "props": { "name": "Notes", "route": "/notes" },
"slots": { "operations": [
{ "id": "notes-list", "type": "Query",
"props": { "name": "list", "returns": "note", "many": true, "description": "The notes." } },
{ "id": "notes-add", "type": "Command",
"props": { "name": "add", "entity": "note", "does": "create", "description": "Adds a note." },
"slots": { "params": [ { "id": "notes-add-text", "type": "Param", "props": { "name": "text", "type": "text" } } ] } }
] }
}Then:
$ npx globetrotter syncSync validates the file and says each problem by its path. It lints it and
writes the contract, the new Python files and a new migration for the note
table. The migration is named for the change and numbered after the last one
(backend/migrations/db/sqlite/0002_…sql). Read it, then apply it:
$ cd backend
$ GLOBETROTTER_ENV=local uv run python -m my_api_core.migrateThe Notes routes now answer (GET /notes, POST /notes/actions/add).
list and add are generated whole from the entity, so there is nothing to
write. The server reloads on a change while it runs as local. A studio save
never writes a migration; only sync does.
An operation the design cannot describe fully, such as does: custom, answers
501 until you write its body. See Your code.
If you already have pages
npx globetrotter add backend drafts a service from the pages' contract: a
service per page at its route, an entity per list. From the project's folder,
on fieldops:
$ npx globetrotter add backend # the service, the workspace root
$ cd backend && uv sync # the Python workspace (uv)
$ export GLOBETROTTER_ENV=local # said outright: unset is production
$ uv run python -m fieldops_core.migrate
db: applied 0001, 0002
$ uv run python -m fieldops_fastapi # :8000; the app's /api/* reaches it (next.config.ts)
$ uv run pytest # Schemathesis: every operation against the contract
12 passedIn a project with both sides, npx globetrotter dev runs the studio, the app
and the backend together, and says when one of them stops. In this repository,
npm run dev:fieldops does the same for the example. init --as picks
frontend, backend, both (the app in frontend/, its own codebase) or
static, and asks in a terminal when --as is left out. add frontend gives a
backend pages.
Next: Concepts for the model, Your code to write an operation, Generated code for what was written where.