What It Does
In-app notification system for social interactions. All notifications are trigger-created (no application-level notification creation).
User Flow
NotificationBell in header shows unread count badge
- Tap bell →
app/notifications.tsx
- Notification list with actor info, content preview, timestamp
- Tap notification → navigates to relevant content, or to the follower’s profile for
follow notifications
- 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)
| Method | Route | Purpose |
|---|
GET | /api/notifications | Get notifications (calls get_notifications RPC) |
PATCH | /api/notifications/read | Mark notifications as read |
GET | /api/notifications/unread-count | Get unread count for badge |
RPC Functions
| Function | Parameters | Returns |
|---|
get_notifications | p_user_id, p_limit (20), p_offset (0) | JSON — notifications with actor profile info, content preview, pagination |
Database
| Column | Type | Notes |
|---|
id | uuid PK | |
recipient_id | FK→profiles | |
actor_id | FK→profiles | |
type | text | CHECK: tag_post, tag_recipe, mention_post_comment, mention_recipe_comment, follow |
content_type | text | CHECK: post, recipe, collection, profile |
content_id | uuid | |
comment_id | uuid (nullable) | |
is_read | bool | default false |
created_at | timestamptz | |
Notification Types
All notifications are created by database triggers:
| Type | Created By | On Table | Event |
|---|
tag_recipe | create_recipe_tag_notification | recipe_tagged_users | INSERT |
tag_post | create_post_tag_notification | post_tagged_users | INSERT |
mention_recipe_comment | create_recipe_comment_mention_notification | recipe_comment_mentions | INSERT |
mention_post_comment | create_post_comment_mention_notification | post_comment_mentions | INSERT |
follow | follows INSERT trigger | follows | INSERT |
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