Setup
Prerequisites
- Node.js 24.
- pnpm 12.18.0 (the version pinned in
package.json). - A local Postgres database.
- Expo tooling for mobile development.
Environment variables
Copy .env.example to .env and fill in the values for:
DATABASE_URLAPI_PORTEXPO_PUBLIC_API_URLEXPO_PUBLIC_WEB_PUSH_VAPID_PUBLIC_KEYfor browser push subscriptions, when web push is enabled.AUTH_SECRETAUTH_BASE_URLAUTH_REDIRECT_URLSfor additional exact client callback URLs (see below).AUTH_GOOGLE_CLIENT_IDAUTH_GOOGLE_CLIENT_SECRETAUTH_APPLE_CLIENT_IDAUTH_APPLE_TEAM_IDAUTH_APPLE_KEY_IDAUTH_APPLE_PRIVATE_KEYorAUTH_APPLE_PRIVATE_KEY_PATHto generate Apple client secrets automatically.AUTH_SESSION_TTL_DAYS
OAuth callback allowlist
AUTH_REDIRECT_URLS adds comma-separated exact client callback URLs to the server’s
built-in allowlist. The production defaults are
https://3spinningplates.com/auth/callback,
https://www.3spinningplates.com/auth/callback, threeplates://auth/callback, and
legacy threeplates://auth-finished. Queries, fragments, and embedded credentials
are rejected. This setting controls the client return location; AUTH_BASE_URL
controls the API callback URL registered with Google and Apple and does not
implicitly authorize a client redirect.
For another web hostname, add its exact /auth/callback URL. For Expo Go, add the
exact callback for the trusted development host, for example
AUTH_REDIRECT_URLS=exp://192.168.1.10:8081/--/auth/callback.
Local web callbacks at http://localhost:8081/auth/callback and
http://localhost:3000/auth/callback are built in only outside production.
Restart the API after changing this environment variable. Do not use wildcards.
Local development
- Install dependencies with
pnpm install. - Start Postgres and apply migrations with
pnpm db:setup. - Start the backend with
pnpm dev:api. - Start the Expo app with
pnpm dev:mobile. - Open the app in web, Android, or iOS as needed.
Hosted native auth smoke test
Check out the commit you want to test. Use an Expo project with access to Expo
Simulators and export its ID as EXPO_PUBLIC_EAS_PROJECT_ID. Sign in to EAS CLI
before building or starting a session.
For Android, build an x86_64 APK from the repository root with the Android SDK and JDK configured:
ORG_GRADLE_PROJECT_reactNativeArchitectures=x86_64 pnpm --filter @3plates/mobile build:android:production
cd apps/mobile
npx --yes eas-cli@27.11.0 simulator:start --platform android --type agent-device --max-duration-minutes 20 --no-force --non-interactive
npx --yes eas-cli@27.11.0 simulator:exec npx --yes agent-device@0.21.41 install com.christitustech.threeplates ./dist/3plates-android-production.apk --platform android
pnpm test:simulator:auth android
npx --yes eas-cli@27.11.0 simulator:stop --non-interactive
For iOS, run the simulator build from apps/mobile and use its build ID when
starting the session:
npx --yes eas-cli@27.11.0 build --platform ios --profile ios-preview --non-interactive
npx --yes eas-cli@27.11.0 simulator:start --platform ios --type agent-device --build-id "$IOS_BUILD_ID" --open-url 'threeplates://auth/callback' --max-duration-minutes 20 --no-force --non-interactive
pnpm test:simulator:auth ios
npx --yes eas-cli@27.11.0 simulator:stop --non-interactive
The smoke test verifies that missing and unsolicited callback parameters are
rejected, and checks the browser handoff for Google, Apple, and WHOOP. Use the
default Android Expo emulator image, which includes Chrome. Screenshots go to
apps/mobile/test-results/expo-auth/. Stop the session even if the test fails.
Complete provider sign-in with a dedicated test account when testing live OAuth
end to end.
Database setup
- The repo ships with
docker-compose.ymlfor a local Postgres 16 instance. - The container binds to
127.0.0.1:${POSTGRES_PORT}so it is not exposed beyond the host. - The Drizzle migrations in
packages/db/drizzle/create both the schema and thepgcryptoprerequisite for UUID generation. - Generate new migration SQL with
pnpm db:generateafter changingpackages/db/src/schema.ts. - Apply migrations with
pnpm db:migrate. pnpm db:setupcombines container startup and migration application for normal local use.- Use
pnpm db:resetto recreate the database volume and replay migrations from scratch. - Use
pnpm db:testafter the API is running to validate container health, migration state, and a persisted API round-trip.
VPS recreation
Use VPS Setup Checklist for a full rebuild and validation pass.
The database rule is fixed for the current scaffold: keep Postgres bound to 127.0.0.1 and keep DATABASE_URL pointed at localhost when the API runs on the VPS host. If the API later moves into Docker on the same compose network, remove the published Postgres port and connect to the postgres service name instead.
Track remaining VPS and website validation work in VPS And Website Tasks.
GitHub Pages setup
- In the GitHub repository, open Settings.
- Open Pages.
- Set Source to GitHub Actions.
- Keep
.github/workflows/jekyll-gh-pages.ymlenabled onmain. - The workflow builds Jekyll from
./docs, uploads./_site, and deploys to GitHub Pages. - Confirm the latest Pages workflow run succeeds and the docs site loads.
Publishing rule
- Keep all documentation pages inside the
docs/folder. - Update
docs/index.mdwhen the site structure changes. - Keep the docs aligned with the actual app scaffold and setup commands.
Validation dependency compatibility
The shared contract, API and mobile client use Zod 4.6.7 or newer. This includes the constrained-collection resource exhaustion fix. Paginated workout responses cap arrays at the existing 50-item page limit so oversized pages fail before individual entries are validated.
@ts-rest/core is pinned to 3.53.0-rc.1, the upstream release candidate that
officially supports Standard Schema and Zod 4.
This is an intentional prerelease dependency: stable 3.52.x requires vulnerable
Zod 3. Before changing the pin, run workspace typechecks and tests, Expo exports
for all platforms, and the dependency audit. No audit finding is suppressed.