百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

freshcart-backend

> 前端框架
开源

FreshCart — 采用 Angular 20 SPA 的 .NET 10 + Aspire 微服务参考电子商务平台

192 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

FreshCart — 采用 Angular 20 SPA 的 .NET 10 + Aspire 微服务参考电子商务平台

FreshCart — Online Supermarket Reference Architecture

Start here: open index.html in any browser. That single page is the animated architecture guide, the demo-credentials sheet, the operations runbook and the interview tour, all in one self-contained document. The backend platform for FreshCart: twelve bounded contexts, each in a deliberately different architectural style, behind a YARP gateway, hosted on Azure Kubernetes Service through Azure DevOps or GitHub Actions multi-stage pipelines. The Angular 20 signal-based storefront lives in a companion repository — amasen02/freshcart-web.


Try it now — demo URLs + seeded credentials

The platform ships with three pre-seeded accounts so you can sign in and walk through the customer and back-office flows in under a minute. The IdentityDataSeeder creates them automatically on first boot when ASPNETCORE_ENVIRONMENT=Development. It refuses to run in any other environment.

Boot the platform

bash
# 0. Clone
git clone https://github.com/amasen02/freshcart-backend.git && cd freshcart-backend

# 1. Whole .NET stack via Aspire — boots its backing stores, every microservice and the gateway
dotnet run --project src/AspireAppHost/FreshCart.AppHost/FreshCart.AppHost.csproj --launch-profile http

# 2. Customer storefront (separate repo) — ng serve proxies /api and /hubs to the gateway on 7100
git clone https://github.com/amasen02/freshcart-web.git
cd freshcart-web && npm ci && npm start

Open in the browser

Surface URL What it shows
Customer storefront https://localhost:4200 Catalog, basket, checkout, orders, support chat, real-time notifications
Aspire dashboard http://localhost:15888 Every service + live traces, metrics, logs
YARP API Gateway https://localhost:7100 Single public edge; cookie-to-JWT BFF exchange
Identity API (OpenAPI) https://localhost:7101 Sign-up, sign-in, refresh, MFA enrollment
Customer Support API (development Swagger UI) https://localhost:7111/swagger OpenAPI schema exploration; support operations still require a JWT
Reporting API (OpenAPI) https://localhost:7110 Dashboards, invoices, Excel exports
Seq (logs) http://localhost:5341 Structured logs across every service
Grafana (metrics) http://localhost:3000 RED + USE dashboards (admin / freshcart_local_dev)
Prometheus http://localhost:9090 Raw metric store
RabbitMQ management http://localhost:15672 Queues + exchanges (freshcart / freshcart_local_dev)

Customer Support exposes its OpenAPI surface locally during Development:

  • https://localhost:7111/swagger serves the self-hosted Swagger UI assets.
  • https://localhost:7111/openapi/v1.json serves the generated document consumed by that UI.
  • The document endpoint is available for local schema exploration; support operations remain protected by their configured JWT policies. The UI does not mint or supply credentials.
  • GET /support/sessions/active returns ChatSessionDto values; GET /support/sessions returns a paginated ChatSessionDto envelope; and GET /support/sessions/{sessionId}/messages returns a paginated ChatMessageDto envelope.

Sign in with one of the seeded accounts

Role Email Password What this account can do
Customer [email protected] Demo-P@ssw0rd-2026 Browse catalog, add to basket, check out, view orders, chat to support
SupportAgent [email protected] Support-P@ssw0rd-2026 Answer support chats; query the Reporting API for order context
Administrator [email protected] Admin-P@ssw0rd-2026 Reporting API: KPI dashboards, invoices, inventory health, exports

Production safety. The seeder is guarded by IHostEnvironment.IsDevelopment() and the sign-up validator rejects any *.test email — these accounts cannot exist in Staging or Production.

The admin SPA is a planned phase (see CHANGELOG.md). Until it ships, the SupportAgent and Administrator surfaces are reached through the Reporting API and the support hub directly.

90-second guided tour after sign-in

  1. Open → sign in as [email protected].
  2. Browse the catalog (30 seeded products across 8 categories), add three items to the basket.
  3. Check out — accept the default address. The Ordering saga drives stock reservation, payment capture, and delivery booking.
  4. A toast notification appears within ~1 second — that is the NotificationHub SignalR push through the Redis backplane.
  5. Open the support panel and start a chat; a SupportAgent session picks it up over the WebSocket hub.
  6. Hit the Reporting API at with the [email protected] token → Sales overview reflects the test order in the GMV and order-count tiles.
  7. POST /invoices for the order → a QuestPDF-rendered PDF opens via a 15-minute Azure Blob SAS URL.
  8. GET /exports/sales-transactions.xlsx — ClosedXML Excel with frozen header and auto-width columns.

Why this repo exists

The candidate's CV lists eleven years of work across .NET, Angular, Azure, AWS, IdentityServer4, SignalR, RabbitMQ, microservices, DDD, CQRS, Event Sourcing, Saga, polyglot persistence, EF Core + Dapper hybrid, SonarQube, Prometheus + Grafana, AKS, EKS, Azure DevOps CI/CD.

A long list of skills is unfalsifiable. This repository is the falsifiable evidence for the backend — every claim anchored to running code, an ADR, and a walkthrough card. The Angular front-end evidence lives in the companion repo freshcart-web.


Domain — twelve bounded contexts

# Context Architecture Persistence Status
1 Identity Clean Architecture + ASP.NET Identity Azure SQL Built
2 Catalog Vertical Slice + Carter + MediatR PostgreSQL + Marten Built
3 Pricing gRPC service SQLite (in-container) Built
4 Basket Vertical Slice + Outbox + Decorator PostgreSQL + Redis HybridCache Built
5 Ordering Clean / Onion + DDD + Saga SQL Server (EF Core writes, Dapper reads) Built
6 Inventory Layered (3-tier) + Dapper SQL Server Built
7 Payment Clean + Event Sourcing MongoDB events + SQL Server projection Built
8 Delivery Hexagonal (Ports & Adapters) MongoDB (geo indexes) Built
9 Notification Pipes-and-filters + SignalR MongoDB + Redis backplane Built
10 CustomerSupport Stateful WebSocket MongoDB transcripts + Redis presence Built
11 Reviews Vertical Slice + Document DB MongoDB Built
12 Reporting CQRS read model + QuestPDF MySQL warehouse + Blob Storage Built

Edge and clients:

Surface Technology Status
YARP API Gateway .NET 10 + YARP; cookie-to-JWT BFF exchange Built
AdminBackoffice Modular monolith (IModule pattern) Planned
Customer SPA Angular 20 standalone + signals + Bootstrap 5 Built — separate repo: freshcart-web
Admin SPA Angular 20 standalone + signals + Bootstrap 5 Planned — will live in freshcart-web

The browser clients live in the companion frontend repository amasen02/freshcart-web; this repository is the backend platform they reach through the gateway.

BuildingBlocks carries the cross-cutting libraries: BuildingBlocks (CQRS, behaviors, exception handling, pagination, security), BuildingBlocks.Messaging (integration event contracts, outbox, MassTransit wiring), BuildingBlocks.Observability, and ServiceDefaults.


Reporting suite

The Reporting service is a first-class member of the platform:

  • Executive KPI dashboards — GMV, net revenue, AOV, refund rate, customer LTV, delivery success rate, inventory health.
  • PDF invoice generation via QuestPDF with gap-free per-year per-kind invoice numbering (INV-2026-000123, CR-2026-000018, PF-2026-000009).
  • Excel exports via ClosedXML (managed-only, no Office install).
  • Daily scheduled reports dropped into Azure Blob Storage by a BackgroundService.
  • Event projection pipeline — OrderConfirmed, OrderRefunded integration events consumed by MassTransit, UPSERT-ed into denormalised MySQL tables. Idempotent at every hop via the projection inbox.

See index.html → Reporting & Invoices tab for the full surface.


Cross-cutting concerns

  • Authentication. ASP.NET Identity + HttpOnly + Secure + SameSite=Strict cookies for the browser; JWT bearer for service-to-service. Anti-forgery double-submit on every state-changing endpoint.
  • Authorisation. Per-endpoint policies (Customer, SupportAgent, Administrator, BackOfficeUser); resource-based authorization handlers defeat BOLA.
  • Observability. OpenTelemetry → OTLP → Azure App Insights + Log Analytics; Azure Managed Prometheus + Managed Grafana. W3C TraceContext propagated through HTTP, gRPC, MassTransit, SignalR.
  • Resilience. AddStandardResilienceHandler() on every typed HttpClient (retry + circuit breaker + timeout + bulkhead).
  • Validation. FluentValidation dispatched by the MediatR ValidationBehavior.
  • Errors. Single CustomExceptionHandler mapping domain exceptions to RFC 7807 ProblemDetails with traceId.
  • Outbox. Transactional outbox in Basket and Ordering; OutboxPublisher background worker; consumers idempotent via inbox.
  • Security headers. UseFreshCartSecurityHeaders() middleware applies CSP strict, X-Frame-Options=DENY, Referrer-Policy, Permissions-Policy, COOP/COEP/CORP.
  • SSRF exposure. Both typed HttpClients use a fixed BaseAddress with relative request URIs, so no caller-supplied URL reaches an outbound call, and the AKS egress NetworkPolicy blocks 169.254.169.254. OutboundUrlAllowListHandler is written and unit-tested but is not yet attached to any typed HttpClient — see SECURITY.md.
  • Crypto. Argon2id password hashing (replaces PBKDF2). Refresh-token reuse detection.

Full OWASP Top-10 2025 mapping in docs/adr/ADR-0004-owasp-top-10-control-mapping.md.


Reliability & correctness — proven, not claimed

The hard parts of a distributed system are the races. Each guarantee below is backed by a real-database concurrency test (Testcontainers spins up the actual engine and fires N parallel callers) rather than asserted in prose:

  • Exactly-once read projections (Reporting). The idempotency record commits in the same transaction as the projection, so an at-least-once redelivery can never double-count an additive aggregate (refund totals, customer lifetime value). Proven by a redelivery test and a 12-way concurrent MySQL test. (REP-001)
  • No oversubscribed delivery slots. Booking is a single conditional increment guarded by BookedCount < Capacity; the loser of a race is redelivered and re-scheduled against the remaining slots. Proven by a 20-way concurrent MongoDB test. (DLV-001)
  • Gap-free, collision-free invoice numbers. Allocation is one atomic upsert (INSERT … ON DUPLICATE KEY UPDATE … LAST_INSERT_ID), never a read-then-write. Proven by a 25-way concurrent MySQL test yielding exactly {1..25}. (REP-002)
  • Single-use refresh tokens. Rotation is claimed with one conditional UPDATE; a concurrent reuse is treated as a stolen-token

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#angularazureclean-architecturecqrs

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架