Files
2026-06-06 10:40:48 +08:00

1 line
21 KiB
JSON
Raw Permalink 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":"EduPlatform","domain":"education","contract":{"projectName":"EduPlatform","domain":"education","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","instructor"]},{"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":"Courses","table":"courses","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":"title","type":"VARCHAR(256)","required":true,"isPrimary":false,"isAuto":false},{"name":"description","type":"TEXT","required":false,"isPrimary":false,"isAuto":false},{"name":"instructor","type":"VARCHAR(64)","required":false,"isPrimary":false,"isAuto":false},{"name":"price","type":"DECIMAL(10,2)","required":false,"isPrimary":false,"isAuto":false},{"name":"cover_url","type":"TEXT","required":false,"isPrimary":false,"isAuto":false},{"name":"category","type":"VARCHAR(64)","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":"Chapters","table":"chapters","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":"course_id","type":"UUID","required":false,"isPrimary":false,"isAuto":false,"fkEntity":"courses","fkColumn":"id"},{"name":"title","type":"VARCHAR(256)","required":true,"isPrimary":false,"isAuto":false},{"name":"sort_order","type":"INTEGER","required":false,"isPrimary":false,"isAuto":true},{"name":"duration_min","type":"INTEGER","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"},{"type":"belongsTo","entity":"courses","via":"course_id"}]},{"name":"Students","table":"students","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(64)","required":true,"isPrimary":false,"isAuto":false},{"name":"email","type":"VARCHAR(256)","required":false,"isPrimary":false,"isAuto":false},{"name":"enrolled_at","type":"TIMESTAMPTZ","required":false,"isPrimary":false,"isAuto":true},{"name":"progress","type":"DECIMAL(5,2)","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":"Assignments","table":"assignments","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":"course_id","type":"UUID","required":false,"isPrimary":false,"isAuto":false,"fkEntity":"courses","fkColumn":"id"},{"name":"title","type":"VARCHAR(256)","required":true,"isPrimary":false,"isAuto":false},{"name":"description","type":"TEXT","required":false,"isPrimary":false,"isAuto":false},{"name":"due_date","type":"DATE","required":false,"isPrimary":false,"isAuto":false},{"name":"max_score","type":"INTEGER","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"},{"type":"belongsTo","entity":"courses","via":"course_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","cover_url":"coverUrl","course_id":"courseId","sort_order":"sortOrder","duration_min":"durationMin","enrolled_at":"enrolledAt","due_date":"dueDate","max_score":"maxScore","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","total_amount":"totalAmount","address_id":"addressId","remind_at":"remindAt","message":"message","sent":"sent"},"camelToSnake":{"createdAt":"created_at","updatedAt":"updated_at","userId":"user_id","passwordHash":"password_hash","avatarUrl":"avatar_url","coverUrl":"cover_url","courseId":"course_id","sortOrder":"sort_order","durationMin":"duration_min","enrolledAt":"enrolled_at","dueDate":"due_date","maxScore":"max_score","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","totalAmount":"total_amount","addressId":"address_id","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","instructor"],"defaultValue":"user"}},"Courses":{"id":{"required":true},"title":{"required":true}},"Chapters":{"id":{"required":true},"title":{"required":true}},"Students":{"id":{"required":true},"name":{"required":true}},"Assignments":{"id":{"required":true},"title":{"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│ EduPlatform — 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":"/courses","description":"课程发布","dataFlow":["GET /api/courses → 获取课程发布列表","POST /api/courses → 创建课程发布"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"章节管理","route":"/chapters","description":"章节管理","dataFlow":["GET /api/chapters → 获取章节管理列表","POST /api/chapters → 创建章节管理"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"学员进度","route":"/students","description":"学员进度","dataFlow":["GET /api/students → 获取学员进度列表","POST /api/students → 创建学员进度"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"作业批改","route":"/assignments","description":"作业批改","dataFlow":["GET /api/assignments → 获取作业批改列表","POST /api/assignments → 创建作业批改"],"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":"course","label":"课程管理","features":["课程中心","视频播放"],"responsibilities":["提供 课程中心 相关功能","提供 视频播放 相关功能"]},{"name":"exercise","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":"courses","description":"课程发布表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"title","type":"VARCHAR(256)","constraints":"NOT NULL"},{"name":"description","type":"TEXT"},{"name":"instructor","type":"VARCHAR(64)"},{"name":"price","type":"DECIMAL(10,2)"},{"name":"cover_url","type":"TEXT"},{"name":"category","type":"VARCHAR(64)"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_courses_user ON courses(user_id)"]},{"table":"chapters","description":"章节管理表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"course_id","type":"UUID","constraints":"FK → courses.id"},{"name":"title","type":"VARCHAR(256)","constraints":"NOT NULL"},{"name":"sort_order","type":"INTEGER","constraints":"DEFAULT 0"},{"name":"duration_min","type":"INTEGER"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_chapters_user ON chapters(user_id)"]},{"table":"students","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(64)","constraints":"NOT NULL"},{"name":"email","type":"VARCHAR(256)"},{"name":"enrolled_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"progress","type":"DECIMAL(5,2)","constraints":"DEFAULT 0"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_students_user ON students(user_id)"]},{"table":"assignments","description":"作业批改表","fields":[{"name":"id","type":"UUID","constraints":"PK, DEFAULT gen_random_uuid()"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"course_id","type":"UUID","constraints":"FK → courses.id"},{"name":"title","type":"VARCHAR(256)","constraints":"NOT NULL"},{"name":"description","type":"TEXT"},{"name":"due_date","type":"DATE"},{"name":"max_score","type":"INTEGER","constraints":"DEFAULT 100"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_assignments_user ON assignments(user_id)"]}],"apiDesign":[{"resource":"assignments","basePath":"/api/assignments","endpoints":[{"method":"GET","path":"/api/assignments","description":"获取作业批改列表"},{"method":"POST","path":"/api/assignments","description":"创建作业批改"}]},{"resource":"auth","basePath":"/api/auth","endpoints":[{"method":"POST","path":"/api/auth/login","description":"用户登录"},{"method":"GET","path":"/api/auth/me","description":"获取当前用户"}]},{"resource":"chapters","basePath":"/api/chapters","endpoints":[{"method":"GET","path":"/api/chapters","description":"获取章节管理列表"},{"method":"POST","path":"/api/chapters","description":"创建章节管理"}]},{"resource":"courses","basePath":"/api/courses","endpoints":[{"method":"GET","path":"/api/courses","description":"获取课程发布列表"},{"method":"POST","path":"/api/courses","description":"创建课程发布"}]},{"resource":"students","basePath":"/api/students","endpoints":[{"method":"GET","path":"/api/students","description":"获取学员进度列表"},{"method":"POST","path":"/api/students","description":"创建学员进度"}]}],"directoryStructure":["eduplatform/","├── 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/","│ │ │ ├── course/","│ │ │ │ ├── course.controller.ts","│ │ │ │ ├── course.service.ts","│ │ │ │ ├── course.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:37.455Z","sourceDomain":"education","moduleCount":6,"tableCount":5,"apiEndpointCount":10}}