Backend Stack Overview
Stack (new apps — latest stable)
| Layer | Choice |
|---|---|
| Framework | NestJS 11 on Fastify |
| ORM | Prisma 8 (prisma@latest, @prisma/orm-postgres) |
| DB | PostgreSQL |
| Auth | JWT + Passport |
| Validation | class-validator via shared DTO decorators |
| Files | @fastify/multipart + local uploads/ |
| Docs | Swagger (ENABLE_SWAGGER=true) |
Legacy apps may use Prisma 6/7 with modules/global-dto/ and tools/ — detect and match.
Project Layout
src/
├── main.ts
├── app.module.ts
├── common/
│ ├── dto/ # Global DTOs + decorators
│ ├── filters/ # Exception filters
│ ├── interceptors/
│ ├── services/ # BaseService, PerformanceTracker
│ └── utils/ # response.handler, error.handler
├── config/
├── modules/
│ ├── prisma/ # @Global
│ ├── storage/ # @Global
│ ├── auth/
│ └── {feature}/
├── integrations/ # Cross-cutting (webhooks, CAPI)
└── templates/emails/
prisma/schema.prisma
prisma/migrations/
uploads/
Bootstrap (main.ts)
Fastify → CORS → ValidationPipe → multipart → static files → Helmet → CSRF → listen
App Module
ConfigModule, ThrottlerGuard, EventEmitterModule, ScheduleModule, global filters once in app.module.ts only.
Conventions
- Action-first routes:
get-all-X,create-X,update-X,delete-X - HTTP 200 for most endpoints
- Response:
{ status: 'success', data }or{ status, count, data } - Bilingual fields:
name_en/name_ar - Soft delete:
deleted DateTime? - Tabs, single quotes, 120 width;
strict: truefor new apps
Related Skills
| Task | Skill |
|---|---|
| New module | @backend-nest/create-module |
| DTOs | @backend-nest/global-dtos |
| Files | @backend-nest/file-upload |
| Errors | @backend-nest/error-handling |
| Auth | @backend-nest/auth |
| Database | @backend-nest/prisma-database |