OpenDDD.NET
2.0.0-alpha.3
dotnet add package OpenDDD.NET --version 2.0.0-alpha.3
NuGet\Install-Package OpenDDD.NET -Version 2.0.0-alpha.3
<PackageReference Include="OpenDDD.NET" Version="2.0.0-alpha.3" />
paket add OpenDDD.NET --version 2.0.0-alpha.3
#r "nuget: OpenDDD.NET, 2.0.0-alpha.3"
// Install OpenDDD.NET as a Cake Addin #addin nuget:?package=OpenDDD.NET&version=2.0.0-alpha.3&prerelease // Install OpenDDD.NET as a Cake Tool #tool nuget:?package=OpenDDD.NET&version=2.0.0-alpha.3&prerelease
OpenDDD.NET
OpenDDD.NET is an open-source framework for domain-driven design (DDD) development using C# and .NET. It provides a set of powerful tools and abstractions to help developers build scalable, maintainable, and testable applications following the principles of DDD.
Key Features
- Aggregates: Define domain aggregates with clear boundaries and encapsulate domain logic within them.
- Entities and Value Objects: Create entities and value objects to represent domain concepts and ensure strong type safety.
- Repositories: Define repositories to abstract away data access and enable persistence of domain objects.
- Domain Events: Implement domain events to facilitate communication between domain objects and decouple them from each other.
- Integration Events: Implement integration events to facilitate communication between bounded contexts and decouple them from each other.
- Application Services: Use application services to coordinate the execution of domain logic and manage transactions.
- Dependency Injection: Leverage the built-in dependency injection support in .NET for easy integration with your application.
- Testability: Comes prepared with base test classes for efficient and simple unit testing of actions.
- Horizontal Scaling: Seamlessly scale your application horizontally to handle increased traffic and demand.
Basic Concepts
The map below visually represents the key concepts and their interrelationships.
Supported Versions
- .NET Core 3.1
- .NET 5
- .NET 6 (upcoming)
- .NET 7 (upcoming)
- .NET 8 (upcoming)
Getting Started
To get started with OpenDDD.NET, follow these simple steps:
- Install the NuGet package: Use the NuGet package manager or the .NET CLI to add the OpenDDD.NET package to your project.
dotnet add package OpenDDD.NET
- Install the project template: If you want to quickly scaffold new projects using OpenDDD.NET, you can install the OpenDDD.NET project template NuGet package.
dotnet new install OpenDDD.NET-Templates
- Create a new project: Use the OpenDDD.NET project template to create a new project with the necessary files, folder structure, and initial configuration already set up.
dotnet new opendddnet-sln-netcore31 -n "YOUR_SOLUTION_NAME"
- Start building your application: Utilize the power of OpenDDD.NET to build scalable and maintainable applications following the principles of DDD.
Example Usage
In your Startup.cs
file, you'll need to register various services and configure the middleware pipeline to set up your project for OpenDDD.NET.
Here's an example of how to typically configure your application in Startup.cs:
using Microsoft.Extensions.DependencyInjection;
using OpenDDD.Infrastructure.Services.Serialization;
using YourCrawlingContext.Domain.Model.Property;
using YourCrawlingContext.Infrastructure.Ports.Adapters.Site.ThailandProperty;
namespace YourCrawlingContext.Main
{
public class Startup
{
// ... (existing code)
public void ConfigureServices(IServiceCollection services)
{
// ... (other service configurations)
// Event processor
services.AddEventProcessorHostedService(Configuration);
services.AddEventProcessorDatabaseConnection(Configuration);
services.AddEventProcessorMessageBrokerConnection(Configuration);
services.AddEventProcessorOutbox();
// Action services
services.AddActionDatabaseConnection(Configuration);
services.AddActionMessageBrokerConnection(Configuration);
services.AddActionOutbox();
// Actions
services.AddAction<CrawlSearchPage.Action, CrawlSearchPage.Command>();
services.AddAction<GetProperties.Action, GetProperties.Command>();
// Publishers
services.AddDomainPublisher();
services.AddIntegrationPublisher();
// Listeners
services.AddDomainEventListener(SearchPageCrawledListener);
services.AddIntegrationEventListener(IcAccountCreatedListener);
// Repositories
services.AddRepository<IPropertyRepository, PropertyRepository>();
services.AddRepository<ISiteRepository, SiteRepository>();
}
// ... (existing code)
}
}
Example:
Implement one of the Actions
that collectively form your Application Service
:
using OpenDDD.Application;
using OpenDDD.Domain.Model.Event;
using YourCrawlingContext.Domain.Model;
// ... (other imports)
namespace YourCrawlingContext.Application
{
public class CrawlSearchPageAction : BaseAction<Command, SearchResults>
{
private readonly ISiteRepository _siteRepository;
public CrawlSearchPageAction(
IActionDatabaseConnection actionDatabaseConnection,
IActionOutbox outbox,
ISiteRepository siteRepository,
ISomeWebSitePort someWebSiteAdapter,
IDomainPublisher domainPublisher,
ILogger<CrawlSearchPageAction> logger)
: base(actionDatabaseConnection, outbox, someWebSiteAdapter, domainPublisher, logger)
{
_siteRepository = siteRepository;
}
public override async Task<SearchResults> ExecuteAsync(Command command, ActionId actionId, CancellationToken ct)
{
var site = await GetAggregateOrThrowAsync(command.SiteId, _siteRepository, actionId, ct);
var siteAdapter = GetSiteAdapterOrThrow(command.SiteId);
var searchResults = await site.CrawlSearchPageAsync(siteAdapter, _domainPublisher, actionId, ct);
await _siteRepository.SaveAsync(site, actionId, ct);
return searchResults;
}
}
}
Example:
Publish an Domain Event
from an Aggregate Root
:
using OpenDDD.Application;
using OpenDDD.Domain.Model.AggregateRoot;
using OpenDDD.Domain.Model.Entity;
using OpenDDD.Domain.Model.Event;
// ... (other imports)
namespace YourCrawlingContext.Domain.Model.Site
{
public class Site : AggregateRoot, IAggregateRoot, IEquatable<Site>
{
public SiteId SiteId { get; set; }
public string Name { get; set; }
// ... (other methods)
public async Task<SearchResults.SearchResults> CrawlSearchPageAsync(ISitePort siteAdapter, IDomainPublisher domainPublisher, ActionId actionId, CancellationToken ct)
{
var searchResults = await siteAdapter.CrawlSearchPageAsync(ct);
await domainPublisher.PublishAsync(new SearchPageCrawled(SiteId, searchResults, actionId));
return searchResults;
}
// ... (other methods)
}
}
Release History
- v1.0.0-alpha.1 (2022-10-02): Initial alpha release.
- v1.0.0-alpha.2 (2022-10-09): Make the hexagonal architecture pattern more represented in the namespaces.
- v1.0.0-alpha.3 (2022-11-20): Refactor JwtToken and add IdToken.
For a complete list of releases and their changelogs, please visit the Releases page.
Note: We have just released an alpha version of major version 2 of this framework, and some features are still under development. Avoid using it in production environments and expect some code to not be implemented still.
Contributing
We welcome contributions from the community. To contribute to OpenDDD.NET, please follow these steps:
- Fork the repository and clone it to your local machine.
- Create a new branch for your feature or bug fix.
- Implement your changes and ensure that the existing tests pass.
- Write new tests to cover your changes and make sure they pass as well.
- Commit your changes and push them to your fork.
- Submit a pull request with a clear description of your changes and the problem they solve.
Please make sure to review our Contributing Guidelines before submitting a pull request.
License
OpenDDD.NET is licensed under the GPLv3 License. Feel free to use it in your own projects.
Acknowledgements
OpenDDD.NET is inspired by the principles and ideas of Domain-Driven Design (DDD) and the fantastic work done by the DDD community. We would like to thank all the contributors and supporters who have helped make this project possible.
Get in Touch
If you have any questions, suggestions, or feedback, please don't hesitate to reach out to us. You can find more information and ways to contact us on our Website.
Let's build better software together with OpenDDD.NET!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Azure.Messaging.ServiceBus (>= 7.5.1)
- CompareNETObjects (>= 4.77.0)
- dotenv.net (>= 3.1.1)
- Microsoft.ApplicationInsights (>= 2.20.0)
- Microsoft.AspNet.WebApi.WebHost (>= 5.2.8)
- Microsoft.AspNetCore.TestHost (>= 3.1.26)
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Logging (>= 6.0.0)
- Microsoft.Extensions.Logging.ApplicationInsights (>= 2.20.0)
- Microsoft.Extensions.Logging.Console (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Npgsql (>= 6.0.4)
- NSwag.AspNetCore (>= 13.15.10)
- PowerIAM (>= 2.3.0)
- RabbitMQ.Client (>= 6.2.2)
- System.IdentityModel.Tokens.Jwt (>= 6.17.0)
- WireMock.Net (>= 1.5.0)
- xunit (>= 2.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0-alpha.3 | 91 | 10/3/2023 |
2.0.0-alpha.2 | 77 | 10/3/2023 |
2.0.0-alpha.1 | 79 | 10/1/2023 |
1.0.0-alpha.17 | 90 | 6/27/2023 |
1.0.0-alpha.16 | 89 | 5/7/2023 |
1.0.0-alpha.15 | 99 | 5/1/2023 |
1.0.0-alpha.14 | 91 | 4/30/2023 |
1.0.0-alpha.13 | 92 | 4/28/2023 |
1.0.0-alpha.12 | 97 | 4/28/2023 |