This ASP.NET Core system delivers a scalable, event-driven e-commerce order processor. It showcases key production patterns: a decoupled microservices architecture, reliable asynchronous message processing with RabbitMQ, and robust distributed transaction management utilizing PostgreSQL.
┌─────────────┐ ┌──────────────┐ ┌──────────────────┐
│ Client/UI │ ──────> │ OrderAPI │ ──────> │ RabbitMQ │
│ │ <────── │ (Publisher) │ │ Message Broker │
└─────────────┘ └──────────────┘ └──────────────────┘
│
┌────────────────────────────┼────────────────────┐
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Payment Worker │ │ Inventory Worker │ │ Email Worker │
│ (Consumer) │ │ (Consumer) │ │ (Consumer) │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
└────────────────────────────┼────────────────────┘
▼
┌──────────────────┐
│ PostgreSQL │
│ Database │
└──────────────────┘
- ✅ Asynchronous Order Processing - Non-blocking order placement with immediate API response
- ✅ Event-Driven Architecture - Loose coupling between services using message queues
- ✅ Distributed Transaction Management - Multi-step order workflow with status tracking
- ✅ Fault Tolerance - Message acknowledgment, retry logic, and dead letter queue support
- ✅ Data Persistence - Full ACID compliance with PostgreSQL
- ✅ Audit Trail - Complete order history with timestamps and status transitions
- 🔐 Secure Configuration Management - User Secrets for development, environment variables for production
- 📊 Real-time Status Tracking - Monitor order progress across multiple processing stages
- 🔄 Automatic Retries - Failed messages are automatically requeued for processing
- 📝 Comprehensive Logging - Structured logging with correlation IDs
- 🔍 Distributed Tracing - OpenTelemetry traces exported to Jaeger across the API and workers
- 🎯 Input Validation - FluentValidation for robust request validation
- 🐳 Docker Support - Full containerization with Docker Compose
- 📚 API Documentation - Interactive Swagger/OpenAPI documentation
- Clone the repository
git clone https://github.com/yourusername/PixelMartOrderProcessor.git
cd PixelMartOrderProcessor- Start infrastructure services
docker-compose up -dThis starts PostgreSQL, RabbitMQ, and Jaeger containers.
- Configure User Secrets (for each project)
# OrderApi
cd OrderApi
dotnet user-secrets init
dotnet user-secrets set "DB_PASSWORD" "your_postgres_password"
# PaymentWorker
cd ../PaymentWorker
dotnet user-secrets init
dotnet user-secrets set "DB_PASSWORD" "your_postgres_password"
# InventoryWorker
cd ../InventoryWorker
dotnet user-secrets init
dotnet user-secrets set "DB_PASSWORD" "your_postgres_password"
# EmailWorker
cd ../EmailWorker
dotnet user-secrets init
dotnet user-secrets set "DB_PASSWORD" "your_postgres_password"- Apply database migrations
cd OrderApi
dotnet ef database update-
Run the application
Open 4 separate terminal windows:
# Terminal 1 - API
cd OrderApi (PixelMartOrderProcessor)
dotnet run
# Terminal 2 - Payment Worker
cd PaymentWorker
dotnet run
# Terminal 3 - Inventory Worker
cd InventoryWorker
dotnet run
# Terminal 4 - Email Worker
cd EmailWorker
dotnet run-
Access the application
- API:
https://localhost:5001 - Swagger UI:
https://localhost:5001/swagger - RabbitMQ Management:
http://localhost:15672(guest/guest) - Jaeger UI:
http://localhost:16686
- API:
-
Place a new order
Send a
POSTrequest to create an order. TheIdempotency-Keyheader is required (use a unique value per order; repeat the same key to safely retry without creating duplicates).
curl -X POST https://localhost:7197/api/orders \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"customerEmail": "customer@example.com",
"totalAmount": 149.97,
"items": [
{
"productId": "SKU-001",
"productName": "Wireless Mouse",
"quantity": 1,
"price": 29.99
},
{
"productId": "SKU-002",
"productName": "Mechanical Keyboard",
"quantity": 2,
"price": 59.99
}
]
}'On Windows PowerShell, generate a unique idempotency key with [guid]::NewGuid().ToString() instead of uuidgen.
The API provides built-in health monitoring for reliable observability. All critical components (PostgreSQL DB, RabbitMQ, and the three background workers) are actively monitored.
GET /health— Overall system health (API + DB + RabbitMQ + Workers)GET /health/ready— Readiness probeGET /health/live— Liveness probeGET /health-ui— Interactive health dashboard
The API and workers use OpenTelemetry for traces and metrics—instrumenting ASP.NET Core, HTTP clients, EF Core, RabbitMQ message propagation, and custom activities. Spans are exported to Jaeger via OTLP (http://localhost:4317, configurable in appsettings.Development.json). Jaeger starts automatically with docker-compose up -d, or on its own:
docker-compose -f docker-compose.jaeger.yml up -dOpen Jaeger UI at http://localhost:16686, place an order, then search for traces from OrderApi to follow the request through payment, inventory, and email workers.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request