A clean architecture, CQRS patterned online product store with REST APIs for product management and purchase, including unit tests. Built with C# and EF Core.
CodeChallengeProject/
│
├── CodeChallengeProject.src/
├── CodeChallengeProject.core/
├── CodeChallengeProject.Domain/
│ ├── Entities/
│ ├── Models/
│ └── Shared/
│ └── ValueObjects/
│
├── CodeChallengeProject.Application/
│ ├── Features/
│ ├── Mapping/
│ └── ViewModels/
│
├── CodeChallengeProject.infrastructure/
├── CodeChallengeProject.Infrastructure/
├── CodeChallengeProject.Persistence/
│ ├── Data/
│ ├── Repositories/
│ └── Contexts/
│ └── EntityConfigurations/
│ └── Repositories/
│
├── CodeChallengeProject.presentation/
├── CodeChallengeProject.WebApi/
│ ├── Controllers/
│ ├── Program.cs/
│
├── CodeChallengeProject.tests/
├── CodeChallenge.UnitTests/
│ ├── Features/
│
└── OnlineProductStore.sln
- C#
- .NET 8
- EF Core
- CQRS
- Clean Architecture
- In-Memory Caching
- Unit Testing (xUnit)
Consider a simple online store in which users can buy only one product in each order. This system has the following entities:
- Id
- Title
- InventoryCount
- Price
- Discount (percentage)
- Id
- Name
- Orders
- Id
- Product
- CreationDate
- Buyer
- Add a product with a predefined
InventoryCount
.product
's title must be validated to be less than 40 characters. Also,product
's name must be unique. - Increase
InventoryCount
of a product and update the product. - Get a
product
byid
with properprice
considering currentdiscount
value. - "Buy" endpoint that changes the inventory count of a product and adds an order to user orders.
- Write unit tests for two use cases of the application.
- You have to use
ef core
as your ORM (code first). - For the third API you have to apply a caching procedure (any simple caching solution like in memory, ...) to reduce database hits.
- There is no need to use an auth system.
- Both simplicity and cleanliness of your code matters.
- Add some sample users without any orders
The code is thoroughly documented with XML comments explaining the functionality of each component and method. Clear instructions are provided on how to build, run, and use the application.
This project is licensed under the MIT License - see the LICENSE file for details.