Skip to content

Job Processing API demo project — Clean Architecture + Background Processing + Middlewares + Authentication + Unit Testing

Notifications You must be signed in to change notification settings

yuniko-software/dotnet-async-jobs-demo

Repository files navigation

Job Migration Platform API

JobMigrationPlatform API demo project — Clean Architecture + Background Processing + Middlewares + Authentication + Unit Testing

Overview

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.

Architecture

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

Features

  • 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

API Endpoints

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

Authentication

The API requires Basic Authentication (except for Swagger UI).

  • Username: testuser
  • Password: 1Q2W3E4R

Running the project

Prerequisites

  • .NET 9 SDK
  • Docker & Docker Compose

Run with Docker Compose

docker-compose up --build

Run in Visual Studio

  • Run MongoDb container
    docker-compose up mongodb
    
    
  • Run API in Debug mode → Visual Studio F5

Testing

Unit tests are implemented using xUnit and Moq.

To run tests

dotnet test

About

Job Processing API demo project — Clean Architecture + Background Processing + Middlewares + Authentication + Unit Testing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published