DEV Community

Cover image for My First .NET Core Web API Project: Documenting the Rookie Mistakes and Wins on the Way to a Job.
Jervie Gono
Jervie Gono

Posted on

My First .NET Core Web API Project: Documenting the Rookie Mistakes and Wins on the Way to a Job.

The Blueprint - Planning My E-Commerce API Architecture

My First .NET Core Web API Project: Part 1 - Architecture & Planning

Why an E-Commerce API?

When I decided to build my portfolio project, I knew I needed something that would demonstrate real-world skills. An e-commerce API was perfect because it touches on:

  • User management (authentication, profiles)
  • Product catalog (CRUD, search, pagination)
  • Business logic (inventory, orders, payments)
  • Security (data isolation, input validation)

The architecture decision: Clean Architecture

I almost started with a traditional layered architecture, but then I discovered Clean Architecture. Here's why I chose it:

Ecommerce/
├── API/ # ASP.NET Core Web API
├── Core/ # Domain models, business logic
├── Infrastructure/# Data access, external services
└── Shared/ # DTOs, common utilities

Technology Stack Choices

Backend Framework: ASP.NET Core 8

Why I Chose It: Latest features, performance improvements, long-term support
Learning Experience: Initially considered .NET 6 for stability, but embracing the latest version demonstrates adaptability

Database: SQLSERVER

Why I Chose It: Because it was often most used in .net core projects
Consideration: Using Postgresql is a good choice too, but for this project we choose not to use it.

ORM: Entity Framework Core

Why I Chose It: Productivity with LINQ + raw SQL control when needed
Key Learning: Understanding when to use LINQ vs direct SQL for performance

Key Design Patterns

1. CQRS with MediatR

// Commands for write operations
public record CreateProductCommand(CreateProductDto Product) 
    : IRequest<ResponseType<ProductDto>>;

// Queries for read operations  
public record GetProductByIdQuery(Guid Id) 
    : IRequest<ResponseType<ProductDto>>;
Enter fullscreen mode Exit fullscreen mode

We will also adding Repository so our project don't have to be strictly tied in any SQL

public interface IProductRepository
{
    Task<Product> GetByIdAsync(Guid id);
    Task<PaginatedResult<Product>> GetPaginatedAsync(PaginationRequest request);
}
Enter fullscreen mode Exit fullscreen mode

What's Next?

In Part 2, I'll dive into implementing the base architecture with:

  • Dependency injection configuration
  • Response wrapper pattern
  • Swagger/OpenAPI setup
  • Global exception handling

Top comments (0)