How turkayurkmez/ecommerce works
Project type and purpose
• This is a microservices-based e-commerce platform built on .NET 9, employing Domain-Driven Design, Clean Architecture, and event-driven communication.
• Separate bounded contexts for Basket, Catalog, and Identity services, plus shared building blocks and a message/Event bus for inter-service events.
File structure
• Top-level directories:
• src/BuildingBlocks – common utilities (Behaviors, Middleware, EventBus, MessageBroker)
• src/Services – three service folders: Basket, Catalog, Identity.
• Each service follows the Clean Architecture layers:
• .API (presentation / gRPC & HTTP endpoints)
• .Application (use-cases, MediatR commands & queries)
• .Domain (entities, domain events, interfaces)
• .Infrastructure (persistence, Redis or EF Core, event handlers)
• Infrastructure also contains configuration for Redis (Basket), SQL migrations (Catalog, Identity), RabbitMQ settings, and MassTransit publisher.
README for additional insights
• Confirms microservices using gRPC for inter-service calls, Redis for basket persistence, MediatR for domain events, and Clean Architecture layering.
• Mentions Docker Compose possibly used for orchestration, though not in file tree.
Main components and relationships
a. Components to show:
• Basket Service:
• API (HTTP/gRPC)
• Application (MediatR)
• Domain (ShoppingCart aggregate)
• Infra (Redis repository, domain event handlers)
• Redis instance
• Catalog Service:
• API (HTTP)
• Application (commands/queries)
• Domain (Product, Category aggregates)
• Infra (EF Core DbContext, SQL database)
• Identity Service:
• API (HTTP)
• Application (Auth, Roles, Users use cases)
• Domain (User, Role aggregates)
• Infra (EF Core DbContext, SQL database)
• Common Building Blocks:
• ECommerce.Common: middleware, behaviors, extensions
• ECommerce.EventBus: integration event definitions, RabbitMQ settings
• ECommerce.MessageBroker: publisher/consumer abstractions (MassTransit)
• External Infra:
• Redis cache
• RabbitMQ broker
• SQL Databases (CatalogDb, IdentityDb)
b. Relationships & interactions:
• API-layer receives HTTP or gRPC calls from front-end or other services.
• Application layer dispatches commands/queries to domain via MediatR.
• Domain events are raised and handled internally (persisted, side effects) and published as integration events via message broker.
• ECommerce.EventBus publishes/publishes to RabbitMQ.
• Other services subscribe (via ECommerce.MessageBroker consumers) to events (e.g., Basket listens for ProductPriceChanged).
• Services communicate via gRPC for synchronous calls (BasketGrpcService) when needed.
c. Architectural patterns/design principles:
• Clean Architecture (onion layering) per service
• Domain-Driven Design with aggregates and domain events
• CQRS style (commands/queries via MediatR)
• Event-driven async communication via RabbitMQ
• Distributed caching (Redis) for basket
d. Key technologies/frameworks:
• .NET 9, C# 12
• MediatR library
• gRPC (.proto definitions in Basket)
• MassTransit for RabbitMQ integration
• StackExchange.Redis
• Entity Framework Core for SQL persistence
• Newtonsoft.Json for serialization