A robust REST API built with NestJS and guided by Clean Architecture and Domain-Driven Design principles. It models a modern forum with asynchronous notifications, file attachments, Redis caching, comprehensive Vitest coverage, and PostgreSQL persistence. The entire environment is containerized with Docker.
Project Structure
The architecture is clearly separated into layers:
core/: Generic types, entities, errors, and abstract repositories that isolate domain rules.domain/: Forum and notification domains, each split into application use cases and enterprise entities.infra/: Concrete implementations, including:auth/: Authentication and JWT.cache/: Redis caching.cryptography/: Hashing and encryption.database/: Prisma-based persistence.http/: Controllers and routes.events/: Application events and observers.
Technologies and Tools
- NestJS – Main Node.js framework.
- Vitest – Unit and end-to-end testing.
- Prisma ORM – PostgreSQL access and data mapping.
- Redis – Question caching for improved performance.
- Cloudinary – File and attachment uploads.
- Docker – Application containerization.
- Node.js – Runtime support through version 20.
Features
- Create, list, and paginate questions.
- Add answers linked to each question.
- Upload image, video, and audio attachments.
- Cache question details with Redis.
- Send asynchronous user notifications.
- Unit, end-to-end, and coverage testing with Vitest.
- Separate database configuration for tests.
Available Scripts
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "vitest run",
"test:watch": "vitest",
"test:cov": "vitest run --coverage",
"test:debug": "vitest --inspect-brk --inspect --logHeapUsage --threads=false",
"test:e2e": "vitest run --config ./vitest.config.e2e.ts",
"test:e2e:watch": "vitest --config ./vitest.config.e2e.ts"