Files
16gagent/cases/mealprep-v2/arch.json
T
2026-06-06 10:40:48 +08:00

1 line
13 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"projectName":"MealPrep","domain":"ecommerce","techStack":{"frontend":"React Native 0.76 + Expo","backend":"NestJS + Prisma","database":"PostgreSQL 15 + Redis 7","deployment":"Docker Compose + Nginx","considerations":[]},"architectureDiagram":"┌─────────────────────────────────────────────────────────┐\n│ MealPrep — System Architecture │\n├─────────────────────────────────────────────────────────┤\n│ │\n│ ┌──────────────────────┐ ┌──────────────────────┐ │\n│ │ Client Layer │ │ Admin / Web │ │\n│ │ React Native 0.76 + Expo │ │ React + Vite (Web) │ │\n│ └──────────┬───────────┘ └──────────┬───────────┘ │\n│ │ │ │\n│ └──────────┬────────────────┘ │\n│ │ │\n│ ┌─────────▼──────────┐ │\n│ │ API Gateway │ │\n│ │ Nginx / Kong │ │\n│ └─────────┬──────────┘ │\n│ │ │\n│ ┌─────────▼──────────┐ │\n│ │ Backend Services │ │\n│ │ NestJS + Prisma │ │\n│ └─────────┬──────────┘ │\n│ │ │\n│ ┌───────────────┼───────────────┐ │\n│ │ │ │ │\n│ ┌─────▼─────┐ ┌──────▼──────┐ ┌────▼─────┐ │\n│ │ PostgreSQL 15│ │ Redis Cache │ │ MinIO │ │\n│ │ Primary │ │ Session │ │ Files │ │\n│ └───────────┘ └─────────────┘ └──────────┘ │\n│ │\n├─────────────────────────────────────────────────────────┤\n│ Modules: │\n│ 1 食物库 │\n│ 2 客户管理 │\n│ 3 餐计划 │\n│ 4 营养计算 │\n│ 5 购物清单 │\n│ 6 模板功能 │\n│ │\n└─────────────────────────────────────────────────────────┘","dataFlows":[{"page":"食物库","route":"/食物库","description":"管理食物信息(名称","dataFlow":["GET /api/食物库 → 获取食物库列表","POST /api/食物库 → 创建食物库"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"客户管理","route":"/客户管理","description":"客户档案(姓名","dataFlow":["GET /api/客户管理 → 获取客户管理列表","POST /api/客户管理 → 创建客户管理"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"餐计划","route":"/餐计划","description":"为每个客户创建每周餐计划(早/中/晚/加餐","dataFlow":["GET /api/餐计划 → 获取餐计划列表","POST /api/餐计划 → 创建餐计划"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"营养计算","route":"/营养计算","description":"自动计算每餐和每日总营养,与客户目标对比。","dataFlow":["GET /api/营养计算 → 获取营养计算列表","POST /api/营养计算 → 创建营养计算"],"direction":"Client → API Gateway → Backend → Database → Response → Client"}],"modules":[{"name":"食物库","label":"食物库","features":["食物库"],"responsibilities":["提供 食物库 相关功能"]},{"name":"客户管理","label":"客户管理","features":["客户管理"],"responsibilities":["提供 客户管理 相关功能"]},{"name":"餐计划","label":"餐计划","features":["餐计划"],"responsibilities":["提供 餐计划 相关功能"]},{"name":"营养计算","label":"营养计算","features":["营养计算"],"responsibilities":["提供 营养计算 相关功能"]},{"name":"购物清单","label":"购物清单","features":["购物清单"],"responsibilities":["提供 购物清单 相关功能"]},{"name":"模板功能","label":"模板功能","features":["模板功能"],"responsibilities":["提供 模板功能 相关功能"]},{"name":"product","label":"商品管理","features":["商品浏览"],"responsibilities":["提供 商品浏览 相关功能"]},{"name":"order","label":"订单管理","features":["订单管理"],"responsibilities":["提供 订单管理 相关功能"]}],"databaseSchema":[{"table":"users","description":"用户表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"phone","type":"VARCHAR(20)","constraints":"UNIQUE"},{"name":"nickname","type":"VARCHAR(64)"},{"name":"avatar_url","type":"TEXT"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_users_phone ON users(phone)"]},{"table":"products","description":"商品表","fields":[{"name":"id","type":"UUID","constraints":"PK"},{"name":"title","type":"VARCHAR(256)","constraints":"NOT NULL"},{"name":"price","type":"DECIMAL(10,2)","constraints":"NOT NULL"},{"name":"stock","type":"INTEGER","constraints":"DEFAULT 0"},{"name":"images","type":"JSONB"},{"name":"category_id","type":"UUID","constraints":"FK → categories.id"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_products_category ON products(category_id)"]},{"table":"orders","description":"订单表","fields":[{"name":"id","type":"UUID","constraints":"PK"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"status","type":"VARCHAR(32)","constraints":"DEFAULT 'pending'"},{"name":"total_amount","type":"DECIMAL(10,2)"},{"name":"address_id","type":"UUID","constraints":"FK → addresses.id"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}]},{"table":"order_items","description":"订单明细表","fields":[{"name":"id","type":"UUID","constraints":"PK"},{"name":"order_id","type":"UUID","constraints":"FK → orders.id"},{"name":"product_id","type":"UUID","constraints":"FK → products.id"},{"name":"quantity","type":"INTEGER","constraints":"NOT NULL"},{"name":"unit_price","type":"DECIMAL(10,2)"}]},{"table":"logistics","description":"物流追踪表","fields":[{"name":"id","type":"UUID","constraints":"PK"},{"name":"order_id","type":"UUID","constraints":"FK → orders.id, UNIQUE"},{"name":"carrier","type":"VARCHAR(64)"},{"name":"tracking_number","type":"VARCHAR(128)"},{"name":"status","type":"VARCHAR(32)"},{"name":"events","type":"JSONB","constraints":"DEFAULT '[]'"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}]}],"apiDesign":[{"resource":"auth","basePath":"/api/auth","endpoints":[{"method":"POST","path":"/api/auth/login","description":"用户登录"},{"method":"GET","path":"/api/auth/me","description":"获取当前用户"}]},{"resource":"客户管理","basePath":"/api/客户管理","endpoints":[{"method":"GET","path":"/api/客户管理","description":"获取客户管理列表"},{"method":"POST","path":"/api/客户管理","description":"创建客户管理"}]},{"resource":"营养计算","basePath":"/api/营养计算","endpoints":[{"method":"GET","path":"/api/营养计算","description":"获取营养计算列表"},{"method":"POST","path":"/api/营养计算","description":"创建营养计算"}]},{"resource":"食物库","basePath":"/api/食物库","endpoints":[{"method":"GET","path":"/api/食物库","description":"获取食物库列表"},{"method":"POST","path":"/api/食物库","description":"创建食物库"}]},{"resource":"餐计划","basePath":"/api/餐计划","endpoints":[{"method":"GET","path":"/api/餐计划","description":"获取餐计划列表"},{"method":"POST","path":"/api/餐计划","description":"创建餐计划"}]}],"directoryStructure":["mealprep/","├── apps/","│ ├── mobile/ # React Native / Flutter 移动端","│ │ ├── src/","│ │ │ ├── screens/ # 页面组件","│ │ │ │ ├── 食物库/","│ │ │ │ ├── 客户管理/","│ │ │ │ ├── 餐计划/","│ │ │ │ ├── 营养计算/","│ │ │ ├── components/ # 通用组件","│ │ │ ├── hooks/ # 自定义 Hooks","│ │ │ ├── services/ # API 调用层","│ │ │ ├── store/ # 状态管理","│ │ │ └── utils/ # 工具函数","│ │ ├── app.json","│ │ └── package.json","│ └── web/ # Web 管理后台","│ ├── src/","│ │ ├── pages/","│ │ ├── components/","│ │ └── layouts/","│ └── package.json","├── packages/","│ └── shared/ # 共享类型/常量","├── server/ # NestJS 后端服务","│ ├── src/","│ │ ├── modules/ # 业务模块","│ │ │ ├── 食物库/","│ │ │ │ ├── 食物库.controller.ts","│ │ │ │ ├── 食物库.service.ts","│ │ │ │ ├── 食物库.module.ts","│ │ │ │ └── dto/","│ │ │ ├── 客户管理/","│ │ │ │ ├── 客户管理.controller.ts","│ │ │ │ ├── 客户管理.service.ts","│ │ │ │ ├── 客户管理.module.ts","│ │ │ │ └── dto/","│ │ │ ├── 餐计划/","│ │ │ │ ├── 餐计划.controller.ts","│ │ │ │ ├── 餐计划.service.ts","│ │ │ │ ├── 餐计划.module.ts","│ │ │ │ └── dto/","│ │ │ ├── 营养计算/","│ │ │ │ ├── 营养计算.controller.ts","│ │ │ │ ├── 营养计算.service.ts","│ │ │ │ ├── 营养计算.module.ts","│ │ │ │ └── dto/","│ │ │ ├── 购物清单/","│ │ │ │ ├── 购物清单.controller.ts","│ │ │ │ ├── 购物清单.service.ts","│ │ │ │ ├── 购物清单.module.ts","│ │ │ │ └── dto/","│ │ ├── common/ # 通用(guards, filters, interceptors","│ │ ├── prisma/ # Prisma ORM","│ │ │ └── schema.prisma","│ │ ├── config/ # 环境配置","│ │ └── main.ts","│ ├── test/","│ ├── Dockerfile","│ └── package.json","├── docker-compose.yml","├── .github/workflows/ # CI/CD","│ └── ci.yml","├── .env.example","├── README.md","└── turbo.json # Monorepo 配置"],"deployment":{"environments":["development","staging","production"],"strategy":"Docker Compose + Nginx","services":["API Server (NestJS)","PostgreSQL 15","Redis 7"],"ci":"GitHub Actions → Build → Test → Deploy"},"meta":{"generatedAt":"2026-06-05T10:19:15.527Z","sourceDomain":"ecommerce","moduleCount":8,"tableCount":5,"apiEndpointCount":10}}