This is a modular .NET 8 Web API project following the principles of Clean Architecture. The architecture separates concerns into distinct layers: Presentation, API, Application, Domain, and Infrastructure.
π¦ Project.Root
βββ Api/ --> Entry point, config, middleware, static files
β βββ Extensions/
β βββ Factories/
β βββ Middleware/
β βββ Models/
β β βββ Errors/
β βββ wwwroot/
β βββ Program.cs
β βββ appsettings.json
β
βββ Presentation/ --> HTTP Controllers
β βββ Controllers/
β
βββ Application/ --> Application logic and services
β βββ Dtos/
β βββ Common/
β β βββ Settings/ --> Includes JwtSettings
β βββ Interfaces/
β βββ Services/
β βββ MappingProfiles/
β βββ Validations/
β
βββ Domain/ --> Core business models and rules
β βββ Entities/
β βββ Errors/
β βββ Exceptions/
β βββ Interfaces/
β βββ Settings/
β βββ Specifications/
β
βββ Infrastructure/ --> External integrations and implementations
βββ Persistence/
βββ Services/
JWT Authentication is implemented using a strongly-typed JwtSettings class located in:
Application/Common/Settings/Jwt.cs
JWT tokens are generated and validated in the Application or Infrastructure layer and configured in Program.cs.
- DTO validation using FluentValidation.
- Business rules are handled in the
Domainlayer using entities, exceptions, or specifications. - Custom validation errors are returned using
ProblemDetailsandValidationErrorResponse.
Custom middleware (like global exception handler) is registered in the API layer under:
Api/Middleware/
- Clone the repo.
- Set your connection strings and JWT keys in
appsettings.json. - Run EF Core migrations if needed.
- Build & run the API.
- Following Separation of Concerns and Dependency Inversion.
- Use of AutoMapper for mapping between DTOs and Entities.
- Ready to plug in external services like Stripe, Email, etc.
Built by Mostafa ELshenawy β using Clean Architecture with love.