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

1 line
11 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":"NoteApp","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│ NoteApp — 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 Storage │\n│ 3 全文搜索 │\n│ 4 多端同步 │\n│ 5 Content │\n│ 6 编辑器 │\n│ │\n└─────────────────────────────────────────────────────────┘","dataFlows":[{"page":"笔记列表","route":"/notes","description":"文件夹导航、笔记列表、搜索","dataFlow":["GET /api/notes → 笔记列表","POST /api/notes → 创建笔记"],"direction":"Client → API Gateway → Backend → Database → Response → Client"},{"page":"标签管理","route":"/tags","description":"标签列表、关联笔记","dataFlow":["GET /api/tags → 标签列表"],"direction":"Client → API Gateway → Backend → Database → Response → Client"}],"modules":[{"name":"笔记编辑","label":"笔记编辑","features":["笔记编辑"],"responsibilities":["提供 笔记编辑 相关功能"]},{"name":"storage","label":"Storage","features":["文件夹/标签"],"responsibilities":["提供 文件夹/标签 相关功能"]},{"name":"全文搜索","label":"全文搜索","features":["全文搜索"],"responsibilities":["提供 全文搜索 相关功能"]},{"name":"多端同步","label":"多端同步","features":["多端同步"],"responsibilities":["提供 多端同步 相关功能"]},{"name":"content","label":"Content","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":"notes","basePath":"/api/notes","endpoints":[{"method":"GET","path":"/api/notes","description":"笔记列表"},{"method":"POST","path":"/api/notes","description":"创建笔记"},{"method":"PUT","path":"/api/notes/:id","description":"更新笔记"},{"method":"DELETE","path":"/api/notes/:id","description":"删除笔记"}]},{"resource":"tags","basePath":"/api/tags","endpoints":[{"method":"GET","path":"/api/tags","description":"标签列表"}]}],"directoryStructure":["noteapp/","├── apps/","│ ├── mobile/ # React Native / Flutter 移动端","│ │ ├── src/","│ │ │ ├── screens/ # 页面组件","│ │ │ │ ├── 笔记编辑/","│ │ │ │ ├── storage/","│ │ │ │ ├── 全文搜索/","│ │ │ │ ├── 多端同步/","│ │ │ ├── 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/","│ │ │ ├── storage/","│ │ │ │ ├── storage.controller.ts","│ │ │ │ ├── storage.service.ts","│ │ │ │ ├── storage.module.ts","│ │ │ │ └── dto/","│ │ │ ├── 全文搜索/","│ │ │ │ ├── 全文搜索.controller.ts","│ │ │ │ ├── 全文搜索.service.ts","│ │ │ │ ├── 全文搜索.module.ts","│ │ │ │ └── dto/","│ │ │ ├── 多端同步/","│ │ │ │ ├── 多端同步.controller.ts","│ │ │ │ ├── 多端同步.service.ts","│ │ │ │ ├── 多端同步.module.ts","│ │ │ │ └── dto/","│ │ │ ├── content/","│ │ │ │ ├── content.controller.ts","│ │ │ │ ├── content.service.ts","│ │ │ │ ├── content.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-05T09:43:40.792Z","sourceDomain":"note","moduleCount":7,"tableCount":4,"apiEndpointCount":5}}