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

1 line
12 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":"BookShelf","domain":"note","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│ BookShelf — 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 Analytics │\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"}],"modules":[{"name":"书籍库","label":"书籍库","features":["书籍库"],"responsibilities":["提供 书籍库 相关功能"]},{"name":"阅读状态","label":"阅读状态","features":["阅读状态"],"responsibilities":["提供 阅读状态 相关功能"]},{"name":"阅读进度","label":"阅读进度","features":["阅读进度"],"responsibilities":["提供 阅读进度 相关功能"]},{"name":"笔记和标注","label":"笔记和标注","features":["笔记和标注"],"responsibilities":["提供 笔记和标注 相关功能"]},{"name":"书评","label":"书评","features":["书评"],"responsibilities":["提供 书评 相关功能"]},{"name":"analytics","label":"Analytics","features":["统计仪表盘"],"responsibilities":["提供 统计仪表盘 相关功能"]},{"name":"搜索和筛选","label":"搜索和筛选","features":["搜索和筛选"],"responsibilities":["提供 搜索和筛选 相关功能"]},{"name":"editor","label":"编辑器","features":["笔记编辑"],"responsibilities":["提供 笔记编辑 相关功能"]},{"name":"search","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":"notes","description":"笔记表","fields":[{"name":"id","type":"UUID","constraints":"PK"},{"name":"user_id","type":"UUID","constraints":"FK → users.id"},{"name":"title","type":"VARCHAR(256)"},{"name":"content","type":"TEXT"},{"name":"is_markdown","type":"BOOLEAN","constraints":"DEFAULT false"},{"name":"folder_id","type":"UUID","constraints":"FK → folders.id"},{"name":"created_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"},{"name":"updated_at","type":"TIMESTAMPTZ","constraints":"DEFAULT NOW()"}],"indexes":["idx_notes_user ON notes(user_id)","idx_notes_folder ON notes(folder_id)","idx_notes_fts ON notes USING GIN (to_tsvector('simple', title || ' ' || content))"]},{"table":"tags","description":"标签表","fields":[{"name":"id","type":"UUID","constraints":"PK"},{"name":"name","type":"VARCHAR(64)","constraints":"NOT NULL, UNIQUE"},{"name":"color","type":"VARCHAR(7)"}]},{"table":"note_tags","description":"笔记-标签关联表","fields":[{"name":"note_id","type":"UUID","constraints":"FK → notes.id"},{"name":"tag_id","type":"UUID","constraints":"FK → tags.id"},{"name":"PRIMARY KEY (note_id, tag_id)"}]}],"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":["bookshelf/","├── 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 / K8s(规模化)","services":["API Server (NestJS)","PostgreSQL 15","Redis 7"],"ci":"GitHub Actions → Build → Test → Deploy"},"meta":{"generatedAt":"2026-06-05T10:19:14.758Z","sourceDomain":"note","moduleCount":9,"tableCount":4,"apiEndpointCount":10}}