A simple Query Builder web application built with Spring Boot (backend) and H2 in-memory database. It allows users to dynamically select tables, columns, and filters to execute queries and return results as JSON.
This project is a mini version designed for learning and prototyping, with a frontend (can be extended in Svelte) and a REST API backend.
src/main/java/com/example/querybuilder/
├─ controller/ # REST API endpoints
├─ dto/ # DTOs for query and filters
├─ model/ # JPA entities (User, Order)
├─ repository/ # JPA Repositories
├─ service/ # services
├─ config/ # DataSeeder for initial data
└─ utils/ # Optional helpers
The app initializes with two tables:
app_user
)id | name | age | |
---|---|---|---|
1 | Alice | [email protected] | 28 |
2 | Bob | [email protected] | 35 |
3 | Charlie | [email protected] | 42 |
orders
)id | product | amount | date | user_id |
---|---|---|---|---|
1 | Laptop | 1200 | 2025-10-01 | 1 |
2 | Phone | 800 | 2025-10-04 | 2 |
3 | Tablet | 400 | 2025-10-05 | 3 |
4 | Monitor | 300 | 2025-10-03 | 1 |
GET /api/tables
Response Example:
["users", "orders"]
GET /api/columns?table={tableName}
Example:
GET /api/columns?table=app_user
Response:
["id","name","email","age"]
POST /api/query
Request Body Example:
{
"table": "orders",
"columns": ["product", "amount"],
"filters": [
{
"column": "amount",
"operator": "<",
"value": "1000"
}
]
}
Response Example:
[
["Phone", 800],
["Tablet", 400],
["Monitor", 300]
]
Notes:
table
→ entity/table name (app_user
or orders
)
columns
→ list of column names to return
filters
→ list of filter objects:
column
→ column nameoperator
→ =
, <
, >
, like
value
→ string value (numeric columns are parsed automatically)curl http://localhost:8080/api/tables
curl http://localhost:8080/api/columns?table=orders
curl -X POST http://localhost:8080/api/query \
-H "Content-Type: application/json" \
-d '{"table":"orders","columns":["product","amount"],"filters":[{"column":"amount","operator":"<","value":"1000"}]}'