How aakash-bist/nestjs-auth-skeleton works
Project Type and Purpose
• The project is a NestJS starter application meant for building scalable, server-side (backend) applications. It leverages NestJS’s modular system to separate concerns between different functionalities like authentication (under src/auth), core services (under src/core), and even seeding functionalities (under src/seeds).
• The README emphasizes its use as a starting point for NestJS applications, indicating a backend service architecture with API endpoints, middleware, and dependency injection.
File Structure for Key Components
• Top-level files (.env, package.json, etc.) indicate configuration and environment setup.
• The “src” directory contains the entry point (src/main.ts) and the primary modules of the application.
• The “src/auth” directory holds all files related to authentication (controllers, services, DTOs, strategies, and models), highlighting its importance.
• The “src/core” directory encapsulates configuration modules, constants, decorators, filters, guards, middleware, and utility services. This suggests the project makes significant use of cross-cutting concerns (error handling, request context management, logging, etc.).
• The “src/seeds” directory implies the inclusion of data seeding functionality, likely used during the initial setup or testing stages.
• The “test” directory contains testing configurations and files, emphasizing unit and end-to-end tests.
a. Main Application Entry Point and Bootstrapping:
• Application start-up using an “Entry Point” block (src/main.ts) that initializes the NestJS application.
b. Modules:
• Auth Module: Show the Auth Controller, Auth Service, DTOs, JWT strategies, and associated models. Indicate that it handles authentication logic.
• Core Module: Illustrate configuration (ConfigService), constants, decorators, filters (like the fallback and HTTP filters), guards (JWT Auth, roles, refresh tokens), middleware (request-context and send-email), and service utilities (e.g., LoggerService).
• Seeds Module: Clearly indicate its role in populating initial data.
c. External Systems and Infrastructure:
d. Testing:
• A testing module or environment that interacts with the production modules, emphasizing unit tests for controllers (e.g., app.controller.spec.ts) and end-to-end tests in the test directory.
Relationships and Interactions
• That the Auth Module interacts with services (auth.service.ts) and depends on various strategies (JWT access, JWT refresh) to handle authentication.
• How the Core Module provides common utilities like configuration, logging, middleware for request processing, and error handling (filters).
• Inter-module communication where, for instance, the Auth Module might rely on configuration data from the Core Config Service.
Final Recommendations
• Aim for clarity: Every block should clearly state its function.