NorthwindTraders
Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.
Top Related Projects
Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
Clean Architecture Solution Template for ASP.NET Core
Full Modular Monolith application with Domain-Driven Design approach.
Examples and Tutorials of Event Sourcing in .NET
Quick Overview
NorthwindTraders is a sample application built using ASP.NET Core and Entity Framework Core, showcasing Clean Architecture principles. It demonstrates how to implement a modern web application using domain-driven design and CQRS (Command Query Responsibility Segregation) patterns, providing a practical example for developers to learn from and use as a reference.
Pros
- Implements Clean Architecture, promoting separation of concerns and maintainability
- Uses modern ASP.NET Core and Entity Framework Core technologies
- Demonstrates CQRS pattern implementation
- Includes comprehensive unit and integration tests
Cons
- May be overly complex for simple applications or beginners
- Requires understanding of multiple design patterns and architectural concepts
- Limited documentation for some advanced features
- Sample data might not cover all real-world scenarios
Code Examples
- Domain Entity Example:
public class Product : AuditableEntity
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public int? SupplierId { get; set; }
public int? CategoryId { get; set; }
public string QuantityPerUnit { get; set; }
public decimal? UnitPrice { get; set; }
public short? UnitsInStock { get; set; }
public short? UnitsOnOrder { get; set; }
public short? ReorderLevel { get; set; }
public bool Discontinued { get; set; }
public Category Category { get; set; }
public Supplier Supplier { get; set; }
}
- CQRS Query Example:
public class GetProductsListQuery : IRequest<ProductsListVm>
{
public class GetProductsListQueryHandler : IRequestHandler<GetProductsListQuery, ProductsListVm>
{
private readonly IApplicationDbContext _context;
private readonly IMapper _mapper;
public GetProductsListQueryHandler(IApplicationDbContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}
public async Task<ProductsListVm> Handle(GetProductsListQuery request, CancellationToken cancellationToken)
{
var products = await _context.Products
.ProjectTo<ProductDto>(_mapper.ConfigurationProvider)
.OrderBy(p => p.ProductName)
.ToListAsync(cancellationToken);
var vm = new ProductsListVm
{
Products = products,
CreateEnabled = true
};
return vm;
}
}
}
- Controller Example:
[Authorize]
public class ProductsController : ApiController
{
[HttpGet]
public async Task<ActionResult<ProductsListVm>> GetAll()
{
return await Mediator.Send(new GetProductsListQuery());
}
[HttpGet("{id}")]
public async Task<ActionResult<ProductDto>> Get(int id)
{
return await Mediator.Send(new GetProductQuery { Id = id });
}
[HttpPost]
public async Task<ActionResult<int>> Create(CreateProductCommand command)
{
return await Mediator.Send(command);
}
}
Getting Started
-
Clone the repository:
git clone https://github.com/jasontaylordev/NorthwindTraders.git
-
Navigate to the project directory:
cd NorthwindTraders
-
Restore dependencies and build the solution:
dotnet restore dotnet build
-
Update the database:
cd src/WebUI dotnet ef database update
-
Run the application:
dotnet run
The application should now be running on https://localhost:5001
.
Competitor Comparisons
Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
Pros of eShopOnWeb
- More comprehensive e-commerce functionality, including a catalog, basket, and ordering system
- Demonstrates microservices architecture and containerization with Docker
- Includes examples of Azure integration and cloud-native development practices
Cons of eShopOnWeb
- More complex and potentially overwhelming for beginners
- Less focus on clean architecture principles compared to NorthwindTraders
- Requires more setup and resources to run due to its microservices nature
Code Comparison
NorthwindTraders:
public class CreateCustomerCommand : IRequest<int>
{
public string Id { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }
}
eShopOnWeb:
public class CatalogItem
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public string PictureUri { get; set; }
}
The code snippets show that NorthwindTraders focuses on CQRS patterns with command objects, while eShopOnWeb uses more traditional entity models. This reflects the different architectural approaches of the two projects.
A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
Pros of Craftsman
- Provides a CLI tool for generating boilerplate code and project structures
- Offers more flexibility in customizing the generated code and architecture
- Supports multiple database providers and authentication options
Cons of Craftsman
- Steeper learning curve due to its extensive configuration options
- Less comprehensive documentation compared to NorthwindTraders
- May require more setup time for complex projects
Code Comparison
NorthwindTraders:
public class CreateCustomerCommand : IRequest<int>
{
public string Name { get; set; }
public string Address { get; set; }
}
Craftsman:
public class CustomerForCreationDto
{
public string Name { get; set; }
public string Address { get; set; }
}
Both repositories demonstrate clean architecture principles, but Craftsman focuses on code generation and customization, while NorthwindTraders provides a more complete sample application. Craftsman's approach allows for greater flexibility in project structure and technology choices, but may require more initial setup. NorthwindTraders offers a more straightforward example of Clean Architecture implementation, making it easier for developers to understand and adopt the pattern quickly.
Clean Architecture Solution Template for ASP.NET Core
Pros of CleanArchitecture
- More comprehensive implementation of Clean Architecture principles
- Includes additional features like API versioning and Swagger documentation
- Better suited for larger, more complex applications
Cons of CleanArchitecture
- Steeper learning curve due to its more complex structure
- May be overkill for smaller projects or prototypes
- Requires more initial setup and configuration
Code Comparison
NorthwindTraders:
public class CreateCustomerCommand : IRequest<int>
{
public string Id { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
}
CleanArchitecture:
public class CreateTodoItemCommand : IRequest<int>
{
public int ListId { get; set; }
public string Title { get; set; }
}
Both repositories demonstrate command objects, but CleanArchitecture uses a more streamlined approach with fewer properties, reflecting its focus on simplicity and separation of concerns.
Full Modular Monolith application with Domain-Driven Design approach.
Pros of modular-monolith-with-ddd
- Implements a more complex, real-world architecture with modular design and DDD principles
- Provides extensive documentation on architectural decisions and patterns used
- Includes advanced features like CQRS, event sourcing, and integration events
Cons of modular-monolith-with-ddd
- Higher complexity may be overwhelming for beginners or smaller projects
- Less focus on UI/frontend implementation compared to NorthwindTraders
- Steeper learning curve due to advanced architectural concepts
Code Comparison
modular-monolith-with-ddd:
public class CreateMeetingGroupCommand : CommandBase<Guid>
{
public string Name { get; }
public string Description { get; }
public string MemberId { get; }
public string LocationCity { get; }
public string LocationCountryCode { get; }
}
NorthwindTraders:
public class CreateProductCommand : IRequest<int>
{
public string ProductName { get; set; }
public int? SupplierId { get; set; }
public int? CategoryId { get; set; }
public string QuantityPerUnit { get; set; }
public decimal? UnitPrice { get; set; }
}
Both repositories demonstrate clean code practices and use of CQRS pattern, but modular-monolith-with-ddd shows a more complex command structure with additional properties and inheritance from a base command class.
Examples and Tutorials of Event Sourcing in .NET
Pros of EventSourcing.NetCore
- Focuses on event sourcing patterns, providing in-depth examples and implementations
- Offers a comprehensive set of samples covering various aspects of event sourcing
- Includes detailed documentation and explanations of event sourcing concepts
Cons of EventSourcing.NetCore
- More complex and specialized, potentially steeper learning curve for beginners
- Less focus on general application architecture and patterns
- May require additional effort to adapt to specific business requirements
Code Comparison
EventSourcing.NetCore:
public class ShoppingCart : Aggregate
{
public void AddProduct(Guid productId, int quantity)
{
Apply(new ProductAddedToShoppingCart(Id, productId, quantity));
}
}
NorthwindTraders:
public class CreateProductCommand : IRequest<int>
{
public string ProductName { get; set; }
public int? SupplierId { get; set; }
public int? CategoryId { get; set; }
public string QuantityPerUnit { get; set; }
}
EventSourcing.NetCore focuses on event-driven design, while NorthwindTraders demonstrates a more traditional CRUD-based approach. The EventSourcing.NetCore example shows how events are applied to an aggregate, whereas NorthwindTraders uses command objects for operations.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Northwind Traders
Description
This repository has been archived and is no longer actively maintained or supported. The project was initially developed to demonstrate the simplest approach to Clean Architecture with .NET Core. While it is no longer actively maintained, feel free to explore the codebase and adapt it to your own needs if it serves as a useful reference.
For an updated version of this project, you can check out the Clean Architecture Solution Template. The Clean Architecture Solution Template is a new project that demonstrates the simplest approach to Clean Architecture with .NET. It is actively maintained and supported, providing an improved and up-to-date implementation of the principles showcased in this archived repository.
Project Status
This project has been archived, which means that no further updates, bug fixes, or support will be provided. You can still fork the repository and make modifications if desired.
Installation and Usage
As this project is archived, there are no installation instructions or usage guidelines provided. However, if you decide to fork the repository, make sure to update any necessary dependencies, configurations, or settings.
Contributing
Contributions to this project are no longer accepted as it has been archived. You can still fork the repository and work on your own version.
Issues
As this project is archived, any existing issues have also been closed. You can refer to the existing issues for historical context, but no new issues will be addressed.
License
This project is licensed under the MIT License. Please review the license file for more information.
Contact
As this project is archived, there is no active contact person or maintainer. You may refer to the contributors listed in the repository for individual contact information.
Top Related Projects
Sample ASP.NET Core 8.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
A .NET scaffolding tool to help you stop worrying about boilerplate and focus on your business logic 🚀
Clean Architecture Solution Template for ASP.NET Core
Full Modular Monolith application with Domain-Driven Design approach.
Examples and Tutorials of Event Sourcing in .NET
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot