OpenTrip Docs
Operations

Operations

Operations

Local development

make setup             # first time: install + .env + Postgres + migrate + seed
make dev               # Postgres (if needed) + web + api

make dev ensures the root .env exists, starts Postgres via Docker when port 5430 is not already reachable, applies pending migrations, then runs both dev servers in parallel:

Other useful targets:

CommandPurpose
make dev-nodbStart web + api only (skip Postgres startup)
make dev-webVite only
make dev-apiPostgres + migrations + API only
make dev-docsFumadocs only on http://localhost:5171
make miniappGenerate native-shell config and open WeChat DevTools
make miniapp-openSync config, clear DevTools project cache, and reopen apps/miniapp
make miniapp-sync-configGenerate gitignored AppID/API/PWA config from apps/miniapp/.env
make miniapp-clear-cacheClear DevTools file/compile cache and rebuild its file watcher
make dev-miniapp-apiPostgres + API + PWA dev servers for shell development
make postgres-up / make postgres-downStart/stop local Postgres container
make db-initdb:migrate + db:seed
make db-resetdrop all tables, then db:migrate + db:seed
make deploy-upFull docker stack (postgres + api + web on :8090)

WeChat Mini Program local debug details: ../frontend/miniapp.md.

.env is created from .env.example on first run. BASE_URL is the single public origin used by the frontend API client and Better Auth (default: http://localhost:5170). Ensure DATABASE_URL matches the Postgres credentials (defaults: opentrip:opentrip@localhost:5430/opentrip).

Local verification

pnpm install
pnpm typecheck
pnpm test
pnpm build
pnpm docs:check

make check runs typecheck + lint + test + build. Dev servers are intentionally not part of automated verification.

Environment variables

VariableUsed byNotes
BASE_URLweb + apipublic API/auth origin used by browser and Better Auth
DATABASE_PROVIDERapipostgres (default) or mysql; inferred from DATABASE_URL when omitted
DATABASE_URLapi (Node/Docker)Postgres or MySQL connection string
BETTER_AUTH_SECRETapi>= 32 chars
TRUSTED_ORIGINSapicomma-separated web origins
STORAGE_BACKENDapirequired: fs, s3, or native Worker r2
STORAGE_ROOTapifilesystem root or optional object prefix
STORAGE_PUBLIC_URLapioptional public base URL; defaults to BASE_URL/api/uploads
R2_BUCKET_NAMECloudflare deploybucket injected as R2_FILE_STORAGE; not exposed as a Worker var
S3_BUCKETapi (s3)bucket name
S3_REGIONapi (s3)region; use auto for Cloudflare R2
S3_ENDPOINTapi (s3)S3-compatible endpoint URL
S3_ACCESS_KEY_IDapi (s3)secret access key id
S3_SECRET_ACCESS_KEYapi (s3)secret access key
S3_FORCE_PATH_STYLEapi (s3)optional true/false, default false
WECHAT_WEB_APP_ID / WECHAT_WEB_APP_SECRETapioptional WeChat Open Platform website QR login
WECHAT_MINI_PROGRAM_APP_ID / WECHAT_MINI_PROGRAM_APP_SECRETapi onlyMini Program login (jscode2session); never ship secret to the client
MINIAPP_APP_IDmake miniapp*AppID generated into gitignored project.private.config.json
MINIAPP_API_BASE_URLnative shellAPI request origin generated into gitignored miniprogram/config.js
MINIAPP_WEB_BASE_URLnative shellPWA business-domain origin generated into gitignored miniprogram/config.js
CLOUDFLARE_OBSERVABILITY_TOKENlocal operatorhistorical Workers Logs query token; never synced to the Worker

On Cloudflare, DATABASE_URL is replaced by the Hyperdrive binding; set Worker var DATABASE_PROVIDER to postgres or mysql to match the origin database. Better Auth and S3 credential values are set with wrangler secret.

Production Mini Programs must configure MINIAPP_WEB_BASE_URL as a WeChat business domain and MINIAPP_API_BASE_URL as a request domain.

Common commands

CommandPurpose
pnpm db:migrateapply pending Prisma migrations
pnpm db:seedload prototype seed data
pnpm db:resetdrop public schema, then migrate + seed
pnpm db:generateregenerate Prisma Client after schema changes
make helplist Make targets

Deployment

Logs and backup

  • Cloudflare: pnpm logs:cf for historical Workers Logs and pnpm logs:cf -- --live for Wrangler live logs.
  • Docker: docker compose logs -f api; Postgres backup via pg_dump (see docker.md).
  • Agent/API trace correlation, Sentry queries, structured-log fields, and symptom runbooks: observability.md.
  • Production incident notes and regression checks: incidents/2026-07-14-workers-caching.md.

On this page