Dual-Database Architecture
Memron utilizes a resilient dual-database design to isolate high-throughput web operations from intensive vector similarity searches and agent MCP tool executions.
Primary Web DB vs. Supabase Agent Node
- Primary Web App DB (Aiven PostgreSQL): Handles WorkOS AuthKit sessions, dashboard analytics, user accounts, bucket access policies, and primary key registries.
- MCP Sovereign Node (Supabase PostgreSQL + pgvector): Houses vector embeddings (1536 dimensions), blind-indexed graph nodes (graph_nodes), temporal edges (graph_edges), and the real-time API key verification cache (SELECT * FROM api_keys WHERE key_hash = $1).
- Firebase Cloud Storage: Provides cloud backup redundancy for cross-region disaster recovery.
Self-Healing Sync Contract
Whenever an API key is provisioned or revoked in the Next.js frontend, apps/landing/src/lib/supabase-sync.ts opportunistically mirrors the record to Supabase. If the user does not yet exist in Supabase, the engine auto-provisions the user identity, default workspace organization, and sets is_active = true on the fly.
// apps/landing/src/lib/supabase-sync.ts
const supabaseUser = await resolveOrProvisionSupabaseUser({
authUserId: user.id,
email: user.email,
name: user.name,
});
// Mirror API key hash to Supabase for sub-millisecond MCP auth
await syncApiKeyToSupabase({
keyId: newKey.id,
keyHash: newKey.key_hash,
keyPrefix: newKey.key_prefix,
name: newKey.name,
userId: supabaseUser.id,
});