Files
route-commerce/PRODUCTION_SETUP.md
T
Nora 42f5745c97 docs: refresh stale docs to match current implementation
Documentation pass — reviewed codebase in full, identified stale references,
and aligned docs with actual code state.

Changes:
- CLAUDE.md, PRODUCTION_SETUP.md, LAUNCH_CHECKLIST.md, src/auth.config.ts:
  middleware path src/middleware.ts → src/proxy.ts (Next.js 16+ convention)
- CLAUDE.md, ENVIRONMENT.md, README.md:
  dev server port localhost:3000 → localhost:4000 (per package.json dev
  script 'next dev --webpack -H 0.0.0.0 -p 4000')
- PRODUCTION_DEPLOYMENT_CHECKLIST.md:
  rewrote migration list — actual db/migrations/ contains 10 files
  (0000–0091), not the Supabase-era 001–092 series. Updated platform
  version 1.6 → 2.0 and last-updated stamp.
- MEMORY.md:
  refreshed 'Last updated' to 2026-06-25 and added a current-state header
  flagging the 'Auth.js v5 wiring' section as historical (current auth
  is Neon Auth/Better Auth). Also flags the 'GitHub origin' notes as
  historical (only Gitea origin exists).
- LAUNCH_CHECKLIST.md:
  added 'Last updated: 2026-06-25' header and refresh note in footer.

Verification:
- npx tsc --noEmit: pre-existing Stripe API version + test mock errors
  only (verified by stashing changes and re-running — same error set).
- No new errors introduced.
2026-06-25 20:13:19 -06:00

99 lines
2.5 KiB
Markdown

# Route Commerce - Production Setup Guide
## Quick Start
```bash
# Install dependencies
npm install
# Copy environment variables
cp .env.example .env.local
# Start development server
npm run dev
```
## Configuration
### 1. Neon Auth (Better Auth)
1. Set up Neon Auth on your Neon project (`neonctl neon-auth init`)
2. Copy keys to `.env.local`:
```
NEON_AUTH_BASE_URL=https://xxx.neonauth.io
NEON_AUTH_COOKIE_SECRET=<openssl rand -base64 32>
NEXT_PUBLIC_SITE_URL=https://yourdomain.com
```
3. Configure middleware in `src/proxy.ts`
### 2. Stripe Payments
1. Create Stripe account
2. Create products and prices in Stripe Dashboard
3. Update `.env.local` with:
```
STRIPE_SECRET_KEY=sk_test_xxx
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
```
### 3. Database (Postgres / Neon)
The app talks to Postgres directly via `pg` (no Supabase, no REST gateway). Point `DATABASE_URL` at any reachable Postgres — Neon, Supabase (the underlying Postgres), RDS, etc. The Supabase JS client and PostgREST are not used.
1. Provision a Postgres database (Neon recommended — it also hosts Neon Auth)
2. Run migrations: `npm run migrate`
3. Update `.env.local` with:
```
DATABASE_URL=postgresql://user:pass@host:5432/dbname?sslmode=require
```
### 4. Optional Services
#### Sentry (Error Monitoring)
```
SENTRY_DSN=https://xxx@sentry.io/xxx
```
#### PostHog (Analytics)
```
NEXT_PUBLIC_POSTHOG_API_KEY=phc_xxx
```
## Deployment
### Vercel
1. Connect repository to Vercel
2. Add all environment variables
3. Deploy
### Other Platforms
Ensure environment variables are set before deployment.
## Key Files
- `src/proxy.ts` - Neon Auth (Better Auth) middleware
- `src/lib/stripe-billing.ts` - Stripe integration
- `src/lib/analytics.ts` - PostHog analytics
- `src/lib/sentry.ts` - Sentry error tracking
- `src/components/admin/AnalyticsDashboard.tsx` - Admin dashboard
- `src/components/onboarding/OnboardingFlow.tsx` - User onboarding
- `src/components/referral/ReferralSystem.tsx` - Referral tracking
- `src/components/changelog/ChangelogFeed.tsx` - Product updates
- `db/migrations/` - Database schema (applied via `scripts/migrate.js`)
## Scripts
```bash
npm run dev # Start development server
npm run build # Production build
npm run lint # Run ESLint
npm run migrate # Run database migrations
```
## Documentation
- Full documentation: [CLAUDE.md](./CLAUDE.md)
- Launch checklist: [LAUNCH_CHECKLIST.md](./LAUNCH_CHECKLIST.md)