- DevCraft Platform
- Documentation
- Getting started
Start here
Getting started
This page takes you from an empty machine to a running DevCraft Platform: the Docker Compose stack with the Laravel API, PostgreSQL, Redis and the helper services, a seeded database, and the Vue single-page application talking to the live API. It is written for developers and administrators who want to run the platform locally, look around and start working on it.
Prerequisites
PHP, Composer, PostgreSQL and Redis all run inside containers. On the host you need only Docker and Node.js.
| Tool | Version | Notes |
|---|---|---|
| Docker Desktop | current release | On Windows use the WSL 2 backend (winget install Docker.DockerDesktop) and start it once before the first docker compose command. See the Docker Desktop documentation. |
| Docker Compose | v2 (docker compose) | Ships with Docker Desktop. |
| Node.js | 22 or later | frontend/package.json and runner/package.json declare "node": ">=22". CI runs on Node 24. The runner container itself uses node:22-alpine. |
| npm | the version bundled with your Node.js | Used for the SPA in frontend/. |
| Git | any recent version | To get the source. |
You do not need a native PHP installation. Every PHP command in this documentation runs inside the api container (docker compose exec api php artisan …).
Get the source
The repository is not public yet. Once it is published, clone it and work from the repository root:
git clone <repository-url> devcraft-platform
cd devcraft-platform
The top-level folders you will touch while getting started:
compose.yaml- The local development stack (all services below).
backend/- Laravel 12 REST API (PHP 8.4), bind-mounted into the
apiandschedulercontainers. frontend/- Vue 3 + TypeScript SPA, run on the host with Vite.
runner/- The background script runner service (Node, no dependencies).
scripts/backend-test.sh(backend test suite) andcheck-baseline.mjs(baseline guard).
The development guide describes the full layout.
The Docker Compose stack
compose.yaml defines the project devcraft-platform with six services and one named volume (pgsql-data).
| Service | Image or build | Command | Host ports | Purpose |
|---|---|---|---|---|
api | build ./backend (php:8.4-cli-alpine with pdo_pgsql, intl, zip, bcmath, pcntl, opcache, redis) | php artisan serve --host=0.0.0.0 --port=8000 --no-reload | 8000 | The REST API under /api/v1. Source is bind-mounted from ./backend. PHP_CLI_SERVER_WORKERS=4. |
scheduler | build ./backend | php artisan schedule:work | none | Runs the due scheduled commands every minute: platform:logs:prune daily at 03:15, platform:packages:prune-previews hourly, platform:remote-sets:prune daily at 03:45. |
runner | build ./runner (node:22-alpine) | node server.mjs | none (3001 inside the network) | Executes background scripts. No database, no secrets, read-only root filesystem, tmpfs on /tmp, mem_limit: 768m, pids_limit: 64. |
pgsql | postgres:17-alpine | default | 5432 | Database devcraft, user devcraft, data in the pgsql-data volume, health check with pg_isready. |
redis | redis:7-alpine | default | 6379 | Cache store (including the metadata cache) and queue connection. |
mailpit | axllent/mailpit:latest | default | 8025 (web UI), 1025 (SMTP) | Catches outgoing mail. The api service is configured with MAIL_MAILER=smtp and MAIL_HOST=mailpit. |
api and scheduler wait for pgsql to be healthy and for redis to start. Both share the entrypoint backend/docker/entrypoint.sh, which on every start:
- runs
composer installwhenbackend/vendoris missing; - copies
backend/.env.exampletobackend/.envwhen.envis missing; - generates
APP_KEYwhen.envhas none; - runs
php artisan migrate --force.
The development server needs several workers because a background script calls the API back while the request that started it is still open. The built-in PHP server honours PHP_CLI_SERVER_WORKERS only with --no-reload, which also means it does not restart when backend/.env changes. Restart the api container after editing .env.
First start
Start Docker Desktop. From the repository root, start the whole stack in the background:
docker compose up -dThe first run builds the
api,schedulerandrunnerimages, installs the Composer dependencies, createsbackend/.env, generates the application key and runs the migrations. Follow progress withdocker compose logs -f api.Align
backend/.envwith the Compose services. Openbackend/.env(just created from the example) and set:DB_HOST=pgsql REDIS_HOST=redis CACHE_STORE=redisThen restart the API:
docker compose restart api. The environment alignment section explains why this step is needed.Check that the API answers:
curl -i http://localhost:8000/up curl -s http://localhost:8000/api/v1/health/upis the framework liveness check./api/v1/healthperforms a database round trip and returns503when the platform is degraded.Seed the database (next section).
Seeding the database
Migrations create the empty schema. The seeders fill it with the platform's own metadata, the roles, the first administrator and, locally, fictional demo records:
docker compose exec api php artisan db:seed
DatabaseSeeder runs, in this order:
| Seeder | What it writes | When |
|---|---|---|
RoleSeeder | The roles admin, security_admin, platform_user, itil, user_admin. | always |
PlatformMetadataSeeder | The platform baseline dictionary through the family seeders in database/seeders/Platform/, in dependency order: IdentitySeeder, AssetSeeder, CmdbSeeder, TaskSeeder, SystemTablesSeeder. Tables, fields, overrides, default forms and lists, plus reference data such as relationship types. | always |
| first administrator | A user with the roles admin, security_admin and platform_user, from PLATFORM_ADMIN_EMAIL and PLATFORM_ADMIN_PASSWORD. | only when no user holds admin yet |
DemoDataSeeder | Fictional people, locations, departments, groups, assets, configuration items, incidents, problems and changes of an invented organisation, with reserved example e-mail domains. | only when APP_ENV=local |
Platform seeders and demo data are deliberately separate:
- Platform seeders are idempotent and additive. Every object gets a deterministic id derived from its package key, so two fresh installations produce identical ids. Existing tables, fields, overrides, forms and lists are never overwritten, so your local customisations survive a re-seed. All writes go through
MetadataWriterandRecordWriter. - Demo data is written through
RecordWriterlike any API call, so validation, references, numbering and audit apply. People, locations, departments, groups and configuration items are matched by name; task records are seeded once.
You can run one part on its own with the standard Laravel --class option:
docker compose exec api php artisan db:seed --class=PlatformMetadataSeeder
docker compose exec api php artisan db:seed --class=DemoDataSeeder
PlatformMetadataSeeder invalidates the metadata cache before it starts, because the database may have been reset underneath a shared cache.
The first administrator
Set the two variables in backend/.env before the first seed if you want to choose the account:
| Variable | Effect |
|---|---|
PLATFORM_ADMIN_EMAIL | E-mail address of the first administrator (stored in lower case). Empty in a local environment: the seeder falls back to the project owner's development identity. Empty outside a local environment: no administrator is created and the seeder prints a warning. |
PLATFORM_ADMIN_PASSWORD | Its password. Empty: the seeder generates a 20-character password and prints it once in the seeder output. |
PLATFORM_ADMIN_USER_NAME | Optional user name (config key platform.admin.user_name, default admin). |
The platform never ships a hardcoded password, and the documentation never prints one.
Running the SPA
The SPA runs on the host with the Vite development server:
cd frontend
npm install
npm run dev
Vite listens on http://localhost:5173. Out of the box the SPA runs in mock mode. To use the live API, create frontend/.env.local (start from frontend/.env.example):
VITE_API_MODE=http
Restart npm run dev after changing the file. The variables in frontend/.env.example:
| Variable | Default | Meaning |
|---|---|---|
VITE_API_MODE | mock | mock: in-memory mock data, no backend needed. http: the live contracts talk to the Laravel API (see Mock mode and live API). |
VITE_API_URL | empty | Base URL of the API as seen from the browser. Leave it empty to use the Vite proxy, which is the recommended local setup. |
VITE_PROXY_TARGET | http://localhost:8000 | Where the dev-server proxy forwards /api, /sanctum and exactly /up. |
With the proxy, the SPA and the API share one origin, so the Sanctum session cookie and the XSRF token work without CORS. The /up rule is an exact match so that SPA pages such as /update-sets are not proxied to Laravel.
The frontend entry in .claude/launch.json runs the same command with --port 5173 --strictPort.
Signing in
With VITE_API_MODE=http, open http://localhost:5173. The login page says "Connected to the local DevCraft API". Sign in with the administrator from backend/.env: the address in PLATFORM_ADMIN_EMAIL (or the one the seeder printed) and the password from PLATFORM_ADMIN_PASSWORD (or the generated one).
What happens behind the form:
- The SPA calls
GET /sanctum/csrf-cookie, thenPOST /api/v1/auth/loginwith{ email, password, remember? }. - The API answers with the
Sessionpayload (user, roles, environment, workspace, platform date settings).GET /api/v1/auth/sessionreturns it again on reload. - Sign-in attempts are throttled to 5 per minute per e-mail and IP. After
PLATFORM_LOCKOUT_ATTEMPTSfailures (default 5) the account is locked and the API answers423 account_locked. The answer never reveals whether an address exists.
In mock mode the login accepts any valid work e-mail with a password of at least 8 characters, and nothing is sent to a server. The page says so.
Details on sessions, tokens and roles: Access control.
Service URLs and ports
| What | Address | Notes |
|---|---|---|
| SPA (Vite) | http://localhost:5173 | Runs on the host, not in Compose. |
| Service Portal | http://localhost:5173/portal | End-user surface of the same SPA. |
| API | http://localhost:8000 | Base path /api/v1. |
| Liveness | http://localhost:8000/up | Framework health route. |
| Health | http://localhost:8000/api/v1/health | Database round trip, version; 503 when degraded. |
| Mailpit | http://localhost:8025 | SMTP on localhost:1025. |
| PostgreSQL | localhost:5432 | Database and user devcraft; the password is in compose.yaml and is for local use only. |
| Redis | localhost:6379 | No password locally. |
| Script runner | http://runner:3001 | Only inside the Compose network; not published to the host. |
CORS and stateful session origins are configured for localhost:5173 and 127.0.0.1:5173 (SANCTUM_STATEFUL_DOMAINS, CORS_ALLOWED_ORIGINS).
Environment alignment with Compose
The API container gets its settings from two places:
- the
environment:block of theapiservice incompose.yaml(DB_HOST=pgsql,REDIS_HOST=redis,CACHE_STORE=redis,QUEUE_CONNECTION=redis, mail and runner URLs); - the file
backend/.env, created frombackend/.env.example, whose defaults target a native setup (DB_HOST=127.0.0.1,REDIS_HOST=127.0.0.1,CACHE_STORE=database).
In this setup the web worker started by php artisan serve --no-reload reads backend/.env, while commands started with docker compose exec api … read the Compose environment: block. If the two disagree, the web process and the command line use different databases or, more subtly, different metadata caches.
The practical consequence: php artisan platform:meta:cache-clear clears the cache the CLI sees, and the SPA keeps showing the old dictionary because the web process reads another cache store.
Never commit backend/.env. backend/.env.example is the reference for every variable, including the limits for XML transfer (TRANSFER_*), update set packages (PACKAGE_*), remote instances (REMOTE_*), system logs (PLATFORM_LOG_*) and background scripts (SCRIPT_*). Operations lists them.
Stopping, resetting and the metadata cache
Stopping
docker compose down # stop and remove the containers, keep the database volume
docker compose down -v # also delete the pgsql-data volume (all data)
Stop Vite with Ctrl+C in its terminal.
Resetting the database
Two ways, depending on how far you want to go:
Full reset.
docker compose down -v, thendocker compose up -d(the entrypoint migrates the empty database), thendocker compose exec api php artisan db:seed.Schema reset in place. Rebuild the tables and seed again:
docker compose exec api php artisan migrate:fresh docker compose exec api php artisan db:seed
Clearing the metadata cache after migrate:fresh
Table definitions are cached in the configured cache store under a version key (meta:version). MetadataWriter invalidates it after every write, but migrate:fresh resets the database underneath a running instance while Redis keeps the old dictionary. After migrate:fresh, either seed (the platform seeder invalidates the cache) or clear it explicitly:
docker compose exec api php artisan platform:meta:cache-clear
The command prints the new cache version. If the SPA still shows stale tables afterwards, check the environment alignment.
Mock mode and live API
All screens call api.* from frontend/src/api. frontend/src/api/index.ts binds each contract either to an in-memory mock or to the HTTP implementation. The list of live contracts is exported as liveContracts.
| Contract | VITE_API_MODE=mock | VITE_API_MODE=http |
|---|---|---|
auth | simulated sign-in, nothing verified | Live Sanctum session |
meta, records, references | prototype definitions only; generic table screens show an explanatory state | Live /api/v1/meta, /api/v1/table |
portal | mock | Live /api/v1/portal |
scripts | prototype mode: runs are reported as not executed | Live runner service |
transfer, updateSets, packages, remote | not available; the UI hides or explains the feature | Live |
users, catalogItems, dashboard, notifications | mock | Still mocked prototype screens, labelled as such |
flows | stored in the browser | Still in the browser until a flow API exists |
Prototype-only screens carry a visible prototype badge. Mock data resets on reload. The Service Portal's catalogue and knowledge articles are illustrative client data in both modes and are labelled as such.
A first tour
Sign in as the administrator in live mode, then try these in order.
Open the incident list. Go to
http://localhost:5173/incident/list(or Incidents in the navigator). This is the generic list: columns, sort, per-column filters, search and paging come from the backend list layout. Every table is served the same way at/{table}/list,/{table}/newand/{table}/{recordId}. Filters, sort, page and search live in the URL; try right-clicking a cell and choosing Show matching, then look at theqparameter.Create a record. Choose New (or open
/incident/new). Fill Short description and Caller (both mandatory; the caller is a reference picker over the live Table API) and save. The number is assigned by the server with theINCprefix. Change a field and save again: updates use optimistic locking, so a concurrent change answers409 conflict. Administrators can open View history from the form's actions menu.Pick an update set. On a wide window, the top bar shows the update set picker (administrators, live mode only). Without a selection, configuration changes go to the scope's Default set. Open Administration → Update Sets (
/update-sets), create a set and choose Make current. Now change something that counts as configuration (for example a system property at/sys_property/list) and look at the captured changes of your set. Incidents are operational data and are never captured. See Update sets.Run a background script. Open Platform → Background Scripts (
/background-scripts). Paste:const incidents = await DevCraft.record('incident') .where('active', true) .orderBy('number', 'desc') .limit(5) .find(); DevCraft.log.info(`Found ${incidents.length} incidents`);Run it. The script executes in the
runnerservice, never in PHP or the browser, with a short-lived token of your account. A script that callsinsert,updateordeleteasks for confirmation first. See Scripting and flows.Look at the logs and the dictionary. System Logs are at
/syslog/list(administrators only, read-only). The data model is at/sys_table/list.Visit the portal. Open
/portal, raise a request from New request and find it as an incident in/incident/list.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
The SPA shows tables or fields that no longer exist after migrate:fresh, or a new table is missing. | The metadata cache in Redis outlived the database reset. | Run docker compose exec api php artisan platform:meta:cache-clear or seed again. |
platform:meta:cache-clear reports success but the SPA does not change. | backend/.env points the web process at another cache store or database than the CLI. | Set DB_HOST=pgsql, REDIS_HOST=redis, CACHE_STORE=redis in backend/.env and docker compose restart api. |
An edit to backend/.env has no effect. | artisan serve --no-reload does not watch .env. | docker compose restart api. |
| The SPA accepts any password and shows no real data. | Mock mode. | Create frontend/.env.local with VITE_API_MODE=http and restart npm run dev. |
| Generic table screens show an explanatory state instead of records. | Mock mode: the mock data source only knows the prototype tables. | Use live mode. |
| The update set picker, Export XML or Import XML… are missing. | Mock mode, a non-administrator account, or (for the picker) a narrow window. | Use live mode as an administrator; widen the window. |
Sign-in answers 419 csrf_token_mismatch or the session is lost after login. | The SPA does not reach the API through the Vite proxy, or runs on an origin outside SANCTUM_STATEFUL_DOMAINS (for example another port because 5173 was taken). | Leave VITE_API_URL empty, keep Vite on port 5173, check VITE_PROXY_TARGET. |
Sign-in answers 423 account_locked. | Too many failed attempts (PLATFORM_LOCKOUT_ATTEMPTS). | An administrator unlocks the account; locally you can also reset the database. |
Sign-in answers 429 rate_limited. | More than 5 attempts per minute for one e-mail and IP. | Wait for the Retry-After interval. |
No administrator was created by db:seed. | An administrator already exists, or PLATFORM_ADMIN_EMAIL is empty outside a local environment. | Read the seeder output; set the variables before the first seed or reset the database. |
A background script ends as unavailable. | The runner is not running, or SCRIPT_RUNNER_URL is empty in backend/.env. Nothing was executed. | docker compose up -d runner; check SCRIPT_RUNNER_URL=http://runner:3001 and restart api. |
| A background script hangs until its timeout. | The API runs with a single worker, so the script cannot call it back. | Keep PHP_CLI_SERVER_WORKERS above 1 and the --no-reload flag, as in compose.yaml. |
| Saving configuration answers 422 "The requested change set is no longer in progress". | Your current update set was completed. | Choose another set in the picker or clear the selection. |
A remote instance on http:// or a private address is refused. | The outbound policy allows only https to public addresses. | For local experiments only, set REMOTE_ALLOW_LOCAL=true in backend/.env. Never in production. |
| Tests wiped your local data. | php artisan test was run inside the api container against the development database. | Always use scripts/backend-test.sh; see the development guide. |
When something fails in the API, every response carries an X-Request-Id header. Search for it in System Logs (/syslog/list) or in docker compose logs api.