How aawwad172/dotnet-template works
Project Type & Purpose
• This is a .NET template meant for quickly setting up a robust application using modern best practices such as DDD, Clean Architecture, CQRS, and UnitOfWork patterns.
• The solution is split across four main layers: Domain, Application, Infrastructure, and Presentation. Its purpose is to serve as a scaffolding for building feature-rich web APIs integrated with PostgreSQL and secured via JWT authentication.
Major Components
• Contains core business entities (User, RefreshToken, etc.), enums, and custom exceptions.
• Emphasizes the business logic of the application.
• Contains the CQRS implementation including command handlers (Authentication handlers: Login, Logout, RefreshToken, RegisterUser), commands, interfaces, and helper services (e.g., AuthenticationService, JwtService).
• Also includes dependency injection setup for decoupling components.
• Implements data access logic using EF Core, repositories (generic and custom), and database context along with migrations for PostgreSQL.
• Contains additional configurations and utility extensions (e.g., PostgresEnumExtensions, pagination queries).
• Provides the Web API project including middleware layers (JWT authentication middleware, ExceptionHandlerMiddleware for global exception handling), routes, validators, and API models.
• Contains configuration files (appsettings.json) that enable database connections, JWT settings, and other security-related configurations.
Relationships and Interactions
• The Domain layer represents the core business models and is independent from the rest.
• The Application layer orchestrates use-case logic via CQRS command and query handlers and calls upon Domain services and entities.
• The Infrastructure layer provides implementations that support the application (e.g., repositories for data persistence) and interacts directly with the data store.
• The Presentation layer is the entry point for external clients, performing request validations, invoking Application layer services, and handling HTTP responses.
• How the Presentation layer calls the Application layer.
• How the Application layer leverages Domain for business rules and Infrastructure for data persistence.
• How cross-cutting concerns (JWT authentication, exception handling, and Fluent Validation) are integrated.
Architectural Patterns and Important Technology Elements
• DDD and Clean Architecture by segregating concerns.
• CQRS and UnitOfWork patterns found in the Application layer.
• Technologies such as:
• .NET (C#) for the overall platform.
• EF Core and PostgreSQL for data persistence.
• JWT for authentication, accompanied by a dedicated JWT service.
• Fluent Validation for command and API input validation.
• Middleware components that handle exception processing and logging (via repositories and ApiResponse classes).
• Usage of Husky (for pre-commit hooks) and Makefile for .NET CLI tasks, though these are more related to development processes rather than runtime architecture.