Lightweight, modular, and production-oriented backend service for the W-W platform built with NestJS, Prisma, and pnpm. Designed for clarity, scalability, and feature-flag driven evolution.
- Overview
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Running & Scripts
- Database & Migrations
- Optional Redis Integration
- API Documentation (Swagger)
- Testing
- Security
- Contributing
- License
This repository houses the backend services for W-W. It provides authentication, membership, wallet foundation, and extensible domain modules. Redis is currently disabled but the code remains in place for future activation.
- JWT-based auth (access & refresh tokens)
- Rate limiting (Nest Throttler)
- Modular architecture (Auth, Users, Membership, Wallet, Redis placeholder)
- Prisma ORM (PostgreSQL)
- Centralized response filters & exception handling
- Optional Redis caching/pubsub (fully disabled by default)
- Structured logging (Winston)
- Swagger auto-generated docs
- Runtime: Node.js (NestJS + Fastify adapter)
- ORM: Prisma
- DB: PostgreSQL
- Cache / PubSub (optional): Redis (ioredis + Keyv) – currently disabled
- Auth: Passport JWT strategies
- Testing: Jest (unit & e2e)
- Logging: Winston
- Package Manager: pnpm
src/
modules/
auth/
common/
feature-flags/
membership/
users/
wallet/
redis/ (disabled; keep for future use)
lib/
config/
filters/
middleware/
main.ts
Core principles:
- Separation by domain (feature-focused modules)
- Providers & services isolated from controllers
- Shared infrastructure (Prisma, hashing, throttling) lives in
commonmodule - Optional integrations (Redis) are isolated and can be toggled without touching active modules
Prerequisites:
- Node.js >= 18
- pnpm (
npm i -g pnpm) - PostgreSQL instance (local or managed)
Setup:
pnpm install
cp .env-sample .env # create & edit values
pnpm prisma migrate deploy
pnpm run start:devIf using Docker for DB:
docker-compose up -dEssential variables (see src/env.ts for full list):
| Key | Description |
|---|---|
NODE_ENV |
development or production |
API_PORT |
Port the HTTP server listens on |
API_URL |
Base URL (without version path) |
DATABASE_URL |
PostgreSQL connection string |
JWT_SECRET |
Access token secret |
JWT_EXPIRATION_TIME |
Access token lifetime (seconds) |
JWT_REFRESH_SECRET |
Refresh token secret |
JWT_REFRESH_EXPIRATION_TIME |
Refresh token lifetime (seconds) |
HASH_SALT_ROUNDS |
bcrypt salt rounds |
RATE_LIMIT_DEFAULT_TTL_MS |
Throttler window TTL in ms |
RATE_LIMIT_DEFAULT_LIMIT |
Requests allowed per window |
REDIS_REST_URL / REDIS_REST_TOKEN |
Reserved for future Redis REST usage |
Add others (Firebase, Sentry, etc.) as needed based on integration.
# Development (watch)
pnpm run start:dev
# Production build & run
pnpm run build
pnpm run start:prod
# Format & lint
pnpm run lint
pnpm run format # if configuredGenerate client after schema changes:
pnpm prisma generateCreate a new migration:
pnpm prisma migrate dev --name <migration_name>Apply migrations in deployment:
pnpm prisma migrate deployView data (GUI):
pnpm prisma studioRedis code is kept but currently disabled:
RedisModuleimport commented incommon.module.ts- Cache falls back to in-memory
Enable later by: uncommenting imports & providers and adding proper Redis env vars.
Auto-generated at runtime. Default path:
/docs
Bearer auth schemes for access & refresh tokens are preconfigured.
# Unit tests
pnpm run test
# E2E tests
pnpm run test:e2e
# Coverage
pnpm run test:covTest files live beside services (*.spec.ts).
See SECURITY.md for responsible disclosure and out-of-scope items.
- Fork & branch (
feat/<short-name>) - Keep changes focused & small
- Run lint & tests before pushing
- Open PR with clear description & context
This project is released under the MIT License.
Made with care for the W-W platform. Future enhancements: enable Redis, add GraphQL gateway, expand wallet domain.