A .NET 9 solution demonstrating a job queue architecture with AWS SQS, PostgreSQL, and background processing.
- Order Management
- Create orders with validation
- Track order status transitions
- Filter orders by status
- Job Queue System
- AWS SQS integration
- Automatic retry mechanism
- Job status tracking (Queued → Processing → Completed/Failed)
- Background Processing
- Worker service with .NET
BackgroundService - Batch job processing
- Worker service with .NET
- Database
- PostgreSQL relational storage
- Entity Framework Core migrations
- API
- Minimal API endpoints
- FluentValidation integration
- DTO-based request/response models
| Component | Technologies Used |
|---|---|
| Backend | .NET 9, C# 13 |
| Database | PostgreSQL, Entity Framework Core 8 |
| Messaging | AWS SQS |
| Architecture | Clean Architecture |
| Validation | FluentValidation, FluentResults |
| Containerization | Docker, Docker Compose |
OrderProcessing/
├── OrderProcessing.Api/ # Web API Layer
├── OrderProcessing.Domain/ # Domain Models, Interfaces and Errors
├── OrderProcessing.Infrastructure/ # Infrastructure Services
└── OrderProcessing.Worker/ # Background Processing
- Domain
- Models:
Order,Job - Interfaces:
IOrderRepository,IQueueService - Errors: Domain-specific error types
- Models:
- Infrastructure
- Data: EF Core DbContext, Repository
- Messaging: AWS SQS implementation
- API
- Minimal API endpoints
- Request/Response DTOs
- Validation handlers
- Worker
- Background job processing
- Queue polling implementation
- Docker Desktop
- .NET 9 SDK (for local development)
-
Clone the repository:
git clone https://github.com/aenvis/OrderProcessing.git cd OrderProcessing -
Start all services (PostgreSQL, API, and Worker):
docker-compose up --build -d
-
Apply database migrations (in a new terminal):
docker-compose exec api dotnet ef database update --project OrderProcessing.Infrastructure --startup-project ../OrderProcessing.Api -
The system is now ready:
- API: http://localhost:8080
- PostgreSQL: Available at
localhost:5432(user: postgres, password: postgres) - Worker: Running in background processing jobs
Create a test order:
curl -X POST http://localhost:8080/api/orders \
-H "Content-Type: application/json" \
-d '{"customerName":"Test Customer","items":[{"productName":"Sample","quantity":1,"unitPrice":29.99}]}'docker-compose down- .NET 9 SDK
- Docker Desktop
- AWS CLI (for local development)
# Start dependencies
docker-compose -f docker-compose.yml up -d
# Apply database migrations
dotnet ef database update --project OrderProcessing.Api# Start API
dotnet run --project OrderProcessing.Api
# Start Worker
dotnet run --project OrderProcessing.Worker| Endpoint | Method | Description |
|---|---|---|
POST /api/orders |
POST | Create new order |
GET /api/orders/{id} |
GET | Get order details |
GET /api/orders |
GET | List all orders |
GET /api/orders/status/{status} |
GET | Filter orders by status |
Sample Request:
POST /api/orders
Content-Type: application/json
{
"customerName": "John Doe",
"items": [
{
"productName": "Sample Product",
"quantity": 1,
"unitPrice": 29.99
}
]
}-
Domain-Centric Design
- Business logic isolated in Domain project
- Explicit error handling with FluentResults
- Entity validation in domain models
-
Queue Patterns
- SQS message visibility timeouts
- Dead-letter queue support
- Batch message processing
-
Worker Service
- Exponential backoff retries
- Transactional database updates
- Graceful shutdown handling
- Add authentication/authorization
- Add performance metrics
- Containerize entire solution
- Load testing scenarios