https://github.com/arafatsabbir/eshop-microservice-dotnet
Microservices on .Net platforms which used Asp.Net Web API, Docker, RabbitMQ, MassTransit, gRPC, Ocelot API Gateway, MongoDB, Redis, PostgreSQL, SqlServer, Dapper, Entity Framework Core, CQRS and Clean Architecture implementation.
https://github.com/arafatsabbir/eshop-microservice-dotnet
api-gateway asp-net-core clean-architecture cqrs-pattern csharp dapper docker dotnet entity-framework-core grpc masstransit mongodb postgresql rabitmq rest-api sql-server
Last synced: 3 days ago
JSON representation
Microservices on .Net platforms which used Asp.Net Web API, Docker, RabbitMQ, MassTransit, gRPC, Ocelot API Gateway, MongoDB, Redis, PostgreSQL, SqlServer, Dapper, Entity Framework Core, CQRS and Clean Architecture implementation.
- Host: GitHub
- URL: https://github.com/arafatsabbir/eshop-microservice-dotnet
- Owner: ArafatSabbir
- License: mit
- Created: 2023-05-02T06:39:38.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-12T21:05:52.000Z (almost 2 years ago)
- Last Synced: 2025-03-11T07:49:48.352Z (3 months ago)
- Topics: api-gateway, asp-net-core, clean-architecture, cqrs-pattern, csharp, dapper, docker, dotnet, entity-framework-core, grpc, masstransit, mongodb, postgresql, rabitmq, rest-api, sql-server
- Language: C#
- Homepage:
- Size: 93.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Eshop Microservice in .NET 6
See the overall picture of **implementations on microservices with .net tools** on real-world **e-commerce microservices** project;
There is a couple of microservices that implemented **e-commerce** modules over **Catalog, Basket, Discount** and **Ordering** microservices with **NoSQL (MongoDB, Redis)** and **Relational databases (PostgreSQL, SQL Server)** with communicating over **RabbitMQ Event-Driven Communication** and using **Ocelot API Gateway**.
## What Including In This Repository
We have implemented the below **features over the eshop-microservice-dotnet repository**.#### Catalog microservice which includes;
* ASP.NET Core Web API application
* REST API principles, CRUD operations
* **MongoDB database** connection and containerization
* Repository Pattern Implementation
* Swagger Open API implementation#### Basket microservice which includes;
* ASP.NET Web API application
* REST API principles, CRUD operations
* **Redis database** connection and containerization
* Consume Discount **Grpc Service** for inter-service sync communication to calculate product final price
* Publish BasketCheckout Queue with using **MassTransit and RabbitMQ**
#### Discount microservice which includes;
* ASP.NET **Grpc Server** application
* Build a Highly Performant **inter-service gRPC Communication** with Basket Microservice
* Exposing Grpc Services with creating **Protobuf messages**
* Using **Dapper for micro-orm implementation** to simplify data access and ensure high performance
* **PostgreSQL database** connection and containerization#### Microservices Communication
* Sync inter-service **gRPC Communication**
* Async Microservices Communication with **RabbitMQ Message-Broker Service**
* Using **RabbitMQ Publish/Subscribe Topic** Exchange Model
* Using **MassTransit** for abstraction over the RabbitMQ Message-Broker system
* Publishing BasketCheckout event queue from Basket microservices and Subscribing to this event from Ordering microservices
* Create **RabbitMQ EventBus.Messages library** and add references Microservices#### Ordering Microservice
* Implementing **DDD, CQRS, and Clean Architecture** with using Best Practices
* Developing **CQRS using MediatR, FluentValidation, and AutoMapper packages**
* Consuming **RabbitMQ** BasketCheckout event queue with using **MassTransit-RabbitMQ** Configuration
* **SqlServer database** connection and containerization
* Using **Entity Framework Core ORM** and auto migrate to SqlServer when application startup
#### API Gateway Ocelot Microservice
* Implement **API Gateways with Ocelot**
* Sample microservices/containers to reroute through the API Gateways
* Run multiple different **API Gateway/BFF** container types
* The Gateway aggregation pattern in Shopping.Aggregator#### WebUI ShoppingApp Microservice
* ASP.NET Core Web Application with Bootstrap 4 and Razor template
* Call **Ocelot APIs with HttpClientFactory** and **Polly**#### Microservices Cross-Cutting Implementations
* Implementing **Centralized Distributed Logging with Elastic Stack (ELK); Elasticsearch, Logstash, Kibana and SeriLog** for Microservices
* Use the **HealthChecks** feature in back-end ASP.NET microservices
* Using **Watchdog** in a separate service that can watch health and load across services, and report health about the microservices by querying with the HealthChecks#### Microservices Resilience Implementations
* Making Microservices more **resilient Use IHttpClientFactory** to implement resilient HTTP requests
* Implement **Retry and Circuit Breaker patterns** with exponential backoff with IHttpClientFactory and **Polly policies**#### Ancillary Containers
* Use **Portainer** for Container lightweight management UI which allows you to manage your different Docker environments easily
* **pgAdmin PostgreSQL Tools** feature rich Open Source administration and development platform for PostgreSQL#### Docker Compose establishment with all microservices on docker;
* Containerization of microservices
* Containerization of databases
* Override Environment variables## Run The Project
You will need the following tools:* [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/)
* [.Net 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
* [Docker Desktop](https://www.docker.com/products/docker-desktop)### Installing
Follow these steps to get your development environment set up: (Before Run Start the Docker Desktop)
1. Clone the repository
2. Once Docker for Windows is installed, go to the **Settings > Advanced option**, from the Docker icon in the system tray, to configure the minimum amount of memory and CPU like so:
* **Memory: 4 GB**
* CPU: 2
3. At the root directory which include **docker-compose.yml** files, run below command:
```csharp
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
```>Note: If you get a connection timeout error Docker for Mac please [Turn Off Docker's "Experimental Features".](https://github.com/aspnetrun/run-aspnetcore-microservices/issues/33)
4. Wait for docker compose all microservices. That’s it! (some microservices need extra time to work so please wait if they are not working in the first shot)
5. You can **launch microservices** as below URLs:
* **Catalog API -> http://host.docker.internal:8000/swagger/index.html**
* **Basket API -> http://host.docker.internal:8001/swagger/index.html**
* **Discount API -> http://host.docker.internal:8002/swagger/index.html**
* **Ordering API -> http://host.docker.internal:8004/swagger/index.html*** **pgAdmin PostgreSQL -> http://host.docker.internal:5050** -- [email protected]/admin1234
* **Portainer -> http://host.docker.internal:9000** -- admin/admin1234
* **Rabbit Management Dashboard -> http://host.docker.internal:15672** -- guest/guest**checkout the basket** you can follow **queue record on RabbitMQ dashboard**.
>Note: If you are running this application in macOS then use `docker.for.mac.localhost` as DNS name in `.env` file and the above URLs instead of `host.docker.internal`.