# Implementation Plan: Issue #53 - Visual Query Builder

## Summary
Implement a full-stack visual query builder with a JSON AST-to-SQL translation backend (QueryService), saved query CRUD (SavedQueryController), and a Vue 3 visual filter builder component with AND/OR nesting, live preview, saved queries sidebar, and export.

## Files to Create/Modify

### New Files
1. **`lib/Migration/Version000013Date20260407000012.php`** - DB migration for oc_mv_saved_queries table
2. **`lib/Db/SavedQuery.php`** - Entity class
3. **`lib/Db/SavedQueryMapper.php`** - Mapper class  
4. **`lib/Service/QueryService.php`** - JSON AST to SQL translation + execution
5. **`lib/Controller/QueryController.php`** - REST controller for saved queries + execution
6. **`src/stores/queries.js`** - Pinia store for query builder state
7. **`src/components/QueryBuilder.vue`** - Visual query builder component
8. **`src/views/QueryBuilder.vue`** - View wrapping the query builder with saved queries sidebar
9. **`tests/Unit/QueryServiceTest.php`** - Unit tests for AST translation

### Modified Files  
10. **`appinfo/routes.php`** - Add query-related routes
11. **`src/router.js`** - Add query builder route

## Acceptance Criteria Checklist
1. [ ] DB migration creates oc_mv_saved_queries with id, name, query_json, sort_json, created_by, created_at
2. [ ] QueryService translates JSON AST with AND/OR nesting to Doctrine DBAL conditions
3. [ ] Field whitelist validation prevents SQL injection
4. [ ] Supported operators: =, !=, <, >, <=, >=, contains, starts_with, is_empty, is_not_empty
5. [ ] SavedQueryController with list, create, update, delete, execute endpoints
6. [ ] Ad-hoc query execution endpoint (POST /api/v1/queries/execute)
7. [ ] QueryBuilder.vue with field/operator/value condition rows
8. [ ] AND/OR toggle and nested sub-groups
9. [ ] Save, load, delete saved queries
10. [ ] Live preview of results
11. [ ] Router entry for /queries view
12. [ ] Unit tests for QueryService AST translation
