Clean rebuild of the Over The Top Restoration CRM — roofing and storm-restoration lifecycle from lead to closeout.
PR-002 auth — Better Auth login, sessions, roles. See docs/prs/PR-002-auth.md.
cp .env.example .env.local
# Edit DATABASE_URL
npm install
# Drizzle CLI needs DATABASE_URL in the shell or a root .env (not .env.local alone):
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/top2
npm run db:migrate
npm run db:seed
npm run devSign in at /login with the seeded dev admin (see Preview login below).
Environment notes: Next.js loads .env.local for npm run dev. Drizzle commands (db:migrate, db:seed, db:generate) read DATABASE_URL from the process environment. CI sets DATABASE_URL directly in GitHub Actions.
Health check: GET http://localhost:3000/api/health
Auth protects the app, so deploy previews require login.
Seeded dev admin (development / preview / non-production only):
| Field | Value |
|---|---|
admin@example.com |
|
| Password | password12345 |
Seed command (uses Better Auth sign-up — same password hashing as normal users):
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/top2
npm run db:migrate
npm run db:seedDeploy preview database: not seeded automatically on deploy. After pointing at a preview database, run db:migrate and db:seed manually from your local dev shell. See docs/deploy/netlify.md for Netlify-specific seed gating caveats. Vercel preview deploys (VERCEL_ENV=preview) also allow the dev admin seed with the default password; production deploys skip it unless SEED_DEV_ADMIN=true and SEED_ADMIN_PASSWORD is set to a non-default value.
If login fails in preview:
- Confirm migrations ran against the preview
DATABASE_URL - Run
npm run db:seedagainst that database - Set
BETTER_AUTH_URLto the preview URL (e.g.https://deploy-preview-123--top2.netlify.app) - Confirm the user exists: seed logs should mention
admin@example.com
These credentials are for development/preview review only — not a production backdoor.
| Document | Purpose |
|---|---|
| docs/BLUEPRINT.md | Stack, data model, API, UI, build sequence, risks |
| docs/API.md | API route reference |
| docs/schema.sql | Forward-looking reference schema (applied changes ship via Drizzle migrations per PR) |
| docs/prs/PR-001-scaffold.md | First PR spec |
| docs/prs/PR-002-auth.md | Second PR spec |
| docs/prs/PR-003-app-shell.md | Third PR spec |
| docs/deploy/netlify.md | Netlify deployment, preview env vars, and seed caveats |
| docs/decisions/ADR-001-hosting-database.md | Hosting and database decisions |
| AGENTS.md | Rules for humans and AI agents working in this repo |
- Job-centric. Every workflow orbits the job lifecycle.
- One mutation path. No duplicate ways to update the same business object.
- Events over hacks. KU, CI, and lifecycle changes are logged on the activity timeline.
- Small PRs. Each change is reviewable, testable, and reversible.
Lead → Inspection Scheduled → Inspection Complete → Claim Filed → Adjuster Meeting Scheduled → Approved → Contract Signed → Material Ordered → Production Scheduled → Installed → Invoiced → Paid → Closed