A robust, production-ready .NET Web API for a modern e-commerce platform built with Onion Architecture and Domain-Driven Design concepts. Features high-performance Redis caching, JWT-based security, server-validated order orchestration, and webhooks-driven Stripe payment processing.
The solution follows Onion Architecture, keeping core domain entities insulated from infrastructure concerns:
ECommerce.API ──▶ Controllers, Middleware, Action Filters (Presentation Layer)
├── ECommerce.Infrastructure ──▶ EF Core, Redis, Stripe, Identity (Infrastructure Layer)
├── ECommerce.Application ──▶ Services, Specifications, DTOs, Mapping (Application Layer)
└── ECommerce.Domain ──▶ Entities, Interfaces, Enums (Core Domain Layer)
| Layer | Project | Responsibility |
|---|---|---|
| Domain | ECommerce.Domain |
Entities, Value Objects, Repository Interfaces (Zero Dependencies) |
| Application | ECommerce.Application |
Business Services, DTOs, Specification Pattern, AutoMapper |
| Infrastructure | ECommerce.Infrastructure |
EF Core DbContext, Redis Cache, Stripe SDK, ASP.NET Identity |
| API | ECommerce.API |
REST Controllers, JWT Authentication, Custom Action Filters, Swagger |
- 🛍️ Product Catalog — Specification-based filtering, pagination, sorting, and brand/type categorization.
- 🚀 Redis Response Caching — Custom
[Cached]attribute filter caches read-heavy catalog endpoints. - 🔐 Identity & JWT Authentication — Secure registration, login, role management, and bearer token evaluation.
- 🛒 Redis Shopping Basket — Fast ephemeral basket state powered by
StackExchange.Redis. - 🛡️ Order Orchestration — Server-side price recalculation (prevents client-side price tampering).
- 💳 Stripe Payment Gateway — Integrated PaymentIntents & Stripe CLI webhook listener for automated payment status transitions.
- 🖥️ Admin Dashboard — Dev interface for catalog product management (
AdminDashboard/).
- Framework: ASP.NET Core Web API (.NET 10)
- Database: Entity Framework Core & SQL Server
- Caching & Ephemeral Storage: Redis (
StackExchange.Redis) - Security: ASP.NET Core Identity & JWT Bearer Tokens
- Payment Gateway: Stripe.net API & Webhooks
- Object Mapping: AutoMapper
| Module | Method | Endpoint | Access Level |
|---|---|---|---|
| Catalog | GET |
/api/products |
Public |
| Catalog | GET |
/api/products/{id} |
Public |
| Catalog | GET |
/api/products/brands |
Public |
| Catalog | GET |
/api/products/types |
Public |
| Catalog | POST |
/api/products |
Admin Only |
| Auth | POST |
/api/account/login |
Public |
| Auth | POST |
/api/account/register |
Public |
| Auth | GET |
/api/account/address |
Authenticated |
| Basket | GET/POST |
/api/basket |
Public / Authenticated |
| Orders | POST |
/api/orders |
Authenticated |
| Orders | GET |
/api/orders |
Authenticated |
| Payments | POST |
/api/payments/{basketId} |
Authenticated |
| Payments | POST |
/api/payments/webhook |
Stripe Service |
git clone https://github.com/Moha-sami/ECommerce.git
cd ECommerce
dotnet restoredocker run -d --name redis -p 6379:6379 rediscd ECommerce.API
dotnet user-secrets init
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=.;Database=ECommerceDb;Trusted_Connection=True;TrustServerCertificate=True;"
dotnet user-secrets set "ConnectionStrings:IdentityConnection" "Server=.;Database=ECommerceIdentityDb;Trusted_Connection=True;TrustServerCertificate=True;"
dotnet user-secrets set "JwtSettings:Key" "YOUR_SUPER_SECRET_JWT_KEY_32_BYTES_MIN"
dotnet user-secrets set "StripeSettings:SecretKey" "sk_test_..."
dotnet user-secrets set "StripeSettings:PublishableKey" "pk_test_..."dotnet ef database update --context AppDbContext --project ECommerce.Infrastructure --startup-project ECommerce.API
dotnet ef database update --context AppIdentityDbContext --project ECommerce.Infrastructure --startup-project ECommerce.API
dotnet run --project ECommerce.APISwagger UI is automatically available at https://localhost:<port>/swagger in Development mode.