Local Environment Setup
This guide provides step-by-step instructions for configuring a local development environment for the wedding website platform. Following this guide ensures consistent environment configuration, reproducible database schemas, and clean verification gates.
1. Prerequisites
Before installing the application, verify that your machine meets the minimum system requirements:
- Node.js & npm: Node.js v22.x LTS (
>=22.22.1 <23.0.0, pinned in.nvmrc) andnpm@10.9.x(^10.9.0, pinned viapackageManagerfor Corepack and enforced via.npmrcanddevEnginesinpackage.jsonanddocker/prisma-cli/package.json). Runnvm useandcorepack enable, then verify your active versions withnode -vandcorepack npm -v(npm -v). - Git: Modern Git for version control and branch management (
git --version). - PostgreSQL Database: A running PostgreSQL instance (v15+ recommended). You can run PostgreSQL locally, via Docker, or use cloud-hosted instances (e.g. Neon, Supabase, Railway, AWS RDS, GCP Cloud SQL). Refer to the PostgreSQL Database Contract in DEPLOYMENT.md and Application Runtime Contract for operational expectations.
- Docker & Docker Compose (Optional): Recommended for automated test database containerization and container smoke tests.
2. Cloning the Repository & Installing Dependencies
Clone the repository, select Node.js 22 LTS, and activate Corepack:
bashgit clone https://github.com/fderuiter/wedding_website.git cd wedding_website nvm use corepack enableInstall project dependencies from the lockfile:
bashnpm ciThe
postinstalllifecycle hook automatically runsnext typegen,prisma generateto compile the Prisma Client, andnode scripts/pretest.mjs --record-install-stateto prune unreachable WASM optional packages on non-wasm32hosts and recordnode_modules/.package-lock-hashso the first test run skips redundant dependency installation.
3. Environment Variables Configuration
The platform relies on environment variables for database connections, administrative credentials, and runtime features.
Create an environment file:
Copy the provided
.env.exampletemplate to.env(or.env.local/.env.development):bashcp .env.example .envYou can verify your local configuration at any time with
npm run preflight:env, which cascades.env.development.local,.env.local,.env.development, and.envindevelopmentmode (pass--mode productionbefore production deployments to enforce production secret blocklists).Configure Required & Core Variables:
Open
.envin your editor and review or customize the core runtime variables. By default,DATABASE_URLmatches the local PostgreSQL container (POSTGRES_USER=wedding,POSTGRES_PASSWORD=wedding123,POSTGRES_DB=weddingbound on127.0.0.1:5432indocker-compose.yml/docker-compose.ci.yml):env# PostgreSQL connection (matches `docker compose up -d db` local setup) DATABASE_URL="postgresql://wedding:wedding123@localhost:5432/wedding?schema=public" DB_PASSWORD="wedding123" # Required for Admin Login (16-byte salt + 64-byte scrypt hash verified by src/utils/password.ts, NOT plaintext) ADMIN_PASSWORD="scrypt:AAAAAAAAAAAAAAAAAAAAAA==:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" # Trusted host domains allowed to access the application ALLOWED_HOSTS="localhost,127.0.0.1,*.localhost,wedding.example,*.wedding.example" # Global guest passcode and distinct HMAC-SHA256 guest session secret (32+ chars in production) GUEST_PASSCODE="your-unique-guest-passcode" GUEST_SESSION_SECRET="your-dedicated-guest-session-secret"Generating the Admin Password Hash:
Security Guardrail: Never commit unencrypted administrative passwords or private credentials to the repository. The dummy
ADMIN_PASSWORDplaceholder in.env.examplesatisfies schema format checks fordb:seedbut cannot authenticate logins.Generate a 64-byte scrypt hash (
N=16384, r=8, p=1, required bysrc/utils/password.ts) usingscripts/generate-password-hash.mjs:bashnode scripts/generate-password-hash.mjs "your_secure_password"Copy the output string (
scrypt:[saltBase64]:[keyBase64]) and paste it as the value ofADMIN_PASSWORDin your.envfile.Optional Variables (Commented Out by Default in
.env.example):POSTGRES_URL_NON_POOLING: Direct non-pooling/shadow database connection string read byprisma.config.ts. Keep commented out for local PostgreSQL sonpm run migrate:devautomatically creates a temporary shadow database instead of failing against a nonexistent shadow URL.S3_BUCKET,S3_REGION,S3_ACCESS_KEY_ID,S3_SECRET_ACCESS_KEY,S3_ENDPOINT,S3_PUBLIC_URL: S3/R2 object storage settings. Keep all six commented out locally sosrc/utils/storage.tsusesLocalStorageProvider.CRON_SECRET: Optional bearer secret for scheduled broadcast cron endpoints.STRIPE_SECRET_KEY,NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,STRIPE_WEBHOOK_SECRET: Optional Stripe card checkout credentials (leave commented out for direct transfer registry funds).DB_USER,DB_NAME,DB_PORT,CONTAINER_DATABASE_URL,CONTAINER_POSTGRES_URL_NON_POOLING: Optional Docker Compose PostgreSQL and external container database overrides (NODE_ENVis also commented out so host processes default todevelopmentwhile Next.js builds useproduction, andCONTAINER_POSTGRES_URL_NON_POOLINGprevents hostPOSTGRES_URL_NON_POOLINGshadow URLs from leaking into Compose services).HISTORY_VERSION_LIMIT: Maximum number of historical versions retained for content audits (defaults to50).
4. Database Initialization & Seeding
Start Local PostgreSQL (if using Docker Compose) & Run Migrations:
Start the PostgreSQL container and apply the Prisma schema to create application tables:
bashdocker compose up -d db npm run migrate:devSeed Initial Application Data (Optional):
Populate the database with baseline
AppConfigsettings (partner1Name,partner2Name,baseUrl, hero content, and venue details) fromscripts/seed.ts:bashnpm run db:seednpm run db:seedrunsdotenv -c development -- tsx scripts/seed.ts, automatically loading.envwithout manual shell exports.Note on
SetupWizardBypass &/Redirect: SeedingAppConfigpopulates non-placeholder partner names andbaseUrl, which satisfiesisSiteInitializedinsrc/lib/config.ts, skips<SetupWizard />insrc/app/layout.tsx, and causessrc/middleware.tsto redirect unauthenticated visits to/(303 See Other) to/guest/login(sign in withGUEST_PASSCODE, or visit/admin/loginwith yourADMIN_PASSWORD). Leave the database unseeded (skipnpm run db:seed) if you want to test the First-Run Setup Wizard.Regenerate Prisma Client (if modifying schemas):
bashnpm run prisma:generate
5. Running the Development Server
Start the Next.js development server with Turbopack:
npm run devThe application will start at http://localhost:3000.
First-Run Setup Wizard
If you start npm run dev with an unseeded database, navigating to http://localhost:3000 renders all five steps of the First-Run Setup Wizard (src/components/setup/SetupWizard.tsx):
- Step 1 — Admin Authentication (
Welcome to Your Wedding Site!): Authenticate with the plaintext password corresponding to the 64-byteADMIN_PASSWORDscrypt hash generated vianode scripts/generate-password-hash.mjsin.env. - Step 2 — The Essentials: Enter Partner 1 & Partner 2 names, wedding date, timezone, canonical Site URL (
baseUrl), optional host contact email, venue name/city/state, and theme preset and brand colors (ThemeConfigurationPanel, with layout and print tuning deferred to Site Settings), saved via/api/admin/setup. - Step 3 — Sample Data Selection: Choose a starter archetype preset and populate optional sample data modules (
registry,guests,seating,weddingParty,attractions), or skip to start blank. - Step 4 — Guest List Import: Import a guest list CSV spreadsheet (
CsvImportWizardModal) to issue invitation codes right away, or skip for later. - Step 5 — Complete Setup: Optionally manage wedding party members (
WeddingPartyManagerModal) and local attractions (AttractionsManagerModal), then open/admin/dashboard. OnceAppConfigis initialized,/api/admin/setupis sealed against unauthenticated replay attacks (403 Forbidden), and unauthenticated/requests redirect to/guest/login.
Database-Free Static Showcase Preview (npm run build:export)
To compile and inspect the database-free GitHub Pages showcase locally without PostgreSQL:
npm run build:exportnpm run build:export (scripts/build-export.mjs) exports static HTML into out/ (supporting optional NEXT_PUBLIC_BASE_PATH subpath prefixes via resolveShowcasePath in src/lib/basePath.ts). In static export mode, RootLayoutClient (src/components/layout/RootLayoutClient.tsx) enables DemoProvider (src/components/demo/DemoContext.tsx) and DemoToolbar (src/components/demo/DemoToolbar.tsx), hydrating wedding_showcase_demo_v1 localStorage state via hydrateDemoStateFromStorage in src/lib/demo/demoStore.ts from deterministic archetype datasets built by buildArchetypeSeedData in src/lib/sampleData/builder.ts, intercepting /api/* and /api/admin/* mutations via installDemoFetchInterceptor in src/lib/demo/demoApiHandler.ts, simulating non-charging card contributions via SimulatedCardCheckout (SIMULATED_TEST_CARDS) in src/features/registry/components/SimulatedCardCheckout.tsx, and rendering <SetupWizard /> on /admin/setup via AdminSetupPage in src/app/admin/setup/page.tsx. (Remove out/ after local inspection so npm run check:identifiers and Git status stay clean.)
6. Verification & Next Steps
Before opening a pull request, run the shared quality workflow (npm run check:static for fast static checks or npm run quality for the full pre-push suite). Rather than duplicating test, linting, and agent rules here, refer to each authoritative guide:
- Testing Strategy: Fast cached local Jest unit/integration tests (
npm test), coverage threshold verification (npm run test:cov),wedding_testpretest database isolation, Playwright E2E (npm run test:e2e), WCAG 2.2 AA accessibility audits (npm run test:a11y), and standalone/container smoke tests. - Contribution Guidelines: Feature module scaffolding (
npm run scaffold), ESLint/Knip rules,.githooks/pre-commitworkflow, and documentation synchronization (npm run check:doc-sync). - Agent & Architecture Guidelines: Module boundaries, the five-file TypeScript configuration split (
npm run typecheck), and non-interactive verification workflows. - Application Runtime Contract & Deployment Strategy: Canonical environment variable matrix, persisted
prisma/schema.prismaentities, and cloud hosting recipes.