Skip to main content

Development Guide

How to set up and contribute to LoyaltyOS development.

Requirements​

  • Node.js >= 20
  • pnpm >= 9
  • Docker + Docker Compose

First Time Setup​

git clone https://github.com/jvillatox/loyaltyos.git
cd loyaltyos

# Copy environment file
cp .env.example .env

# Start infrastructure
docker compose up -d

# Install dependencies
pnpm install

# Create and seed the database
pnpm --filter @loyaltyos/api db:reset
pnpm --filter @loyaltyos/api db:seed

# Start dev servers
pnpm dev

Common Commands​

CommandDescription
pnpm installInstall all dependencies
pnpm devStart all apps in dev mode
pnpm buildBuild all packages and apps
pnpm testRun all tests
pnpm typecheckType-check the entire monorepo
pnpm lintLint all packages
pnpm formatFormat code with Prettier
pnpm --filter @loyaltyos/api db:resetDrop and recreate database
pnpm --filter @loyaltyos/api db:seedSeed demo data
pnpm --filter @loyaltyos/api db:studioOpen Prisma Studio
pnpm --filter @loyaltyos/api db:migrateCreate a new migration

Conventions​

  • TypeScript strict — no any without justification.
  • Conventional commits — feat:, fix:, docs:, refactor:, test:, chore:.
  • Pre-commit hooks — Husky runs ESLint, Prettier, and commitlint on staged files.
  • Formatting — Prettier with single quotes, trailing commas, and 100-char print width.
  • API validation — every endpoint is validated with Zod.
  • Idempotency — Idempotency-Key header on accumulate, redeem, and convert operations.

Package Layout​

packages/<module>/
├── src/
│ ├── index.ts # public exports
│ ├── service.ts # business logic
│ ├── repository.ts # data access
│ ├── types.ts
│ └── __tests__/
├── package.json
└── README.md

Troubleshooting​

Ports already in use​

lsof -i :5432
lsof -i :6379
docker ps --filter "publish=5432"
docker stop <container-id>

Reset everything​

docker compose down -v
docker compose up -d
pnpm --filter @loyaltyos/api db:reset
pnpm --filter @loyaltyos/api db:seed

Database connection errors​

docker compose ps postgres
# Should show "healthy" status

pnpm --filter @loyaltyos/api exec prisma migrate status

Prisma migration conflicts​

Never edit a migration that has already been applied. Create a new one:

pnpm --filter @loyaltyos/api exec prisma migrate dev --name fix_description