🔷 ASP.NET Core Web API – N-Tier Architecture (.NET 9)
🔷 Repository Pattern + Unit Of Work + JWT Authentication
Ecommerce API is a complete backend e-commerce system built using professional clean architecture principles and modern ASP.NET Core practices.
The system allows users to:
- Browse products and categories
- Register and login securely
- Manage shopping cart
- Place orders
- Upload images
- Filter and paginate products
The project demonstrates enterprise-level backend architecture using:
- ✅ N-Tier Architecture
- ✅ Repository Pattern
- ✅ Generic Repository
- ✅ Unit of Work Pattern
- ✅ JWT Authentication
- ✅ Microsoft Identity
- ✅ Policy-Based Authorization
- ✅ DTO Pattern
- ✅ Fluent Validation
- ✅ Entity Framework Core
- ✅ Async Programming
- ✅ AutoMapper
- ✅ Image Upload
- ✅ Product Filtering
- ✅ Pagination
- ✅ Logging with Serilog
- ✅ API Versioning
- ✅ CORS
- ✅ Data Seeding
- ✅ Audit Logging
Ecommerce.API
│
├── Ecommerce.APIs → Presentation Layer
├── Ecommerce.BLL → Business Logic Layer
├── Ecommerce.DAL → Data Access Layer
└── Ecommerce.Common → Shared Models & UtilitiesClient Request
↓
API Controller
↓
Manager (BLL)
↓
Unit Of Work
↓
Repository
↓
DbContext (EF Core)
↓
SQL Server- API Controllers
- Program.cs
- Middleware Configuration
- Handle HTTP Requests
- Return JSON Responses
- JWT Authentication
- Authorization
- API Versioning
- Logging
- CORS Configuration
- Managers
- DTOs
- Validators
- AutoMapper Profiles
- Business Rules
- Validation
- Data Transformation
- Business Logic
- Calling UnitOfWork
- Handling Responses
- ProductManager
- CategoryManager
- CartManager
- OrderManager
- AuthManager
- ImageManager
- DbContext
- Repositories
- Unit Of Work
- Entity Configurations
- Seed Data
- IGenericRepository
- GenericRepository
- IProductRepository
- ICategoryRepository
- ICartRepository
- IOrderRepository
- GeneralResult Wrapper
- Pagination Models
- Error Models
- Shared Utilities
- ✅ Repository Pattern
- ✅ Generic Repository
- ✅ Unit Of Work
- ✅ DTO Pattern
- ✅ Dependency Injection
- ✅ Dependency Inversion Principle
- ✅ Fluent Validation
- ✅ AutoMapper
- ✅ Async Programming
Implemented using:
- JWT Authentication
- Microsoft Identity
- Policy-Based Authorization
- User Registration
- User Login
- Secure Endpoints
- Extract UserId from JWT Claims
SQL Server
Entity Framework Core
Handled using:
ApplicationUser : IdentityUserOne Category → Many Products
Many Products → One Category
One User → One Cart
Many CartItems → One Cart
Many CartItems → One Product
One User → Many Orders
Many OrderItems → One Order
Many OrderItems → One Product
Implemented inside AppDbContext
Default data is seeded automatically:
- Categories
- Products
- Register
- Login
- JWT Token Generation
- Get All Categories
- Get Category By Id
- Create Category
- Update Category
- Delete Category
- Upload Category Image
- Get Products
- Product Details
- Create Product
- Update Product
- Delete Product
- Upload Product Image
- Filtering
- Search
- Pagination
- Add To Cart
- Update Quantity
- Remove From Cart
- Get User Cart
- Place Order
- Orders History
- Get Order Details
- Upload Images
- Save Images Locally
- Return Image URL
POST /api/auth/register
POST /api/auth/loginGET /api/categories
GET /api/categories/{id}
POST /api/categories
PUT /api/categories/{id}
DELETE /api/categories/{id}GET /api/products
GET /api/products/{id}
POST /api/products
PUT /api/products/{id}
DELETE /api/products/{id}GET /api/cart
POST /api/cart
PUT /api/cart
DELETE /api/cart/{productId}GET /api/orders
GET /api/orders/{id}
POST /api/ordersInside appsettings.json
"ConnectionStrings": {
"Ecommerce": "Server=.;Database=EcommerceDB;Trusted_Connection=True;TrustServerCertificate=True;"
}Add-Migration InitDb
Update-Databasedotnet runAPI tested using:
- Postman
Includes:
- Authentication Testing
- CRUD Operations
- Cart Flow
- Order Flow
- Separation of Concerns (SoC)
- Single Responsibility Principle (SRP)
- Dependency Inversion Principle (DIP)
- DRY Principle
- Clean Architecture
- Loose Coupling
- ASP.NET Core Web API
- Entity Framework Core
- SQL Server
- Microsoft Identity
- JWT
- FluentValidation
- AutoMapper
- Serilog
- Swagger / OpenAPI
This project demonstrates:
- Enterprise-level backend architecture
- Professional API development
- Clean code organization
- Real-world e-commerce business flow
- Secure authentication system
- Advanced backend patterns
Software Engineer