A FastAPI backend that analyzes SQL queries for performance issues, provides AI-powered optimization suggestions using Claude, and tracks data lineage.
- SQL Parsing — Extracts tables, columns, joins, subqueries using sqlglot
- Issue Detection — Identifies SELECT *, missing WHERE, ORDER without LIMIT, excessive joins, high complexity
- AI Optimization — Uses Claude to suggest query rewrites, index definitions, and structural improvements
- Data Lineage — Tracks which tables and columns each query accesses, with graph representation
- Query History — Stores and retrieves past analyses with pagination
- FastAPI — async Python web framework
- PostgreSQL / SQLite — query history storage
- sqlglot — SQL parsing and analysis
- Claude API — AI-powered optimization suggestions
- Docker — containerized deployment
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# optional: add your API key for AI suggestions
cp .env.example .env
uvicorn app.main:app --reloadexport ANTHROPIC_API_KEY=sk-ant-xxxxx
docker compose up --buildAPI docs at http://localhost:8000/docs
Analyze a SQL query and get optimization suggestions.
curl -X POST http://localhost:8000/queries/analyze \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total > 100 ORDER BY o.created_at"}'Paginated query history.
Full details of a previously analyzed query.
Analyze data lineage for a SQL query.
Get stored lineage for a previously analyzed query.
Health check.