Skip to main content

What It Does

In-app notification system for social interactions. All notifications are trigger-created (no application-level notification creation).

User Flow

  1. NotificationBell in header shows unread count badge
  2. Tap bell → app/notifications.tsx
  3. Notification list with actor info, content preview, timestamp
  4. Tap notification → navigates to relevant content, or to the follower’s profile for follow notifications
  5. Mark as read on view

Components

NotificationBell (src/components/common/NotificationBell.tsx) — bell icon with unread count badge.

Data Access Pattern

The mobile app calls Supabase directly — supabase.rpc('get_notifications') and supabase.from('notifications').update(). The web API routes exist for the web client (Phase 2).

Web API Routes (Phase 2)

MethodRoutePurpose
GET/api/notificationsGet notifications (calls get_notifications RPC)
PATCH/api/notifications/readMark notifications as read
GET/api/notifications/unread-countGet unread count for badge

RPC Functions

FunctionParametersReturns
get_notificationsp_user_id, p_limit (20), p_offset (0)JSON — notifications with actor profile info, content preview, pagination

Database

ColumnTypeNotes
iduuid PK
recipient_idFK→profiles
actor_idFK→profiles
typetextCHECK: tag_post, tag_recipe, mention_post_comment, mention_recipe_comment, follow
content_typetextCHECK: post, recipe, collection, profile
content_iduuid
comment_iduuid (nullable)
is_readbooldefault false
created_attimestamptz

Notification Types

All notifications are created by database triggers:
TypeCreated ByOn TableEvent
tag_recipecreate_recipe_tag_notificationrecipe_tagged_usersINSERT
tag_postcreate_post_tag_notificationpost_tagged_usersINSERT
mention_recipe_commentcreate_recipe_comment_mention_notificationrecipe_comment_mentionsINSERT
mention_post_commentcreate_post_comment_mention_notificationpost_comment_mentionsINSERT
followfollows INSERT triggerfollowsINSERT
Collection notification types are no longer part of the allowed notification set.

RLS Policies

  • SELECT: auth.uid() = recipient_id (private)
  • INSERT: auth.uid() = actor_id
  • UPDATE: auth.uid() = recipient_id (for marking as read)
  • DELETE: auth.uid() = recipient_id