Project Name: Argus (formerly AetherQuery)
Project Type: SQL Query Optimization & Execution Platform
Tech Stack:
- Backend: Python FastAPI + DuckDB/PostgreSQL/MySQL
- Frontend: React 19 + TypeScript + Vite
Status: ~40-50% Complete (MVP partially implemented, core features working)
Primary Goal: A unified platform for executing SQL queries in both exact and approximate modes, with automatic query plan parsing, visualization, and structural comparison.
Problems It Solves:
- Query Optimization Visualization - Helps developers understand how their queries are being executed by parsing and visualizing query plans
- Approximate Query Processing - For COUNT/SUM/AVG operations, offers faster approximate results using sampling when exact results aren't needed
- Multi-Database Support - Single interface to query across DuckDB, PostgreSQL, and MySQL
- Plan Comparison - Structural similarity matching for query plans
Core Structure:
backend/
├── main.py # FastAPI app setup + CORS middleware
├── requirements.txt # Dependencies
├── api/ # API routers
│ ├── execute.py # Execute queries (exact/approx)
│ ├── plan.py # Parse & analyze query plans
│ ├── upload.py # CSV file upload
│ └── optimize.py # Query rewriting for approximation
├── core/ # Business logic
│ ├── router.py # Route to exact/approx execution
│ ├── exact_engine.py # Exact query execution
│ ├── approx_engine.py # Approximate sampling logic
│ ├── plan_parser.py # Parse EXPLAIN output into tree structure
│ ├── matcher.py # Plan similarity scoring
│ └── cache.py # In-memory query result caching
├── db/ # Database adapters
│ ├── duckdb.py # DuckDB queries + CSV loading
│ ├── postgres.py # PostgreSQL queries
│ └── mysql.py # MySQL queries
└── models/
└── query.py # Pydantic request/response models
Key Components:
-
API Layer (
/api)POST /api/execute- Execute query in exact or approx modePOST /api/sql/execute- Execute aliasPOST /api/plan- Get query planPOST /api/sql/parse-plan- Get query plan aliasPOST /api/upload- Upload CSV filePOST /api/optimize- Rewrite query for approximation
-
Execution Engine (
core/router.py+ engines)- Routes queries to exact or approximate execution path
- Handles mode parameter: "exact" or "approx"
- Measures execution time and returns structured responses
-
Database Adapters (
/db)- DuckDB: Default, in-memory/persistent, CSV auto-loading with UUID filenames
- PostgreSQL: Requires env vars (PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD)
- MySQL: Requires env vars (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE)
- Each adapter provides
execute_query()andexplain_query()methods
-
Query Plan Parser (
core/plan_parser.py)- Handles multiple EXPLAIN formats: DuckDB text, PostgreSQL JSON, MySQL explain
- Parses into normalized tree structure:
{ "type": "OPERATOR_NAME", # e.g., "SEQ_SCAN", "PROJECTION", "UNGROUPED_AGGREGATE" "columns": [...], "aggregates": [...], "rows": estimated_rows, "children": [...] # Child operators } - Generates human-readable explanations
-
Approximate Query Engine (
core/approx_engine.py)- Currently supports: Simple COUNT(*), SUM(column), AVG(column) queries
- Uses sampling: 10% sample rate (TABLESAMPLE for most DBs, USING SAMPLE for DuckDB)
- Rewrites query to sample data, then scales results (e.g., COUNT(*) / 0.1)
- Returns both scaled result and rewritten query for transparency
-
Caching Layer (
core/cache.py)- In-memory thread-safe cache with 30-second TTL
- Cache key = SHA256(source|mode|query)
- Returns cached results with
"cached": trueflag
Structure:
frontend/
├── src/
│ ├── App.tsx # Main app component (split-panel design)
│ ├── main.tsx # Entry point
│ ├── index.css # Global dark theme styling
│ ├── components/
│ │ └── PlanGraph.tsx # ReactFlow visualization of query plan tree
│ ├── pages/
│ │ └── QueryPlan.tsx # Planned but not fully implemented
│ └── utils/
│ └── planToFlow.ts # Convert plan tree to ReactFlow nodes/edges
├── package.json
├── vite.config.ts
├── tsconfig.json
└── eslint.config.js
UI Layout:
- Header: "Query Executor Workspace" title + subtitle
- Upload Bar: File input for CSV upload with visual confirmation
- CSV Mode Banner: Shows when CSV is loaded (locks source to DuckDB)
- Suggested Queries: Auto-generated for uploaded CSVs (SELECT *, COUNT, AVG)
- Two-Column Panel Layout:
- Left Panel (Exact Mode):
- Source selector (DuckDB/PostgreSQL/MySQL)
- Query editor textarea
- "Analyze Query" button (parses plan)
- "Run Query" button (executes)
- Results table/output
- Plan tree visualization with ReactFlow
- Right Panel (Approx Mode):
- (Same layout as exact panel)
- Executes with approximate sampling
- Shows sample rate and rewritten query
- Left Panel (Exact Mode):
Design:
- Dark theme (#0f0f0f background, #1a1a1a panels)
- Modern typography: Syne font (headers), JetBrains Mono (code)
- Blue accent color (#5aaaf5) for interactive elements
- Full responsive two-column layout that works on wide screens
Key Features Implemented:
- CSV upload with DuckDB auto-loading
- Real-time query editing in both panels
- Side-by-side execution comparison (exact vs approx)
- Query plan parsing and tree visualization
- Results displayed in formatted tables
- Error handling with user-friendly messages
- Caching indication (
"cached": true) - Query execution timing
- Rewritten query display for approximate mode
POST /api/execute
Content-Type: application/json
{
"query": "SELECT * FROM table LIMIT 10",
"mode": "exact", // or "approx"
"source": "duckdb" // or "postgres", "mysql"
}
Response:
{
"result": [[...], [...]], // Rows
"rows": [[...], [...]],
"columns": ["col1", "col2"],
"time": 0.123456, // Seconds
"approx": false, // true if approx mode
"sample_rate": 0.1, // Only for approx
"rewritten_query": "...", // Only for approx
"source": "duckdb",
"cached": false // true if from cache
}POST /api/plan
Content-Type: application/json
{
"query": "SELECT * FROM table",
"source": "duckdb" // or "postgres", "mysql"
}
Response:
{
"success": true,
"source": "duckdb",
"raw_plan": [...], // Raw EXPLAIN output
"parsed_plan": {...}, // Parsed structure
"plan_tree": { // Tree structure for visualization
"type": "PROJECTION",
"columns": [...],
"aggregates": [...],
"rows": null,
"children": [...]
},
"explanation": "Selects columns: ..."
}POST /api/upload
Content-Type: multipart/form-data
file: <binary CSV file>
Response:
{
"table_name": "table_a1b2c3d4",
"path": "/Users/.../datasets/a1b2c3d4.csv"
}POST /api/optimize
Content-Type: application/json
{
"query": "SELECT COUNT(*) FROM table",
"source": "duckdb"
}
Response:
{
"success": true,
"mode": "approx",
"rewritten_query": "SELECT COUNT(*) / 0.1 AS approx_value FROM (SELECT * FROM table USING SAMPLE 10 PERCENT) t"
}-
Exact Query Execution
- Execute arbitrary SQL against DuckDB, PostgreSQL, MySQL
- Timing measurement
- Result formatting (columns + rows)
- Error handling with detailed messages
-
CSV Upload & DuckDB Integration
- Upload CSV files via UI
- Auto-create DuckDB views with safe identifiers
- UUID-based file naming in
/datasets/directory - Auto-generate suggested queries
-
Query Plan Parsing
- Handle DuckDB EXPLAIN text format
- Handle PostgreSQL EXPLAIN JSON format
- Handle MySQL EXPLAIN format
- Parse into normalized tree structure
- Generate human-readable explanations
-
Basic Approximate Query Processing
- Simple COUNT(*), SUM(column), AVG(column) detection via regex
- Automatic query rewriting with 10% sampling
- Scaling results (e.g., COUNT / 0.1)
- Display rewritten query to user
-
Query Caching
- SHA256-based cache keys (source|mode|query)
- 30-second TTL
- Returns with "cached" flag
-
Plan Visualization (Partial)
- Convert tree to ReactFlow nodes/edges
- Basic graph rendering with layout
- Shows node types
-
UI/UX
- Dark theme with proper styling
- Two-column side-by-side comparison
- CSV mode detection and locking
- Error messages and status indicators
-
Plan Visualization
- Tree structure created ✅
- ReactFlow rendering ✅
- Missing: Proper automatic layout (currently random positioning)
- Missing: Detailed node information on hover
- Missing: Dagre layout algorithm integration (package installed but not used)
-
Approximate Query Processing
- Basic rewriting for simple queries ✅
- Missing: Support for WHERE clauses
- Missing: Support for GROUP BY queries
- Missing: Multi-table queries
- Missing: Complex aggregates (MIN, MAX, MEDIAN, PERCENTILES)
-
Plan Comparison Feature
match_plans()function exists inmatcher.py- Missing: API endpoint to compare two plans
- Missing: UI panel to visualize similarity score
- Missing: History of compared plans
-
Optimization Recommendations
- No analysis of slow queries
- No index suggestions
- No rewrite suggestions beyond basic approximation
-
Query History & Saved Queries
- No persistent storage
- No query history tracking
- No favorites/bookmarks
-
Advanced Approx Features
- No dynamic sampling rate adjustment
- No sampling strategy options
- No confidence intervals
- No materialized sample tables
-
Advanced UI Features
- Missing: QueryPlan page (created but empty)
- Missing: Dark/light theme toggle
- Missing: Query result export (CSV, JSON)
- Missing: Plan comparison view
- Missing: Query builder/autocomplete
- Missing: Database schema browser
-
Performance Features
- No query result pagination
- No large result streaming
- No incremental result display
-
Data Management
- No table management interface
- No sample dataset management
- No dataset metadata display
- aetherquery.duckdb - Default local DuckDB file
- aetherquery.duckdb.wal - DuckDB write-ahead log
- Multiple CSV files (UUID-named, uploaded by users)
- PostgreSQL TPCH benchmark results (Q1, Q3, etc.)
- Metrics and plans JSON from test runs
Current Status: ~70% MVP Complete
- ✅ Execute queries against multiple databases (DuckDB, PostgreSQL, MySQL)
- ✅ Parse and visualize query execution plans
- ✅ Support approximate query processing for simple aggregates
- ✅ Upload CSV and query it through DuckDB
- ✅ Split-screen comparison of exact vs approximate execution
- 🔄 (5/10) Detailed plan comparison and similarity scoring
- Query history and saved queries
- Advanced approximate processing (GROUP BY, WHERE clauses, etc.)
- Optimization recommendations and hints
- Plan comparison dashboard
- Dataset management and schema browser
- Query result export
- Performance analytics and insights
- Multi-user collaboration features
- ✅ Core execution engines
- ✅ Basic plan parsing
- ✅ CSV upload
- 🔄 Plan visualization with proper layout
- 🔄 UI polish and edge case handling
- Implement full plan comparison API endpoint
- Add similarity scoring UI display
- Build plan history tracking
- Create plan recommendation engine (based on patterns)
- Support WHERE clauses in approximate mode
- Add GROUP BY support with confidence intervals
- Implement dynamic sampling strategies
- Add multi-table approximate joins
- Query performance profiling
- Automatic index recommendations
- Query rewrite suggestions
- Historical performance trends
- User authentication and multi-tenancy
- Collaborative workspace features
- Advanced dataset management
- Mobile-friendly interface
- Python 3.9+
- Node.js 16+
- Virtual environment
cd /Users/nehadamani/Argus
source .venv/bin/activate
pip install -r backend/requirements.txt
python -m uvicorn backend.main:app --reload --port 8093Backend runs at: http://127.0.0.1:8093
API Docs: http://127.0.0.1:8093/docs
cd frontend
npm install
npm run devFrontend runs at: http://localhost:5173
For PostgreSQL:
PGHOST=localhost
PGPORT=5432
PGDATABASE=tpch
PGUSER=postgres
PGPASSWORD=password
For MySQL:
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=password
MYSQL_DATABASE=mysql
For DuckDB:
AETHERQUERY_DUCKDB_PATH=/path/to/aetherquery.duckdb # Optional
-
Clean Separation of Concerns
- API layer (routers)
- Business logic (core engines)
- Data access (adapters)
- Models (Pydantic schemas)
-
Database Abstraction
- Each DB has consistent interface
- Easy to add new databases
-
Modern Tech Stack
- FastAPI for async support and auto-documentation
- React 19 with TypeScript for type safety
- Pydantic for schema validation
-
Error Handling
- Specific HTTP error codes
- User-friendly error messages
- Detailed error context
-
Logging & Monitoring
- Basic logging exists
- Missing performance metrics
- No trace-level debugging
-
Testing
- No unit tests visible
- No integration tests
- No E2E tests
-
Configuration Management
- Hardcoded defaults in code
- Should use
.envfiles more consistently
-
Code Documentation
- Minimal docstrings
- Complex logic could use explanation
-
Frontend State Management
- Using only React useState
- Could benefit from state management library for complex interactions
| Component | Completion | Status |
|---|---|---|
| Backend Core Engines | 100% | ✅ Complete |
| Database Adapters | 100% | ✅ Complete |
| API Endpoints | 80% | 🔄 Missing plan comparison |
| Query Caching | 100% | ✅ Complete |
| Plan Parsing | 90% | 🔄 Layout algorithm not used |
| Approximate Engine | 60% | 🔄 Only simple queries |
| Frontend UI | 85% | 🔄 Some pages incomplete |
| Plan Visualization | 70% | 🔄 Needs better layout |
| CSV Upload | 100% | ✅ Complete |
| Dark Theme | 100% | ✅ Complete |
| Query History | 0% | ❌ Not started |
| Optimization Hints | 0% | ❌ Not started |
| Overall | ~65% | 🔄 In Active Development |
- Open frontend at
http://localhost:5173 - Select database source (DuckDB, PostgreSQL, or MySQL)
- Write SQL query in either panel (exact/approx)
- Click "Run Query" to execute
- Results appear below in table format
- Click "Upload CSV" and select a file
- CSV is loaded into DuckDB as a temporary view
- Use suggested queries or write custom SQL
- Both panels are locked to DuckDB (CSV mode)
- Query the uploaded data like any other table
- Write SQL query
- Click "Analyze Query"
- Plan tree appears below
- Visual graph shows operator flow
- Tree structure shows estimated rows and operations
- Write same query in both panels
- Click "Run Query" on both
- Left shows exact results with full precision
- Right shows approximate results (10% sample)
- Compare execution time and accuracy
- View rewritten approximate query
- Implement plan comparison API endpoint
- Fix plan visualization layout using Dagre
- Add plan comparison to UI
- Add unit tests for core engines
- Document all API endpoints
- Extend approximate engine to support WHERE clauses
- Add GROUP BY support with confidence intervals
- Implement query history storage (local storage or DB)
- Create dataset schema browser
- Add result export functionality
- Multi-table approximate joins
- Advanced sampling strategies
- Performance profiling and analytics
- Optimization recommendations
- QueryPlan page implementation
Argus is a well-architected SQL execution and analysis platform at the ~65% completion stage. The core infrastructure is solid and MVP-ready, with most critical features working. The main gaps are in advanced approximation support, plan visualization refinement, and feature expansion (history, recommendations, etc.).
The project is positioned to become a powerful tool for:
- Database developers optimizing queries
- Data analysts understanding query performance
- Organizations seeking faster approximate results for exploratory analytics
- Educational purposes (understanding query execution)
With the roadmap outlined above, reaching a production-ready 1.0 release would require 2-3 more months of focused development.