DevelopmentChat System
Overview
Chat package overview
The @suitsbooks/chat package provides a reusable, realtime, virtualized chat experience that follows SuitsBooks conventions:
- API access: Uses
{APP_CONFIG.api.suitsbooks}for fetch/insert (/fetch/data,/data/insert) with requiredX-Company-Id,X-Organization-Id,X-User-Idheaders via existing hooks - Realtime: Subscribes to Supabase Postgres changes on the target
table - Virtualization: Efficient rendering using
@tanstack/react-virtual - Mentions: Out-of-the-box
@mentions usingreact-mentions, sourced from theuserstable - Attachments: S3-compatible uploads (DigitalOcean Spaces) via
/api/files/upload/upload-legacy, with previews for images and videos - UI conventions: Buttons, icons, and typography comply with workspace rules (brand actions,
rounded-sm,text-primary,text-secondary)
Components
Chat: High-level chat component (list + input + realtime + mentions + attachments)MessageList: Virtualized message listMessageItem: An individual message with avatar, timestamp, and attachment previewsMessageInput: Input withreact-mentionsand an attach button
Required environment / assumptions
- The app is configured with
APP_CONFIGand the standard API endpoints. - Supabase client is configured in
lib/supabase/client. - User context is available via
useUserStorewithuser_id,company_id,organization_id.