Skip to content

Application Runtime Contract ​

This document defines the authoritative, provider-neutral runtime contract for the wedding website application. Any supported hosting infrastructure—including Docker containers, cloud container services (e.g., Google Cloud Run, AWS App Runner/ECS, Azure Container Apps), serverless hosting (e.g., Vercel), static showcase CDNs, or bare-metal/VM local production environments—must satisfy the specifications described here.


1. Node.js & Next.js Standalone Runtime ​

  • Target Architecture: Dual-mode Next.js App Router configuration in next.config.ts:
    • Standalone Server Mode (Default): Configured with output: 'standalone' when STATIC_EXPORT is unset or false, producing a self-contained Node.js server bundle at .next/standalone/server.js (packaged at /app/server.js in OCI containers).
    • Static Showcase Export Mode (STATIC_EXPORT): Setting STATIC_EXPORT=true or STATIC_EXPORT=1—or running npm run build:export (scripts/build-export.mjs)—switches next.config.ts to output: 'export' with distDir: '.next-export', trailingSlash: true, images.unoptimized: true, and optional subpath routing via NEXT_PUBLIC_BASE_PATH (basePath, assetPrefix, and client/showcase URL resolution via withBasePath and resolveShowcasePath in src/lib/basePath.ts). scripts/build-export.mjs stages build inputs without src/app/api (and without public/uploads or public/mockServiceWorker.js) inside .next/export-stage, compiles with turbopack.root pinned to the repository root, persists the export build cache in .next-export/cache, moves the generated out/ directory to the repository root without modifying src/app/api or .next/standalone, and cleans up .next/export-stage automatically on exit or SIGINT/SIGTERM/SIGHUP while src/lib/config.ts and feature repositories render pages against deterministic static seed data from buildArchetypeSeedData in src/lib/sampleData/builder.ts without requiring PostgreSQL connectivity.
  • Node.js & Package Manager Requirement: Node.js v22.x LTS runtime (>=22.22.1 <23.0.0 across engines.node and devEngines.runtime) and npm ^10.9.0 (npm@10.9.x), pinned via .nvmrc, .npmrc, and both engines and devEngines (onFail: "error") in package.json.
  • OCI Container Support:
    • The official Dockerfile compiles build stages on node:22-bookworm-slim (pinned by @sha256 digest, configuring update-notifier=false in /usr/local/etc/npmrc and a lockfile-pinned /opt/prisma-cli) and produces a multi-platform runner OCI image on debian:bookworm-slim (pinned by @sha256 digest) containing only the stripped Node.js v22 /usr/local/bin/node binary (openssl, ca-certificates, tini, libstdc++6, and zero npm/npx/corepack/yarn), offline /usr/local/bin/prisma (symlinked at /app/node_modules/.bin/prisma), tini installed as PID 1 (ENTRYPOINT ["/usr/bin/tini", "-s", "--", "docker-entrypoint.sh"]), setuid/setgid bits stripped across the root filesystem, and a built-in /api/live HEALTHCHECK.
    • The isolated Prisma CLI is installed outside /app at /opt/prisma-cli (owned by root:root, invoked through /usr/local/bin/prisma and symlinked at /app/node_modules/.bin/prisma) alongside /usr/local/bin/docker-entrypoint.sh (root:root). Under /app, only the Next.js standalone server output (server.js and traced node_modules), .next/static, public, prisma, prisma.config.ts, src/lib/postgres-url.js, and /app/scripts/generate-password-hash.mjs (scripts/generate-password-hash.mjs, not the entire repository scripts/ directory) are packaged and owned by root:root so the non-root runtime user (nextjs:nodejs, UID/GID 1001) holds write access to zero static code paths (only runtime cache/upload mountpoints /app/.next/cache and /app/public/uploads are owned by nextjs:nodejs).

2. Network Interface, Listening Port & Host Binding ​

  • Listening Port & Host Interface:
    • Listening port is configured via the PORT environment variable (defaults to 3000).
    • Host interface binding is configured via the HOSTNAME environment variable (ENV HOSTNAME="0.0.0.0" in Dockerfile and HOSTNAME: "0.0.0.0" in docker-compose.yml), ensuring the standalone server.js binds to all available network interfaces (0.0.0.0) rather than a container-internal hostname.
  • Protocol: HTTP/1.1 or HTTP/2 unencrypted traffic internally, expecting TLS termination at the ingress/reverse-proxy layer.

3. Database Specification & PostgreSQL Policy ​

  • Engine: PostgreSQL version 15.0 or higher (tested with PostgreSQL 15-alpine and Neon serverless Postgres).
  • Driver / ORM & Singleton Pool: Prisma ORM with @prisma/adapter-pg backed by a process-wide singleton pg.Pool cached on globalThis via globalForPrisma (GlobalPrismaState prisma and pgPool properties in src/lib/prisma.ts) so SSR, API Route Handlers, hot reloads, and shutdown hooks share one connection pool. Pool parameters are constructed via buildPostgresRuntimeConfig (src/lib/postgresPool.ts), defaulting connectionTimeoutMillis to 10000ms (10s, overridable in seconds via ?connect_timeout= or ?pool_timeout= from DEFAULT_POSTGRES_CONNECTION_TIMEOUT_MS in src/lib/postgres-url.js), query_timeout to 10000ms (10s, overridable in seconds via ?socket_timeout= from DEFAULT_POSTGRES_QUERY_TIMEOUT_MS in src/lib/prisma.ts), and max to 5 (overridable via ?connection_limit=). Custom ?schema= identifiers are validated against /^[A-Za-z_][A-Za-z0-9_$]*$/ (1–63 UTF-8 bytes), double-quoted across /api/ready, AuthLockout, and all raw SQL queries (qualifyPostgresTable), and set via -c search_path on direct non-pooled pg.Pool connections while omitting startup options on PgBouncer/transaction poolers (isPooledPostgresUrl); TLS modes (disable, allow, prefer, require, no-verify, verify-ca, verify-full) follow standard PostgreSQL libpq semantics.
  • Connection Strings:
    • DATABASE_URL: Primary connection string bound to datasource.url via resolvePrismaDatasourceUrl (normalized for Prisma CLI via rewritePostgresUrlForPrismaCli) in prisma.config.ts. Used for Next.js runtime operations (supporting PgBouncer, Neon Connection Pooling, Supabase Pooler, or direct TCP) and Prisma CLI commands. When DATABASE_URL routes through a transaction-mode connection pooler (isPooledPostgresUrl) and POSTGRES_URL_NON_POOLING is an unpooled PostgreSQL URI targeting the same database and schema, resolvePrismaDatasourceUrl in prisma.config.ts promotes POSTGRES_URL_NON_POOLING as datasource.url so prisma migrate deploy, status, and resolve can acquire advisory locks directly (or operators can pass an explicit DATABASE_URL override), and verifyPostgresTlsHandshake (src/lib/postgres-url.js) validates libpq TLS certificates on the effective migration endpoint (resolveDirectMigrationPostgresUrl) before prisma migrate runs in docker-entrypoint.sh, scripts/preflight-migration-summary.ts, and db-migrate.yml.
    • POSTGRES_URL_NON_POOLING (Optional): Direct, non-pooled connection URL inspected by resolvePrismaDatasourceUrl and resolvePrismaShadowDatabaseUrl in prisma.config.ts. When DATABASE_URL is pooled and POSTGRES_URL_NON_POOLING is unpooled for the same database and schema, prisma.config.ts promotes it as datasource.url for migrations while keeping datasource.shadowDatabaseUrl undefined outside prisma migrate dev, reset, and diff (preventing Prisma P3025 collisions); when POSTGRES_URL_NON_POOLING points to a separate shadow database during migrate dev/reset/diff, resolvePrismaShadowDatabaseUrl binds it to datasource.shadowDatabaseUrl.
  • Provider Neutrality: No database-vendor specific features or proprietary extensions are required. Standard relational PostgreSQL features (tables, foreign keys, indexes, JSONB) are used.

Persisted Entities, Full-Site Backups & Multi-Site Isolation (prisma/schema.prisma) ​

  • Persisted Relational Entities: prisma/schema.prisma defines the authoritative relational data model persisted in PostgreSQL:
    • Configuration & Content: AppConfig, ContentNode, SnapshotVersion, Media
    • Celebration Roster & Venue Logistics: WeddingPartyMember, Attraction, SeatingTable
    • Guest Access, Events & RSVPs: InvitationCode, SubEvent, SubEventAccess, SubEventRsvp
    • HouseholdMember — Relational individual household member profile (PRIMARY, PARTNER, CHILD, PLUS_ONE) linked to InvitationCode and optional SeatingTable.
    • SubEventMemberRsvp — Per-member sub-event RSVP attendance, meal option, and dietary notes linked to SubEventRsvp and HouseholdMember.
    • Gift Registry & Contributions: RegistryItem, ExternalRegistry, Contributor
    • Communications: BroadcastMessage, BroadcastRecipient
    • Security & Rate Limiting: AuthLockout (ephemeral HMAC-SHA256 hashed IP brute-force lockout counters)
  • Full-Site Backup & Restore Coverage: Administrative maintenance backups (/api/admin/maintenance/export and /api/admin/maintenance/import) export and restore all 18 domain prisma/schema.prisma models (excluding ephemeral AuthLockout counters) so operators can migrate or snapshot an entire wedding deployment without vendor lock-in.
  • Multi-Site Subdomain Scope (MULTISITE_ENABLED): Enabling MULTISITE_ENABLED=true routes subdomain requests (X-Forwarded-Host checked before Host in src/lib/config.ts) to subdomain-specific AppConfig branding/profile rows only. All other persisted models in prisma/schema.prisma are shared across subdomains without tenant row isolation.

4. Environment Variable Matrix ​

All operator-facing configuration across application runtime (src/env.ts, src/lib/config.ts), Next.js and VitePress build pipelines (next.config.ts, scripts/build-export.mjs, docs-portal/.vitepress/config.mts), and container orchestration (Dockerfile, docker-compose.yml, docker-compose.rollout.yml) is supplied via environment variables. Core runtime variables are validated at startup by src/env.ts (Zod schema). Internal framework and test-runner flags (NEXT_RUNTIME, npm_lifecycle_event, and JEST_WORKER_ID) are managed automatically by Next.js, npm, and Jest rather than configured by operators.

Mandatory Runtime Variables ​

VariableDefault ValueDescription & Validation Requirements
DATABASE_URLNonePrimary PostgreSQL connection URL (datasource.url in prisma.config.ts). Must be a valid postgresql:// or postgres:// connection string.
ADMIN_PASSWORDNoneScrypt hash for admin authentication. Must match format scrypt:[16-byte saltBase64]:[64-byte keyBase64] (generated via scripts/generate-password-hash.mjs); plaintext passwords, non-64-byte hashes, and ALWAYS_BLOCKED_PROD_ADMIN_HASHES placeholders are rejected, E2E_FALLBACK_ADMIN_HASHES are blocked in production unless E2E_TEST=true, and src/core/auth/auth.server.ts derives a domain-separated HMAC signing key from the decoded hash bytes.

Production-Required Variables ​

These variables provide convenience defaults for local development and test modes in src/env.ts, but startup validation strictly requires unique, non-default values when NODE_ENV=production (Security Note: setting E2E_TEST=true under NODE_ENV=production disables the E2E_FALLBACK_ADMIN_HASHES, E2E_FALLBACK_GUEST_PASSCODES, and E2E_FALLBACK_SESSION_SECRETS blocklists in src/env.ts for disposable container smoke tests while keeping ALWAYS_BLOCKED_PROD_ADMIN_HASHES, ALWAYS_BLOCKED_PROD_GUEST_PASSCODES, and ALWAYS_BLOCKED_PROD_SESSION_SECRETS enforced—never set E2E_TEST=true in real production deployments):

VariableDev / Test DefaultProduction Requirements & Description
GUEST_PASSCODEwedding2026Global passcode required for guest website access. Required in production (must not be empty or match ALWAYS_BLOCKED_PROD_GUEST_PASSCODES such as wedding2026 or template placeholders; E2E_FALLBACK_GUEST_PASSCODES are also rejected unless E2E_TEST=true).
GUEST_SESSION_SECRETdefault-guest-session-secretDedicated server secret for signing and verifying guest invitation session tokens (HMAC-SHA256). Required in production; must be at least 32 characters long, distinct from GUEST_PASSCODE, and must not match ALWAYS_BLOCKED_PROD_SESSION_SECRETS (default-guest-session-secret or template placeholders; E2E_FALLBACK_SESSION_SECRETS are also rejected unless E2E_TEST=true).

Security Warning (E2E_TEST): Setting E2E_TEST=true (src/env.ts, isE2ETestMode) disables NODE_ENV=production blocklists for the repository's committed E2E_FALLBACK_ADMIN_HASHES, E2E_FALLBACK_GUEST_PASSCODES, and E2E_FALLBACK_SESSION_SECRETS (while ALWAYS_BLOCKED_PROD_ADMIN_HASHES, ALWAYS_BLOCKED_PROD_GUEST_PASSCODES, and ALWAYS_BLOCKED_PROD_SESSION_SECRETS remain rejected). Never enable E2E_TEST=true in real production deployments.

Optional Infrastructure & Feature Variables ​

VariableDefault ValueDescription
NODE_ENVdevelopmentRuntime mode (production, development, test). Automatically set to production in Dockerfile runner environments.
ALLOWED_HOSTSlocalhost,127.0.0.1,*.localhostComma-separated list of whitelisted host domains or wildcard patterns validated against X-Forwarded-Host / Host in src/middleware.ts. Defaults to loopback hosts; production deployments serving custom domains must explicitly include their public hostnames (e.g., localhost,127.0.0.1,wedding.example,*.wedding.example).
POSTGRES_URL_NON_POOLINGNoneDirect non-pooled connection string read by prisma.config.ts (resolvePrismaDatasourceUrl promotes it when DATABASE_URL uses PgBouncer for the same database and schema, and resolvePrismaShadowDatabaseUrl binds it during prisma migrate dev/reset/diff when targeting a separate shadow database).
MULTISITE_ENABLEDfalseEnable subdomain-based AppConfig branding/profile routing (src/lib/config.ts resolves host via TRUST_PROXY-gated resolveRequestSubdomain) and tenant claim enforcement (siteId and subdomain) across admin_auth, guest_auth, guest_invite_session, and guest_photo_session cookies. Switches AppConfig rows only; all other persisted models in prisma/schema.prisma are shared across subdomains without tenant row isolation.
RUN_MIGRATIONSfalseAutomatically run database schema migrations (./node_modules/.bin/prisma migrate deploy) during container startup in docker-entrypoint.sh when set to true or 1 (both docker-entrypoint.sh and src/env.ts accept RUN_MIGRATIONS=true and RUN_MIGRATIONS=1).
TRUST_PROXYfalseOpt-in boolean (true/false) or non-negative integer hop count enabling trusted hop selection on X-Forwarded-Host, X-Forwarded-Proto, X-Forwarded-For, and X-Real-IP behind reverse proxies.
HISTORY_VERSION_LIMIT50Maximum version history entries retained per content item (integer >= 1).
CRON_SECRETNoneBearer authorization secret for triggering scheduled background endpoints (/api/cron/*).

Optional Object Storage Variables (S3-Compatible) ​

When storing uploaded media assets externally, all four core S3 credential variables must be supplied together as a coherent group:

VariableRequirementDefault ValueDescription
S3_BUCKETRequired if using S3NoneTarget S3/R2 bucket name.
S3_REGIONRequired if using S3NoneS3 region (e.g., us-east-1 or auto for Cloudflare R2; S3_REGION=auto requires S3_ENDPOINT).
S3_ACCESS_KEY_IDRequired if using S3NoneAWS/S3 API access key ID.
S3_SECRET_ACCESS_KEYRequired if using S3NoneAWS/S3 API secret access key.
S3_ENDPOINTRequired when S3_REGION=auto; Optional otherwiseNoneCustom S3 API endpoint URL (e.g., https://<account_id>.r2.cloudflarestorage.com, https://storage.googleapis.com, or MinIO).
S3_PUBLIC_URLRequired when S3_ENDPOINT targets *.r2.cloudflarestorage.com; Optional otherwiseNoneCustom CDN, R2 Custom Domain, or public https://pub-<id>.r2.dev asset delivery URL prefix.

Note: Supplying partial core S3 credentials—or configuring Cloudflare R2 with S3_REGION=auto without S3_ENDPOINT or a private *.r2.cloudflarestorage.com endpoint without S3_PUBLIC_URL—will cause startup and build-time environment validation to fail.

Optional Stripe Card Checkout Variables ​

When enabling online credit card and digital wallet processing for cash and experience funds, STRIPE_SECRET_KEY and NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY must be supplied together as a pair (or both omitted for direct-transfer-only registries):

VariableRequirementDefault ValueDescription
STRIPE_SECRET_KEYRequired if using Stripe card checkoutNoneServer-side Stripe API secret key (sk_... or rk_...). Placeholder mock keys are rejected in non-test environments.
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYRequired if using Stripe card checkoutNoneClient-side Stripe publishable key (pk_...) used by Stripe Elements. Placeholder mock keys are rejected in non-test environments.
STRIPE_WEBHOOK_SECRETOptional (recommended if using Stripe webhooks)NoneEndpoint signing secret (whsec_...) used to verify incoming /api/registry/webhook/stripe events.

Note: Supplying only one of STRIPE_SECRET_KEY or NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY will cause startup environment validation to fail fast.

Optional Server, Build, Portal & Container Variables ​

These variables configure container port binding, static HTML export builds, VitePress documentation portal asset paths, Docker Compose PostgreSQL service interpolation, and E2E setup bypasses:

VariableDefault ValueScopeDescription
PORT3000Container / Standalone ServerHTTP listening port (ENV PORT=3000 in Dockerfile; 127.0.0.1:${PORT:-3000}:3000 in docker-compose.yml).
HOSTNAME0.0.0.0Container / Standalone ServerNetwork interface address bound by standalone server.js (ENV HOSTNAME="0.0.0.0" in Dockerfile; HOSTNAME: "0.0.0.0" in docker-compose.yml).
NEXT_PHASENoneBuild (src/env.ts)Next.js build phase identifier (phase-production-build) set automatically during next build so build-time schema checks allow template placeholders before runtime secret enforcement.
STATIC_EXPORTNoneBuild (next.config.ts, scripts/build-export.mjs, src/)Switches Next.js to static HTML export (output: 'export') and STATIC_MOCK_CONFIG data when set to 'true' or '1'.
NEXT_PUBLIC_BASE_PATHNoneStatic Export Build & Client Runtime (next.config.ts, src/lib/basePath.ts)Optional URL subpath prefix (basePath, assetPrefix, and root-relative client API, redirect, download, and asset URL resolution via withBasePath) when serving under a subpath and value is not '/'.
VITEPRESS_BASE/Docs Portal (docs-portal/.vitepress/config.mts)Base URL path for building and serving the VitePress documentation portal.
E2E_TESTfalse (docker-compose.yml)Runtime / Compose (src/env.ts, src/lib/config.ts, docker-compose.yml)Defaults to false in docker-compose.yml so <SetupWizard /> onboarding and full production credential blocklists stay active; setting E2E_TEST=true bypasses <SetupWizard /> in src/lib/config.ts and disables NODE_ENV=production blocklists for committed E2E_FALLBACK_* credentials in src/env.ts. Restrict strictly to .env.ci, docker-compose.ci.yml, and automated E2E harnesses—never enable in production.
CONTAINER_DATABASE_URLNoneDocker Compose (docker-compose.yml, docker-compose.rollout.yml)Explicit PostgreSQL connection URL override (${CONTAINER_DATABASE_URL:-...}) for migration, app, and app-standby containers (e.g., external managed PostgreSQL) so host DATABASE_URL (@localhost:5432) never leaks into container networking.
CONTAINER_POSTGRES_URL_NON_POOLINGNoneDocker Compose (docker-compose.yml, docker-compose.rollout.yml)Optional direct non-pooling PostgreSQL connection URL override (${CONTAINER_POSTGRES_URL_NON_POOLING:-}) forwarded as POSTGRES_URL_NON_POOLING into migration, app, and app-standby containers when CONTAINER_DATABASE_URL uses PgBouncer, preventing host POSTGRES_URL_NON_POOLING (@localhost:5432/wedding_shadow) from leaking into containers.
DB_USERweddingDocker Compose (docker-compose.yml)PostgreSQL username interpolated into the db container (POSTGRES_USER) and fallback migration/app CONTAINER_DATABASE_URL default.
DB_PASSWORDNoneDocker Compose (docker-compose.yml)Mandatory PostgreSQL password (${DB_PASSWORD:?...}) interpolated into the db container (POSTGRES_PASSWORD) and fallback migration/app CONTAINER_DATABASE_URL default (.env.example and .env.ci supply wedding123 for local and CI runs).
DB_NAMEweddingDocker Compose (docker-compose.yml)PostgreSQL database name interpolated into the db container (POSTGRES_DB) and fallback migration/app CONTAINER_DATABASE_URL default.
DB_PORT5432Docker Compose (docker-compose.yml)Loopback host TCP port published to container port 5432 for the db service (127.0.0.1:${DB_PORT:-5432}:5432).
STANDBY_PORT3001Docker Compose Rollout (docker-compose.rollout.yml, scripts/rollout-vps.sh)Loopback host TCP port published to container port 3000 for the temporary app-standby service during zero-downtime VPS rollouts (127.0.0.1:${STANDBY_PORT:-3001}:3000).

Optional Site Configuration Overrides (SITE_*) ​

src/lib/config.ts (getEnvConfigOverrides, readNonEmptySiteEnv, and getAppConfig) supports 32 optional Layer 1 environment variable overrides that take precedence over database AppConfig rows and APP_DEFAULTS. Both docker-compose.yml (app) and docker-compose.rollout.yml (app-standby) forward all 32 SITE_* keys from the host environment (${SITE_*:-}), and readNonEmptySiteEnv trims leading/trailing whitespace via .trim() while treating empty or whitespace-only strings as unset (undefined) before validation and isSiteInitialized checks (whereas non-empty malformed overrides fail AppConfigSchema / coordinateSchema validation at runtime, throwing Production Configuration Validation Failure in NODE_ENV=production):

VariableDefault ValueTarget AppConfig FieldDescription
SITE_PARTNER1_NAMENonepartner1Name, brideNameOverride Partner 1 display name and synchronize legacy brideName (when non-empty).
SITE_PARTNER2_NAMENonepartner2Name, groomNameOverride Partner 2 display name and synchronize legacy groomName (when non-empty).
SITE_BRIDE_NAMENonebrideName, partner1NameLegacy alias overriding both brideName and partner1Name (when non-empty).
SITE_GROOM_NAMENonegroomName, partner2NameLegacy alias overriding both groomName and partner2Name (when non-empty).
SITE_WEDDING_DATENoneweddingDateISO 8601 date/timestamp string trimmed via readNonEmptySiteEnv and parsed via new Date(...) when non-empty (blank/whitespace values are ignored; non-empty invalid date strings fail AppConfigSchema validation).
SITE_BASE_URLNonebaseUrlCanonical public base URL of the wedding website.
SITE_VENUE_NAMENonevenueNamePrimary wedding venue name (when non-empty).
SITE_VENUE_ADDRESSNonevenueAddressStreet address of the primary venue.
SITE_VENUE_CITYNonevenueCityCity of the primary venue.
SITE_VENUE_STATENonevenueStateState/province of the primary venue.
SITE_VENUE_ZIPNonevenueZipPostal/ZIP code of the primary venue.
SITE_LATITUDENonelatitudeVenue latitude coordinate trimmed via readNonEmptySiteEnv and parsed via parseFloat(...) when non-empty (blank/whitespace values are ignored; non-empty non-numeric or out-of-range values fail coordinateSchema validation).
SITE_LONGITUDENonelongitudeVenue longitude coordinate trimmed via readNonEmptySiteEnv and parsed via parseFloat(...) when non-empty (blank/whitespace values are ignored; non-empty non-numeric or out-of-range values fail coordinateSchema validation).
SITE_TIMEZONENonetimezoneIANA timezone identifier for event schedules (e.g., America/Chicago).
SITE_COLOR_PRIMARYNonecolorPrimaryPrimary brand hex color token (when non-empty).
SITE_COLOR_SECONDARYNonecolorSecondarySecondary accent hex color token (when non-empty).
SITE_THEME_PRESETNonethemePresetActive theme preset identifier (e.g., classic).
SITE_THEME_TOKENSNonethemeTokensJSON-encoded map of custom CSS design token overrides (malformed JSON is ignored).
SITE_SHOW_COUNTDOWNNoneshowCountdownBoolean string ('true' / 'false', case-insensitive) toggling the homepage countdown widget.
SITE_SHOW_ADD_TO_CALENDARNoneshowAddToCalendarBoolean string ('true' / 'false', case-insensitive) toggling the homepage Add-to-Calendar widget.
SITE_SEO_TITLENoneseoTitleCustom HTML <title> / Open Graph title override.
SITE_SEO_DESCRIPTIONNoneseoDescriptionCustom meta / Open Graph description override.
SITE_BRAND_MONOGRAMNonebrandMonogramCouple monogram text displayed in branding elements.
SITE_BRAND_LOGO_URLNonebrandLogoUrlURL or asset path for the custom brand logo image.
SITE_BRAND_LOGO_ALTNonebrandLogoAltAccessible alt text for the custom brand logo image.
SITE_HERO_IMAGE_URLNoneheroImageUrlURL or asset path for the homepage hero image.
SITE_HERO_IMAGE_ALTNoneheroImageAltAccessible alt text for the homepage hero image.
SITE_BRAND_WATERMARK_URLNonebrandWatermarkUrlURL or asset path for the decorative brand watermark graphic.
SITE_BRAND_WATERMARK_ALTNonebrandWatermarkAltAccessible alt text for the decorative brand watermark graphic.
SITE_BADGE_GRAPHIC_URLNonebadgeGraphicUrlURL or asset path for the custom badge graphic.
SITE_BADGE_GRAPHIC_ALTNonebadgeGraphicAltAccessible alt text for the custom badge graphic.
SITE_CONTACT_EMAILNonecontactEmailHost contact email address displayed to guests.

5. Statelessness & Filesystem Expectations ​

  • Stateless Application Layer: The application process is fully stateless and ephemeral.
  • Local Filesystem & Read-Only Root Execution: Scratch write operations to /tmp or /app/.next/cache (for Next.js /_next/image optimization) are temporary and must not be relied upon across container restarts or horizontal scaling. docker-compose.yml (and docker-compose.rollout.yml for app-standby) enforces read_only: true, cap_drop: [ALL], and security_opt: [no-new-privileges:true] on application and migration containers (NoNewPrivs: 1 across db, migration, app, and app-standby), shm_size: "256mb" on db, bounded json-file log rotation (max-size: "10m", max-file: "3"), explicit pids_limit and mem_limit caps, and ephemeral tmpfs volumes at /tmp and /app/.next/cache:uid=1001,gid=1001,mode=0755.
  • Data & Media Persistence:
    • Application state, registry items, contributors, and content configurations are stored in PostgreSQL (prisma/schema.prisma).
    • Uploaded media files are stored in S3-compatible object storage when S3_* credentials are configured, or written to /app/public/uploads via LocalStorageProvider (src/utils/storage.ts) when backed by a persistent volume/disk (such as uploads_data:/app/public/uploads in docker-compose.yml or a Render Persistent Disk) and streamed dynamically at /uploads/* in standalone mode (next.config.ts server rewrites() + src/app/api/uploads/[...path]/route.ts with X-Content-Type-Options: nosniff).

6. Reverse Proxy & Forwarded Header Handling ​

The application expects to be deployed behind an HTTP reverse proxy, load balancer, or cloud ingress controller (e.g., NGINX, Cloudflare, Google Cloud Run Ingress, AWS ALB).

  • Host Header Forwarding (TRUST_PROXY):
    • Direct deployments (TRUST_PROXY=false, the default) ignore X-Forwarded-Host and evaluate only the Host header against ALLOWED_HOSTS.
    • Reverse proxies (e.g., Nginx with proxy_set_header Host $host; and proxy_set_header X-Forwarded-Host $host;) must pair forwarded headers with TRUST_PROXY=1 (or TRUST_PROXY=2 behind two-hop load balancers). When TRUST_PROXY is enabled, resolveRequestHost (src/utils/hostValidation.ts) selects the configured right-to-left hop from X-Forwarded-Host before falling back to Host, and src/middleware.ts, src/lib/config.ts, src/app/metadata.ts, and export/broadcast origin helpers validate the resolved host against ALLOWED_HOSTS (rejecting invalid or unapproved hosts at the perimeter with HTTP 400 Bad Request).
  • Perimeter Session Exclusions:
    • Public static exclusions in src/middleware.ts are limited to explicit asset prefixes (/images/, /assets/, /fonts/, /_next/static/, /_next/image/, /favicon.ico, and /robots.txt).
    • Non-probe perimeter-exempt paths (/api/registry/webhook/stripe, /api/cron/*, and /uploads/*) enforce full ALLOWED_HOSTS validation (isHostAllowed) in src/middleware.ts before bypassing guest/admin session cookies in favor of route-specific controls (stripe-signature verification via STRIPE_WEBHOOK_SECRET, Authorization: Bearer <CRON_SECRET>, or path-contained nosniff media streaming).
    • Stateless read-only (GET and HEAD) probe requests to /api/live, /api/health, and /api/ready enforce syntactic Host validation (isHostSyntaxValid in src/utils/hostValidation.ts) only, rejecting empty, whitespace, comma-separated, CRLF, or invalid-port headers while permitting platform probe hosts (e.g., healthcheck.railway.app, Cloud Run internal pod/kubelet IPs, and 127.0.0.1:3000). Non-read-only methods (such as POST) on probe paths still enforce full ALLOWED_HOSTS validation.
  • Protocol Header Forwarding (TRUST_PROXY):
    • Proxies should forward X-Forwarded-Proto (https or http); resolveRequestProtocol honors X-Forwarded-Proto only when TRUST_PROXY is enabled and ignores spoofed forwarded protocol headers when TRUST_PROXY=false.
  • Client IP Header Forwarding (TRUST_PROXY):
    • By default (TRUST_PROXY=false), the rate limiter ignores X-Forwarded-For and X-Real-IP headers so direct callers cannot spoof IP headers to bypass lockouts. Set TRUST_PROXY=1 behind single-hop reverse proxies (Caddy, Nginx, Vercel, Railway, Render) or TRUST_PROXY=2 behind two-hop load balancers such as Google Cloud Run (<client-ip>, <lb-ip>).

7. HTTPS Assumptions & Security Policy ​

  • Transport Security: Production deployments assume HTTPS termination at the reverse proxy/ingress layer.
  • Security Headers (Standalone / Server Mode Only):
    • Static Non-CSP Headers (next.config.ts): When running in standalone/server mode (!isStaticExport), next.config.ts (headers()) injects static non-CSP security headers across all routes (/(.*)):
      • Strict-Transport-Security: max-age=31536000; includeSubDomains
      • X-Frame-Options: SAMEORIGIN
      • X-Content-Type-Options: nosniff
      • Referrer-Policy: strict-origin-when-cross-origin
      • Permissions-Policy: camera=(), microphone=(), geolocation=()
    • Per-Request Nonced Application CSP (src/middleware.ts & src/lib/csp.ts): On non-upload routes, src/middleware.ts generates a cryptographic base64 nonce (x-nonce / CSP_NONCE_HEADER) and emits a per-request Content-Security-Policy via buildContentSecurityPolicy (src/lib/csp.ts)—replacing production 'unsafe-inline' and 'unsafe-eval' in script-src with 'nonce-<base64>', 'wasm-unsafe-eval', and blob: workers (allowing 'unsafe-eval' only when NODE_ENV === 'development'), enforcing object-src 'none', base-uri 'self', form-action 'self', and frame-ancestors 'self', and scoping connect-src to 'self', https://api.stripe.com, https://js.stripe.com, https://hooks.stripe.com, https://*.basemaps.cartocdn.com, and any configured S3_PUBLIC_URL origin (src/app/layout.tsx reads x-nonce via headers() when !isStaticExport and passes nonce to the inline theme <script>).
    • Sandboxed Upload Stream CSP (src/app/api/uploads/[...path]/route.ts): src/middleware.ts skips /uploads/* and /api/uploads/* when emitting the application Content-Security-Policy so src/app/api/uploads/[...path]/route.ts emits a single Content-Security-Policy: default-src 'none'; sandbox header alongside Cross-Origin-Resource-Policy: same-origin (and Content-Disposition: attachment for fallback application/octet-stream payloads).
  • Static Export Header Caveat: Next.js headers() and Edge Middleware are disabled when STATIC_EXPORT is 'true' or '1' (output: 'export'). Operators serving static showcase builds must configure equivalent Content-Security-Policy (including 'wasm-unsafe-eval', worker-src 'self' blob:, and blob: in script-src so /heart Rapier WASM physics and 3D text blob: workers succeed), Permissions-Policy, HSTS, framing, MIME-sniffing, and referrer headers at their CDN, static host, or reverse-proxy layer.

8. Application Lifecycle & Probes ​

 +------------------+     +----------------------------------+     +-----------------------+     +-----------------------+
 |   Build Phase    | --> |         Migration Phase          | --> |      Start Phase      | --> | Liveness & Readiness  |
 | npm run build    |     | ./node_modules/.bin/prisma       |     | tini -> entrypoint -> |     | GET /api/live         |
 | (or build:export)|     | migrate deploy (offline in OCI)  |     | exec node server.js   |     | GET /api/health       |
 +------------------+     +----------------------------------+     +-----------------------+     | GET /api/ready        |
                                                                                                 +-----------------------+
  1. Build Phase (npm run build / npm run build:export):
    • Executes Prisma Client generation (prisma generate), Next.js standalone compilation (output: 'standalone'), and standalone asset staging (postbuild), or static HTML export (output: 'export') via npm run build:export (STATIC_EXPORT=true).
    • Does not require an active database connection. Safe for CI/CD build environments.
  2. Migration Phase (/usr/local/bin/prisma migrate deploy / ./node_modules/.bin/prisma migrate deploy):
    • Runs offline before application startup via the migration service in docker-compose.yml (./node_modules/.bin/prisma migrate deploy), via Cloud Run Jobs or PaaS release hooks (/usr/local/bin/prisma migrate deploy), in docker-entrypoint.sh when RUN_MIGRATIONS=true or RUN_MIGRATIONS=1 (normalizing and preserving non-empty POSTGRES_URL_NON_POOLING, unsetting blank values, and invoking /opt/prisma-cli via /usr/local/bin/prisma symlinked at /app/node_modules/.bin/prisma with NPM_CONFIG_UPDATE_NOTIFIER=false and CHECKPOINT_DISABLE=1 so zero npm registry calls occur), or via CI/CD release pipelines (.github/workflows/db-migrate.yml).
    • Applies pending database migrations safely without data loss.
  3. Start Phase (tini -> docker-entrypoint.sh -> node server.js):
    • /usr/bin/tini -s runs as PID 1 (or subreaper under init: true) and invokes docker-entrypoint.sh, which validates DATABASE_URL and hands off via exec "$@" (exec node server.js), launching the Next.js standalone HTTP server on PORT (0.0.0.0) and validating src/env.ts.
  4. Liveness, Startup, & Readiness Probes:
    • Liveness Endpoint (GET /api/live, src/app/api/live/route.ts):
      • Direct Next.js Route Handler returning HTTP 200 OK with { "status": "alive", "timestamp": "..." } and Cache-Control: no-store without querying PostgreSQL.
      • Exempted from guest/admin session checks (src/middleware.ts), invite revocation checks (src/utils/withApiMiddleware.ts), and API rate limits (src/utils/withApiMiddleware.ts, src/utils/rateLimit.ts).
      • Targeted by the Dockerfile HEALTHCHECK, docker-compose.yml app healthcheck, and Google Cloud Run --liveness-probe=httpGet.path=/api/live,httpGet.port=3000,periodSeconds=30 (or Knative livenessProbe) so transient database blips never trigger container restart loops.
    • Startup & Rollout Health Endpoint (GET /api/health, src/app/api/health/route.ts):
      • Wrapped in withApiMiddleware (isHealthProbe: true in src/utils/withApiMiddleware.ts), executes SELECT 1 via Prisma, and returns HTTP 200 OK with Cache-Control: no-store and wrapped JSON { "success": true, "data": { "status": "ok", "timestamp": "...", "database": "connected" } } when PostgreSQL is reachable.
      • When PostgreSQL is unreachable, GET /api/health returns HTTP 503 Service Unavailable with Cache-Control: no-store, and withApiMiddleware (isHealthProbe: true) preserves diagnostic probe fields { "success": false, "status": "degraded", "database": "disconnected", "timestamp": "...", "error": "Database connection failed" } (sanitizing error text in NODE_ENV=production so internal driver details never leak).
      • Used by Cloud Run Knative startupProbe (httpGet.path: /api/health, port: 3000), Railway deploy healthchecks (/api/health with Host: healthcheck.railway.app), and CI/CD post-deployment/rollback verification alongside /api/ready (.github/workflows/deploy-stage.yml and .github/workflows/rollback.yml).
      • Exempted from guest/admin session checks in src/middleware.ts (normalizedPath === '/api/health') and exempted from API rate limiting in src/utils/withApiMiddleware.ts (isHealthPath).
    • Readiness Endpoint (GET /api/ready, src/app/api/ready/route.ts):
      • Direct Next.js Route Handler (not wrapped by withApiMiddleware, setting Cache-Control: no-store) backed by the zero-I/O manifest in src/lib/readinessManifest.ts (scripts/check-prisma-schema.ts enforces compile-time parity) that verifies all 16 persisted prisma/schema.prisma tables (AppConfig, Media, WeddingPartyMember, Attraction, RegistryItem, Contributor, InvitationCode, SeatingTable, ContentNode, SnapshotVersion, SubEvent, SubEventAccess, SubEventRsvp, BroadcastMessage, BroadcastRecipient, AuthLockout) exist in current_schema() via information_schema.tables and—when _prisma_migrations is present—confirms all 47 committed migrations in REQUIRED_MIGRATION_NAMES completed with zero failed or unfinished entries (finished_at IS NULL AND rolled_back_at IS NULL) while allowing extra forward N+1 migrations during N-1 rollbacks. When _prisma_migrations is absent (for example after prisma db push in playwright.config.ts), /api/ready succeeds as soon as all 16 schema tables exist.
      • Never calls isSiteInitialized (src/lib/config.ts) and never requires rows in AppConfig, returning HTTP 200 OK with Cache-Control: no-store and unwrapped JSON { "status": "ready", "database": "connected", "timestamp": "..." } on unseeded migrated databases so first-run <SetupWizard /> onboarding (src/app/layout.tsx) and pre-seed container boot succeed.
      • Returns HTTP 503 Service Unavailable with Cache-Control: no-store and { "status": "unhealthy", "database": "connected", "error": "Database schema is not ready", "timestamp": "..." } on zero-table databases, any missing schema table, any missing required migration, or failed migrations, or { "status": "unhealthy", "database": "disconnected", "error": "Database connection failed", "timestamp": "..." } on database connection failures (internal table, migration, and driver details are masked when NODE_ENV=production).
      • Exempted from guest/admin session checks in src/middleware.ts (normalizedPath === '/api/ready') and not subject to withApiMiddleware rate-limit buckets (enforcing its own 100 req / 60s IP burst limit and 5s single-flight healthy memoization).
    • Perimeter Host Validation: Read-only (GET and HEAD) requests to /api/live, /api/health, and /api/ready validate Host header syntax (isHostSyntaxValid in src/utils/hostValidation.ts) without requiring ALLOWED_HOSTS membership, allowing PaaS and container orchestrator probes (such as healthcheck.railway.app, 169.254.1.1:3000, and loopback 127.0.0.1:3000) while still rejecting malformed or CRLF-injected Host headers with HTTP 400. Non-read-only methods on probe routes and all non-probe routes enforce full ALLOWED_HOSTS checks (isHostAllowed).
  5. Process Shutdown, Pool Draining & Signal Delivery:
    • Dockerfile runs /usr/bin/tini -s as PID 1 (and docker-compose.yml sets init: true and stop_grace_period: 15s on app; standalone docker run deployments should pass --init --stop-timeout 15) while docker-entrypoint.sh hands off via exec "$@" so SIGTERM and SIGINT propagate cleanly to node server.js and orphaned child processes are reaped.
    • src/lib/prisma.ts caches globalForPrisma.prisma and globalForPrisma.pgPool on globalThis across all module graphs in every environment and registers idempotent SIGTERM and SIGINT hooks (registerPrismaShutdownHooks()): when framework signal listeners (such as Next.js standalone start-server.js) are attached, interceptProcessExitUntilDrained() wraps process.exit with an unref'd 5000ms drain safety timer so HTTP listeners finish in-flight requests before shutdownPrisma() runs prisma.$disconnect() and pool.end(); when no framework listener is attached, handleTerminationSignal runs shutdownPrisma() directly under a 5000ms safety timer and exits with code 130 (SIGINT) or 143 (SIGTERM), transmitting PostgreSQL Terminate (0x58) frames well within the 15s container stop grace window.

Released under the AGPL-3.0 License.