Skip to content

Commit 0687232

Browse files
docs: rewrite new-dev setup guide (env, seed, tests, gotchas) (#529)
Rewrites docs/GETTING_STARTED.md as the canonical "how to run this project" guide and fixes the README quick start. Corrections to what was there: - README told devs to open localhost:3000 — tenant resolution reads the subdomain, so localhost bounces every authenticated page to /join-school. Both docs now say lvh.me:3000 and explain why. - Guide recommended cloud Supabase first and `db push` for local setup; local flow is `supabase start` + `npm run db:reset`. - Guide said to confirm signup email via Mailpit — email confirmations are disabled locally (config.toml enable_confirmations = false). Adds what new devs were missing: - Copy-paste .env.local block with the local Supabase keys. - Seed-account table annotated with which subdomain to log in on. - Full seed inventory (tenants free vs enterprise and why, courses, products, plans, alice's pre-seeded subscription) and why the seed hand-writes auth.users — handle_new_user() doesn't fire on SQL insert. - Migration workflow, unit + E2E test rules (dev server first, lvh.me, workers=1), Stripe CLI's two distinct webhook secrets, cron secret, mcp-server's port-3000 clash with next dev. - Troubleshooting: join-school bounce, port clash + the site_url=localhost:3005 in config.toml, stale JWT after role change, the tables with no tenant_id that error the whole query. Claude-Session: https://claude.ai/code/session_01853LDokPbhv9Kg9Ctz9DB5 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent dbbfd9c commit 0687232

2 files changed

Lines changed: 321 additions & 286 deletions

File tree

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,45 @@ A multi-tenant SaaS Learning Management System. Schools run on subdomains (`scho
2323
2. **Configure environment**
2424
```bash
2525
cp .env.example .env.local
26-
# Fill in at minimum: NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY
26+
```
27+
For local Supabase, set these four. Run `supabase status` (after step 3) and copy its **Publishable** and **Secret** keys — they are local-only dev keys, the same on every machine:
28+
```bash
29+
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
30+
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY=<Publishable key from `supabase status`>
31+
SUPABASE_SERVICE_ROLE_KEY=<Secret key from `supabase status`>
32+
NEXT_PUBLIC_PLATFORM_DOMAIN=lvh.me:3000
2733
```
2834

2935
3. **Start local Supabase** _(requires Docker)_
3036
```bash
3137
supabase start
32-
supabase db reset # applies all migrations + seeds test data
38+
npm run db:reset # applies all migrations + seeds tenants, users, courses, products
3339
```
3440

3541
4. **Run the dev server**
3642
```bash
3743
npm run dev
3844
```
3945

40-
5. **Open the app**
41-
Visit `http://localhost:3000` — or use a tenant subdomain like `http://testschool.lvh.me:3000`
46+
5. **Open the app at `http://lvh.me:3000` — not `localhost`**
47+
48+
Tenant resolution reads the subdomain; `lvh.me` resolves `*.lvh.me` to `127.0.0.1`. On `localhost` no tenant resolves and authenticated pages bounce to `/join-school`.
49+
50+
- `http://lvh.me:3000` — Default School (free plan)
51+
- `http://code-academy.lvh.me:3000` — Code Academy Pro (enterprise plan)
52+
53+
6. **Log in** with a seeded account (all passwords `password123`), on the subdomain matching its tenant:
54+
55+
| Email | Tenant | Role |
56+
|--|--|--|
57+
| `student@e2etest.com` | Default School (`lvh.me:3000`) | student |
58+
| `owner@e2etest.com` | Default School (`lvh.me:3000`) | admin + super admin |
59+
| `creator@codeacademy.com` | Code Academy (`code-academy.lvh.me:3000`) | admin |
60+
| `alice@student.com` | Code Academy (`code-academy.lvh.me:3000`) | student |
61+
62+
Local-dev credentials only — seeded by `npm run db:reset`.
63+
64+
**Full walkthrough — seed contents, migrations, tests, optional services, troubleshooting: [`docs/GETTING_STARTED.md`](docs/GETTING_STARTED.md).**
4265

4366
## npm Scripts
4467

@@ -47,14 +70,17 @@ A multi-tenant SaaS Learning Management System. Schools run on subdomains (`scho
4770
| `npm run dev` | Start dev server |
4871
| `npm run build` | Production build (TypeScript + lint) |
4972
| `npm run lint` | Run ESLint |
50-
| `npm test` | Run Playwright E2E tests |
73+
| `npm run typecheck` | `tsc --noEmit` |
74+
| `npm run test:unit` | Vitest unit tests |
75+
| `npm test` | Playwright E2E tests (dev server must already be running) |
5176
| `npm run db:reset` | Reset local DB (migrations + seed) |
5277
| `npm run db:push` | Push migrations to cloud Supabase |
78+
| `npm run db:types` | Regenerate `lib/database.types.ts` |
5379
| `npm run mcp:build` | Build the MCP server sub-project |
5480

5581
## Documentation
5682

57-
- [`docs/GETTING_STARTED.md`](docs/GETTING_STARTED.md) — full local setup guide
83+
- [`docs/GETTING_STARTED.md`](docs/GETTING_STARTED.md)**full local setup guide: env, seed data, migrations, tests, troubleshooting**
5884
- [`CLAUDE.md`](CLAUDE.md) — architecture reference for AI agents and developers
5985
- [`docs/DATABASE_SCHEMA.md`](docs/DATABASE_SCHEMA.md) — complete DB schema
6086
- [`docs/AUTH.md`](docs/AUTH.md) — authentication flows

0 commit comments

Comments
 (0)