Skip to content

E-commerce API project using DDD, Clean Architecture, and CQRS with .NET 8 and PostgreSQL

License

Notifications You must be signed in to change notification settings

ImVictorM/ECommerceManagement

Repository files navigation

E-commerce Management API

Overview 💡

The E-commerce Management API is a study project designed to apply and deepen knowledge of software architecture principles and patterns. This project focuses on implementing core functionalities of real-world e-commerce systems, including product management, user management, order processing, and payment handling.

Key principles and patterns applied in the project include:

  • Domain-Driven Design (DDD)
  • Clean Architecture
  • CQRS (Command Query Responsibility Segregation)
  • SOLID Principles

Although this is a study project, significant effort has been dedicated to ensuring the system is as close as possible to a production-ready e-commerce application.

Payment Integration

The project includes an abstraction layer that emulates the behavior of real-world payment gateways. While no actual payment gateways are integrated and no real payments or charges are created, the abstraction mimics how payment processing works, including webhooks and transaction handling.

Features

Click here to learn more about the API features and to see additional documentation.

Main technologies used 🧰

Static Badge Static Badge Static Badge
Static Badge Static Badge Static Badge

Running the application ⚙️

Running with docker 🐋 (recommended)

You must have docker installed

  1. Clone and enter the repository
git clone [email protected]:ImVictorM/ECommerceManagement.git && cd ECommerceManagement
  1. Create a .env file at the root to configure environment variables for Docker. Use the .env-example file as a reference.

  2. Build and run the containers

docker-compose up -d --build
  1. Run the migrations
dotnet ef database update -p .\src\Infrastructure -s .\src\WebApi --connection "Host=localhost;Port=8010;Username=postgres;Password=postgres;Database=ecommerce-management;Trust Server Certificate=true;"

Running locally 🖥️

You must have dotnet and postgres installed

  1. Clone and enter the repository
git clone [email protected]:ImVictorM/ECommerceManagement.git && cd ECommerceManagement
  1. Configure the file src/WebApi/appsettings.json. Update the DbConnectionSettings section with your database credentials as follows:
{
  "DbConnectionSettings": {
    "Host": "localhost",
    "Port": "5432",
    "Database": "ecommerce-management",
    "Username": "your-username",
    "Password": "your-password"
  }
}
  1. Restore the dependencies
dotnet restore ECommerceManagement.sln
  1. Run the migrations
dotnet ef database update -p .\src\Infrastructure -s .\src\WebApi --connection "Host=localhost;Port=8010;Username=postgres;Password=postgres;Database=ecommerce-management;Trust Server Certificate=true;"
  1. Run the WebApi project
dotnet run --project ./src/WebApi

Testing 🛠️

Note: The integration tests use TestContainer and Respawn to manage test databases dynamically using Docker containers. Ensure Docker is running on your system to execute integration tests successfully.

Command to run all tests:

dotnet test ECommerceManagement.sln

Command to run the unit tests:

Replace {layer_name} with the specific layer you want to test, such as Domain, Application, or SharedKernel.

dotnet test ./tests/UnitTests/{layer_name}.UnitTests

Command to run the integration tests:

dotnet test ./tests/IntegrationTests

References 📌

I separated this section to share some cool (and free) stuff I found when studying and creating this project.

Amichai Mantiband Playlist on Clean Architecture + DDD
Specifications by Eric Evans and Martin Fowler
Polymorphism in Entity Framework
CQRS and MediatR in ASP.NET Core
How Payment is Done using the Mercado Pago Service
Webhooks and Security