xiaohongshu
xiaohongshu
moai-baas-supabase-ext
Enterprise Supabase PostgreSQL Platform with AI-powered open-source BaaS architecture, Context7 integration, and intelligent PostgreSQL orchestration for scalable modern applications
Full skill instructions
| Field | Value |
|---|---|
| Skill Name | moai-baas-supabase-ext |
| Version | 4.0.0 (2025-11-13) |
| Tier | Enterprise Database Platform Expert |
| AI-Powered | ✅ Context7 Integration, Intelligent Architecture |
| Auto-load | On demand when Supabase keywords detected |
Enterprise Supabase PostgreSQL Platform expert with AI-powered open-source BaaS architecture, Context7 integration, and intelligent PostgreSQL orchestration for scalable modern applications.
Revolutionary v4.0.0 capabilities:
Automatic triggers:
Manual invocation:
# AI-powered Supabase architecture optimization with Context7
class SupabaseArchitectOptimizer:
def __init__(self):
self.context7_client = Context7Client()
self.postgresql_analyzer = PostgreSQLAnalyzer()
self.realtime_optimizer = RealtimeOptimizer()
async def design_optimal_supabase_architecture(self,
requirements: ApplicationRequirements) -> SupabaseArchitecture:
"""Design optimal Supabase architecture using AI analysis."""
# Get latest Supabase and PostgreSQL documentation via Context7
supabase_docs = await self.context7_client.get_library_docs(
context7_library_id='/supabase/docs',
topic="postgresql rls realtime edge-functions optimization 2025",
tokens=3000
)
postgresql_docs = await self.context7_client.get_library_docs(
context7_library_id='/postgresql/docs',
topic="performance optimization indexing extensions 2025",
tokens=2000
)
# Optimize PostgreSQL configuration
db_optimization = self.postgresql_analyzer.optimize_configuration(
requirements.database_workload,
postgresql_docs
)
# Design real-time architecture
realtime_design = self.realtime_optimizer.design_realtime_system(
requirements.realtime_needs,
supabase_docs
)
return SupabaseArchitecture(
database_configuration=db_optimization,
realtime_system=realtime_design,
edge_functions=self._design_edge_functions(requirements),
storage_configuration=self._optimize_storage(requirements),
auth_integration=self._integrate_authentication(requirements),
rls_policies=self._design_row_level_security(requirements),
performance_predictions=db_optimization.predictions
)
-- Comprehensive RLS policies for enterprise applications
-- Enable RLS on sensitive tables
ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
-- User can only access their own profile
CREATE POLICY "Users can view own profile" ON profiles
FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY "Users can update own profile" ON profiles
FOR UPDATE USING (auth.uid() = user_id);
-- Project access based on team membership
CREATE POLICY "Team members can view team projects" ON projects
FOR SELECT USING (
user_id IN (
SELECT user_id FROM team_members
WHERE team_id = projects.team_id
)
);
CREATE POLICY "Team admins can manage team projects" ON projects
FOR ALL USING (
user_id IN (
SELECT user_id FROM team_members
WHERE team_id = projects.team_id AND role = 'admin'
)
);
-- Document access with role-based permissions
CREATE POLICY "Document access control" ON documents
FOR ALL USING (
CASE
WHEN is_public THEN true
WHEN owner_id = auth.uid() THEN true
WHEN user_id IN (
SELECT user_id FROM document_shares
WHERE document_id = documents.id AND permission IN ('read', 'write', 'admin')
) THEN true
ELSE false
END
);
// Advanced real-time subscription management
import { RealtimeChannel } from '@supabase/supabase-js';
class RealtimeManager {
private subscriptions: Map<string, RealtimeChannel> = new Map();
subscribeToDataChanges(
table: string,
filter: object,
callback: (payload: any) => void
): string {
const subscriptionId = `${table}_${Date.now()}`;
const channel = supabase
.channel(subscriptionId)
.on(
'postgres_changes',
{
event: '*',
schema: 'public',
table: table,
filter: filter
},
callback
)
.subscribe();
this.subscriptions.set(subscriptionId, channel);
return subscriptionId;
}
subscribeToUserSpecificData(userId: string) {
return {
profile: this.subscribeToDataChanges(
'profiles',
{ user_id: `eq.${userId}` },
(payload) => this.handleProfileUpdate(payload)
),
projects: this.subscribeToDataChanges(
'projects',
{ team_id: `in.(${this.getUserTeamIds(userId).join(',')})` },
(payload) => this.handleProjectUpdate(payload)
),
notifications: this.subscribeToDataChanges(
'notifications',
{ user_id: `eq.${userId}` },
(payload) => this.handleNotification(payload)
)
};
}
unsubscribe(subscriptionId: string) {
const channel = this.subscriptions.get(subscriptionId);
if (channel) {
supabase.removeChannel(channel);
this.subscriptions.delete(subscriptionId);
}
}
}
// Advanced Edge Function with TypeScript
import { serve } from 'https://deno.land/[email protected]/http/server.ts';
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2';
interface NotificationPayload {
userId: string;
type: 'message' | 'mention' | 'project_update';
title: string;
body: string;
data?: Record<string, any>;
}
serve(async (req) => {
try {
const { userId, type, title, body, data }: NotificationPayload = await req.json();
// Initialize Supabase client
const supabaseUrl = Deno.env.get('SUPABASE_URL')!;
const supabaseKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!;
const supabase = createClient(supabaseUrl, supabaseKey);
// Validate user exists and has notifications enabled
const { data: user, error: userError } = await supabase
.from('profiles')
.select('id, notification_preferences')
.eq('id', userId)
.single();
if (userError || !user?.notification_preferences?.[type]) {
return new Response(JSON.stringify({ error: 'Invalid user or preferences' }), {
status: 400,
headers: { 'Content-Type': 'application/json' }
});
}
// Store notification in database
const { error: insertError } = await supabase
.from('notifications')
.insert({
user_id: userId,
type,
title,
body,
data,
created_at: new Date().toISOString()
});
if (insertError) throw insertError;
// Trigger real-time notification
const { error: realtimeError } = await supabase
.channel('notifications')
.send({
type: 'broadcast',
event: 'new_notification',
payload: { userId, type, title, body, data }
});
return new Response(JSON.stringify({ success: true }), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
} catch (error) {
console.error('Notification function error:', error);
return new Response(JSON.stringify({ error: error.message }), {
status: 500,
headers: { 'Content-Type': 'application/json' }
});
}
});
class FirebaseToSupabaseMigrator:
def __init__(self):
self.supabase_client = SupabaseClient()
self.firebase_client = FirebaseClient()
self.data_transformer = DataTransformer()
async def migrate_firestore_to_supabase(self,
firebase_config: FirebaseConfig,
supabase_config: SupabaseConfig) -> MigrationResult:
"""Migrate Firestore collections to Supabase PostgreSQL."""
# Get all Firestore collections
collections = await self.firebase_client.list_collections()
migration_results = []
for collection in collections:
# Get all documents from collection
documents = await self.firebase_client.get_collection_documents(collection)
# Transform Firebase data to PostgreSQL schema
transformed_data = await self.data_transformer.transform_firestore_to_postgresql(
documents, collection
)
# Create PostgreSQL table if not exists
await self.supabase_client.create_table_from_schema(
collection, transformed_data.schema
)
# Insert transformed data
insert_result = await self.supabase_client.bulk_insert(
collection, transformed_data.data
)
migration_results.append({
collection: collection,
documents_migrated: len(documents),
status: insert_result.status
})
return MigrationResult(
collections_migrated=len(collections),
total_documents=sum(r['documents_migrated'] for r in migration_results),
results=migration_results,
success=True
)
create_table(schema_definition) - Create PostgreSQL tableenable_rls(table_name) - Enable Row-Level Securitycreate_policy(table, name, definition) - Create RLS policydeploy_edge_function(name, code) - Deploy Edge Functioncreate_realtime_subscription(channel, filter) - Create real-time subscriptionget_latest_supabase_documentation() - Official Supabase docs via Context7analyze_postgresql_optimization() - PostgreSQL performance via Context7optimize_realtime_architecture() - Real-time best practices via Context7moai-baas-foundation (Enterprise BaaS architecture patterns)moai-domain-database (Database design and optimization)moai-baas-neon-ext (PostgreSQL alternative comparison)moai-essentials-perf (Performance optimization)moai-security-api (API security and authorization)moai-foundation-trust (Security and compliance)moai-baas-firebase-ext (Firebase migration comparison)moai-domain-backend (Backend database integration)End of Skill | Updated 2025-11-13
End of Enterprise Supabase PostgreSQL Platform Expert v4.0.0
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience