How pomarec/sangre works
Main Components Identification
a) Data Source Layer:
• PostgreSQL Database (with logical replication enabled)
• Supabase Realtime (as the change data capture broker)
b) Core Processing Layer (Node System):
• Source Nodes (postgres_table.ts, array.ts, growing_array.ts)
• Operator Nodes (filter.ts, join_*.ts, diffed.ts, etc.)
• Node Factory (node_factory.ts)
c) API Layer:
• Express.js Integration (express.ts)
• WebSocket Endpoints
d) Client Layer:
• Client Applications (Flutter example shown)
[Database Layer]
• ↓
[Change Data Capture Layer]
• ↓
[Core Processing Layer]
• ↓
[API Layer]
• ↓
[Client Layer]
Specific Implementation Details
• The node-based architecture (from src/nodes/)
• Different types of nodes (sources, operators)
• How joins and filters are processed
• The diffing mechanism for minimal network load
• WebSocket streaming implementation
Important Relationships
• PostgreSQL → Supabase Realtime → Source Nodes
• Source Nodes → Operator Nodes (showing transformation flow)
• Operator Nodes → Express.js Integration
• Express.js → WebSocket Connections → Clients
Additional Elements
• Sample data flow for a typical query
• Error handling paths
• Scaling points
Implementation Notes
Use tools like:
Remember to emphasize the project's key differentiators:
• Real-time processing of relational queries
• Incremental updates via diffs
• Integration with existing backend frameworks
• Offline sync capabilities