Installation & Setup Guide
Prerequisites
- Node.js LTS and the chosen package manager by the team (pnpm is recommended).
- Local PostgreSQL 15+ and Redis 7+, or Docker Compose for both.
- Separate repositories:
frontend(Next.js) andbackend(NestJS + Prisma).
Backend NestJS
cd backend
pnpm install
cp .env.example .env
pnpm prisma generate
pnpm prisma migrate dev
pnpm start:dev
Minimum contents for local .env:
NODE_ENV=development
PORT=3001
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/membership_hub
REDIS_URL=redis://localhost:6379
APP_URL=http://localhost:3001
FRONTEND_URL=http://localhost:3000
Run worker on a separate terminal if not combined with the development process:
pnpm start:worker
API is available at http://localhost:3001; Swagger is available at http://localhost:3001/api/docs in development/staging.
Frontend Next.js
cd project/frontend
pnpm install
cp .env.example .env.local
pnpm dev
Use NEXT_PUBLIC_API_URL=http://localhost:3001. Do not store database, Redis, payment secret, or JWT private key in the frontend environment.
Database and queue
- Create a new migration with
pnpm prisma migrate dev --name <description>. - Commit Prisma migration files together with schema changes.
- Use
pnpm prisma studioonly for development. - Verify Redis before testing email, scheduler, or worker: worker must be connected and no failed jobs are ignored.
Pre-merge checks
- Run lint, unit test, integration test, and build backend.
- Run migration on an empty database and database upgrade copy to verify compatibility.
- Test Midtrans/Xendit sandbox, including invalid signature and webhook retry.
- Test email/lifecycle job with Redis active and simulate retry.