{"id":20465876,"url":"https://github.com/fernandocalmet/dotnet-onion-architecture-skeleton","last_synced_at":"2025-04-13T08:50:34.033Z","repository":{"id":104177498,"uuid":"424291079","full_name":"FernandoCalmet/dotnet-onion-architecture-skeleton","owner":"FernandoCalmet","description":"🦄 This project is a .NET template skeleton built on the Onion Architecture, providing a solid foundation for scalable, maintainable, and robust application development.","archived":false,"fork":false,"pushed_at":"2024-02-04T03:47:25.000Z","size":2181,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T00:22:53.071Z","etag":null,"topics":["clean-architecture","csharp","dotnet","dotnet-core","net8","onion-architecture"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FernandoCalmet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"fernandocalmet","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-11-03T16:03:03.000Z","updated_at":"2024-08-17T11:43:00.000Z","dependencies_parsed_at":"2024-01-12T07:06:23.785Z","dependency_job_id":"72a15cde-ba52-4891-841d-f7d83771353d","html_url":"https://github.com/FernandoCalmet/dotnet-onion-architecture-skeleton","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FernandoCalmet%2Fdotnet-onion-architecture-skeleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FernandoCalmet%2Fdotnet-onion-architecture-skeleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FernandoCalmet%2Fdotnet-onion-architecture-skeleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FernandoCalmet%2Fdotnet-onion-architecture-skeleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FernandoCalmet","download_url":"https://codeload.github.com/FernandoCalmet/dotnet-onion-architecture-skeleton/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688417,"owners_count":21145763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","csharp","dotnet","dotnet-core","net8","onion-architecture"],"created_at":"2024-11-15T13:20:15.564Z","updated_at":"2025-04-13T08:50:34.001Z","avatar_url":"https://github.com/FernandoCalmet.png","language":"C#","funding_links":["https://ko-fi.com/fernandocalmet"],"categories":[],"sub_categories":[],"readme":"# 🦄 DOTNET TEMPLATE SKELETON BASED ON ONION ARCHITECTURE\n\n[![Github][github-shield]][github-url]\n[![Kofi][kofi-shield]][kofi-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n[![Khanakat][khanakat-shield]][khanakat-url]\n\n## CONTENT\n\n* 🔥 [Description](#description)\n* ⚙️ [Installation](#installation)\n* 🍵 [Usage](#usage)\n* 📓 [Summary](#summary)\n* 🏗️ [Project Structure](#project-structure)\n* 📄 [License](#license)\n* ⭐️ [Give me a star](#give-me-a-star)\n\n## DESCRIPTION\n\nThis project is a .NET template skeleton built on the Onion Architecture, providing a solid foundation for scalable, maintainable, and robust application development.\n\n## INSTALLATION\n\n### Clone project\n\n📌 You can Clone this repository using:\n\n```bash\ngit clone https://github.com/FernandoCalmet/dotnet-onion-architecture-skeleton.git\n```\n\n### Setup dotnet template\n\n📌 To install this ``dotnet template``, navigate to the root directory of this repository and run the following command:\n\n```bash\ndotnet new install .\n```\n\n### Data migration\n\n📌 To migrate your data with ``Entity Framework Core`` you can run the following commands using the Package Manager Console:\n\nCommand | Description\n--- | ---\nadd-migration ``[name]`` --startup-project MyCompany.MyProduct.Api --project MyCompany.MyProduct.Persistence --context ApplicationDbContext | Create a new migration with the specific migration name\nremove-migration | Remove the latest migration.\nupdate-database | Update the database to the latest migration.\nupdate-database ``[name]`` | Update the database to a specific migration name point.\nget-migrations | Lists all available migrations.\nscript-migration | Generates a SQL script for all migrations.\ndrop-database | Drop the database.\n\n## USAGE\n\nTo create a new project using this template, use the dotnet new command followed by the template name. You can specify additional parameters to customize the generated project.\n\n```bash\ndotnet new onion-architecture-skeleton --MyCompanyMyProduct true --DatabaseProvider postgres\n```\n\n### Parameters\n\nThe following parameters are available for this template:\n\nParameter | Short Option | Description\n--- | --- | ---\n--UseSwagger | -U | Includes Swagger UI in the generated project.\n--DatabaseProvider | -D | Specifies the database provider to use. Supported values are sqlserver and postgresql.\n\n### Conditional Code and Files\n\nThis template uses conditional syntax to include or exclude certain parts of the code based on the parameters you provide. For example, if you specify -D postgresql, the generated project will include a PostgresSql specific repository implementation, and exclude the other database provider files.\n\n## SUMMARY\n\n### Simplifying Software Development\nDeveloping a robust, scalable, and maintainable software architecture is a complex task. The Onion Architecture, a design pattern developed by Jeffrey Palermo and inspired by Uncle Bob's Clean Architecture, addresses these challenges. This architecture aims to make software independent of external dependencies like frameworks, databases, and UI, promoting decoupling and testability.\n\n### Understanding Onion Architecture\nThe Onion Architecture is structured in four key layers:\n\n### Domain Layer\nThe core of the architecture, containing business logic, entities, value objects, business rules, and interfaces for contracts with other layers.\n\n### Application Layer\nServes as an interface between the Presentation and Domain layers, containing services that orchestrate application flow and data mapping.\n\n### Infrastructure Layer\nHouses technical details like data storage, logging, messaging, etc., and implements interfaces from the Domain layer.\n\n### Presentation Layer\nResponsible for presenting output to users and communicating with the Application layer to access Domain layer information.\n\n### Benefits of Onion Architecture in Dotnet\nThe Onion Architecture enhances testability, maintainability, and flexibility. It allows writing unit tests that depend solely on the Domain layer, unaffected by external frameworks or dependencies. This design also follows the Single Responsibility Principle, simplifying maintenance and refactoring.\n\n## Project Structure\nThe updated project structure aligns with the principles of Onion Architecture, ensuring a clear separation of concerns and improved maintainability. Here's an overview of the updated directory structure:\n\n```\nMyCompany.MyProduct.sln\n│\n├───src\n│   ├───Solution Items\n│   │   ├───.editorconfig\n│   │   ├───DirectoryBuild.props\n│   │   └───Directory.Packages.props\n│   ├───Core\n│   │   ├───MyCompany.MyProduct.Application\n│   │   │   ├───Abstractions\n│   │   │   │   ├───Authentication\n│   │   │   │   ├───Authorization\n│   │   │   │   ├───Caching\n│   │   │   │   ├───Clock\n│   │   │   │   ├───Data\n│   │   │   │   ├───Emails\n│   │   │   │   └───Messaging\n│   │   │   ├───Behaviors\n│   │   │   ├───Exceptions\n│   │   │   ├───Extensions\n│   │   │   └───Features\n│   │   └───MyCompany.MyProduct.Domain\n│   │       ├───Abstractions\n│   │       ├───Entities\n│   │       ├───Enums\n│   │       ├───Errors\n│   │       ├───Events\n│   │       ├───Primitives\n│   │       ├───Repositories\n│   │       ├───Services\n│   │       ├───Shared\n│   │       ├───Time\n│   │       └───ValueObjects\n│   └───External\n│       ├───MyCompany.MyProduct.Api\n│       │   ├───Extensions\n│       │   ├───Middleware\n│       │   ├───OpenApi\n│       │   └───Dockerfile\n│       ├───MyCompany.MyProduct.Infrastructure\n│       │   ├───Authentication\n│       │   ├───Authorization\n│       │   ├───BackgroundJobs\n│       │   ├───Caching\n│       │   ├───Clock\n│       │   ├───Emails\n│       │   ├───EventBus\n│       │   ├───Extensions\n│       │   ├───Logging\n│       │   └───Notifications\n│       ├───MyCompany.MyProduct.Persistence\n│       │   ├───Configurations\n│       │   ├───Constants\n│       │   ├───Data\n│       │   ├───Interceptors\n│       │   ├───Extensions\n│       │   ├───Migrations\n│       │   ├───Repositories\n│       │   └───Specifications\n│       └───MyCompany.MyProduct.Presentation\n│           ├───Authorization\n│           ├───Contracts\n│           ├───Endpoints\n│           ├───Extensions\n│           └───Routes\n├───tests\n│   ├───MyCompany.MyProduct.Api.FunctionalTests\n│   │   ├───.files\n│   │   └───Infrastructure\n│   ├───MyCompany.MyProduct.Application.UnitTests\n│   ├───MyCompany.MyProduct.ArchitectureTests\n│   │   ├───Application\n│   │   ├───Domain\n│   │   ├───Infrastructure\n│   │   ├───Persistence\n│   │   ├───Presentation\n│   │   └───Layers\n│   ├───MyCompany.MyProduct.Domain.UnitTests\n│   │   └───Infrastructure\n│   └───MyCompany.MyProduct.IntegrationTests\n│       ├───.files\n│       └───Infrastructure\n└───docker-compose\n```\n\nThis structure ensures that each component of our system is neatly organized, facilitating easier navigation and understanding of the codebase.\n\n### Conclusion\nOnion Architecture offers a robust framework for building maintainable and scalable applications in .NET. By segregating the application into distinct layers, it promotes a clean separation of concerns and enhances the overall software quality. We encourage you to adopt this architecture in your next .NET project for a noticeable improvement in your development process.\n\n## LICENSE\nThis project is licensed under the License (MIT License) - see the [LICENSE](LICENSE) file for details.\n\n## GIVE ME A STAR\nIf you found this Implementation useful or used it in your Projects, please give it a star. Thank you! Or, if you're feeling really generous, [Support the project with a small contribution!](https://ko-fi.com/fernandocalmet).\n\n\u003c!--- reference style links ---\u003e\n[github-shield]: https://img.shields.io/badge/-@fernandocalmet-%23181717?style=flat-square\u0026logo=github\n[github-url]: https://github.com/fernandocalmet\n[kofi-shield]: https://img.shields.io/badge/-@fernandocalmet-%231DA1F2?style=flat-square\u0026logo=kofi\u0026logoColor=ff5f5f\n[kofi-url]: https://ko-fi.com/fernandocalmet\n[linkedin-shield]: https://img.shields.io/badge/-fernandocalmet-blue?style=flat-square\u0026logo=Linkedin\u0026logoColor=white\u0026link=https://www.linkedin.com/in/fernandocalmet\n[linkedin-url]: https://www.linkedin.com/in/fernandocalmet\n[khanakat-shield]: https://img.shields.io/badge/khanakat.com-brightgreen?style=flat-square\n[khanakat-url]: https://khanakat.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandocalmet%2Fdotnet-onion-architecture-skeleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffernandocalmet%2Fdotnet-onion-architecture-skeleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffernandocalmet%2Fdotnet-onion-architecture-skeleton/lists"}