All Work

E-Commerce Platform

Clean Architecture at scale — extensible, production-ready, AI-recommended.

RoleFull-Stack Developer
Year2024
Duration3 months
TeamSolo Project
Status✓ Completed
E-Commerce — Homepage with featured products

At a Glance

26Screens Built
RedisCaching Layer
4Clean Architecture Layers

The Problem

Standard e-commerce implementations result in tightly coupled controllers that become unmaintainable as features grow. Adding a new payment provider typically requires changes across 15+ files. This project demonstrated that Clean Architecture keeps e-commerce codebases extensible — adding a payment provider requires changing only one infrastructure class.

The Solution

A four-layer Clean Architecture where all business rules live in framework-agnostic C# classes. Redis caches product listings at the infrastructure boundary, keeping the Application layer unaware of any caching strategy. A collaborative-filtering recommendation engine analyses purchase history to surface personalised suggestions without a third-party ML service.

Architecture

Key Features

Screenshots

Code Highlight

Preventing Inventory Race Conditions — Optimistic Concurrency
// When two users try to buy the last item simultaneously,
// only one transaction succeeds — the other receives a clear error.
public async Task<OrderResult> PlaceOrderAsync(OrderDto dto)
{
    await using var tx = await _context.Database.BeginTransactionAsync();
    try
    {
        var product = await _context.Products
            .FirstOrDefaultAsync(p => p.Id == dto.ProductId);

        if (product.Stock < dto.Quantity)
            return OrderResult.Failed("Insufficient stock");

        product.Stock -= dto.Quantity;

        // EF Core detects concurrent modifications via RowVersion
        // and throws DbUpdateConcurrencyException automatically
        await _context.SaveChangesAsync();
        await tx.CommitAsync();
        return OrderResult.Success();
    }
    catch (DbUpdateConcurrencyException)
    {
        await tx.RollbackAsync();
        return OrderResult.Failed("Item just purchased by another user.");
    }
}

Challenges & Solutions

🎯 Real-time cart updates without page refresh

Used AJAX with vanilla JavaScript to handle cart operations asynchronously, providing instant UI feedback and updating the cart counter badge without a full page reload.

🎯 Building a recommendation engine without ML dependencies

Implemented collaborative filtering in pure C# that analyses user purchase patterns and product category overlap to generate personalised recommendations — no ML.NET, no external service.

🎯 Inventory race conditions with concurrent orders

Used EF Core optimistic concurrency (RowVersion) wrapped in a database transaction — if two users buy the last item simultaneously, only one succeeds and the other receives a clear, actionable error message.

Tech Stack

ASP.NET Core MVCC#Entity Framework CoreSQL ServerRedisClean ArchitectureBootstrap 5JavaScript

What I Learned

Links

Interested in a similar solution?

Let's discuss how I can build something like this for your business.