This document serves as the Single Source of Truth for the architectural decisions, technology stack, and development discipline of the ECommerceStock project.
- Scope: A high-performance system centered on inventory, warehouse, and operation management.
- Architecture: Event-Driven Modular Monolith. Built with a microservices mindset but deployed as a scalable monolithic structure.
- Design Philosophy: Domain-Driven Design (DDD).
- Internal Module Communication (Synchronous/Transactional): Uses MediatR for Domain Events .
- Automatic Dispatch: When an entity is saved,
AppDbContextautomatically dispatches events to local handlers (e.g.,ProductCreatedEvent->ProductCreatedEventHandler) . - External/Inter-Module Communication (Asynchronous): Uses RabbitMQ with MassTransit integration.
- Integration Events: After a successful transaction, an Integration Event is published to the broker to notify other modules (e.g., notifying the Inventory module after a Catalog update).
- Framework: .NET 10 LTS.
- Database: SQL Server 2022 (Running on Docker).
- Message Broker: RabbitMQ with MassTransit.RabbitMQ.
- Tooling: Visual Studio 2026, WSL 2 (Ubuntu), Docker Desktop.
- Separation: All source code is located under the
src/folder to separate business logic from configuration and documentation.
- AppDbContextFactory: Uses
AppDomain.CurrentDomain.BaseDirectoryto dynamically locateappsettings.jsonduring design-time (migrations) . - Single Source of Truth: Ensures a shared connection string between the API and Infrastructure layers .
- Automatic Auditing: An
UpdateAuditableEntitiesInterceptoris registered to automatically populateCreatedAtandUpdatedAtfields for all entities deriving fromBaseEntity.
- Rich Domain Models: Entities use private setters and encapsulated business methods (e.g.,
UpdatePrice,AddDomainEvent) to prevent invalid state changes . - Value Objects: Complex types like
Money,Sku, andAddressare implemented as Value Objects for structural equality and validation .
The system is divided into 6 main modules, managing 38 entity types across dedicated database schemas:
- Catalog: Products, Brands, Categories, Variants/SKUs.
- Inventory (WMS): Warehouses, Bins, Stock Ledgers, Adjustments.
- Purchasing: Suppliers, Purchase Orders, Goods Receipts.
- Sales (OMS): Customers, Sales Orders, Invoices, Shipments.
- Pricing: Price Lists, Dynamic Discounts.
- Identity: User Management and IAM.
Last Updated: March 21, 2026