This project is a highly scalable and maintainable e-commerce system built using ASP.NET Core 8, Clean Architecture, and Microservices. Each service follows domain-driven design (DDD) principles and is deployed as an independent unit, ensuring flexibility and resilience.
- .NET 8 - Modern, high-performance framework
- C# - Core development language
- Entity Framework Core - Database ORM
- Ocelot API Gateway - API aggregation and routing
- RabbitMQ - Event-driven messaging
- Redis - Caching and data synchronization
- Docker - Containerization and deployment
- SQL Server - Relational database management
- xUnit - Unit testing framework
- Fluent Assertions - Assertion library for readable tests
The system follows Clean Architecture, separating concerns into distinct layers:
- API Layer: Handles API requests
- Application Layer: Business logic and use cases with CQRS Pattern and Mediator Pattern
- Domain Layer: Core entities, aggregates, and domain services
- Infrastructure Layer: Data persistence, external services, and message brokers
- CQRS Pattern: Separates read and write operations for optimized performance
- Mediator Pattern: Centralizes request handling for loose coupling
- AutoMapper: Simplifies object-to-object mapping
- Fluent Validation + Custom Error Handling Middleware: Ensures robust input validation and error management
- Logging with Serilog: Structured logging for debugging and monitoring
- Dependency Injection & SOLID Principles: Ensures maintainable and testable code
- Generic Repository: Reusable data access patterns
- Fluent API: Configures Entity Framework relationships
- Pagination Schema: Efficient data retrieval for large datasets
- Localization (EN/AR Support): Multi-language support
Each service operates independently and communicates through RabbitMQ (event-driven) or HTTP APIs (via Ocelot Gateway).
- Manages user authentication and authorization
- Implements JWT & Refresh Tokens for secure access
- Handles user registration, login, and Identity & Role Management
- Features:
- Email Confirmation
- External Login With Google
- Reset Password System
- Change Password
- Unit Testing with xUnit & Fluent Assertions
- Manages product catalog (CRUD operations)
- Stores product details, pricing, and availability
- Publishes events when product stock changes
- Unit Testing: xUnit with Fluent Assertions
- Processes customer orders
- Ensures payment validation before order confirmation
- Implements retry mechanisms for failed transactions
- Unit Testing: xUnit with Fluent Assertions
- Tracks stock levels and updates product availability
- Subscribes to product stock updates from RabbitMQ
- Notifies Order Service of stock shortages
- Unit Testing: xUnit with Fluent Assertions
- Manages user shopping carts
- Supports session-based and persistent cart storage
- Syncs with Inventory Service to prevent stock issues
- Unit Testing: xUnit with Fluent Assertions
- Handles transactions securely
- Integrates with third-party payment gateways
- Uses RabbitMQ to notify Order Service upon successful payment
- Unit Testing: xUnit with Fluent Assertions
- Allows users to save favorite products
- Syncs with Product Service for availability updates
- Uses Redis for fast retrieval
- Unit Testing: xUnit with Fluent Assertions
- Provides utilities such as logging, notifications, and email services
- Ensures cross-cutting concerns are handled consistently
- Routes all requests to the appropriate microservices
- Implements authentication, caching, and rate-limiting
- Enhances security by preventing direct access to services
- Facilitates asynchronous communication between services
- Ensures system resilience by handling event-based updates
- Used for order processing, inventory updates, and payment confirmation
- Each service runs inside a Docker container
- Docker Compose is used to manage multi-container setup
git clone https://github.com/mostafasharaby/E-Commerce-Microservices.git
cd ecommerce-microservices
docker-compose up --build
docker-compose-redis up --build
http://localhost:5279/api/products
http://localhost:5211/orders
dotnet test
We welcome contributions! Follow these steps:
- Fork the repository
- Create a new branch (
feature-branch
) - Commit your changes
- Submit a pull request
Mostafa Sharaby