EventDrivenEcommerce

Back to ASP.Net Core

A microservices-based e-commerce backend built with ASP.NET Core. Four independent services communicate asynchronously through RabbitMQ. Implements the Outbox Pattern for transactional message guarantees, idempotent consumers for safe at-least-once delivery, and CorrelationId-based distributed tracing across service boundaries.

Tech

  • ASP.NET Core
  • C#
  • Microservices
  • Event-Driven Architecture
  • RabbitMQ
  • Outbox Pattern
  • PostgreSQL
  • Docker
  • API Versioning

Services

  • Catalog.Api — product catalogue management.
  • Order.Api — order creation with idempotency key support; publishes domain events on order state changes.
  • Payment.Api — consumes order events and processes payments; publishes payment result events.
  • Notification.Api — consumes downstream events and handles customer notifications.

Architecture

  • Outbox Pattern — domain events are written to an outbox table in the same database transaction as the business entity, then published to RabbitMQ by a background job. Guarantees no message is lost even if the broker is temporarily unavailable.
  • Idempotent consumers — each consumer tracks processed message IDs to prevent duplicate side-effects under at-least-once delivery semantics.
  • Dead-letter queues & retries — failed messages are requeued with configurable retry logic; exhausted retries are routed to a dead-letter exchange for investigation.
  • Manual message acknowledgment — messages are acknowledged only after successful processing, preventing silent data loss.
  • CorrelationId tracing — a correlation ID is propagated in every message and HTTP request header, enabling end-to-end request tracing across service boundaries.
  • API Versioning — versioned endpoints allow backward-compatible evolution of public service contracts.
  • Health Checks — each service exposes a health endpoint; Docker Compose uses it to coordinate startup order.