eShop on Dapr
eShop on Dapr is an exemplary distributed application built on .NET Core and powered by Dapr, specifically designed to demonstrate the capabilities and advantages of Dapr in building microservices applications. It is inspired by the well-known eShopOnContainers application and now targets .NET 7.
The project is supported by a comprehensive e-book titled Dapr for .NET Developers, which elaborates on the features and benefits of Dapr using this sample application. The e-book is accessible online and can be downloaded for free.
What is Dapr?
Dapr (Distributed Application Runtime) is a platform that facilitates the development of microservices across any language or framework. It handles many challenges encountered in distributed systems, such as:
- Service discovery and synchronous communication.
- Implementation of asynchronous messaging.
- Maintenance of contextual information across transactions.
- Building resilience against failures.
- Scalability to match varying demand.
- Monitoring and observability of services.
eShopOnDapr Architecture
eShopOnDapr has evolved from eShopOnContainers by incorporating Dapr’s building blocks, adjusting its architecture to demonstrate Dapr's advantages effectively:
-
Frontend: The frontend is a web application written in Blazor. It handles user interactions and communicates requests to the backend through an API gateway.
-
API Gateway: This layer, built with Envoy, acts as an intermediary between the frontend and the backend microservices. It routes incoming requests to the appropriate backend services, mostly executing simple CRUD operations.
-
Aggregator Microservice: For complex requests requiring coordination between various services, an aggregator microservice orchestrates the workflow necessary to complete these operations efficiently.
-
Core Backend Microservices: Each backend microservice within eShopOnDapr is independently responsible for a specific business capability within an eCommerce framework:
- Basket Service: Manages customer shopping baskets.
- Catalog Service: Handles product listings.
- Identity Service: Manages user authentication and identity.
- Ordering Service: Processes and oversees customer orders.
- Payment Service: Facilitates customer transactions.
-
Event Bus: An event bus allows asynchronous communication via a publish/subscribe model among the microservices, supporting any Dapr-compatible message broker.
Running eShopOnDapr
To run eShopOnDapr, Docker is required, as the application operates within containers. There are multiple ways to initiate the application, catering to different development needs:
- Using the Command Line Interface (CLI).
- Through Visual Studio for an optimal debugging experience.
- Via Visual Studio Code, which lets developers debug individual containers.
- On a local Kubernetes cluster using Docker for Desktop.
- On an external Kubernetes cluster.
- On Azure Container Apps.
Before beginning, it may take some time to start all necessary containers. A health check UI is available at http://localhost:5107
to confirm readiness. Once ready, users can access the eShopOnDapr UI via http://localhost:5104
.
The eShop on Dapr reference implementation is a remarkable tool for developers looking to dive into building distributed microservices applications with Dapr while leveraging the robust .NET ecosystem.