How to get the demo running locally and what each part is doing once it's running.
- Node.js 20 or newer
- pnpm 9 or newer
- Docker Desktop (for PostgreSQL)
- Xcode (for iOS) or Android Studio (for Android), if you want to run the mobile app on a simulator/emulator
- A LAN-accessible API URL if you want to run on a physical device
From the repo root:
pnpm install
# Boot Postgres in the background
docker compose up -d postgres
# Configure the API
cp apps/api/.env.example apps/api/.env
# Run migrations and seed demo data
pnpm --filter @sdui/api exec prisma migrate dev
pnpm --filter @sdui/api db:seed
# Configure the admin and mobile envs
cp apps/admin/.env.example apps/admin/.env.local
cp apps/mobile/.env.example apps/mobile/.env.localEdit apps/mobile/.env.local if you need a non-localhost API URL — see the comments in the file for iOS simulator, Android emulator, and physical device variants.
Open three terminals:
pnpm dev:api # NestJS → http://localhost:3000/api
pnpm dev:admin # Next.js → http://localhost:3001
pnpm dev:mobile # Expo dev server, then press `i` for iOS or `a` for AndroidThe default URLs:
| Service | URL |
|---|---|
| API | http://localhost:3000/api |
| Admin | http://localhost:3001 |
| Metro | http://localhost:8081 |
| PostgreSQL | localhost:5432 |
- Open the admin (
http://localhost:3001). - Pick a screen (e.g.
home). - Drag, edit, save draft, then publish.
- Pull-to-refresh on the phone (or background and foreground the app).
- Mobile fetches the new published revision.
pnpm --filter @sdui/api exec prisma migrate reset
pnpm --filter @sdui/api db:seedpnpm typecheckpnpm buildcurl -sS \
-H 'x-ui-schema-version: 1' \
-H 'x-user-id: u_42' \
-H 'x-client-os: ios' \
-H 'x-client-os-version: 18.0' \
-H 'x-client-app-version: 1.0.0' \
http://localhost:3000/api/v1/screens/home | jq .- Mobile can't reach the API. Check
EXPO_PUBLIC_API_URLinapps/mobile/.env.local. iOS sim →localhost; Android emu →10.0.2.2; device → your machine's LAN IP. - Admin save fails with 401. Confirm
NEXT_PUBLIC_ADMIN_SECRET(admin) matches thex-admin-secretthe API expects (defaultdev-only-secret). - Mobile shows stale layout. The cache is intentionally stale-while-revalidate. Pull to refresh, focus a different screen and back, or restart the app.
- Schema validation error from the API. The
ValidationPipeis set toforbidNonWhitelisted. If you sent extra fields, strip them. If a DTO is rejecting valid input, check that all decorators are correct in@sdui/contracts. prisma migrate devfails. Confirm Postgres is up (docker ps | grep sdui-postgres). If schema drift, runprisma migrate reset(destructive — wipes data).
apps/api/— NestJS service. Read itsREADMEfor the module map.apps/admin/— Next.js authoring tool. Editor lives atapp/screens/[id]/page.tsx.apps/mobile/— Expo + RN. Renderer engine lives atsrc/renderer/.packages/sdui-contracts/— shared DTOs and Zod schemas.