Unified Social Feed
Relevant source files
The following files were used as context for generating this wiki page:
The Unified Social Feed is a core component of the TAMV MD-X4 ecosystem, residing within the DM-X4-01 Social Cell domain. It serves as the primary interface for social interaction, enabling users to view, create, and interact with dynamic content in real-time. The system is designed to provide a seamless flow of information by aggregating posts from the community while maintaining high performance and data integrity through Supabase integration.
Architecturally, the feed utilizes a paginated loading strategy combined with real-time subscriptions to ensure that new content is visible to users without manual refreshes. It integrates deeply with the project's security and profile systems, ensuring that post visibility adheres to user-defined privacy settings and that author information is accurately enriched for every post.
Sources: PLAN-TAMV-MODULAR.md:23-25, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:3-5, src/hooks/useSocialFeed.ts:1-7
Architecture and Data Flow
The Unified Social Feed operates as a reactive system powered by the useSocialFeed hook. It manages data fetching from the Supabase posts table, enriches the data with user profiles, and listens for real-time INSERT events to update the UI instantly.
Component Structure
The feed is composed of several high-level components and hooks:
- UnifiedSocialFeed: The main container component that orchestrates the display of posts.
- SocialFeedPost: The individual presentation component for a single post.
- CreatePostComposer: The interface for generating new content.
- useSocialFeed Hook: The logic engine handling pagination, enrichment, and real-time synchronization.
Sources: PLAN-TAMV-MODULAR.md:27-28, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:10-18
Data Flow Diagram
The following diagram illustrates how the useSocialFeed hook interacts with Supabase and the local UI state to provide a real-time experience.
This diagram shows the sequence of initial loading, data enrichment, and the real-time update loop.
Sources: src/hooks/useSocialFeed.ts:47-97, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:100-110
Data Models
The social system relies on two primary tables in the Supabase schema: posts and profiles.
Post Structure
The posts table stores the content and metadata for every interaction in the feed.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key, generated automatically. |
author_id | UUID | Foreign key to the user who created the post. |
content | TEXT | The main message of the post (up to 2000 characters). |
media_url | TEXT | Optional link to images, video, or audio. |
media_type | TEXT | Type of media: text, image, video, audio, or live. |
visibility | TEXT | Controls privacy: public, friends, private, or group. |
likes_count | INTEGER | Counter for user likes. |
Sources: supabase/migrations/20251024005602_26440f5d-289f-4821-9cc0-7520dacde20f.sql:47-60, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:47-50
Social Hook Interface (useSocialFeed)
The system provides a standardized interface for consuming social data through the useSocialFeed hook.
// src/hooks/useSocialFeed.ts:31-37
export interface UseSocialFeedReturn {
posts: SocialPost[];
loading: boolean;
hasMore: boolean;
loadMore: () => void;
refreshFeed: () => void;
}
Real-time Implementation
The real-time functionality is implemented via Supabase Channels. The hook subscribes specifically to INSERT events on the public.posts table. When a new post is added to the database, the refreshFeed() function is triggered to reset the feed to page zero and pull the latest content.
Subscription Sequence
This sequence ensures that the feed remains "unified" and current across all connected clients simultaneously.
Sources: src/hooks/useSocialFeed.ts:114-129, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:94-96
Quality Metrics and Governance
The Unified Social Feed is subject to strict performance and governance standards defined in the project's modular plan and social manual.
Performance Targets
| Metric | Target | Description |
|---|---|---|
| Initial Feed Load | < 300-500ms | Time to render the first 20 posts. |
| Real-time Latency | < 500ms | Delay between DB insertion and UI update. |
| WebSocket RTT | < 150-200ms | Round-trip time for unified chat/social socket. |
Sources: PLAN-TAMV-MODULAR.md:37-41, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:120-126
Governance: DAO-Comunidad
The DAO-Comunidad (Community DAO) has the authority to define and adjust parameters related to the social feed, including:
- Visibility policies (Public vs. Community).
- Moderation parameters.
- Real-time presence display settings.
However, the DAO is restricted from altering the monetization logic or the underlying technical contracts if they violate the QA/Architecture standards defined in QC-TAMV-01.
Sources: PLAN-TAMV-MODULAR.md:43-47, 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:135-142
Implementation Status
As of the current development phase, the Unified Social Feed is in the following state:
- Logic (Hooks): Paginating and real-time logic implemented in
useSocialFeed. - UI Components:
UnifiedSocialFeedandSocialFeedPostexisting but transitioning from dummy data to real queries. - Integration: Supabase RLS (Row Level Security) and basic migrations are active.
Sources: PLAN-TAMV-MODULAR.md:23-28, TASKS-TAMV-MODULAR.md:16-25
The Unified Social Feed serves as the bedrock of community engagement within TAMV MD-X4, bridging static documentation and dynamic human interaction through its real-time, high-performance architecture.