Ordering.API Layer Exposing Minimal Api Endpoints with Carter and REPR Pattern

Mehmet Ozkaya
4 min readMar 27, 2024


We are going to develop Ordering.API Layer for exposing Minimal REST APIs w/ Carter following REPR Pattern.

I have just published course — .NET 8 Microservices: C# 12, DDD, CQRS, Vertical/Clean Architecture.

The Ordering.API layer, an integral component of our Ordering microservice, is being sculpted to meet these needs by adopting the Clean Architecture principles and leveraging the Carter library to expose minimal REST APIs. This initiative is underscored by the implementation of the REPR (Request-Endpoint-Response) design pattern, which harmonizes with the CQRS and MediatR Request Lifecycle, setting a new standard in microservices API development.

Simplifying API Development with REPR Pattern

The REPR pattern, standing for Request, Endpoint, and Response, offers a simplified and structured approach to developing REST API endpoints. This pattern ensures a clear delineation of responsibilities, making API endpoints more intuitive and single-responsibility oriented. By adopting this pattern, we’re able to define endpoints with clarity, where each component has a distinct role:

  • Request: The incoming data structure expected by the endpoint.
  • Endpoint: The core logic that processes the incoming request.
  • Response: The outgoing data structure returned by the endpoint.

This design not only enhances the maintainability of our APIs but also aligns perfectly with the principles of Clean Architecture, ensuring each layer and component has a well-defined responsibility.

CQRS and MediatR in Action

Our journey through the API request lifecycle unveils a seamless flow from the presentation layer, facilitated by Carter endpoints, to the domain layer where business logic resides.

This journey is orchestrated by MediatR, which acts as the conductor, ensuring that commands and queries are processed by the appropriate handlers, leading to a well-organized and maintainable codebase.

Creating Order APIs with Precision

The development of the Ordering.API layer is a meticulous process where we’re dedicated to crafting endpoints that not only meet the functional requirements but also adhere to the architectural principles we’ve set. These include:

  • Developing CRUD Endpoints: For managing orders, encapsulating the business logic within the domain layer and exposing it through minimalistic and clean APIs.
  • Implementing Health Checks: Ensuring our microservice is always in its prime, ready to serve requests efficiently.
  • Cross-Cutting Concerns: Addressing concerns like exception handling at the API layer, ensuring a consistent and graceful handling of unexpected scenarios.

Embracing Minimalism with Carter

Carter, a library that enriches the ASP.NET Core routing to build web applications and APIs, is at the heart of our approach to expose minimal REST APIs.

It’s not just about reducing the boilerplate code; it’s about embracing a philosophy where every line of code serves a purpose, making our microservice lightweight yet powerful.

Conclusion: A Leap Towards Future-Ready Microservices

The development of the Ordering.API layer, with its minimal REST APIs and the adoption of the REPR pattern, is more than just an upgrade; it’s a strategic move towards building microservices that are ready for the challenges of tomorrow. By intertwining Clean Architecture with DDD principles, we’re setting a new benchmark in microservices development, ensuring our Ordering microservice is not just functional, but also a beacon of modern software architecture practices.

I have just published course — .NET 8 Microservices: C# 12, DDD, CQRS, Vertical/Clean Architecture.

This is step-by-step development of reference microservices architecture that include microservices on .NET platforms which used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12.



Mehmet Ozkaya

Software Architect | Udemy Instructor | AWS Community Builder | Cloud-Native and Serverless Event-driven Microservices https://github.com/mehmetozkaya