┌─────────────────────────────────────────────────────────────────────────────────┐
│ 客户端 (浏览器) │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ ┌───────────────┐ │
│ │ React 页面 │ │ 购物车上下文 │ │ Toast/UI │ │ 会话 │ │
│ │ (SSR + CSR) │ │ (全局状态) │ │ 组件 │ │ (NextAuth) │ │
│ └───────┬────────┘ └───────┬────────┘ └────────────────┘ └───────┬───────┘ │
└──────────┼───────────────────┼───────────────────────────────────────┼──────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ NEXT.JS 服务器 (App Router) │
│ │
│ ┌─────────────────────────────────────────────────────────────────────────────┐│
│ │ API 路由 ││
│ │ ││
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ ││
│ │ │ /api/ │ │ /api/ │ │ /api/ │ │ /api/auth/ │ ││
│ │ │ products │ │ cart │ │ checkout │ │ [...nextauth] │ ││
│ │ │ categories │ │ orders │ │ webhooks │ │ register │ ││
│ │ │ inventory │ │ user/* │ │ /stripe │ │ forgot-password │ ││
│ │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └────────┬─────────┘ ││
│ │ │ │ │ │ ││
│ └─────────┼─────────────────┼─────────────────┼───────────────────┼───────────┘│
│ │ │ │ │ │
│ ┌─────────┼─────────────────┼─────────────────┼───────────────────┼───────────┐│
│ │ │ 管理后台 API 路由 │ │ ││
│ │ │ ┌──────────────────────────────┐│ │ ││
│ │ │ │ /api/admin/ ││ │ ││
│ │ │ │ products, orders, stats ││ │ ││
│ │ │ │ categories, inventory ││ │ ││
│ │ │ │ shipping, upload-image ││ │ ││
│ │ │ └──────────────────────────────┘│ │ ││
│ └─────────┼───────────────────────────────────┼───────────────────┼───────────┘│
└────────────┼──────────────────────────── ───────┼───────────────────┼────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────┐ ┌─────────────────────────────────────────────────────────┐
│ │ │ 外部服务 │
│ 数据层 │ │ │
│ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ ┌───────────────┐ │ │ │ Stripe │ │ Resend │ │ Cloudinary │ │
│ │ PostgreSQL │ │ │ │ │ │ │ │ │ │
│ │ (Neon) │ │ │ │ • 结账 │ │ • 订单 │ │ • 商品 │ │
│ │ │ │ │ │ • 会话 │ │ 确认 │ │ 图片 │ │
│ │ • users │ │ │ │ • Webhooks │ │ • 发货 │ │ • 上传/ │ │
│ │ • products │ │ │ │ • 支付 │ │ 通知 │ │ 删除 │ │
│ │ • categories │ │ │ │ │ │ • 密码 │ │ │ │
│ │ • orders │ │ │ └──────┬──────┘ │ 重置 │ └─────────────────┘ │
│ │ • order_items │ │ │ │ └─────────────┘ │
│ │ • cart_items │ │ │ │ │
│ │ • addresses │ │ │ ▼ │
│ │ • inventory │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ • password_ │ │ │ │ Google │ │ 17track │ │ Redis │ │
│ │ reset_tokens│ │ │ │ OAuth │ │ API │ │ (Upstash) │ │
│ └───────────────┘ │ │ │ │ │ │ │ │ │
│ │ │ │ • SSO 登录 │ │ • 物流 │ │ • 商品缓存 │ │
│ │ │ │ • 用户信息 │ │ 信息 │ │ • 限流 │ │
│ │ │ │ │ │ • 状态 │ │ • 会话存储 │ │
│ │ │ └─────────────┘ └─────────────┘ └─────────────────┘ │
└─────────────────────┘ └─────────────────────────────────────────────────────────┘