docs: freeze YuXinGu lexicon, journey, and P1 engineering sources
Establish product language contract, user journey with dual growth engines, ERD/OpenAPI/Go boundaries, and H5 routes (/profile, /portrait, /relation, /membership) before P1 implementation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
# ERD — P1 Schema(冻结草案)
|
||||
|
||||
实现时用 migration 落地;列名可微调但**表/聚合关系不得偏离**。
|
||||
类型:Postgres。敏感:生日等属 Profile,需可删账号级联。
|
||||
|
||||
---
|
||||
|
||||
## Tables
|
||||
|
||||
### users
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| created_at | timestamptz | |
|
||||
| status | text | active/deleted |
|
||||
|
||||
### device_identities
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| device_key | text unique | Visitor |
|
||||
| user_id | uuid null FK→users | 升级后绑定 |
|
||||
|
||||
### profiles
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK→users | |
|
||||
| relation | text | self \| other |
|
||||
| display_name | text | |
|
||||
| birth_date | date | required P1 |
|
||||
| birth_time | time null | optional |
|
||||
| birth_place | text null | optional |
|
||||
| gender | text null | |
|
||||
| relation_type | text null | partner/family/friend… when other |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### scales
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| slug | text unique | |
|
||||
| title | text | 探索测试标题 |
|
||||
| status | text | published/draft |
|
||||
|
||||
### scale_questions
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| scale_id | uuid FK | |
|
||||
| sort | int | |
|
||||
| body | jsonb | 题干与选项 |
|
||||
|
||||
### scale_results
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| scale_id | uuid FK | |
|
||||
| profile_id | uuid FK | |
|
||||
| answers | jsonb | |
|
||||
| result | jsonb | 探索结果摘要(可公开字段) |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### growth_reports
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| profile_id | uuid FK | |
|
||||
| type | text | portrait \| relation \| … |
|
||||
| summary | jsonb | **基础版**,始终可按规则返回 |
|
||||
| detail | jsonb | **深度版**,服务端按权益剥离 |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### relation_insights
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| profile_a_id | uuid FK | usually self |
|
||||
| profile_b_id | uuid FK | other |
|
||||
| summary | jsonb | 对比标签等基础 |
|
||||
| report_id | uuid null FK→growth_reports | 深度建议所在报告 |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### ask_threads
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| profile_id | uuid FK | 当前解读对象 |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### ask_messages
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| thread_id | uuid FK | |
|
||||
| role | text | user \| assistant |
|
||||
| content | text | |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### memberships
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| user_id | uuid PK FK→users | |
|
||||
| plan | text | month/quarter/year |
|
||||
| status | text | active/expired |
|
||||
| expires_at | timestamptz | |
|
||||
| ask_quota_left | int | |
|
||||
|
||||
### orders
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| kind | text | membership \| deep_access |
|
||||
| amount_cents | int | |
|
||||
| status | text | created/paid/failed |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### payments
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| order_id | uuid FK | |
|
||||
| channel | text | mock \| wechat… |
|
||||
| status | text | |
|
||||
| raw | jsonb null | |
|
||||
|
||||
### deep_accesses
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| report_id | uuid FK→growth_reports | |
|
||||
| order_id | uuid FK | |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
### moods(P2 可先建表空用)
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| day | date | |
|
||||
| score | int null | |
|
||||
| note | text null | |
|
||||
|
||||
### memory_items(P3)
|
||||
| column | type | notes |
|
||||
|---|---|---|
|
||||
| id | uuid PK | |
|
||||
| user_id | uuid FK | |
|
||||
| kind | text | |
|
||||
| payload | jsonb | |
|
||||
| created_at | timestamptz | |
|
||||
|
||||
---
|
||||
|
||||
## Relationship sketch
|
||||
|
||||
```
|
||||
users 1──* profiles
|
||||
users 1──* scale_results
|
||||
users 1──* growth_reports
|
||||
users 1──0..1 memberships
|
||||
users 1──* orders 1──* payments
|
||||
growth_reports 1──* deep_accesses
|
||||
profiles ── relation_insights ── profiles
|
||||
users 1──* ask_threads 1──* ask_messages
|
||||
```
|
||||
Reference in New Issue
Block a user