# NestJS Rules

Full coding rules for this stack. Read this in full before writing or modifying any NestJS code in this project — not just once, keep applying it to every edit in the session, not only the first.

---

## Project Architecture

NestJS follows a strict **Module-based** architecture. Every feature should be contained in its own module.

```
src/
├── app.module.ts
├── main.ts
└── features/
    └── [feature-name]/
        ├── [feature].module.ts
        ├── [feature].controller.ts
        ├── [feature].service.ts
        ├── [feature].entity.ts (if using TypeORM)
        └── dto/
            ├── create-[feature].dto.ts
            └── update-[feature].dto.ts
```

---

## NestJS Rules

- Use **Constructor Injection** for all dependencies.
- Always use **DTOs** (Data Transfer Objects) with `class-validator` for input validation.
- Annotate controllers with `@Controller()`.
- Use `@Injectable()` for services.
- Leverage **Pipes** for data transformation and validation.
- Leverage **Interceptors** for logging and response mapping.

---

## Testing Rules

- Use the built-in **Jest** testing suite.
- Use `Test.createTestingModule` to create isolated environments for unit tests.
