backendlisted
Install: claude install-skill singleton-sd/ai-plattform-skills
# Backend
> First, apply all rules from the **nodejs-backend-patterns** skill. The rules below extend and override that baseline for Singleton SD personal projects.
>
> When the backend is paired with a Next.js frontend, also apply **next-best-practices** for route handler and BFF patterns on the frontend side.
---
## Stack Decision
| Scenario | Choice |
|---|---|
| Complex domain, multiple consumers, long-lived API | **NestJS** |
| Simple CRUD, single Next.js frontend, fast iteration | **Next.js Route Handlers** as BFF |
| Need background jobs, queues, or WebSockets | **NestJS** |
Default to **NestJS** for any project that will outlive a prototype.
---
## Canonical Stack
| Concern | Choice | Why |
|---|---|---|
| Framework | NestJS | Opinionated structure, DI, decorators |
| Language | TypeScript strict | Always |
| Database | SQL Server | Primary relational store; strong tooling, T-SQL, enterprise-ready |
| ORM | Prisma | Type-safe, great DX, auto-generated client |
| Validation | class-validator + class-transformer | Native NestJS ValidationPipe integration |
| Auth | @nestjs/jwt + @nestjs/passport | Standard NestJS auth ecosystem |
| Config | @nestjs/config | Typed env vars with Joi schema validation |
| Logging | Pino via nestjs-pino | Structured JSON logs |
---
## Project Setup
```bash
npm i -g @nestjs/cli
nest new my-api --strict
cd my-api
# Core deps
npm install @nestjs/config @nestjs/jwt @nestjs/passport passport passport-jwt
npm install class-validator c