Messaging & Chat Transcripts
Relevant source files
The following files were used as context for generating this wiki page:
The Messaging & Chat Transcripts system provides the core communication infrastructure for SoulSeer, enabling both asynchronous direct messaging between users and real-time text-based interactions during spiritual consultations. The system is designed to handle standard messaging, premium content monetization, and post-session archiving for quality assurance and user reference.
This module encompasses the MessagesPage for direct user-to-user communication and the ChatTranscriptModal used by clients, readers, and administrators to review the history of completed sessions.
Sources: client/src/pages/dashboard/MessagesPage.tsx, client/src/pages/reading/ReadingSessionPage.tsx, client/src/components/ChatTranscriptModal.tsx
Direct Messaging Architecture
The direct messaging system supports private conversations between readers and clients. It features a conversation-based UI that groups messages by recipient, handles unread message counts, and supports "Premium Messages" which can be monetized by readers.
Message Data Structures
Messages are represented by the ApiMessage interface, which tracks sender/receiver details, content, read status, and pricing.
| Field | Type | Description |
|---|---|---|
id | number | Unique identifier for the message |
senderId | number | ID of the user who sent the message |
receiverId | number | ID of the user receiving the message |
content | string | The text content of the message |
price | number | Price in cents to unlock the message (for premium content) |
isRead | boolean | Indicates if the recipient has read/unlocked the message |
createdAt | string | ISO timestamp of message creation |
Sources: client/src/pages/dashboard/MessagesPage.tsx:11-38, shared/src/validators.ts:60-63
Premium Messaging Flow
Readers have the ability to set a price on outbound messages to clients. When a message has a price > 0, the content is hidden from the client until they perform an "Unlock" action, which triggers a balance-check and payment process.
Real-time Session Messaging
During a "Chat" type reading session, messaging is handled via the Agora RTM (Real-Time Messaging) SDK. This ensures low-latency communication during active billed sessions.
Live Chat Integration
- Connection: The system initializes an Agora RTM client using a temporary token retrieved from the server.
- Persistence: While messages are exchanged via RTM for speed, they are also sent to the backend via
POST /api/readings/:id/messageto be recorded in the session'schatTranscript. - UI Components: The
ChatModecomponent renders the message log and handles auto-scrolling to the latest messages.
Sources: client/src/pages/reading/ReadingSessionPage.tsx:128-154, client/src/pages/reading/ReadingSessionPage.tsx:441-460, client/src/types/index.ts:71
Chat Transcripts & Archiving
After a chat reading session is completed, the full log of messages is stored as a chatTranscript in the database. This transcript is accessible to the participants and platform administrators.
Transcript Viewer Component
The ChatTranscriptModal is a specialized component that fetches and renders archived session logs.
- Data Source: Fetches the
Readingobject by ID, specifically accessing thechatTranscriptfield. - Permissions: Intended for use by the client, the reader, and admins. Admin access is managed via the
AdminDashboard. - Filtering: The component ensures it only attempts to render transcripts for readings where
readingType === 'chat'.
Administrative Moderation
Administrators can view transcripts for any session through the Admin Dashboard to resolve disputes or monitor quality.
- Endpoint: Admin access uses the standard reading retrieval but within an elevated context.
- UI Trigger: The
AdminDashboardincludes a "Transcript" button in the Readings table for completed chat sessions.
Sources: client/src/pages/dashboard/AdminDashboard.tsx:413-424, client/src/pages/dashboard/AdminDashboard.tsx:842-846
Summary
The messaging system in SoulSeer serves dual purposes: facilitating long-term client-reader relationships through direct messaging with monetization options, and providing a robust, real-time interface for live consultations. The transcript system ensures that every chat session is safely archived for later review, maintaining accountability and providing value to both users and administrators.