How alimhtsai/e_commerce works
Project type and purpose
• This is a full-stack e-commerce shopping site.
• Frontend: Angular SPA with modules for shop, basket, checkout, orders, account.
• Backend: ASP.NET Core REST API implementing repository, unit-of-work, specification patterns; uses EF Core against SQLite (identity.db) and Redis for basket caching; integrates Stripe for payments via webhooks.
File structure
• Top level:
• API/ – ASP.NET Core Web API
• Core/ – domain entities, interfaces, specifications
• Infrastructure/ – EF Core DbContexts, repositories, migrations, services
• client/ – Angular application
• docker-compose.yml – spins up Redis container
• Patterns:
• API.Controllers → Controllers
• Core.Interfaces → repository/unit-of-work/ token/ payment service abstractions
• Core.Specifications & Infrastructure.Data.SpecificationEvaluator → specification pattern for querying
• Infrastructure.Data.GenericRepository & UnitOfWork → data access
• Infrastructure.Services → business-facing implementations (OrderService, PaymentService, TokenService, ResponseCacheService)
a. Main components:
– Angular Frontend (client)
– ASP.NET Core API (Controllers → ApplicationServicesExtensions → Services)
– Domain Layer (Core.Entities & Core.Interfaces)
– Persistence Layer (Infrastructure.Data StoreContext & AppIdentityDbContext)
– Redis Cache service (in Docker container)
– Stripe External Payment Service
– SQLite-based identity.db for user accounts
b. Relationships & interactions:
– Browser → Angular HTTPClient → API Controllers (Account, Products, Basket, Orders, Payments)
– Controllers → Core Interfaces (IProductRepository, IBasketRepository, IOrderService, IPaymentService)
– Interfaces → Infrastructure implementations → EF Core contexts → SQL data store
– BasketController uses IResponseCacheService → Redis
– PaymentsController calls PaymentService → Stripe API & listens to webhooks
– TokenService issues JWT via ASP.NET Identity
c. Architectural patterns:
– Layered architecture: Presentation (Angular), API layer, Application/Domain (Core), Persistence (Infrastructure), External services
– Repository + Unit of Work for data decoupling
– Specification pattern for flexible querying
– Dependency Injection throughout ASP.NET Core and Angular
d. Technologies:
– Angular, TypeScript, Bootstrap; ASP.NET Core, C#; EF Core; Redis; Docker Compose; SQLite; Stripe; JWT; ASP.NET Identity
Detail level
• Break the API layer into sub-components: Controllers, Services, Repositories, EF Core contexts
• Where JWT tokens are generated and checked (TokenService, Auth guard/ JWT interceptor)
• How the specification evaluator constructs queries, then GenericRepository executes them
• Redis caching path on basket requests (via CachedAttribute)