JobMigrationPlatform API demo project — Clean Architecture + Background Processing + Middlewares + Authentication + Unit Testing
This project implements a Job Migration Platform API. The API allows clients to:
- Start new jobs
- Check job status
- Retrieve job processing logs
The system supports BULK and BATCH job types, and implements proper architecture patterns and best practices.
The project follows Clean Architecture principles and uses:
-
Domain Layer → Business entities, enums
-
Application Layer → Commands, Queries, Handlers, Interfaces
-
Infrastructure Layer → Repositories, BackgroundService, ExternalJobItemProcessor
-
API Layer → REST API with Controllers, Swagger documentation, Middlewares
Patterns used:
-
CQRS (Command Query Responsibility Segregation)
-
Mediator pattern via MediatR
-
Dependency Injection via .NET built-in container
-
HostedService for background job processing
-
Proper use of Middlewares:
-
Request Logging Middleware
-
Exception Handling Middleware
-
Basic Authentication Middleware
-
- Start new Job via API
- Process Jobs in background
- BULK job: process all items sequentially
- BATCH job: stop processing on first failure
- Check Job status via API
- Retrieve Job logs via API
- Proper logging across API and background processing
- Basic Authentication implemented = Unit tests covering Commands and Queries with proper mocking
Method | Endpoint | Description |
---|---|---|
POST | /api/jobs | Start a new job |
GET | /api/jobs/{id}/status | Get job status |
GET | /api/jobs/{id}/logs | Get job processing logs |
The API requires Basic Authentication (except for Swagger UI).
- Username: testuser
- Password: 1Q2W3E4R
- .NET 9 SDK
- Docker & Docker Compose
docker-compose up --build
- Run MongoDb container
docker-compose up mongodb
- Run API in Debug mode → Visual Studio F5
Unit tests are implemented using xUnit and Moq.
To run tests
dotnet test