How trycatchlearn/skinet-2024 works
Project Type and Purpose
• This is a full-stack e-commerce application (“Skinet”) built with a .NET 8 backend (API, Core, Infrastructure projects) and an Angular 18 frontend (client directory).
• Purpose: Provide a shopping platform with product catalog, cart, checkout (including Stripe payments), order management, caching (Redis), real-time notifications (SignalR), and admin interfaces.
Main Components
A. Frontend (Angular SPA)
• Hosted in client/wwwroot (API) or served via Angular dev server in development.
• Modules:
– Core (guards, interceptors, shared singleton services like auth, cart, shop, Stripe, SignalR)
– Features (account, shop, cart, checkout, orders, admin, test-error)
– Shared components/directives/pipes (dialogs, empty states, order summary, error screens)
– Layout (header)
• Communicates with backend via HTTP REST calls and SignalR.
B. Backend (.NET 8 API)
• Layers:
1. API (Controllers, DTOs, Middleware, SignalR Hub)
2. Core (Domain entities, repository & service interfaces, specifications)
3. Infrastructure (EF Core DbContext, migrations, repository implementations, services, caching, Stripe integration, data seeding)
• Exposes REST endpoints (Products, Cart, Orders, Payments webhook, Admin, Coupons, WeatherForecast)
• Real-time: SignalR NotificationHub for push events (e.g., payment succeeded notifications).
C. Data Stores & External Services
• SQL Server (EF Core via StoreContext)
• Redis (ResponseCacheService for caching GET responses)
• Stripe (payment processing, webhooks)
• Docker Compose spins up SQL Server and Redis on ports 1433/6379.
Relationships & Data Flows
• Browser (Angular) → HTTP(S) → .NET API Controllers
• Controllers → Core services (e.g., ICartService, IPaymentService) → Infrastructure implementations (e.g., CartService → GenericRepository → StoreContext → SQL DB)
• Controllers use Redis cache attributes (CacheAttribute, InvalidateCache) to store/retrieve cached data.
• API uses Stripe CLI webhook forwarding to /api/payments/webhook; PaymentController triggers events.
• API pushes real-time notifications to connected clients via SignalR hub.
Architectural Patterns & Principles
• Clean Architecture / Onion Architecture: separation of API, Core, Infrastructure.
• Repository + Unit of Work (IUnitOfWork, GenericRepository).
• Specification pattern to encapsulate query logic.
• DTO mapping extensions for decoupling domain entities from API contracts.
• Middleware for global exception handling.
• HTTP caching via attributes & Redis.
• Dependency Injection throughout.
• Layout:
1. Client Layer: Browser/Angular SPA
2. API Layer:
• Controllers
• Middleware
• SignalR Hub
3. Application Layer: Core interfaces & domain models
4. Infrastructure Layer: EF Core, repositories, services
5. Data Stores & External: SQL Server, Redis, Stripe.
• From Angular services → REST endpoints (e.g., /products, /cart)
• From Controllers → Core services → Infrastructure → Data stores
• From API → Redis (cache)
• From Stripe webhook → PaymentController
• From API → SignalR Hub → Angular SignalR client
• API Layer (green),
• Core (yellow),
• Infrastructure (orange),
• External (gray).