{"id":29292227,"url":"https://github.com/deadislove/dotnet-hexacleanhybarch-template","last_synced_at":"2026-04-12T00:09:27.777Z","repository":{"id":303051181,"uuid":"1014254203","full_name":"deadislove/dotnet-HexaCleanHybArch-template","owner":"deadislove","description":"Modular, testable backend architecture template in .NET 9. Combines Hexagonal + Clean Architecture with plug-in-style modules (Auth, User, etc.) and dynamic adapter registration for scalable systems.","archived":false,"fork":false,"pushed_at":"2025-09-26T01:43:17.000Z","size":93,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-26T03:45:54.178Z","etag":null,"topics":["api-template","clearn-arch","ddd","docker-compose","dockerfile","dotnet","health-check","hexagonal-architecture","jwt-authentication","modular-design","mssql","plugin","postgresql","rate-limiting","sqlite","swagger-ui"],"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/deadislove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-05T10:54:45.000Z","updated_at":"2025-09-26T01:43:20.000Z","dependencies_parsed_at":"2025-07-05T11:45:45.509Z","dependency_job_id":"16bb1b24-d19e-49df-b38d-4a98ee796be2","html_url":"https://github.com/deadislove/dotnet-HexaCleanHybArch-template","commit_stats":null,"previous_names":["deadislove/dotnet-hexacleanhybarch-template"],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/deadislove/dotnet-HexaCleanHybArch-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadislove%2Fdotnet-HexaCleanHybArch-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadislove%2Fdotnet-HexaCleanHybArch-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadislove%2Fdotnet-HexaCleanHybArch-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadislove%2Fdotnet-HexaCleanHybArch-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deadislove","download_url":"https://codeload.github.com/deadislove/dotnet-HexaCleanHybArch-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadislove%2Fdotnet-HexaCleanHybArch-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020057,"owners_count":26086806,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api-template","clearn-arch","ddd","docker-compose","dockerfile","dotnet","health-check","hexagonal-architecture","jwt-authentication","modular-design","mssql","plugin","postgresql","rate-limiting","sqlite","swagger-ui"],"created_at":"2025-07-06T09:30:35.238Z","updated_at":"2026-04-12T00:09:27.771Z","avatar_url":"https://github.com/deadislove.png","language":"C#","funding_links":["https://ko-fi.com/F1F82YR41'"],"categories":[],"sub_categories":[],"readme":"# HexaCleanHybArch.Template\r\n\r\n![Visitors](https://img.shields.io/badge/visitors-null_total-brightgreen)\r\n![Clones](https://img.shields.io/badge/clones-null_total_null_unique-blue) \u003c!--CLONE-BADGE--\u003e\r\n\r\nA **Modular Hexagonal-Clean Hybrid Architecture** template built with **.NET 9**, designed for scalable, maintainable, and plug-in-style backend systems.\r\n\r\n\u003ca href='https://ko-fi.com/F1F82YR41' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\r\n\r\n---\r\n\r\n## ❓ Why This Architecture\r\n\r\nModern applications require flexibility, feature modularity, and clear separation of concerns. This template combines:\r\n\r\n- **Hexagonal Architecture** for inbound/outbound decoupling\r\n- **Clean Architecture** for layer separation and testability\r\n- **Plugin-based modularity** for scalable and independently evolvable features\r\n\r\n\u003e Ideal for: Domain-rich enterprise apps, modular monoliths, service-oriented backends.\r\n\r\n---\r\n\r\n## 🧩 Architecture Overview\r\n\r\nThis architecture blends concepts from **Hexagonal Architecture**, **Clean Architecture**, and **Plugin-based Modular Monoliths**, with the following principles:\r\n\r\n### 🔑 Key Concepts\r\n\r\n- **Feature-Oriented Modules**  \r\n  Each domain feature (e.g., `User`, `Auth`) is built as an independent module containing its own:\r\n  - Domain Layer\r\n  - Application Layer\r\n  - Infrastructure Layer\r\n\r\n- **Adapters as Boundaries**  \r\n  Instead of treating `interface` as the sole boundary, this pattern treats **entire adapter modules** as the boundary units, following Hexagonal principles. These modules expose `Register()` methods to inject themselves at runtime.\r\n\r\n- **Dynamic Adapter Registration**  \r\n  A lightweight plugin mechanism loads all adapters implementing `IAdapterModule` from their assemblies at runtime, allowing high modularity and minimal API-core coupling.\r\n\r\n- **Decentralized Port Interfaces**  \r\n  Unlike traditional Hexagonal where all `ports` are defined in a central `Core`, this pattern allows each adapter to define its own ports/interfaces to avoid high coupling and make module ownership clearer.\r\n\r\n## 🧱 Layered Structure\r\n\r\nEach module follows the Clean Architecture layering **within itself**:\r\n\r\n```bash\r\n[ Api ]\r\n    ↓\r\n[ Adapter Module ]\r\n  ├── Application\r\n  ├── Domain\r\n  └── Infra\r\n    ↓\r\n[ External Dependency ]\r\n```\r\n\r\n\u003e Core remains free of direct adapter dependencies.\r\n\r\n## 🔌 Modules\r\n\r\nExamples of pluggable modules:\r\n- `HexaCleanHybArch.Template.Adapters.User` – Handles user profile logic\r\n- `HexaCleanHybArch.Template.Adapters.Auth` – Handles authentication \u0026 token flow\r\n\r\nEach implements `IAdapterModule`, and is auto-registered via `AdapterModuleLoader`.\r\n\r\n---\r\n\r\n## ⚙️ Customize the Template\r\nTo start your own project based on this template:\r\n\r\n```bash\r\ndotnet new install .\r\ndotnet new hexa-clean -n {new_project_name}\r\n```\r\n\r\n---\r\n\r\n## 🚀 How to Run\r\n\r\nUsing the DockerFile:\r\n\r\n```bash\r\n## Build image\r\ndocker build -t {image_name} .\r\n\r\n## Run Docker file(http: 8080 -\u003e 8081; https: 8081 -\u003e8082)\r\ndocker run -d -p 8081:8080 -p 8082:8081 --name {container_name} {image_name}\r\n```\r\n\r\nOr using Docker Compose:\r\n\r\n```bash\r\n# For SQLite (default)\r\ndocker-compose -f docker-compose.sqlite.yml up --build\r\n\r\n# For PostgreSQL\r\ndocker-compose -f docker-compose.postgres.yml up --build\r\n\r\n# For MSSQL\r\ndocker-compose -f docker-compose.mssql.yml up --build\r\n```\r\n\r\n## 🧪 Testing Strategy\r\n\r\nThis project separates test types clearly:\r\n\r\n- tests/Unit/\r\n\r\n  Unit tests focused on Core logic and internal rules\r\ne.g., UserServiceTests.cs, AuthServiceTest.cs\r\n\r\n- tests/Integration/\r\n\r\n  API-level tests validating end-to-end flow\r\ne.g., AuthApiIntegrationTests.cs, SharedApiFactoryCollection.cs\r\n\r\nTest Tools Used:\r\n\r\n- xUnit\r\n- Moq\r\n- FluentAssertions\r\n- Microsoft.AspNetCore.Mvc.Testing\r\n\r\nSee: [Integration tests in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-9.0\u0026pivots=xunit)\r\n\r\n## 📦 Prerequisites\r\n\r\n- [.NET 9 SDK](https://dotnet.microsoft.com/en-us/)\r\n- [Docker](https://www.docker.com/) (required for database containers)\r\n\r\n## 🗂️ Project Structure (Simplified)\r\n\r\n```bash\r\nsrc/\r\n├── Api                        // Entry API + Middleware\r\n├── Core                       // Core business logic\r\n├── Adapters/\r\n│   ├── Auth                   // Auth module\r\n│   └── User                   // User module\r\n├── Config                     // Database / DI factory\r\n├── Shared                     // Common exceptions, DTOs\r\ntests/\r\n├── Unit/                      // Pure unit tests\r\n└── Integration/               // API-level tests\r\n```\r\n\r\n## 📈 Architecture Diagram\r\n\r\nThe following diagram illustrates the modular, adapter-boundary-centric architecture you're implementing:\r\n\r\n📎 [Download Architecture Diagram (PNG)](sandbox:/mnt/data/A_diagram_illustrates_a_modular_software_architect.png)\r\n\r\n### Diagram Highlights:\r\n- Each Adapter module contains its own Clean Architecture layers (Application / Domain / Infra)\r\n- The API project composes multiple adapters via their `IAdapterModule` implementations\r\n- The adapter boundary acts as the external interface to the Core\r\n- The Core knows nothing about the Adapters — only ports/interfaces as abstractions\r\n\r\nThis encourages strong modularity, dynamic plug-in style composition, and separation of concerns per feature.\r\n\r\n## 💬 Stay in touch\r\n\r\n- Author - [Da-Wei Lin](https://www.linkedin.com/in/da-wei-lin-689a35107/)\r\n- Website - [David Weblog](https://davidskyspace.com/)\r\n- [MIT LICENSE](https://github.com/deadislove/dotnet-HexaCleanHybArch-template/blob/main/LICENSE)\r\n\r\n## 🏗️ Future Enhancements\r\n\r\n- ✅ MediatR integration\r\n- ✅ FluentValidation auto-loading\r\n- ⏳ Swagger modular plugin support\r\n- ⏳ gRPC and EventBus adapters\r\n\r\n## Reference\r\n\r\n- [Integration tests in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-9.0\u0026pivots=xunit)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadislove%2Fdotnet-hexacleanhybarch-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadislove%2Fdotnet-hexacleanhybarch-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadislove%2Fdotnet-hexacleanhybarch-template/lists"}