Supabase Integration
Relevant source files
The following files were used as context for generating this wiki page:
The Supabase integration within the TAMV Digital Nexus serves as the primary backend infrastructure, providing essential services such as a PostgreSQL database, Authentication (JWT), and a suite of Edge Functions for complex business logic. It acts as the "Civilizatory Operating System" core, managing identity, economy, and social interactions through a unified API and real-time synchronization mechanisms. Sources: README_TAMV_COMPLETO.md, supabase/functions/tamv-unified-api/index.ts:1
Core Architecture and Client Configuration
The system utilizes the @supabase/supabase-js library to interact with the backend. The client is initialized using environment variables (VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY) and is configured with persistent local storage for authentication sessions. Sources: src/integrations/supabase/client.ts:5-17
Connection Strategy
The frontend utilizes a singleton client instance, while Edge Functions create internal clients using service role keys for administrative tasks or anonymous keys for user-scoped requests. Sources: supabase/functions/tamv-fusion-core/index.ts:16, supabase/functions/tamv-unified-api/index.ts:26-30
This diagram illustrates the relationship between the client-side integration, serverless edge functions, and the core Supabase services.
Sources: src/integrations/supabase/client.ts, supabase/functions/tamv-unified-api/index.ts
Database Schema and Managed Tables
The PostgreSQL database is structured into several critical tables that support the ecosystem's domains. Security is enforced through Row Level Security (RLS), ensuring users can only access or modify data they own. Sources: DEPLOYMENT_GUIDE.md:65-135
Critical System Tables
| Table Name | Description | Key Fields |
|---|---|---|
profiles | User identity and metadata | user_id, role, id_nvida |
posts | Social feed content | content, author_id, created_at |
msr_events | Immutable audit trail for system events | action, payload, evidence_hash |
tcep_wallets | Economic balance and transactions | user_id, balance_credits |
dao_proposals | Governance proposals and voting status | title, votes_for, status |
Sources: supabase/functions/tamv-fusion-core/index.ts:55-58, supabase/functions/tamv-unified-api/index.ts:48-120
Edge Functions and API Orchestration
The integration features several specialized Edge Functions that handle complex cross-module workflows.
1. TAMV Unified API
This function acts as an "Omni-Modus" API gateway, exposing endpoints for identity, governance, economy, and security. It handles JWT authentication checks and logs every significant action into the msr_events audit table. Sources: supabase/functions/tamv-unified-api/index.ts:1-200
2. TAMV Fusion Core
An orchestrator responsible for system health checks and triggering content synchronization cycles. It monitors critical table availability and route status across the ecosystem. Sources: supabase/functions/tamv-fusion-core/index.ts:1-10
3. Content Sync
A specialized service that aggregates data from external sources like GitHub and Blogger, structuring it into the ecosystem_data format for the internal DevHub. Sources: supabase/functions/tamv-content-sync/index.ts:10-70
Real-time and Social Interaction
The integration leverages Supabase Realtime for the social feed and user presence. The useSocialFeed and useUserPresence hooks subscribe to changes in the posts table and the tamv-presence channel respectively. Sources: 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:7-60
This sequence diagram shows the flow of real-time data for social updates and presence monitoring.
Sources: 02_MODULOS/M02_SOCIAL/INTERNO/MANUAL-SOCIAL.md:65-85
Security and Integrity Protocols
Security is implemented through a multi-layered approach:
- JWT Authentication: All sensitive API endpoints verify the
Authorizationheader. Sources: supabase/functions/tamv-unified-api/index.ts:28-35 - MSR Registry: Critical actions (transfers, proposals) generate a SHA-256
evidence_hashrecorded in themsr_eventstable for auditability. Sources: supabase/functions/tamv-fusion-core/index.ts:98-110, supabase/functions/tamv-unified-api/index.ts:16-24 - Row Level Security (RLS): Enforced at the database level to isolate user data. Sources: DEPLOYMENT_GUIDE.md:144-148
Conclusion
The Supabase integration provides the technical backbone for the TAMV Digital Nexus, enabling a sovereign digital environment. By combining real-time capabilities with structured Edge Functions and an immutable audit trail (MSR), the system ensures high availability, security, and traceability for all civilizatory modules.