How jhoannpv/node-auth-clean-architecture works
Main Components
• Core Layers:
• Domain: This layer contains business logic, entities, DTOs, use-cases, and domain errors. It encapsulates the core rules and processes.
• Infrastructure: This layer handles integration with external systems (like MongoDB), data mappers, and repository implementations.
• Presentation: This layer exposes the application’s API endpoints through controllers, routes, and middlewares.
• Data: Represents the database interaction configuration and models, specifically for MongoDB.
• Configuration: Contains environment configurations, security utilities (bcrypt, JWT), and validation logic.
• Supporting Components:
• The app/server bootstrap and Docker configuration (docker-compose, .env.template) that manage deployment and development setup.
• Utility files like package.json and tsconfig.json that aid in building and running the application.
Relationships & Interactions
• The Presentation Layer accepts incoming HTTP requests via controllers and routes. It forwards the requests to the Domain Layer.
• The Domain contains the core business logic through use cases, which use domain entities and DTOs to process input.
• Domain use cases rely on repository interfaces; these are implemented by the Infrastructure Layer.
• The Infrastructure Layer handles communication with the Data layer, mainly managing MongoDB operations via models and database configurations.
• Configuration settings are used by all layers, such as environment variables, JWT configurations, and validation utilities.
• From Presentation → Domain (Controller calls use cases)
• From Domain → Infrastructure (Use-case calls repository implementations)
• From Infrastructure → Data (Interaction with MongoDB)
Notable Architectural Patterns
• Clean Architecture: Clear separation of concerns with independent layers (domain, infrastructure, presentation) ensures maintainability and testability.
• Repository Pattern: Abstract data persistence through domain repositories with their concrete implementations in the infrastructure.
• Dependency Injection: Although not explicit, the structure suggests dependencies being inverted by abstracting repositories and datasources.
Technologies, Frameworks, or Libraries
• Node.js and TypeScript as core runtime and language.
• MongoDB for data persistence, with specific configuration and models.
• Bcrypt and JWT in the configuration folder, hinting at authentication and security.
• Docker for containerized deployment (docker-compose.yml is present).