{"projectName":"ShopApp","domain":"ecommerce","contract":{"projectName":"ShopApp","domain":"ecommerce","entities":[{"name":"User","table":"users","description":"系统用户","fields":[{"name":"id","type":"UUID","isPrimary":true,"isAuto":true},{"name":"username","type":"VARCHAR(128)","required":true,"unique":true,"validation":{"minLength":2,"maxLength":50}},{"name":"password_hash","type":"VARCHAR(256)","required":true,"isSecret":true},{"name":"nickname","type":"VARCHAR(128)"},{"name":"role","type":"VARCHAR(32)","defaultValue":"user","enum":["user","admin"]},{"name":"phone","type":"VARCHAR(20)"},{"name":"avatar_url","type":"TEXT"},{"name":"created_at","type":"TIMESTAMP","isAuto":true},{"name":"updated_at","type":"TIMESTAMP","isAuto":true}],"relationships":[]},{"name":"Product","table":"products","description":"商品","fields":[{"name":"id","type":"UUID","isPrimary":true,"isAuto":true},{"name":"user_id","type":"UUID","required":true,"fkEntity":"users","fkColumn":"id"},{"name":"title","type":"VARCHAR(256)","required":true},{"name":"description","type":"TEXT"},{"name":"price","type":"DECIMAL(10,2)"},{"name":"stock","type":"INTEGER","defaultValue":"0"},{"name":"images","type":"JSONB","defaultValue":"[]"},{"name":"created_at","type":"TIMESTAMP","isAuto":true},{"name":"updated_at","type":"TIMESTAMP","isAuto":true}],"relationships":[{"type":"belongsTo","entity":"users","via":"user_id"}]},{"name":"Order","table":"orders","description":"订单","fields":[{"name":"id","type":"UUID","isPrimary":true,"isAuto":true},{"name":"user_id","type":"UUID","required":true,"fkEntity":"users","fkColumn":"id"},{"name":"status","type":"VARCHAR(32)","defaultValue":"pending","enum":["pending","paid","shipped","delivered","cancelled"]},{"name":"total_amount","type":"DECIMAL(12,2)"},{"name":"address_id","type":"UUID","fkEntity":"addresses","fkColumn":"id"},{"name":"created_at","type":"TIMESTAMP","isAuto":true},{"name":"updated_at","type":"TIMESTAMP","isAuto":true}],"relationships":[{"type":"belongsTo","entity":"users","via":"user_id"}]},{"name":"Stocktaking","table":"stocktaking","description":"库存盘点表","fields":[{"name":"id","type":"UUID","required":true,"isPrimary":true,"isAuto":true},{"name":"user_id","type":"UUID","required":false,"isPrimary":false,"isAuto":false,"fkEntity":"users","fkColumn":"id"},{"name":"warehouse","type":"VARCHAR(64)","required":false,"isPrimary":false,"isAuto":false},{"name":"product_name","type":"VARCHAR(128)","required":false,"isPrimary":false,"isAuto":false},{"name":"expected_qty","type":"INTEGER","required":false,"isPrimary":false,"isAuto":false},{"name":"actual_qty","type":"INTEGER","required":false,"isPrimary":false,"isAuto":false},{"name":"diff","type":"INTEGER","required":false,"isPrimary":false,"isAuto":false},{"name":"stocktaken_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true},{"name":"created_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true},{"name":"updated_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true}],"relationships":[{"type":"belongsTo","entity":"users","via":"user_id"}]},{"name":"Suppliers","table":"suppliers","description":"供应商管理表","fields":[{"name":"id","type":"UUID","required":true,"isPrimary":true,"isAuto":true},{"name":"user_id","type":"UUID","required":false,"isPrimary":false,"isAuto":false,"fkEntity":"users","fkColumn":"id"},{"name":"name","type":"VARCHAR(128)","required":true,"isPrimary":false,"isAuto":false},{"name":"contact","type":"VARCHAR(64)","required":false,"isPrimary":false,"isAuto":false},{"name":"phone","type":"VARCHAR(20)","required":false,"isPrimary":false,"isAuto":false},{"name":"email","type":"VARCHAR(256)","required":false,"isPrimary":false,"isAuto":false},{"name":"address","type":"TEXT","required":false,"isPrimary":false,"isAuto":false},{"name":"created_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true},{"name":"updated_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true}],"relationships":[{"type":"belongsTo","entity":"users","via":"user_id"}]},{"name":"StockAlerts","table":"stock_alerts","description":"库存预警表","fields":[{"name":"id","type":"UUID","required":true,"isPrimary":true,"isAuto":true},{"name":"user_id","type":"UUID","required":false,"isPrimary":false,"isAuto":false,"fkEntity":"users","fkColumn":"id"},{"name":"product_name","type":"VARCHAR(128)","required":true,"isPrimary":false,"isAuto":false},{"name":"current_qty","type":"INTEGER","required":false,"isPrimary":false,"isAuto":false},{"name":"threshold","type":"INTEGER","required":false,"isPrimary":false,"isAuto":false},{"name":"alerted_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true},{"name":"created_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true},{"name":"updated_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true}],"relationships":[{"type":"belongsTo","entity":"users","via":"user_id"}]}],"auth":{"registrationFields":["username","password","nickname"],"loginFields":["username","password"],"jwtPayload":["userId","username","role"],"passwordPolicy":{"minLength":6,"requireSpecial":false}},"permissions":[{"role":"admin","allow":["*"]},{"role":"user","allow":["read:own","create:*","update:own","delete:own"]}],"fieldMapping":{"snakeToCamel":{"created_at":"createdAt","updated_at":"updatedAt","user_id":"userId","password_hash":"passwordHash","avatar_url":"avatarUrl","total_amount":"totalAmount","address_id":"addressId","product_name":"productName","expected_qty":"expectedQty","actual_qty":"actualQty","stocktaken_at":"stocktakenAt","current_qty":"currentQty","alerted_at":"alertedAt","id":"id","username":"username","nickname":"nickname","role":"role","phone":"phone","title":"title","description":"description","status":"status","data":"data","amount":"amount","party_a":"partyA","party_b":"partyB","signed_at":"signedAt","expires_at":"expiresAt","file_url":"fileUrl","entity_type":"entityType","entity_id":"entityId","applicant_id":"applicantId","form_data":"formData","name":"name","email":"email","company":"company","source":"source","tags":"tags","breed":"breed","species":"species","birth_date":"birthDate","weight_kg":"weightKg","price":"price","stock":"stock","images":"images","remind_at":"remindAt","message":"message","sent":"sent"},"camelToSnake":{"createdAt":"created_at","updatedAt":"updated_at","userId":"user_id","passwordHash":"password_hash","avatarUrl":"avatar_url","totalAmount":"total_amount","addressId":"address_id","productName":"product_name","expectedQty":"expected_qty","actualQty":"actual_qty","stocktakenAt":"stocktaken_at","currentQty":"current_qty","alertedAt":"alerted_at","id":"id","username":"username","nickname":"nickname","role":"role","phone":"phone","title":"title","description":"description","status":"status","data":"data","amount":"amount","partyA":"party_a","partyB":"party_b","signedAt":"signed_at","expiresAt":"expires_at","fileUrl":"file_url","entityType":"entity_type","entityId":"entity_id","applicantId":"applicant_id","formData":"form_data","name":"name","email":"email","company":"company","source":"source","tags":"tags","breed":"breed","species":"species","birthDate":"birth_date","weightKg":"weight_kg","price":"price","stock":"stock","images":"images","remindAt":"remind_at","message":"message","sent":"sent"}},"validation":{"User":{"username":{"minLength":2,"maxLength":50,"required":true,"unique":true},"password_hash":{"required":true},"role":{"enum":["user","admin"],"defaultValue":"user"}},"Product":{"user_id":{"required":true},"title":{"required":true},"stock":{"defaultValue":"0"},"images":{"defaultValue":"[]"}},"Order":{"user_id":{"required":true},"status":{"enum":["pending","paid","shipped","delivered","cancelled"],"defaultValue":"pending"}},"Stocktaking":{"id":{"required":true}},"Suppliers":{"id":{"required":true},"name":{"required":true}},"StockAlerts":{"id":{"required":true},"product_name":{"required":true}}}},"techStack":{"frontend":"React Native 0.76 + Expo / Flutter 3.x","backend":"NestJS + Prisma","database":"PostgreSQL 15 + Redis 7 + MinIO(文件存储)","deployment":"Docker Compose + Nginx / K8s(规模化)","considerations":[]},"architectureDiagram":"┌─────────────────────────────────────────────────────────┐\n│ ShopApp — System Architecture │\n├─────────────────────────────────────────────────────────┤\n│ │\n│ ┌──────────────────────┐ ┌──────────────────────┐ │\n│ │ Client Layer │ │ Admin / Web │ │\n│ │ React Native 0.76 + Expo / Flutter 3.x │ │ 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":"/products","description":"商品入库出库","dataFlow":["GET /api/products → 获取商品入库出库列表","POST /api/products → 创建商品入库出库"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"库存盘点","route":"/stocktaking","description":"库存盘点","dataFlow":["GET /api/stocktaking → 获取库存盘点列表","POST /api/stocktaking → 创建库存盘点"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"供应商管理","route":"/suppliers","description":"供应商管理","dataFlow":["GET /api/suppliers → 获取供应商管理列表","POST /api/suppliers → 创建供应商管理"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"库存预警","route":"/stock_alerts","description":"库存预警","dataFlow":["GET /api/stock_alerts → 获取库存预警列表","POST /api/stock_alerts → 创建库存预警"],"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":"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, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"product_name","type":"VARCHAR(128)","constraints":"NOT NULL"},{"name":"quantity","type":"INTEGER","constraints":"NOT NULL"},{"name":"supplier","type":"VARCHAR(128)"},{"name":"received_by","type":"UUID","constraints":"FK → users.id"},{"name":"received_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_products_user ON products(user_id)"]},{"table":"stocktaking","description":"库存盘点表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"warehouse","type":"VARCHAR(64)"},{"name":"product_name","type":"VARCHAR(128)"},{"name":"expected_qty","type":"INTEGER"},{"name":"actual_qty","type":"INTEGER"},{"name":"diff","type":"INTEGER"},{"name":"stocktaken_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_stocktaking_user ON stocktaking(user_id)"]},{"table":"suppliers","description":"供应商管理表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"name","type":"VARCHAR(128)","constraints":"NOT NULL"},{"name":"contact","type":"VARCHAR(64)"},{"name":"phone","type":"VARCHAR(20)"},{"name":"email","type":"VARCHAR(256)"},{"name":"address","type":"TEXT"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_suppliers_user ON suppliers(user_id)"]},{"table":"stock_alerts","description":"库存预警表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"product_name","type":"VARCHAR(128)","constraints":"NOT NULL"},{"name":"current_qty","type":"INTEGER"},{"name":"threshold","type":"INTEGER"},{"name":"alerted_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_stock_alerts_user ON stock_alerts(user_id)"]}],"apiDesign":[{"resource":"auth","basePath":"/api/auth","endpoints":[{"method":"POST","path":"/api/auth/login","description":"用户登录"},{"method":"GET","path":"/api/auth/me","description":"获取当前用户"}]},{"resource":"products","basePath":"/api/products","endpoints":[{"method":"GET","path":"/api/products","description":"获取商品入库出库列表"},{"method":"POST","path":"/api/products","description":"创建商品入库出库"}]},{"resource":"stock_alerts","basePath":"/api/stock_alerts","endpoints":[{"method":"GET","path":"/api/stock_alerts","description":"获取库存预警列表"},{"method":"POST","path":"/api/stock_alerts","description":"创建库存预警"}]},{"resource":"stocktaking","basePath":"/api/stocktaking","endpoints":[{"method":"GET","path":"/api/stocktaking","description":"获取库存盘点列表"},{"method":"POST","path":"/api/stocktaking","description":"创建库存盘点"}]},{"resource":"suppliers","basePath":"/api/suppliers","endpoints":[{"method":"GET","path":"/api/suppliers","description":"获取供应商管理列表"},{"method":"POST","path":"/api/suppliers","description":"创建供应商管理"}]}],"directoryStructure":["shopapp/","├── 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/","│ │ │ ├── product/","│ │ │ │ ├── product.controller.ts","│ │ │ │ ├── product.service.ts","│ │ │ │ ├── product.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 / K8s(规模化)","services":["API Server (NestJS)","PostgreSQL 15","Redis 7"],"ci":"GitHub Actions → Build → Test → Deploy"},"meta":{"generatedAt":"2026-06-05T22:08:34.624Z","sourceDomain":"ecommerce","moduleCount":6,"tableCount":5,"apiEndpointCount":10}}