Skip to main content

Capstone Project Requirements

Project: E-Commerce API with Advanced EF Core

Build a production-quality e-commerce API demonstrating all EF Core concepts and patterns.

Domain Model

Entities

// Products
- Product (Id, SKU, Name, Description, Price, StockQuantity, IsActive, IsDeleted, CreatedDate, ModifiedDate, RowVersion)
- Category (Id, Name, ParentId, IsActive)
- ProductCategory (ProductId, CategoryId)
- ProductImage (Id, ProductId, Url, IsPrimary)

// Orders
- Order (Id, OrderNumber, CustomerId, OrderDate, Status, TotalAmount, IsDeleted, RowVersion)
- OrderItem (Id, OrderId, ProductId, Quantity, UnitPrice, Discount)

// Customers
- Customer (Id, Email, FirstName, LastName, Phone, IsActive, CreatedDate)
- Address (Id, CustomerId, Street, City, State, ZipCode, IsDefault)

// Reviews
- ProductReview (Id, ProductId, CustomerId, Rating, Comment, ReviewDate)

// Audit
- AuditLog (Id, EntityName, EntityId, Action, UserId, Timestamp, Changes)

Required Features

1. Relationships

  • One-to-Many: Category → Products, Customer → Orders
  • Many-to-Many: Products ↔ Categories
  • One-to-One: Order → ShippingAddress
  • Self-Referencing: Category hierarchy

2. Query Optimization

  • No N+1 query problems
  • Use AsNoTracking for read-only queries
  • Implement projection for DTOs
  • Use compiled queries for hot paths
  • Implement pagination
  • Use AsSplitQuery for multiple includes

3. Advanced Patterns

  • Global query filter for soft delete
  • Global query filter for active records
  • Optimistic concurrency on Orders and Products
  • Interceptor for audit logging
  • Interceptor for slow query detection
  • Connection resiliency with retry policy

4. Indexing

  • Unique index on Product.SKU
  • Unique index on Customer.Email
  • Composite index on (OrderDate, CustomerId)
  • Filtered index on active products
  • Covering index for common queries

5. Performance

  • DbContext pooling enabled
  • All list endpoints paginated
  • Bulk operations for imports
  • Caching for frequently accessed data
  • Query tags for monitoring

API Endpoints

Products

GET    /api/products              - List with pagination, filters
GET /api/products/{id} - Get with reviews and images
POST /api/products - Create
PUT /api/products/{id} - Update
DELETE /api/products/{id} - Soft delete
GET /api/products/category/{id} - By category with optimization

Orders

GET    /api/orders                - List customer orders
GET /api/orders/{id} - Order details with items
POST /api/orders - Create order (handles concurrency)
PUT /api/orders/{id}/status - Update status
GET /api/orders/customer/{id} - Customer order history

Categories

GET    /api/categories            - Tree structure
GET /api/categories/{id} - With products count
POST /api/categories - Create
PUT /api/categories/{id} - Update

Architecture

src/
├── Domain/
│ ├── Entities/
│ ├── Enums/
│ └── Interfaces/
├── Infrastructure/
│ ├── Data/
│ │ ├── Configurations/
│ │ ├── Interceptors/
│ │ │ ├── AuditInterceptor.cs
│ │ │ └── SlowQueryInterceptor.cs
│ │ ├── Migrations/
│ │ └── AppDbContext.cs
│ └── Repositories/
├── Application/
│ ├── DTOs/
│ ├── Services/
│ └── Specifications/
└── WebApi/
├── Controllers/
├── Middleware/
└── Program.cs

tests/
├── UnitTests/
├── IntegrationTests/
└── PerformanceTests/

Implementation Steps

Phase 1: Domain & Infrastructure

  1. Create all entities
  2. Implement IEntityTypeConfiguration for each
  3. Configure relationships and constraints
  4. Add seed data
  5. Create initial migration

Phase 2: Core Features

  1. Implement repositories (if using pattern)
  2. Create DTOs
  3. Implement basic CRUD operations
  4. Add validation

Phase 3: Query Optimization

  1. Identify and fix N+1 problems
  2. Add AsNoTracking where appropriate
  3. Implement projection for list endpoints
  4. Add compiled queries
  5. Implement pagination

Phase 4: Advanced Features

  1. Add global query filters
  2. Implement optimistic concurrency
  3. Create audit interceptor
  4. Add slow query interceptor
  5. Configure connection resiliency

Phase 5: Testing & Benchmarking

  1. Write integration tests
  2. Create performance benchmarks
  3. Test concurrency scenarios
  4. Validate soft delete behavior
  5. Test pagination

Deliverables

Code

  • Complete source code on GitHub
  • All tests passing
  • Clean, well-organized structure
  • Comprehensive comments

Documentation

  • README with setup instructions
  • Architecture decision records
  • API documentation
  • Performance optimization notes

Benchmarks

  • Before/after optimization metrics
  • Query performance comparisons
  • Memory usage analysis
  • Concurrency test results

Success Criteria

  • All endpoints working correctly
  • No N+1 query problems (verified with logging)
  • All tests passing
  • Performance benchmarks show optimizations
  • Soft delete working across all entities
  • Concurrency handling works correctly
  • Audit log captures all changes
  • Code is production-ready quality

Bonus Challenges

  1. Implement Redis caching
  2. Add full-text search
  3. Implement CQRS with MediatR
  4. Add event sourcing for order history
  5. Implement multi-tenancy
  6. Add GraphQL endpoint
  7. Implement real-time notifications with SignalR
  8. Add distributed tracing

Time Estimate

~40-50 hours over 7-10 days