Skip to content

[Feature] Build a real-time collaborative pool chat/comments feature per group#98

Open
senmalong wants to merge 1 commit into
JointSave-org:mainfrom
senmalong:feat/pool-group-chat
Open

[Feature] Build a real-time collaborative pool chat/comments feature per group#98
senmalong wants to merge 1 commit into
JointSave-org:mainfrom
senmalong:feat/pool-group-chat

Conversation

@senmalong

@senmalong senmalong commented Jun 23, 2026

Copy link
Copy Markdown

Closes #90

Overview

This PR implements a real-time collaborative group chat / discussion feature per savings pool, enabling group members to communicate, coordinate deposit timings, and build trust securely within the app.

Key Achievements

  1. Database Schema & Row Level Security (RLS):

    • Created the pool_messages table with an optimized index for quick fetching.
    • Enforced Row Level Security (RLS) policies allowing select and insert access only to active members of the pool (matched against the pool_members table).
    • Constrained messages to <= 1000 characters using a PostgreSQL CHECK constraint.
    • Enforced rate-limiting (max 1 message per 3 seconds per sender) via a database trigger and function to guarantee server-side prevention of channel spamming.
  2. Automated Notification Integration:

    • Implemented an AFTER INSERT trigger on the pool_messages table that automatically adds in-app notifications to the notifications table for all other pool members whenever a new message is posted.
  3. Frontend Supabase Setup:

    • Registered the pool_messages table under TypeScript Database schema types.
    • Created getSupabaseClient(walletAddress) to dynamically instantiate Supabase clients with client-injected wallet headers to authorize RLS queries.
  4. Sleek Discussion UI:

    • Integrated a beautiful, mobile-responsive Discussion tab alongside the Activity Log.
    • Leveraged Supabase Channels (postgres_changes events) to sync and display messages in real-time.
    • Included a local visual rate-limiting countdown and character counters.
    • Handled access restrictions gracefully by presenting clear user-friendly notices for non-members.
  5. E2E Testing:

    • Added E2E specifications covering message submission, real-time message sync, client-side rate limit UI lockout, and RLS error access restriction state.

…ointSave-org#90)

- Add pool_messages schema with RLS policies restricting read/write to pool members
- Enforce message length limit (<= 1000 characters) and rate limiting (max 1 message per 3 seconds per sender) via DB trigger
- Implement automated trigger to notify other pool members of new chat messages
- Expose pool_messages and update Supabase Client initialization to support dynamic wallet headers
- Create GroupDiscussion UI component featuring real-time message syncing, local rate-limit lockout, and mobile responsiveness
- Integrate 'Discussion' tab inside group detail page layout next to Activity Log
- Configure Playwright E2E coverage for chat functionality
@Sendi0011

Copy link
Copy Markdown
Contributor

@senmalong kindly resolve conflict please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Build a real-time collaborative pool chat/comments feature per group

2 participants