A Rails 8 app for testing the QueryLens engine gem — a natural language SQL query builder powered by AI.
This app provides a realistic small SaaS dataset (users, teams, posts, comments, tags, invoices) and a dashboard UI so you can visually inspect the data and then query it via QueryLens.
git clone https://github.com/bryanbeshore/query_lens_testbed.git
cd query_lens_testbed
# Clone the QueryLens engine alongside this app
cd .. && git clone https://github.com/bryanbeshore/query_lens.git && cd query_lens_testbed
bundle install
bin/rails db:prepare # creates DB, runs migrations, seeds data# Option 1: Inline (key stays out of your shell history on some shells)
ANTHROPIC_API_KEY=sk-ant-your-key-here bin/dev
# Option 2: Export first (persists for the whole terminal session)
export ANTHROPIC_API_KEY=sk-ant-your-key-here
bin/dev- Dashboard: localhost:3000 — overview of all seed data
- QueryLens: localhost:3000/query_lens — natural language query interface
| Model | Records | Notes |
|---|---|---|
| User | 50 | 5 admins, 45 members |
| Team | 10 | mixed plans: free, starter, pro, enterprise |
| Membership | 81 | roles: owner, admin, member |
| Post | 200 | 120 published, 40 draft, 40 archived |
| Comment | 500 | |
| Tag | 15 | engineering, product, design, marketing, etc. |
| PostTag | 500 | many-to-many join table |
| Invoice | 100 | 60 paid, 20 pending, 20 overdue |
Use these in the QueryLens UI to exercise different SQL generation capabilities:
Show me all admin usersHow many posts are published vs draft vs archived?List all teams on the pro plan
Which users have the most comments?Show me all posts tagged with "engineering"List team members of Acme Corp with their roles
What is the total invoice amount by team?How many posts does each team have, sorted by most to least?Show the average invoice amount per plan type
Show all overdue invoices with their team name and amountWhich users posted in the last 30 days?Find teams that have both paid and overdue invoices
Show me users who are members of more than one teamWhat are the top 5 most-used tags across published posts?For each team, show the number of members, posts, and total invoice revenue
The QueryLens initializer is at config/initializers/query_lens.rb:
- Model:
claude-sonnet-4-5-20250929 - Auth: open (allows all requests)
- API key: reads from
ENV["ANTHROPIC_API_KEY"]
- Rails 8.1, Ruby 3.4
- PostgreSQL
- QueryLens engine (local gem at
../query_lens) - RubyLLM + Anthropic Claude