- Added root-level
GET /historyendpoint - This returns recent query history (latest first)
- Imports
query_historydeque fromexecute.py
- Tracks all executed queries in a thread-safe
deque(max 50 entries) - Records:
query,source,mode,time,timestamp,cachedflag - Every call to
/api/executeauto-appends to history - API endpoint:
GET /api/history(available at/api/historywith prefix)
- Sidebar: Shows recent queries with metadata (source, execution time, cache status)
- Main Panel: Query editor with source selector (DuckDB/PostgreSQL/MySQL)
- Features:
- "Analyze Plan" button → parses and visualizes query plan
- "Execute" button → runs query and fetches plan automatically
- Shows plan explanation text
- Displays plan tree as JSON
- Renders interactive graph visualization with ReactFlow
- Hover effects on history items
- Error handling with user-friendly messages
- Active history item highlighting
- History auto-refresh every 5 seconds
- Clear history button
cd /Users/nehadamani/Argus
source .venv/bin/activate
python -m uvicorn backend.main:app --reload --port 8093cd frontend
npm run dev-
Main App (side-by-side exact vs approx):
http://localhost:5173 -
Plan Analyzer Page (NEW!):
Currently embedded in the app — to use as standalone page, you need routing setup
curl http://127.0.0.1:8093/historyShould return [] initially, then populate after queries are executed.
- Open the app at
http://localhost:5173 - Write a query:
SELECT COUNT(*) FROM table_abc; - Click "Run Query" in the main panel
curl http://127.0.0.1:8093/historyShould now show:
[
{
"query": "SELECT COUNT(*) FROM table_abc;",
"source": "duckdb",
"mode": "exact",
"time": 0.012345,
"timestamp": 1711800000.0,
"cached": false,
"cache_key": "abc123..."
}
]Returns recent query history (latest first)
Response:
[
{
"query": "SELECT * FROM table LIMIT 10",
"source": "duckdb",
"mode": "exact",
"time": 0.053456,
"result_rows": 10,
"timestamp": 1711800000.0,
"cached": false
}
]| Feature | Description |
|---|---|
| Recent Queries List | Click any query to auto-load and analyze |
| Query Metadata | Shows source, execution time, and cache status |
| Active Highlight | Currently selected query is highlighted in blue |
| Auto Refresh | History updates every 5 seconds |
| Clear Button | ✕ button clears all history (with confirmation) |
| Hover Effects | Visual feedback when hovering over queries |
- QueryPlanPage (
pages/QueryPlan.tsx): Main page layout - PlanGraph (
components/PlanGraph.tsx): ReactFlow visualization - planToFlow (
utils/planToFlow.ts): Tree-to-graph converter
User types query in QueryPlan page
↓
User clicks "Analyze Plan"
↓
Frontend POST /api/sql/parse-plan
↓
Backend: route_query() → execute query
↓
Backend: append_history() → save to deque ← KEY STEP
↓
Backend returns plan_tree
↓
Frontend: setPlan() → displays tree
↓
ReactFlow: renders visualization
↓
Sidebar: shows query in history list (refreshes every 5s)
Currently, QueryPlan.tsx is not routed. To make it a separate page:
npm install react-router-domThen in main.tsx:
import { BrowserRouter, Routes, Route } from "react-router-dom";
import App from "./App";
import QueryPlanPage from "./pages/QueryPlan";
ReactDOM.createRoot(document.getElementById("root")!).render(
<BrowserRouter>
<Routes>
<Route path="/" element={<App />} />
<Route path="/plan" element={<QueryPlanPage />} />
</Routes>
</BrowserRouter>,
);<nav style={{ padding: "10px", background: "#1a1a1a" }}>
<Link to="/">Executor</Link>
<Link to="/plan">Plan Analyzer</Link>
</nav>Add to QueryPlanPage.tsx:
// Save history to localStorage
useEffect(() => {
localStorage.setItem("queryHistory", JSON.stringify(history));
}, [history]);
// Load from localStorage on mount
useEffect(() => {
const saved = localStorage.getItem("queryHistory");
if (saved) setHistory(JSON.parse(saved));
}, []);Track in backend and display in sidebar:
- Total queries
- Average execution time
- Most frequently used source
- Slow queries (>1s)
const exportHistory = () => {
const json = JSON.stringify(history, null, 2);
const blob = new Blob([json], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "query-history.json";
a.click();
};- Verify backend is running:
curl http://127.0.0.1:8093/ - Check history endpoint:
curl http://127.0.0.1:8093/history - Check browser console for fetch errors
- Verify query is valid SQL for your database
- Check browser console for errors
- Try simple query:
SELECT 1
- Backend already has CORS middleware configured
- If still issues, restart backend server
- It's a component, not routed yet
- To use standalone, set up react-router-dom (see upgrade #1)
| File | Change | Status |
|---|---|---|
backend/main.py |
Added /history endpoint |
✅ Done |
backend/api/execute.py |
Already had history tracking | ✅ Already working |
frontend/src/pages/QueryPlan.tsx |
Complete rewrite | ✅ Done |
frontend/src/App.tsx |
No changes needed | ✅ OK |
frontend/src/components/PlanGraph.tsx |
No changes | ✅ OK |
✅ What You Can Do Now:
- Run queries in the main app
- View all query history at
/historyendpoint - Use QueryPlan page to analyze individual queries
- See execution plans visualized as graphs
- Click history items to quickly re-run queries
🎯 Next Priority: Set up routing if you want QueryPlan as a separate page in your UI navigation.