Overview
Meridian’s data flow is designed for performance, real-time collaboration, and AI-powered insights. Data flows through multiple layers, each optimized for specific operations.Complete Data Flow Diagram
1. File Upload Flow
Step-by-Step Process
User Selects File
User drags and drops or selects a CSV/Excel file in the dashboard.Component:
src/components/dashboard/FileUpload.tsxSupported Formats:- CSV (.csv)
- Excel (.xlsx, .xls)
- JSON (.json)
Process File into DuckDB
File is loaded into DuckDB for analytical queries.File:
src/utils/duckdb.ts:80-148DuckDB Process:- Fetch CSV from R2 URL
- Save to temporary file
- Use
read_csv_auto()to infer schema - Create table with inferred types
- Clean up temporary file
Upload Flow Code References
2. Query Execution Flow
SQL Query Path
Query Execution Sequence
3. AI Agent Flow
Natural Language to SQL
Execute Generated Queries
Queries are queued and executed sequentially.File:
src/routes/_authed/table.$table.tsx:73-75Analysis Mode with Tools
When in analysis mode, the agent uses tools to explore data:4. Insights Generation Flow
Statistical Analysis Pipeline
- 1. Trigger
- 2. DuckDB Analysis
- 3. AI Interpretation
- 4. Cache Results
- 5. Display
User clicks “Generate Insights” button.File:
src/routes/_authed/table.$table.tsx:6205. Real-time Collaboration Flow
Presence & Notifications
Meridian supports real-time collaboration through Convex subscriptions.Notification Types
Query Execution
When a user executes a SQL query
AI Agent Query
When AI generates SQL
AI Analysis
When AI analyzes data
Insights Generated
When insights are created
Chart Created
When visualization is generated
Real-time Update Flow
6. Chart Generation Flow
From AI Tool to Visualization
Performance Optimizations
Caching Strategy
TanStack Query Cache
TanStack Query Cache
Query results cached for 5 minutes.
Insights Cache
Insights Cache
AI-generated insights cached in Convex.
DuckDB Connection Pool
DuckDB Connection Pool
Single DuckDB instance reused across requests.
Streaming Optimizations
AI Responses Stream Incrementally:Error Handling
Graceful Degradation
Next Steps
Architecture Overview
Understand the overall system design
Tech Stack
Explore detailed technology information