信息对象与数据结构
本文档基于
docs/archon/docs/assets/reflekt-health.sql数据库导出文件编写,交叉参考需求文档(raw_requirements_context.md、project_brief.md)、业务架构(business_architecture.md)、技术架构(technical_architecture.md)等,形成 Reflekt Health 真实数据模型。
Schema: reflekt-health(PostgreSQL)
第一部分:领域模型(代码层)
领域模型从业务视角描述核心业务对象及其关系,供后端 Agent 实现业务逻辑使用。 表名与业务 域的映射关系:需求中定义的
ref_*表对应实现中的iot_*表(iot_family_*家族表 + 独立iot_*表)。
1.1 核心业务域
| 业务域 | 英文 | 核心职责 | 数据库表归属 |
|---|---|---|---|
| 用户与认证 | User & Auth | IoT 用户(家属账号)注册登录、AES-256 加密手机号 | iot_user |
| 家庭域 | Family | 家庭档案、成员管理、设备绑定、消息、通话 | iot_family_* 系列表 |
| 设备域 | Device | 设备注册、状态管理、设备分享 | iot_device、iot_device_share |
| 健康数据域 | Health | 心率、血氧、步数、睡眠、体温 | iot_heart_rate、iot_spo、iot_pedo、iot_sleep_raw、iot_temperature |
| AI 对话域 | AI Brain | AI 会话记忆、消息记录、AI 操作日志 | iot_ai_session_memory、iot_ai_session_message、ai_operation_log |
| 雷达事件域 | Radar | 跌倒事件上报、MQTT 订阅管理 | mqtt_fall_event、mqtt_subscription、mqtt_inbound_message |
| 提醒域 | Reminder | 提醒计划创建、播报、执行日志 | iot_family_reminder |
| 告警域 | Alert | 告警触发、升级链路、通知下发 | 待建(需求定义 ref_alert、ref_escalation、ref_notification 表尚未创建) |
| 运营管理域 | Admin | 系统配置、字典、OSS、审计日志 | sys_* 系列表 |
| 定时任务域 | Scheduling | 分布式定时任务调度、重试机制 | sj_* 系列表 |
1.2 核心领域对象
| 对象名称 | 中文名 | 需求对应 | 数据库表 | 主要属性 | 关联对象 |
|---|---|---|---|---|---|
| IoTUser | IoT用户(家属) | CAREGIVER | iot_user | id, phone(AES), nickname, avatar, family_id | Family, Device |
| Family | 家庭 | FAMILY | iot_family_archive | id, family_name, elder_name, elder_age, health_profile(JSON) | IoTUser, Device, Elder |
| Elder | 被照护者 | ELDER | iot_family_archive(同表内嵌) | elder_name, elder_age, health_profile, baseline_hash | Family, Device, HealthData |
| Device | 设备 | DEVICE | iot_device | id, serial_number, device_type(luma/radar/watch), status, last_heartbeat | Family, DeviceEvent |
| DeviceEvent | 设备事件 | DEVICE_EVENT | mqtt_fall_event(跌倒)、mqtt_inbound_message(通用) | id, device_id, event_type, payload(JSON), event_time | Device |
| HealthData | 健康数据 | DEVICE_EVENT | iot_heart_rate、iot_spo、iot_pedo、iot_sleep_raw、iot_temperature | id, device_id, value, measured_at | Device, Elder |
| FamilyMessage | 家庭消息 | NOTIFICATION | iot_family_message | id, family_id, sender_id, content_type(voice/text), content | Family, IoTUser |
| Reminder | 提醒计划 | REMINDER | iot_family_reminder | id, family_id, elder_id, content_type, schedule, frequency, need_confirm | Family, Elder |
| AISessionMemory | AI记忆话题 | MEMORY | iot_ai_session_memory | id, family_id, elder_id, topic, elder_response_url, status(pending/answered/listened) | Family, Elder |
| Alert | 告警事件 | ALERT | 待建 ref_alert | id, elder_id, device_event_id, level(red/amber/normal), status, evidence_pack(JSON) | Elder, DeviceEvent |
| Escalation | 升级链路 | ESCALATION | 待建 ref_escalation | id, alert_id, level, caregiver_id, channel(push/sms/voice), status | Alert, IoTUser |
| Notification | 通知记录 | NOTIFICATION | 待建 ref_notification | id, alert_id, caregiver_id, channel, title, body, status | Alert, IoTUser |
1.3 领域对象关系图
1.4 领域对象状态机
1.4.1 告警状态机(Alert — 待建)
1.4.2 设备状态机(Device)
1.4.3 六状态颜色语言(六态联动 Family App / Luma App 双端)
1.4.4 AI记忆话题状态机(AI Session Memory)
1.4.5 家庭通话状态机(Family Call)
1.4.6 家庭消息状态机(Family Message)
第二部分:数据字典(数据库层)
数据字典描述数据库表结构、字段定义、索引设计,供 DBA 和后端 Agent 创建数据库 Schema 使用。 注:
ref_alert、ref_escalation、ref_notification三表已在需求文档中定义,但尚未在 SQL 导出文件中创建。以下 DDL 章节仅覆盖已导出的实际表。