{
  "name": "NestJS Backend",
  "description": "NestJS backend with TypeORM, PostgreSQL, and comprehensive testing",
  "filePatterns": ["*.ts", "*.js"],
  "excludePatterns": ["*.spec.ts", "*.test.ts", "*.d.ts"],
  "techStack": {
    "framework": "NestJS",
    "language": "TypeScript",
    "database": "TypeORM + PostgreSQL",
    "validation": "class-validator + class-transformer",
    "testing": "Jest + Supertest",
    "documentation": "Swagger/OpenAPI",
    "caching": "Redis + cache-manager",
    "queues": "Bull + Redis"
  },
  "conventions": {
    "naming": {
      "variables": "camelCase",
      "functions": "camelCase",
      "classes": "PascalCase",
      "interfaces": "PascalCase with I prefix",
      "types": "PascalCase with T prefix",
      "enums": "PascalCase",
      "constants": "UPPER_SNAKE_CASE"
    },
    "fileStructure": {
      "modules": "Feature-based modules in src/{feature}/",
      "controllers": "{feature}.controller.ts",
      "services": "{feature}.service.ts",
      "entities": "{feature}.entity.ts",
      "dtos": "dto/{feature}.dto.ts",
      "tests": "{feature}.controller.spec.ts, {feature}.service.spec.ts"
    },
    "imports": {
      "style": "Absolute imports with @ prefix when available",
      "grouping": "Third-party, @nestjs, internal, relative",
      "sorting": "Alphabetical within groups"
    }
  },
  "qualityChecks": {
    "lint": {
      "command": "npx eslint --fix",
      "config": "Google TypeScript ESLint config",
      "autoFix": true
    },
    "format": {
      "command": "npx prettier --write",
      "config": "80 character line limit",
      "autoFix": true
    },
    "build": {
      "command": "npm run build",
      "checkTypes": true,
      "failOnError": true
    },
    "test": {
      "unit": "npm run test:unit",
      "integration": "npm run test:integration",
      "coverage": "npm run test:cov",
      "minimumCoverage": 40
    }
  },
  "codePatterns": {
    "controller": {
      "decorators": ["@Controller", "@ApiTags", "@UseGuards"],
      "methods": ["@Get", "@Post", "@Put", "@Delete", "@Patch"],
      "responses": ["@ApiResponse", "@ApiOperation"],
      "validation": ["@Body", "@Param", "@Query with DTOs"],
      "errorHandling": "Use HttpException and custom exception filters"
    },
    "service": {
      "injection": "Constructor dependency injection with @Injectable",
      "methods": "Async methods with proper error handling",
      "database": "Use TypeORM repository pattern",
      "transactions": "@Transaction decorator for data consistency"
    },
    "entity": {
      "decorators": ["@Entity", "@PrimaryGeneratedColumn", "@Column"],
      "relationships": ["@ManyToOne", "@OneToMany", "@ManyToMany"],
      "validation": "class-validator decorators on fields",
      "timestamps": "Include createdAt, updatedAt with @CreateDateColumn"
    },
    "dto": {
      "validation": "class-validator decorators (@IsString, @IsOptional)",
      "transformation": "class-transformer decorators (@Transform, @Type)",
      "swagger": "Swagger decorators (@ApiProperty, @ApiPropertyOptional)",
      "inheritance": "Use PartialType, PickType for variations"
    },
    "testing": {
      "unit": "Test services and controllers independently with mocks",
      "integration": "Test complete request/response cycles",
      "mocking": "Use jest.mock for dependencies",
      "coverage": "Focus on business logic and edge cases"
    }
  },
  "context7Libraries": [
    "@nestjs/common",
    "@nestjs/core",
    "@nestjs/typeorm",
    "@nestjs/swagger",
    "@nestjs/jwt",
    "@nestjs/passport",
    "@nestjs/cache-manager",
    "@nestjs/throttler",
    "typeorm",
    "class-validator",
    "class-transformer",
    "jest"
  ],
  "commonImports": {
    "controller": [
      "import { Controller, Get, Post, Put, Delete, Patch, Body, Param, Query, UseGuards, HttpException, HttpStatus } from '@nestjs/common';",
      "import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';"
    ],
    "service": [
      "import { Injectable } from '@nestjs/common';",
      "import { InjectRepository } from '@nestjs/typeorm';",
      "import { Repository } from 'typeorm';"
    ],
    "entity": [
      "import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';",
      "import { IsString, IsOptional, IsNumber, IsBoolean, IsDate } from 'class-validator';"
    ],
    "dto": [
      "import { IsString, IsOptional, IsNumber, IsBoolean, IsEmail, IsArray } from 'class-validator';",
      "import { Transform, Type } from 'class-transformer';",
      "import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';"
    ]
  },
  "bestPractices": [
    "Use dependency injection for all services and repositories",
    "Validate all input data using DTOs with class-validator",
    "Document all API endpoints with Swagger decorators",
    "Implement proper error handling with custom exception filters",
    "Use TypeORM repositories for database operations",
    "Write unit tests for all services and integration tests for controllers",
    "Use environment variables for configuration",
    "Implement rate limiting and security guards",
    "Use transactions for operations affecting multiple entities",
    "Follow REST API conventions for endpoint naming"
  ],
  "securityConsiderations": [
    "Validate and sanitize all inputs",
    "Use JWT authentication with proper token validation",
    "Implement role-based access control (RBAC)",
    "Use HTTPS in production environments",
    "Implement rate limiting to prevent abuse",
    "Hash passwords using bcrypt",
    "Use parameterized queries to prevent SQL injection",
    "Implement proper CORS configuration",
    "Log security-relevant events for auditing",
    "Use environment variables for sensitive configuration"
  ]
}
