| Tool | Minimum Version | Recommended |
|---|---|---|
| Node.js | 18.0.0 | 20.x LTS |
| npm | 8.0.0 | 10.x |
| PostgreSQL | 14 | 16 |
| Redis | 6.0 | 7.x |
git clone https://github.com/your-org/PropChain-BackEnd.git
cd PropChain-BackEnd
npm installCopy the example env file and fill in your values:
cp .env.example .envKey variables to configure:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/propchain"
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
# JWT
JWT_SECRET="your-secret-key-here"
JWT_EXPIRATION="15m"
JWT_REFRESH_EXPIRATION="7d"
# Google OAuth (optional)
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
# Application
PORT=3000
NODE_ENV=development
BASE_URL="http://localhost:3000"# Generate Prisma client
npm run db:generate
# Run migrations
npm run migrate
# Seed with test data
npm run db:seednpm run start:devThe API will be available at http://localhost:3000/api.
- Swagger docs:
http://localhost:3000/api/docs - GraphQL playground:
http://localhost:3000/graphql
| Script | Description |
|---|---|
npm start |
Start production server |
npm run start:dev |
Start with hot-reload |
npm run start:debug |
Start in debug mode |
npm run build |
Build for production |
npm test |
Run unit tests |
npm run test:watch |
Run tests in watch mode |
npm run test:cov |
Run tests with coverage |
npm run lint |
Lint and auto-fix |
npm run format |
Format with Prettier |
npm run migrate |
Run Prisma migrations |
npm run migrate:reset |
Reset database and re-migrate |
npm run db:seed |
Seed database with test data |
npm run seed |
Seed database with realistic data |
npm run db:studio |
Open Prisma Studio |
npm run db:generate |
Regenerate Prisma client |
Add to .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug NestJS",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/nest",
"runtimeArgs": ["start", "--debug", "--watch"],
"console": "integratedTerminal",
"restart": true,
"env": { "NODE_ENV": "development" }
}
]
}npm run start:debug
# Then open chrome://inspect in ChromeError: @prisma/client did not initialize yet
Fix:
npm run db:generateError: listen EADDRINUSE: address already in use :::3000
Fix:
lsof -ti:3000 | xargs kill -9Error: connect ECONNREFUSED 127.0.0.1:6379
Fix: Start Redis:
# macOS
brew services start redis
# Docker
docker run -d --name redis -p 6379:6379 redis:alpineError: Can't reach database server at localhost:5432
Fix:
# Ensure PostgreSQL is running
brew services start postgresql@16
# Or via Docker
docker run -d --name propchain-db \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=propchain \
-p 5432:5432 postgres:16npm run migrate:reset
npm run db:seedWarning: This deletes all data. Only use in development.
- Create feature branch from
main - Make changes
- Pre-commit hooks run automatically (ESLint + Prettier)
- Push and create PR
- Address review feedback
- Merge after approval
Husky + lint-staged run automatically on git commit:
- ESLint fixes on
.tsfiles - Prettier formats
.ts,.json,.mdfiles
If the hook fails, fix the issues before committing:
npm run lint # Check for lint errors
npm run format # Fix formatting