Skip to content

Conversation - Technical Map

Auto-generated từ code thực tế ngày 2026-03-23.

Routes và module shell

ItemGiá trịBằng chứng
Module slugconversationtypes.ts:1-5
Root route/conversationmodule.ts:11-26, types.ts:1-5
Detail route/conversation/:idmodule.ts:17-24, types.ts:1-5
Conference route name/conversation/:id/conferencetypes.ts:5
Stringee route name/conversation/stringeetypes.ts:2
NavigationCommented out, chưa bật sidebar itemmodule.ts:33-40

Route graph

text
/conversation
  └─ /conversation/:id
       └─ RouterView

FE pages và shell components

LoạiFileVai trò
Pagepages/ConversationDetail.tsxWrapper workspace, nhận id, phát action video sang conference route
LayoutLayout.tsDùng MainLayout làm shell
Componentcomponents/Conversation/index.tsxHeader workspace, giữ props của message layer, hiện chưa mount body thật
Componentcomponents/ConversationList.tsxInfinite list, select conversation, update read_at
Componentcomponents/ConversationMessages.tsxRender message stream + composer
Componentcomponents/ConversationProvider.tsxProvider shell pass-through
Componentcomponents/StringeeProviderWrapper.tsxFetch token và mount StringeeProvider
Componentcomponents/StringeeConferenceDialog.tsxModal hội thoại video Stringee

Compositions và store

FileVai tròGhi chú
compositions/useConversation.tsComposition placeholderTrả object rỗng
compositions/graphql.tsGetStringeeToken queryQuery stringeeToken(data)
vendors/twilio/compositions/useTwilio.tsLấy token TwilioWrapper twilioToken(data)
vendors/twilio/compositions/graphql.tsGetTwilioToken queryQuery twilioToken(data)
stores/useConversationStore.tsConversation runtime stateconversations, messages, currentConversation, conversationCursor, inCall
utils.tsMerge messages đã sortmergeSortedConversationMessages()

Store behavior

ActionLogicBằng chứng
updateConversations(items)Merge theo id, sort giảm dần theo last_message_created_atuseConversationStore.ts:23-45
updateConversationCursor(items)Lấy timestamp nhỏ nhất trong batch để giữ cursor cũ nhấtuseConversationStore.ts:46-73
updateConversationMessages(messages)Group theo conversation_id, merge từng group bằng helper sortuseConversationStore.ts:74-85
addConversationCursor(data)Update list và cursor trong một bướcuseConversationStore.ts:87-90

GraphQL operations

FE GraphQL

OperationFileInputOutputDùng ở đâu
GetStringeeTokencompositions/graphql.tsStringeeTokenInput { room?, record? }stringeeToken { token, room_token }StringeeProviderWrapper, StringeeConferenceDialog
GetTwilioTokenvendors/twilio/compositions/graphql.tsTwilioTokenInput { room? }twilioToken { token }useTwilio, TwilioVideo overlay

Hasura DB functions

FunctionRoot fieldSession argumentVai trò
search_conversation_currentcustom root field theo metadatahasura_sessionDanh sách conversation runtime
search_unread_conversation_messagescustom root field theo metadatahasura_sessionTìm unread message feed

graphql/conversation.graphql trong module hiện không chứa document nào; các operation thật được colocate ở composition files bên cạnh component/runtime.

Backend service conversation-api

EndpointHandlerMục đích
POST /actionsHasura action routertwilioToken, createConference, stringeeToken, stringeeCallEvent
POST /eventsEvent routerHiện có scaffold event example
GET /healthzversion endpointHealth/version check

Action map

ActionInputOutputBằng chứng
twilioTokendata.room{ token }action/twilio.go:15-47
stringeeTokendata.room, data.record{ token, room_token }action/stringee.go:17-64
stringeeCallEventpayload call event từ StringeeSCCO connect actionaction/stringee.go:67-106
createConferenceconversation_id, name, start_time, end_time, type, participantsconference_id, conference_urlaction/conference.go:29-85

Action context

Thành phầnVai trò
AccessParse session variables của Hasura
ControllerGQL access client để mutate conversation table
StringeeClient tạo token/room Stringee
TwilioClient tạo Twilio JWT
GoogleAPIDefaultEmailWorkspace email mặc định cho Google Meet flow

Vendor runtime

Stringee

FileVai tròGhi chú
vendors/stringee/components/StringeeProvider.tsProvide/connect/disconnect clientEmit connected, disconnected, chatMessage, chatMessageState
vendors/stringee/components/StringeeConference/index.tsxConference shellPreview, sidebar chat/participants, join/leave wiring
vendors/stringee/components/StringeeConference/StringeeVideoConference.tsxRoom runtimeJoin room, publish local track, subscribe remote tracks, share screen
vendors/stringee/components/StringeeConference/StringeeConferenceActions.tsxControl barToggle video/audio/screen/device selection
vendors/stringee/components/types.tsToken / conference constantsSTRINGEE_ERROR_ROOM_NOT_FOUND, StringeeVideoOptions

Twilio

FileVai tròGhi chú
vendors/twilio/components/TwilioVideo/index.tsxFull-screen overlay entrypointĐọc conversationStore.currentConversation.video_room_id
vendors/twilio/components/TwilioVideo/TwilioVideoPreview.tsxPreview trước khi joinCho phép bật/tắt video/mic
vendors/twilio/components/TwilioVideo/TwilioVideo.tsxTwilio room runtimeConnect room, attach tracks, disconnect cleanup

DB model và permissions

Tables

TableVai tròGhi chú
conversationHeader hội thoạivideo_room_provider, video_room_id, visible, closed
conversation_currentView runtimeDenormalized feed cho list hiện tại
conversation_memberMembership + read/mute/in_callLưu read_at, mute_until, is_admin
conversation_messageMessage bodycontent, content_data, subject_id, type, pinned
conversation_message_reactionReactionGắn reaction theo message_id
conversation_message_mentionMention/read stateread_at cho mention
app_conversation_settingApp-level settingCó relationship sang conversation

Permission matrix

AreaRule
conversation selectMember của conversation mới đọc được
conversation insertUser có thể tạo conversation mới, Hasura set created_by/updated_by
conversation update/deleteChỉ member hoặc member admin tùy operation
conversation_member updateUser chỉ cập nhật record của chính mình
conversation_message insertChỉ khi conversation chưa closed và user là member
conversation_message update/deleteChỉ tác giả message
Reaction/MentionChỉ trong scope message/member phù hợp

Ghi chú triển khai

#NoteBằng chứng
1ConversationProvider hiện là pass-through provider, chưa có logic data-fetch riêng.ConversationProvider.tsx:1-20
2Conversation/index.tsx chưa render message list hay compose actions, nên workspace body vẫn là shell.Conversation/index.tsx:10-29
3StringeeConferenceDialog phụ thuộc useUser() để map userId -> display_name/avatar cho participant list.StringeeConferenceDialog.tsx:34-113
4StringeeConference giữ state participant/track ở local refs, không đẩy hết vào store global.StringeeConference/index.tsx:91-320
5conversation-api chỉ expose POST /actions, POST /events, GET /healthz; không có REST CRUD riêng.server/main.go:32-49

Rủi ro / Findings kỹ thuật

#GapBằng chứng
1ConversationList dùng helper mutation stub nên đường update read_at chưa hoàn chỉnh.ConversationList.tsx:188-190
2useConversation.ts trống, không có orchestration layer riêng cho module.useConversation.ts:1-6
3Twilio preview emit payload lệch tên field với parent, dễ làm state microphoneEnabled không phản ánh đúng.TwilioVideoPreview.tsx:69-73, TwilioVideo/index.tsx:27-34
4Route conference không thấy route record độc lập trong tree router của repo.types.ts:5, module.ts:27-31, src/router/routes.ts
5conversation.graphql không chứa document, nên người đọc dễ nhầm là module có 1 file GraphQL duy nhất.conversation.graphql trống, compositions/graphql.ts:29-36