{"id":17947589,"url":"https://github.com/hirannor/hexagonal-architecture-asp-net","last_synced_at":"2026-02-21T09:02:42.008Z","repository":{"id":259234598,"uuid":"874108653","full_name":"hirannor/hexagonal-architecture-asp-net","owner":"hirannor","description":"hexagonal-architecture-asp-net-core","archived":false,"fork":false,"pushed_at":"2024-10-25T13:37:14.000Z","size":331,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-16T16:57:57.659Z","etag":null,"topics":["architecture","asp-net","asp-net-core","clean-architecture","clean-code","csharp","ddd","ddd-patterns","domain-driven-design","dotnet","entity-framework","event-driven","eventbus","hexagonal","hexagonal-architecture","messaging","port-and-adapters","rest-api","software-architecture","software-development"],"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/hirannor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-10-17T09:12:22.000Z","updated_at":"2024-10-25T13:37:17.000Z","dependencies_parsed_at":"2024-10-23T18:57:16.287Z","dependency_job_id":"9d9962d4-9f5b-4702-948a-2beb65ab305d","html_url":"https://github.com/hirannor/hexagonal-architecture-asp-net","commit_stats":null,"previous_names":["hirannor/hexagonal-architecture-asp-net-core"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirannor%2Fhexagonal-architecture-asp-net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirannor%2Fhexagonal-architecture-asp-net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirannor%2Fhexagonal-architecture-asp-net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirannor%2Fhexagonal-architecture-asp-net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hirannor","download_url":"https://codeload.github.com/hirannor/hexagonal-architecture-asp-net/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237901394,"owners_count":19384388,"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":["architecture","asp-net","asp-net-core","clean-architecture","clean-code","csharp","ddd","ddd-patterns","domain-driven-design","dotnet","entity-framework","event-driven","eventbus","hexagonal","hexagonal-architecture","messaging","port-and-adapters","rest-api","software-architecture","software-development"],"created_at":"2024-10-29T08:05:51.973Z","updated_at":"2025-02-09T03:45:16.000Z","avatar_url":"https://github.com/hirannor.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# ASP.NET - Ports-And-Adapters / Hexagonal Architecture with DDD\n\n## Overview\n\nThis project, developed as a practice exercise to gain familiarity with C# and ASP.NET, follows **Hexagonal Architecture** (also known as Ports-and-Adapters Architecture) alongside **Domain-Driven Design** (DDD) principles. \nThe project provides a modular, clean, and testable structure, focusing on:\n- Customer registration and JWT-based authentication\n- Displaying customer's personal details\n- Modifying personal details\n- Changing password\n- Changing email address\n\nDespite its simplicity, this project demonstrates a modern approach to ASP.NET architecture.\n\n| Build Status                                                                                           | License                                                                                           |\n| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- |\n| [![Build Status](https://img.shields.io/github/actions/workflow/status/hirannor/hexagonal-architecture-asp-net-core/.github/workflows/dotnet.yml)](https://github.com/hirannor/hexagonal-architecture-asp-net-core/actions/workflows/dotnet.yml) | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) |\n\n---\n\n## Prerequisites for Development\n\n- **.NET 8.0 SDK**: Latest .NET SDK for optimal performance and security\n- **Visual Studio or VS Code**: IDEs that support .NET development, such as Visual Studio 2022 or VS Code with C# extensions\n- **Docker**: For containerized testing, especially with Testcontainers for integration testing\n- **SQL Server**: Required as the primary database for persistence\n\n## Technology Stack\n\n- **.NET 8.0**: The latest .NET platform, offering performance enhancements and new features\n- **ASP.NET Core**: Framework for building the REST API and handling HTTP requests\n- **Entity Framework Core**: ORM for database interactions with SQL Server\n- **MailKit**: SMTP email library for user notifications\n- **XUnit \u0026 Moq**: Testing frameworks for unit and integration testing\n- **Testcontainers**: For Docker-based integration testing with SQL Server\n- **Fluent Assertions**: Provides a fluent syntax for assertions in unit tests\n\n---\n\n## Adapter Configuration\n\nFollowing Hexagonal Architecture principles, this project is highly modular and configurable. You can specify the adapters for various application layers in `appsettings.json` or `appsettings.Development.json`.\n\n### Sample Configuration\n\n```json\n{\n  \"Adapter\": {\n    \"Web\": \"Rest\",\n    \"Authentication\": \"AspNetIdentity\",\n    \"Persistence\": \"EntityFramework\",\n    \"Messaging\": \"EventBus\",\n    \"Notification\": \"Email\"\n  }\n}\n```\n\n### Available Adapters\n\n- **Authentication**:\n  - AspNetIdentity (manages authentication and roles using ASP.NET Identity)\n- **Persistence**:\n  - EntityFramework (primary storage with SQL Server)\n  - InMemory (demonstration adapter, not fully implemented)\n- **Notification**:\n  - Email (SMTP notifications via MailKit)\n  - Mock (for testing)\n- **Messaging**:\n  - EventBus (event-driven communication)\n- **Web**:\n  - Rest (enables REST API for user interaction)\n\n#### Important Notes:\n\n- **Persistence Adapter**: Ensure to provide a valid SQL Server connection string for `DefaultConnection`.\n\n  ```json\n  {\n    \"ConnectionStrings\": {\n      \"DefaultConnection\": \"\u003cYOUR_CONNECTION_STRING\u003e\"\n    }\n  }\n  ```\n\n- **Email Adapter**: Configure SMTP details for sending emails.\n\n  ```json\n  {\n    \"EmailSettings\": {\n      \"SmtpServer\": \"smtp.yourprovider.com\",\n      \"Port\": 587,\n      \"Username\": \"your-email@example.com\",\n      \"Password\": \"your-email-password\",\n      \"FromEmail\": \"your-email@example.com\"\n    }\n  }\n  ```\n\n---\n\n## API Documentation\n\nFor detailed API exploration, you can access **Swagger UI** at [http://localhost:5194/swagger/index.html](http://localhost:5194/swagger/index.html).\n\n### Available Endpoints\n\n#### **Registration**\n\nRegisters a new user with the system.\n\n```\ncurl -X 'POST'   'http://localhost:5194/api/register'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{\n    \"username\": \"mockuser\",\n    \"emailAddress\": \"mock.user@local.com\",\n    \"password\": \"#TestPassword123\",\n    \"firstName\": \"Mock\",\n    \"lastName\": \"User\",\n    \"birthOn\": \"1990-01-01\"\n  }'\n```\n\n#### **Authentication**\n\nAuthenticates a user and returns a JWT token.\n\n```\ncurl -X 'POST'   'http://localhost:5194/api/auth'   -H 'accept: application/json'   -H 'Content-Type: application/json'   -d '{\n    \"username\": \"mockuser\",\n    \"password\": \"#TestPassword123\"\n  }'\n```\n\n#### **Get Personal Details**\n\nFetches the details of a specific user.\n\n```\ncurl -X 'GET'   'http://localhost:5194/api/customers/{username}'   -H 'accept: application/json'   -H 'Authorization: Bearer {your_jwt_token}'\n```\n\n#### **Change Personal Details**\n\nUpdates a user's personal information.\n\n```\ncurl -X 'PATCH'   'http://localhost:5194/api/customers/{username}'   -H 'accept: application/json'   -H 'Authorization: Bearer {your_jwt_token}'   -H 'Content-Type: application/json'   -d '{\n    \"address\": {\n      \"street\": {\n        \"streetName\": \"Main Street\",\n        \"streetNumber\": \"123\"\n      },\n      \"postalCode\": \"12345\",\n      \"city\": \"Sample City\",\n      \"country\": \"Sample Country\"\n    }\n  }'\n```\n\n#### **Change Email Address**\n\nChanges the user’s registered email address.\n\n```\ncurl -X 'PUT'   'http://localhost:5194/api/customers/{username}/email-address'   -H 'accept: application/json'   -H 'Authorization: Bearer {your_jwt_token}'   -H 'Content-Type: application/json'   -d '{\n    \"oldEmailAddress\": \"old.user@localhost.com\",\n    \"newEmailAddress\": \"new.user@localhost.com\"\n  }'\n```\n\n#### **Change Password**\n\nUpdates a user's password.\n\n```\ncurl -X 'PUT'   'http://localhost:5194/api/customers/{username}/password'   -H 'accept: application/json'   -H 'Authorization: Bearer {your_jwt_token}'   -H 'Content-Type: application/json'   -d '{\n    \"oldPassword\": \"#TestPassword123\",\n    \"newPassword\": \"#NewPassword456\"\n  }'\n```\n\n---\n\n## Pre-defined Customer Credentials\n\n| Username        | Password          | Email Address               |\n|-----------------|-------------------|-----------------------------|\n| janedoe         | #TestPassword123  | jane.doe@localhost.com      |\n| michaeljackson  | #TestPassword123  | michael.jackson@localhost.com |\n| sarahconnor     | #TestPassword123  | sarah.connor@localhost.com  |\n| willsmith       | #TestPassword123  | will.smith@localhost.com    |\n| emilyblunt      | #TestPassword123  | emily.blunt@localhost.com   |\n\n---\n\n## Development and Contribution\n\nTo run the project locally, ensure SQL Server is configured, Docker is running for Testcontainers, and the required connection strings and email settings are properly set. Contributions are welcome to further improve this example. Please follow the coding standards, and consider submitting issues or feature requests if you notice areas of improvement.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirannor%2Fhexagonal-architecture-asp-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirannor%2Fhexagonal-architecture-asp-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirannor%2Fhexagonal-architecture-asp-net/lists"}