Skip to content

Conversation Runtime And Provider Boundary Deep Dive

Bộ tài liệu này đào sâu flow conversation-runtime-and-provider-boundary theo code thực tế hiện tại. Đây là package reverse-engineer trong docs/modules, không phải PRD/spec delivery. Trọng tâm của batch này là làm rõ 3 lớp rất dễ bị lẫn trong module conversation:

  • workspace realtime ở FE hiện mới là shell một phần, nhiều hành vi list/message vẫn đang scaffold (diva-admin/src/modules/conversation/components/Conversation/index.tsx:22, diva-admin/src/modules/conversation/components/ConversationList.tsx:188, diva-admin/src/modules/conversation/components/ConversationMessages.tsx:92),
  • provider runtime tách thành Stringee và Twilio, nhưng conference/token contract không hoàn toàn đồng bộ giữa FE và backend (diva-admin/src/modules/conversation/vendors/twilio/components/TwilioVideo/TwilioVideoPreview.tsx:69, diva-backend/services/conversation-api/action/conference.go:60),
  • read/write permission thật lại nằm ở Hasura tables/functions conversation*, không nằm trong useConversation.ts vì composition này hiện gần như rỗng (diva-admin/src/modules/conversation/compositions/useConversation.ts:1).

Đọc file nào?

Bạn là ai?Nên đọc trướcMục tiêu
PO / BAshared-rules.mdChốt mental model giữa shell FE, provider runtime và DB permission/search
FE Devtype-runtime-workspace-and-unread.md, type-provider-token-and-conference-runtime.mdHiểu list/message shell, route drift, token flow và Twilio/Stringee mismatches
BE Devtype-provider-token-and-conference-runtime.md, type-message-permission-and-search-boundary.mdHiểu action layer, provider config, Hasura permission contract và read models
QAshared-rules.md, type-message-permission-and-search-boundary.mdThiết kế test theo unread/search, permission và conference failure modes
Người mới vào hệ thốngmodule-overview.mdCó bản đồ tổng trước khi đi sâu

Files

FileVai trò
module-overview.mdBản đồ tổng: workspace shell, providers, action layer, read models, findings ưu tiên cao
shared-rules.mdThuật ngữ chuẩn, runtime matrix, provider matrix, invariants, findings
type-runtime-workspace-and-unread.mdDeep dive cho route shell, conversation list, read state, message composer và store
type-provider-token-and-conference-runtime.mdDeep dive cho Stringee/Twilio token flow, conference create, overlay runtime và provider mismatch
type-message-permission-and-search-boundary.mdDeep dive cho tables/functions, permission contract, unread/search read models và mention boundary

Kết luận ngắn

  1. conversation hiện là runtime phân mảnh: FE workspace shell, provider wrappers và Hasura read/write model chưa được nối thành một orchestration layer duy nhất.
  2. Có drift thật ở route/conference:
    • ConversationDetail push sang ROUTE_CONVERSATION_CONFERENCE,
    • nhưng module route tree không có route record nào cho /conversation/:id/conference (module.ts:12, ConversationDetail.tsx:13).
  3. Có drift thật ở FE shell:
    • nút video trong Conversation chưa emit event,
    • ConversationList dùng mutation stub sẽ throw ngay khi click item,
    • composer hiện không gửi message thật.
  4. Có drift mạnh ở provider/backend boundary:
    • Twilio preview emit audioEnabled, trong khi parent đọc microphoneEnabled,
    • createConference update external_call_id thay vì video_room_id/video_room_provider, lại swallow error nếu mutate conversation fail.

Liên kết tài liệu liên quan

Phạm vi của bộ docs này

  • Bám theo code hiện tại của diva-admin, conversation-api và Hasura metadata domain conversation.
  • Ưu tiên mô tả hệ thống đang chạy như thế nào thay vì flow lý tưởng.
  • Chủ động ghi drift, scaffold chưa hoàn tất và contract mismatch giữa FE, backend action và DB permission layer.