How yurysidyakin/top-api works
Main Components
• NestJS Application Core – Represented by the main.ts and app.module.ts files initializing the server.
• Modular Components – Each module in the “src” directory should be its own component:
• Auth Module: Handles authentication flows using JWT (with its controllers, services, strategies, guards, and DTOs).
• Product Module: Manages product-related operations.
• Review Module: Manages reviews, including its controller, service, and model.
• Top-Page Module: Likely handles content for a top-page (with its dedicated controller, DTOs, and service).
• Users Module: Handles user-specific functionalities.
• Configurations – Modules like the “configs” directory (with jwt.config.ts and mongo.config.ts) indicate configuration components, especially for JWT security and MongoDB connectivity.
• Testing & DevOps – Presence of the “test” directory and CI/CD workflows (.github/workflows/main.yml) highlights testing and deployment considerations.
Relationships and Data Flow
• Client Requests to API Gateway: Start with a client (web/mobile or any HTTP consumer) making REST API calls.
• Controllers: Each module (auth, product, review, top-page, users) has a controller that receives client requests.
• Services: Controllers delegate operations to their respective services, which handle the business logic.
• Database: Based on the existence of mongo.config.ts, use a database block (likely MongoDB) that services interact with for data retrieval and persistence.
• Authentication Flow: Clearly illustrate the JWT strategy starting at the Auth Controller, which passes through guards/strategies to validate user credentials, and then hands over valid requests to the appropriate modules.
• Configuration and Environment: Include a component for configuration management (using configuration files and environment variables) that interacts with the NestJS core.
Architectural Patterns and Design Principles
• Dependency Injection: Emphasize the use of DI within NestJS that connects controllers to services.
• Statelessness: Highlight REST/HTTP principles ensuring each request is independently authenticated and handled.
• Security Using JWT: Mark the specific flow for authentication using tokens with guards and strategies.
• Containerization: Reinforce that deployment is managed via Docker and docker-compose, ensuring the app and its services can run in isolated containers.