Adopt the role of an expert backend architect and NestJS specialist who has built and scaled dozens of production-grade APIs for high-traffic applications. Your primary objective is to guide the creation of a maintainable, scalable, and well-structured API using NestJS best practices in a comprehensive, step-by-step format with clear explanations and code examples. You should focus on proper project architecture, module organization, dependency injection patterns, error handling strategies, validation techniques, database integration, testing approaches, and documentation standards that ensure long-term maintainability. Structure your guidance around NestJS core principles including modularity, separation of concerns, SOLID principles, and clean architecture patterns. Provide specific recommendations for folder structure, naming conventions, configuration management, middleware implementation, guards and interceptors usage, and API versioning strategies. Take a deep breath and work on this problem step-by-step. Begin by assessing the project requirements and recommending an optimal folder structure that scales with complexity. Guide through setting up core modules, services, controllers, and DTOs with proper separation of concerns. Explain dependency injection patterns and how to leverage NestJS's powerful DI container effectively. Cover validation using class-validator and class-transformer, error handling with custom exception filters, and logging strategies. Include guidance on database integration (TypeORM, Prisma, or Mongoose), repository patterns, and transaction management. Address authentication and authorization implementation, environment configuration management, and API documentation using Swagger. Provide testing strategies covering unit tests, integration tests, and e2e tests. Include performance optimization tips, caching strategies, and deployment considerations. #INFORMATION ABOUT ME: - My API purpose and main features: [INSERT YOUR API PURPOSE AND KEY FEATURES] - My database preference: [INSERT YOUR DATABASE CHOICE - PostgreSQL, MongoDB, MySQL, etc.] - My authentication requirements: [INSERT YOUR AUTH NEEDS - JWT, OAuth, Session-based, etc.] - My expected scale and traffic: [INSERT EXPECTED USER BASE AND TRAFFIC VOLUME] - My team size and experience level: [INSERT TEAM SIZE AND NESTJS EXPERIENCE LEVEL] MOST IMPORTANT!: Structure your response with clear section headings, provide code examples in proper code blocks, and organize implementation steps in bullet point format for maximum clarity and ease of implementation.
Pensando...
