This repository provides a starter solution template for building REST APIs in .NET, following Clean Architecture and Domain-Driven Design (DDD) principles.
The goal of this template is to offer a clean, consistent and scalable project structure that can be reused as the foundation for future API projects.
No business logic is included. This repository only contains:
- Project structure
- References between layers
- Basic configuration
- Test project scaffolding
This repository is primarily intended as a learning project.
The template has been mainly created to deepen practical understanding of:
- Clean Architecture
- Domain-Driven Design (DDD)
- Testing strategies in .NET APIs
While the structure and decisions are based on well-known principles and best practices, this template should not be considered a definitive or enterprise-approved standard.
Any feedback, comments, or suggestions for improvement are very welcome and highly appreciated.
docs
├── Template Bootstrap Script
src
├── Core
│ ├── Application
│ └── DependencyInjections
│ └── Domain
│ └── Common
│ └── BaseModels
│ ├── AggregateRoot
│ ├── Entity
│ └── ValueObject
├── Infrastructure
│ └── Infrastructure
│ └── DependencyInjections
├── Presentation
│ └── API
│ └── Program
│ └── Contracts
tests
├── ArchitectureTests
├── IntegrationTests
├── SubcutaneousTests
│── UnitTests
│ ├── Application.UnitTests
│ └── Domain.UnitTests
utils
├── bootstrap.py
.editorconfig
.gitignore
Solution.sln
Directory.Build.props
LICENSE
README.md
stylecop.json
- Domain entities
- Value Objects
- Aggregates
- Domain events
- Domain interfaces
- No dependencies on other layers
- Use cases / application services
- DTOs (internal)
- Interfaces (repositories, services)
- Business rules orchestration
- Depends only on
Domain
- Persistence implementations
- External services
- Identity, messaging, file system, etc.
- Implements interfaces defined in
Application - Depends on
ApplicationandDomain
- ASP.NET Core Web API
- Controllers / Minimal APIs
- Dependency Injection configuration
- Depends on
ApplicationandContracts
- Public request/response contracts
- API models shared with clients
- Versionable and decoupled from domain
Ensures architectural rules are respected:
- Domain has no external dependencies
- Application does not depend on Infrastructure
- Presentation does not violate layer boundaries
- Domain: pure business rules
- Application: use cases and orchestration
- Infrastructure: isolated logic when applicable
- API end-to-end tests
- Real DI container
- HTTP pipeline validation
This template includes a bootstrap script that automates the initialization process and ensures consistent naming across the solution.
- Mark this repository as a Template repository
- Create a new repository using this template
- Clone the new repository locally
- Run the bootstrap script:
python utils/bootstrap.py- Provide the required inputs:
- Project name
- Author name
- Company name
- The script will automatically:
- Rename solution and project files
- Update namespaces and internal references
- Configure StyleCop (author, company, license)
- Synchronize file headers
- Regenerate the README
- Start implementing your business logic
Documentation:
Detailed documentation about the script is available at:docs/bootstrap.md
- Clone the repository
- Run the bootstrap script following the related previous steps.
- Push to a new repository
If you prefer not to use the script:
- Clone the repository
- Manually rename:
- Solution file (.slnx)
- Projects
- Namespaces
- Update StyleCop configuration and file headers
- Adjust README and project metadata
This template is intended to:
- Reduce setup time for new API projects
- Enforce architectural consistency
- Serve as a learning and reference project
- Scale from small to large applications
- No business logic is included by design
- No concrete implementations are provided
- This is an evolving template and can be extended as needed
This project is licensed under the MIT License. If you find it useful, a mention or star is always appreciated 🙂
Happy coding! 🚀