Skip to content

Proposal: Introduce MediatR to decouple controllers from services #32

Description

@rajfaujdar1688-cmyk

Problem

Currently, controllers directly depend on application services, which tightly couples the API layer with business logic. As the codebase grows, this can make the application harder to maintain, test, and extend.

Proposal

Introduce MediatR as a mediator layer between controllers and business logic.
Controllers would delegate requests to MediatR commands/queries instead of calling services directly.

Benefits

  • Improved separation of concerns
  • Better testability of business logic
  • Clearer request/response flow (CQRS-friendly)
  • Easier introduction of cross-cutting concerns (logging, validation, transactions)

Scope

  • Incremental adoption (start with a single endpoint)
  • No breaking changes
  • Existing services will remain intact initially

If this approach sounds acceptable, I can prepare a small, focused PR demonstrating the pattern on one controller action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions