Skip to content

Latest commit

Β 

History

History
129 lines (98 loc) Β· 3.92 KB

File metadata and controls

129 lines (98 loc) Β· 3.92 KB

EShopMicroservices

A modern e-commerce platform built using microservices architecture with .NET 8, implementing best practices for cloud-native applications.

πŸ—οΈ Architecture

This project follows a microservices architecture with the following key principles:

  • CQRS (Command Query Responsibility Segregation) - Separation of read and write operations
  • Vertical Slice Architecture - Feature-based organization instead of technical layers
  • Clean Architecture - Clear separation of concerns and dependencies
  • Docker Support - Containerization for easy deployment and scalability

πŸ“‚ Project Structure

EShopMicroservices/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ BuildingBlocks/         # Shared libraries and common components
β”‚   β”‚   └── BuildingBlocks/
β”‚   β”‚       └── CQRS/           # CQRS abstractions (Comma``nds, Queries, Handlers)
β”‚   β”‚           β”œβ”€β”€ ICommand.cs
β”‚   β”‚           β”œβ”€β”€ ICommandHandler.cs
β”‚   β”‚           β”œβ”€β”€ IQuery.cs
β”‚   β”‚           └── IQueryHandler.cs
β”‚   β”œβ”€β”€ Services/               # Microservices
β”‚   β”‚   └── Catalog/            # Product catalog service
β”‚   β”‚       └── Catalog.API/
β”‚   β”‚           β”œβ”€β”€ Models/     # Domain models
β”‚   β”‚           β”‚   └── Product.cs
β”‚   β”‚           β”œβ”€β”€ Products/   # Product features (vertical slices)
β”‚   β”‚           β”‚   └── CreateProduct/
β”‚   β”‚           β”‚       β”œβ”€β”€ CreateProductEndpoint.cs
β”‚   β”‚           β”‚       └── CreateProductHandler.cs
β”‚   β”‚           β”œβ”€β”€ Properties/
β”‚   β”‚           β”‚   └── launchSettings.json
β”‚   β”‚           β”œβ”€β”€ Dockerfile
β”‚   β”‚           β”œβ”€β”€ GlobalUsing.cs
β”‚   β”‚           β”œβ”€β”€ Program.cs
β”‚   β”‚           β”œβ”€β”€ appsettings.json
β”‚   β”‚           └── appsettings.Development.json
β”‚   β”œβ”€β”€ .dockerignore
β”‚   └── eshop-microservices.sln
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

πŸ› οΈ Technologies & Frameworks

Core

  • .NET 8 - Latest .NET framework
  • C# 12 - Modern C# features

Libraries & Packages

  • Carter - Minimal API organization and routing
  • MediatR - Mediator pattern implementation for CQRS
  • Mapster - High-performance object mapping
  • Docker - Containerization

πŸ“¦ Microservices

Catalog Service

Manages product catalog operations including creating, reading, updating, and deleting products.

Features:

  • βœ… Create Product

Planned Features:

  • ⏳ Get Products
  • ⏳ Get Product by ID
  • ⏳ Update Product
  • ⏳ Delete Product

πŸ”§ BuildingBlocks

The BuildingBlocks project contains shared infrastructure and abstractions used across all microservices:

CQRS Infrastructure

  • ICommand / ICommand<TResponse> - Command abstractions for write operations
  • IQuery<TResponse> - Query abstractions for read operations
  • ICommandHandler - Command handler contracts
  • IQueryHandler - Query handler contracts

These interfaces integrate seamlessly with MediatR to provide a consistent CQRS implementation across all services.

πŸš€ Getting Started

Prerequisites

  • .NET 8 SDK
  • Docker (optional, for containerized deployment)
  • Visual Studio 2022 or VS Code

Running the Application

  1. Clone the repository
  2. Restore dependencies - dotnet restore
  3. Run the application - dotnet run
  4. Using Docker - docker build -t catalog-api -f Services/Catalog/Catalog.API/Dockerfile . docker run -p 8080:8080 catalog-api

πŸ“‹ API Examples

Create Product

Endpoint: POST /products

Status Code: 201 Created

Request Body:

{
    "Name": "New Product A",
    "Category": ["c1", "c2"],
    "Description": "Description Product A",
    "ImageFile": "ImageFile Product A",
    "Price": 199
}

Response:

{
    "id": "d6ac5f15-dda8-452d-82e6-ef5aee1c3bef"
}