A .NET project template implementing Clean Architecture, focusing on DDD principles, unit testing, and RESTful API design. This template uses 5 layers to ensure modularity and separation of concerns, and it supports token-based authentication.
- src/
Api
- Controllers and API configuration (e.g., Swagger, API responses)Application
- Application layer with CQRS, MediatR handlers, DTOs, and commands/queries.Domain
- Domain models, entities, and core business logic.Infrastructure
- Database configuration, data access, and external services.SharedKernel
- Common types, constants, and cross-cutting concerns.Host
- Application setup and main entry point (Program.cs and configuration).
- tests/
- Separate unit tests for each layer to ensure isolation and robustness.
-
Clone the repository:
git clone https://github.com/YourUsername/CleanArchitecture.Template.git
-
Navigate to the source directory:
cd src
-
Restore dependencies:
dotnet restore
-
Build the solution:
dotnet build
-
Run the project:
dotnet run --project CleanArchitecture.Template.Host
- Environment Variables: Set up necessary environment variables, like database connections and JWT keys.
- Docker Support: Optionally, run the project using Docker.
Comprehensive documentation is located in the docs/
folder, structured as follows:
features/authentication
- Detailed markdown documentation for authentication, login, and token refresh flows.postman
- Pre-configured Postman collection for testing endpoints.setup
- Guide to run migrations using Entity Framework Core, ensuring seamless database setup.
-
Run Unit Tests:
dotnet test
-
Continuous Integration: GitHub Actions are set up to automatically run tests on each push to
main
anddevelop
branches, ensuring that new changes don’t break existing functionality.
- Swagger: API documentation available at
/swagger
when running the project. - Postman Collection: Available in
docs/postman
to test API endpoints for authentication, user management, and health checks.
The project uses GitHub Actions for CI/CD, with the following workflow:
- .NET Build & Test: Runs on each push to
main
anddevelop
, performingrestore
,build
, andtest
operations.
- Modular Architecture: Divides responsibilities across API, Application, Domain, Infrastructure, SharedKernel, and Host layers.
- Authentication & Authorization: JWT-based token authentication with refresh token mechanism.
- Documentation: Detailed feature documentation and Postman collection to ease testing and integration.
- Docker Support: Optionally run the project in Docker for a standardized environment.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding! 🎉