Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 3.17 KB

development.md

File metadata and controls

87 lines (64 loc) · 3.17 KB

Working on Kindwall

Set up

You need Node 22, Docker, and pnpm through Corepack.

corepack enable
pnpm install
cp .env.example .env
docker compose up -d db
pnpm db:migrate
pnpm dev

docker compose up -d db starts only Postgres, on 127.0.0.1:54330 so it doesn't collide with a Postgres you may already run. pnpm dev then starts three things at once:

What Where Notes
Server http://localhost:3000 Restarts when you change apps/server or a package it uses
Dashboard http://localhost:5190 Vite with hot reload; sends /api and /embed.js to the server
Widget packages/widget/dist Rebuilt on change and served by the server as /embed.js

Work in the dashboard at port 5190. For sample data, put SEED_DEMO_DATA=true in .env and sign in as demo@kindwall.dev / kindwall-demo-password.

Where things are

apps/server         Fastify server: HTTP routes, auth, files, mail, webhooks
apps/dashboard      React app: dashboard, collection pages (/c/…), hosted walls (/w/…)
packages/widget     embed.js, the script customers paste into their sites
packages/shared     Types, Zod schemas and rules shared by everything above
packages/database   Drizzle schema and SQL migrations
packages/config     Environment variables, read and checked once
tests/e2e           Playwright tests of the whole journey
deploy              Dockerfile
tools               Release helpers

docs/api.md describes every HTTP endpoint and is the contract between the server and the dashboard. Shapes and validation live in packages/shared, so both sides use the same code.

Tests

Unit and integration tests use a real database, kindwall_test, which you create once:

docker compose exec db createdb -U kindwall kindwall_test
pnpm test

Point them elsewhere with KINDWALL_TEST_DATABASE_URL.

Browser tests drive the built app in Chromium. They create, and recreate on every run, a database called kindwall_e2e next to the others (override with KINDWALL_E2E_DATABASE_URL):

pnpm --filter @kindwall/e2e exec playwright install chromium   # once
pnpm build
pnpm e2e

To run them against a server that's already running, for example the Docker image with an empty database, set E2E_BASE_URL=http://127.0.0.1:3000.

pnpm verify runs lint, the format check, type checks and tests: the same as CI's first job.

Changing the database

  1. Edit packages/database/src/schema.ts.
  2. Run pnpm db:generate to write a new SQL migration into packages/database/migrations.
  3. Read the SQL it wrote, then pnpm db:migrate.

Migrations that have been released are never edited; add a new one instead.

Build like production

pnpm build
node apps/server/dist/server.mjs

pnpm build produces packages/widget/dist/embed.js, apps/dashboard/dist and the bundled server apps/server/dist/server.mjs, which serves the other two. The Docker image is built from the same steps: docker build -f deploy/Dockerfile -t kindwall .